Guest User

Untitled

a guest
Dec 31st, 2021
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. @staticmethod
  2. def _probe_drop(pad, probe_info):
  3. return Gst.PadProbeReturn.DROP
  4.  
  5. def change_window_handle(self, new_handle):
  6. videoconvert = self._pipeline.get_by_name('videoconvert')
  7. autovideosink = self._pipeline.get_by_name('autovideosink')
  8.  
  9. # Install a blocking probe on the videoconvert so that it can't
  10. # feed any more data into the autovideosink
  11. source_pad = videoconvert.get_static_pad('src')
  12. probe_id = source_pad.add_probe(
  13. Gst.PadProbeType.BLOCK,
  14. self._probe_drop,
  15. )
  16.  
  17. # Unlink the autovideosink, stop it, and remove it
  18. source_pad.unlink(source_pad.get_peer())
  19. autovideosink.set_state(Gst.State.NULL)
  20. self._pipeline.remove(autovideosink)
  21.  
  22. # Make a new autovideosink and link it
  23. new_sink = Gst.ElementFactory.make('autovideosink', 'autovideosink')
  24. self._pipeline.add(new_sink)
  25. source_pad.link(new_sink.get_static_pad('sink'))
  26.  
  27. # Remove the probe and set the new sink to PLAYING
  28. source_pad.remove_probe(probe_id)
  29. new_sink.sync_state_with_parent()
  30.  
  31. # For some reason, the new sink gets stuck in READY state. Even
  32. # the pipeline goes back into PAUSED state for some reason.
  33. print('State of the new sink:', new_sink.get_state(0.1))
  34. print('State of the pipeline:', self._pipeline.get_state(0.1))
Advertisement
Add Comment
Please, Sign In to add comment