import time from pygstc.gstc import * # Create PipelineEntity object to manage each pipeline class PipelineEntity(object): def __init__(self, client, name, description): self._name = name self._description = description self._client = client print("Creating pipeline: " + self._name) self._client.pipeline_create(self._name, self._description) def play(self): print("Playing pipeline: " + self._name) self._client.pipeline_play(self._name) def stop(self): print("Stopping pipeline: " + self._name) self._client.pipeline_stop(self._name) def delete(self): print("Deleting pipeline: " + self._name) self._client.pipeline_delete(self._name) def eos(self): print("Sending EOS to pipeline: " + self._name) self._client.event_eos(self._name) def set_file_location(self, location): print("Setting " + self._name + " pipeline recording/snapshot location to " + location); filesink_name = "filesink_" + self._name; self._client.element_set(self._name, filesink_name, 'location', location); def listen_to(self, sink): print(self._name + " pipeline listening to " + sink); self._client.element_set(self._name, self._name + '_src', 'listen-to', sink); pipelines_base = [] # Create GstD Python client client = GstdClient() # Create camera pipelines #camera0 = PipelineEntity(client, 'camera0', 'videotestsrc ! video/x-raw,format=YUY2,width=1280,height=720 ! interpipesink name=camera0 forward-events=true forward-eos=true sync=false') #camera0 = PipelineEntity(client, 'camera0', 'filesrc location=/run/media/sda1/h264_test_stream.ts ! video/mpegts ! tsdemux ! queue ! h264parse ! v4l2h264dec ! interpipesink name=camera0 forward-events=true forward-eos=true sync=true') camera0 = PipelineEntity(client, 'camera0', 'filesrc location=/run/media/sda1/bbb_4k30_h264.mp4 ! qtdemux ! h264parse ! v4l2h264dec ! imxvideoconvert_g2d ! interpipesink name=camera0 forward-events=true forward-eos=true sync=false') pipelines_base.append(camera0) # Create display pipeline display = PipelineEntity(client, 'display', 'interpipesrc listen-to=camera0 ! waylandsink') pipelines_base.append(display) # Play base pipelines for pipeline in pipelines_base: pipeline.play() time.sleep(10) for pipeline in pipelines_base: pipeline.delete()