def __init__(self, vsource, asource, previewsink): SBinManager.__init__(self) profile = OggRecordingProfile() self.encoder = encoder = OggEncoder(filename="/tmp/test", profile=profile) self.add_many(vsource, asource, previewsink, encoder) print(self.pipeline_desc) PipelineManager.__init__(self, self.pipeline_desc)
class Actioner(easyevent.User): def __init__(self): easyevent.User.__init__(self) self.register_event("caps") def evt_caps(self, event): print("Caps received, %s" % event.content) if __name__ == '__main__': a = Actioner() pipeline_desc = "audiotestsrc ! avenc_aac ! rtpmp4gpay name=pay ! udpsink host=127.0.0.1 port=1234 name=sink" print("pipeline : %s" % (pipeline_desc)) pipelinel = PipelineManager(pipeline_desc) def get_time(time_epoch): if time_epoch == 0: time_epoch = "never" else: time_epoch = time.ctime(time_epoch/1000000000) return time_epoch def get_udp_stats(): sink = pipelinel.pipeline.get_by_name("sink") # Fixme return a structure but data ar not available struct_stat = sink.emit("get-stats", "127.0.0.1", 1234) # Should be struct_stat.get_value("bytes_sent") return True
from gstmanager1.sbins.sources.videotest import VideoTestSource from gstmanager1.sbinmanager import SBinManager logging.basicConfig( level=getattr(logging, "DEBUG"), format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', stream=sys.stderr) v = VideoTestSource() s = XImageSink() s2 = AudioTestSource() s3 = AlsaSink() e = OggEncoder("/tmp/test.ogg") man = SBinManager() man.add_many(v, s, s2, s3, e) if __name__ == '__main__': pipelinel = PipelineManager(man.pipeline_desc) pipelinel.run() GObject.timeout_add(2000, pipelinel.send_eos) GObject.timeout_add(3500, man.get_pipeline) main_loop = GObject.MainLoop() main_loop.run()
def evt_eos(self, event): # This is the callback used for every evt_MSGNAME received logger.info("EOS Recieved") self.pipelinel.stop() sys.exit() def set_brightness(pipelinel, value): # set_property_on_element example pipelinel.set_property_on_element(element_name="balance", property_name="brightness", value=value) if __name__ == '__main__': logging.basicConfig( level=getattr(logging, "DEBUG"), format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', stream=sys.stderr ) pipeline_desc = "videotestsrc num-buffers=100 ! videobalance name=balance ! xvimagesink" pipelinel = PipelineManager(pipeline_desc) eso_actioner = EOS_actioner(pipelinel) pipelinel.run() # Let's schedule some property changing GObject.timeout_add(2000, set_brightness, pipelinel, 0.2) main_loop = GObject.MainLoop() GObject.timeout_add(7000, main_loop.quit) main_loop.run()
class Test(easyevent.User): def __init__(self): easyevent.User.__init__(self) self.register_event("drop_value_change") def evt_drop_value_change(self, event): data = event.content["value"] src = event.content["source"] property = event.content["property"] print("%s reports %s prop change to value %s" % (src, property, data)) caps_in = "video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, framerate=(fraction)30/1" caps_out = "video/x-raw, format=(string)YUY2, width=(int)320, height=(int)240, framerate=(fraction)25/1" pip = "videotestsrc ! %s ! videorate ! %s ! fakesink" % (caps_in, caps_out) p = PipelineManager(pip) p.play() p.activate_polling_of_property_on_element(element_name="videorate0", property="drop", interval_ms=500) print("Will poll element videorate for drop values for 10 seconds on 500ms interval") t = Test() main_loop = GObject.MainLoop() GObject.timeout_add_seconds(10, p.deactivate_pollings) GObject.timeout_add_seconds(12, p.stop) GObject.timeout_add_seconds(13, main_loop.quit) main_loop.run()