return
caps = pad.get_current_caps()
- assert (len(caps))
- s = caps[0]
- name = s.get_name()
- if name.startswith('video'):
- q = Gst.ElementFactory.make('queue')
- conv = Gst.ElementFactory.make('videoconvert')
- sink = Gst.ElementFactory.make('autovideosink')
- self.pipe.add(q, conv, sink)
- self.pipe.sync_children_states()
- pad.link(q.get_static_pad('sink'))
- q.link(conv)
- conv.link(sink)
- elif name.startswith('audio'):
- q = Gst.ElementFactory.make('queue')
- conv = Gst.ElementFactory.make('audioconvert')
- resample = Gst.ElementFactory.make('audioresample')
- sink = Gst.ElementFactory.make('autoaudiosink')
- self.pipe.add(q, conv, resample, sink)
- self.pipe.sync_children_states()
- pad.link(q.get_static_pad('sink'))
- q.link(conv)
- conv.link(resample)
- resample.link(sink)
+ # assert (len(caps)) # we have a Gst.Caps object and it has no length
+ # s = caps[0] # also, it's not a list
+ padsize = caps.get_size()
+ assert(padsize > 0)
+ for i in range(padsize): # pythonic?!
+ s = caps.get_structure(i) # Gst.Structure
+ name = s.get_name()
+ if name.startswith('video'):
+ q = Gst.ElementFactory.make('queue')
+ conv = Gst.ElementFactory.make('videoconvert')
+ sink = Gst.ElementFactory.make('autovideosink')
+ self.pipe.add(q, conv, sink)
+ self.pipe.sync_children_states()
+ pad.link(q.get_static_pad('sink'))
+ q.link(conv)
+ conv.link(sink)
+ elif name.startswith('audio'):
+ q = Gst.ElementFactory.make('queue')
+ conv = Gst.ElementFactory.make('audioconvert')
+ resample = Gst.ElementFactory.make('audioresample')
+ sink = Gst.ElementFactory.make('autoaudiosink')
+ self.pipe.add(q, conv, resample, sink)
+ self.pipe.sync_children_states()
+ pad.link(q.get_static_pad('sink'))
+ q.link(conv)
+ conv.link(resample)
+ resample.link(sink)
async def listen_to_gstreamer_bus(self):
Gst.init(None)