def do_query self query if query type gst QUERY_DURATION if query pars

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
def do_query (self, query):
if query.type == gst.QUERY_DURATION:
if query.parse_duration()[0] == gst.FORMAT_TIME:
query.set_duration(format=gst.FORMAT_TIME, duration=int(self.buf.track.length_in_seconds)*1000000000)
elif query.parse_duration()[0] == gst.FORMAT_BYTES:
query.set_duration(format=gst.FORMAT_BYTES, duration=self.buf.length)
else:
print 'UNHANDLED QUERY DURATION TYPE:', query.parse_duration()
return query
elif query.type == gst.QUERY_LATENCY:
query.set_latency(min_latency=0, live=False, max_latency=-1)
return query
else:
print 'UNHANDLED QUERY:', query.type
return query
return query