-
Notifications
You must be signed in to change notification settings - Fork 55
/
gstc.py
1264 lines (1093 loc) · 38.2 KB
/
gstc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# This file is part of GStreamer Daemon
# Python client library abstracting gstd interprocess communication
#
# Copyright 2015-2022 Ridgerun, LLC (http://www.ridgerun.com)
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# 3. Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import inspect
import json
import traceback
from pygstc.gstcerror import GstdError, GstcError, GstcErrorCode
from pygstc.logger import DummyLogger
from pygstc.tcp import Ipc
GSTD_PROCNAME = 'gstd'
"""
GstClient - GstdClient Class
"""
class GstdClient:
"""
Class used as a client to communicate with the Gstd over
an abstract inter-process communication class.
Methods
----------
ping_gstd ()
Test if Gstd responds in the configured address and port
bus_filter(pipe_name, filter)
Select the types of message to be read from the bus. Separate
with a '+', i.e.: eos+warning+error
bus_read(pipe_name)
Read the bus and wait
bus_timeout(pipe_name, timeout)
Apply a timeout for the bus polling. -1: forever, 0: return
immediately, n: wait n nanoseconds
create(uri, property, value)
Create a resource at the given URI
debug_color(colors)
Enable/Disable colors in the debug logging
debug_enable(enable)
Enable/Disable GStreamer debug
debug_reset(reset)
Enable/Disable debug threshold reset
debug_threshold(threshold)
The debug filter to apply (as you would use with gst-launch)
delete(uri, name)
Delete the resource held at the given URI with the given name
element_get(pipe_name, element, prop)
Queries a property in an element of a given pipeline
element_set(pipe_name, element, prop, value)
Set a property in an element of a given pipeline
event_eos(pipe_name)
Send an end-of-stream event
event_flush_start(pipe_name)
Put the pipeline in flushing mode
event_flush_stop(pipe_name, reset='true')
Take the pipeline out from flushing mode
event_seek(
self,
pipe_name,
rate=1.0,
format=3,
flags=1,
start_type=1,
start=0,
end_type=1,
end=-1,
)
Perform a seek in the given pipeline
list_elements(pipe_name)
List the elements in a given pipeline
list_pipelines( )
List the existing pipelines
list_properties(pipe_name, element)
List the properties of an element in a given pipeline
list_signals(pipe_name, element)
List the signals of an element in a given pipeline
pipeline_create(pipe_name, pipe_desc)
Create a new pipeline based on the name and description
pipeline_delete(pipe_name)
Delete the pipeline with the given name
pipeline_pause(pipe_name)
Set the pipeline to paused
pipeline_play(pipe_name)
Set the pipeline to playing
pipeline_stop(pipe_name)
Set the pipeline to null
pipeline_get_graph(self, pipe_name)
Get the pipeline graph
pipeline_verbose(self, pipe_name, value)
Set the pipeline verbose mode
Only supported on GST Version >= 1.10
read(uri)
Read the resource held at the given URI with the given name
signal_connect(pipe_name, element, signal)
Connect to signal and wait
signal_disconnect(pipe_name, element, signal)
Disconnect from signal
signal_timeout(pipe_name, element, signal, timeout)
Apply a timeout for the signal waiting. -1: forever, 0: return
immediately, n: wait n microseconds
update(uri, value)
Update the resource at the given URI
"""
def __init__(
self,
ip='localhost',
port=5000,
logger=None,
timeout=None,
):
"""
Initialize new GstdClient.
Parameters
----------
ip : string
IP where Gstd is running
port : int
Port where Gstd is running
logger : CustomLogger
Custom logger where all log messages from this class are going
to be reported
timeout : float
Timeout in seconds to wait for a response. 0: non-blocking, None: blocking
"""
if logger:
self._logger = logger
else:
self._logger = DummyLogger()
self._ip = ip
self._port = port
self._logger.info(
'Starting GstClient with ip={} port={}'.format(
self._ip, self._port))
self._ipc = Ipc(self._logger, self._ip, self._port)
self._timeout = timeout
self.ping_gstd()
def _check_parameters(self, parameter_list, type_list):
"""
Checks that every parameter in the parameter list corresponds to the
type in type_list. Then returns an array with the string conversion of
each value.
Parameters
----------
parameter_list: list
The parameters to check and convert
type_list: list
List of types for each parameter
Returns
-------
parameter_string_list : list
List of string conversions of each parameter
"""
parameter_string_list = []
for i, parameter in enumerate(parameter_list):
if not isinstance(parameter, type_list[i]):
raise GstcError(
"{} TypeError: parameter {}: expected {}, '{} found".format(
inspect.stack()[1].function,
i,
type_list[i],
type(parameter)),
GstcErrorCode.GSTC_MALFORMED)
if type_list[i] == str:
parameter_string_list += [parameter]
elif type_list[i] == bool:
if parameter:
parameter_string_list += ['true']
else:
parameter_string_list += ['false']
else:
parameter_string_list += [str(parameter)]
return parameter_string_list
def _send_cmd_line(self, cmd_line):
"""
Send a command using an abstract IPC and wait for the response.
Parameters
----------
cmd_line : string list
Command to be send
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
Returns
-------
result : dictionary
Response from the IPC
"""
try:
cmd = cmd_line[0]
jresult = self._ipc.send(cmd_line, timeout=self._timeout)
result = json.loads(jresult)
if result['code'] != GstcErrorCode.GSTC_OK.value:
self._logger.error(
'{} error: {}'.format(
cmd, result['description']))
raise GstdError(result['description'],
result['code'])
return result
except ConnectionRefusedError as e:
raise GstcError("Failed to communicate with Gstd",
GstcErrorCode.GSTC_UNREACHABLE)\
from e
except TypeError as e:
raise GstcError('GstClient bad command',
GstcErrorCode.GSTC_TYPE_ERROR) from e
except BufferError as e:
raise GstcError('GstClient received a response bigger ' +
'than the maximum size allowed',
GstcErrorCode.GSTC_RECV_ERROR) from e
except TimeoutError as e:
raise GstcError('GstClient time out ocurred',
GstcErrorCode.GSTC_TIMEOUT) from e
def ping_gstd(self):
"""
Test if Gstd responds in the configured address and port
Raises
------
GstcError
Error is triggered when GstClient fails
GstdError
Error is triggered when Gstd IPC fails
"""
self._logger.info('Sending ping to Gstd')
try:
jresult = self._ipc.send(['list_pipelines'], timeout=1)
# Verify correct data format
result = json.loads(jresult)
if ('description' in result and
result['description'] != 'Success'):
raise GstdError(result['description'],
result['code'])
except json.JSONDecodeError as e:
err_msg = 'Gstd corrupted response'
self._logger.error(err_msg)
raise GstcError(err_msg,
GstcErrorCode.GSTC_MALFORMED) from e
except ConnectionRefusedError as e:
err_msg = 'Error contacting Gstd'
self._logger.error(err_msg)
raise GstcError(err_msg,
GstcErrorCode.GSTC_UNREACHABLE) from e
except BufferError as e:
raise GstcError('GstClient received a buffer bigger ' +
'than the maximum size allowed',
GstcErrorCode.GSTC_RECV_ERROR) from e
except TimeoutError as e:
raise GstcError('GstClient time out ocurred',
GstcErrorCode.GSTC_TIMEOUT) from e
def bus_filter(self, pipe_name, filter):
"""
Select the types of message to be read from the bus. Separate
with a '+', i.e.: eos+warning+error.
Parameters
----------
pipe_name: string
The name of the pipeline
filter: string
Filter to be applied to the bus. '+' reparated strings
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info(
'Setting bus read filter of pipeline {} to {}'.format(
pipe_name, filter))
parameters = self._check_parameters([pipe_name, filter], [str, str])
self._send_cmd_line(['bus_filter'] + parameters)
def bus_read(self, pipe_name):
"""
Read the bus and wait.
Parameters
----------
pipe_name: string
The name of the pipeline
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
Returns
-------
result : dictionary
Command response
"""
self._logger.info('Reading bus of pipeline {}'.format(pipe_name))
parameters = self._check_parameters([pipe_name], [str])
result = self._send_cmd_line(['bus_read'] + parameters)
return result['response']
def bus_timeout(self, pipe_name, timeout):
"""
Apply a timeout for the bus polling.
Parameters
----------
pipe_name: string
The name of the pipeline
timeout: int
Timeout in nanoseconds. -1: forever, 0: return
immediately, n: wait n nanoseconds.
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info(
'Setting bus read timeout of pipeline {} to {}'.format(
pipe_name, timeout))
parameters = self._check_parameters([pipe_name, timeout], [str, int])
self._send_cmd_line(['bus_timeout'] + parameters)
def create(
self,
uri,
property,
value,
):
"""
Create a resource at the given URI.
Parameters
----------
uri: string
Resource identifier
property: string
The name of the property
value: string
The initial value to be set
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info(
'Creating property {} in uri {} with value "{}"'.format(
property, uri, value))
parameters = self._check_parameters(
[uri, property, value], [str, str, str])
self._send_cmd_line(['create'] + parameters)
def debug_color(self, colors):
"""
Enable/Disable colors in the debug logging.
Parameters
----------
colors: boolean
Enable color in the debug
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info('Enabling/Disabling GStreamer debug colors')
parameters = self._check_parameters([colors], [bool])
self._send_cmd_line(['debug_color'] + parameters)
def debug_enable(self, enable):
"""
Enable/Disable GStreamer debug.
Parameters
----------
enable: boolean
Enable GStreamer debug
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info('Enabling/Disabling GStreamer debug')
parameters = self._check_parameters([enable], [bool])
self._send_cmd_line(['debug_enable'] + parameters)
def debug_reset(self, reset):
"""
Enable/Disable debug threshold reset.
Parameters
----------
reset: boolean
Reset the debug threshold
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info('Enabling/Disabling GStreamer debug threshold reset')
parameters = self._check_parameters([reset], [bool])
self._send_cmd_line(['debug_reset'] + parameters)
def debug_threshold(self, threshold):
"""
The debug filter to apply (as you would use with gst-launch).
Parameters
----------
threshold: string
Debug threshold:
0 none No debug information is output.
1 ERROR Logs all fatal errors.
2 WARNING Logs all warnings.
3 FIXME Logs all "fixme" messages.
4 INFO Logs all informational messages.
5 DEBUG Logs all debug messages.
6 LOG Logs all log messages.
7 TRACE Logs all trace messages.
9 MEMDUMP Logs all memory dump messages.
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info(
'Setting GStreamer debug threshold to {}'.format(threshold))
parameters = self._check_parameters([threshold], [str])
self._send_cmd_line(['debug_threshold'] + parameters)
def delete(self, uri, name):
"""
Delete the resource held at the given URI with the given name.
Parameters
----------
uri: string
Resource identifier
name: string
The name of the resource to delete
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info('Deleting name {} at uri "{}"'.format(name, uri))
parameters = self._check_parameters([uri, name], [str, str])
self._send_cmd_line(['delete'] + parameters)
def element_get(
self,
pipe_name,
element,
prop,
):
"""
Queries a property in an element of a given pipeline.
Parameters
----------
pipe_name: string
The name of the pipeline
element: string
The name of the element
prop: string
The name of the property
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
Returns
-------
result : string
Command response
"""
self._logger.info(
'Getting value of element {} {} property in pipeline {}'.format(
element, prop, pipe_name))
parameters = self._check_parameters(
[pipe_name, element, prop], [str, str, str])
result = self._send_cmd_line(['element_get'] + parameters)
return result['response']['value']
def element_set(
self,
pipe_name,
element,
prop,
value,
):
"""
Set a property in an element of a given pipeline.
Parameters
----------
pipe_name: string
The name of the pipeline
element: string
The name of the element
prop: string
The name of the property
value: string
The value to set
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info(
'Setting element {} {} property in pipeline {} to:{}'.format(
element, prop, pipe_name, value))
parameters = self._check_parameters(
[pipe_name, element, prop, value], [str, str, str, str])
self._send_cmd_line(['element_set'] + parameters)
def event_eos(self, pipe_name):
"""
Send an end-of-stream event.
Parameters
----------
pipe_name: string
The name of the pipeline
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info(
'Sending end-of-stream event to pipeline {}'.format(pipe_name))
parameters = self._check_parameters([pipe_name], [str])
self._send_cmd_line(['event_eos'] + parameters)
def event_flush_start(self, pipe_name):
"""
Put the pipeline in flushing mode.
Parameters
----------
pipe_name: string
The name of the pipeline
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info(
'Putting pipeline {} in flushing mode'.format(pipe_name))
parameters = self._check_parameters([pipe_name], [str])
self._send_cmd_line(['event_flush_start'] + parameters)
def event_flush_stop(self, pipe_name, reset=True):
"""
Take the pipeline out from flushing mode.
Parameters
----------
pipe_name: string
The name of the pipeline
reset: boolean
Reset the event flush
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info(
'Taking pipeline {} out of flushing mode'.format(pipe_name))
parameters = self._check_parameters([pipe_name, reset], [str, bool])
self._send_cmd_line(['event_flush_stop'] + parameters)
def event_seek(
self,
pipe_name,
rate=1.0,
format=3,
flags=1,
start_type=1,
start=0,
end_type=1,
end=-1,
):
"""
Perform a seek in the given pipeline
Parameters
----------
pipe_name: string
The name of the pipeline
rate: float
The new playback rate. Default value: 1.0.
format: int
The format of the seek values. Default value: 3.
flags: int
The optional seek flags. Default value: 1.
start_type: int
The type and flags for the new start position. Default value: 1.
start: int
The value of the new start position. Default value: 0.
end_type: int
The type and flags for the new end position. Default value: 1.
end: int
The value of the new end position. Default value: -1.
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info(
'Performing event seek in pipeline {}'.format(pipe_name))
parameters = self._check_parameters(
[
pipe_name, rate, format, flags, start_type, start, end_type,
end],
[
str, float, int, int, int, int, int, int])
self._send_cmd_line(['event_seek'] + parameters)
def list_elements(self, pipe_name):
"""
List the elements in a given pipeline.
Parameters
----------
pipe_name: string
The name of the pipeline
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
Returns
-------
result : string
List of elements
"""
self._logger.info('Listing elements of pipeline {}'.format(pipe_name))
parameters = self._check_parameters([pipe_name], [str])
result = self._send_cmd_line(['list_elements'] + parameters)
return result['response']['nodes']
def list_pipelines(self):
"""
List the existing pipelines
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
Returns
-------
result : string
List of pipelines
"""
self._logger.info('Listing pipelines')
result = self._send_cmd_line(['list_pipelines'])
return result['response']['nodes']
def list_properties(self, pipe_name, element):
"""
List the properties of an element in a given pipeline.
Parameters
----------
pipe_name: string
The name of the pipeline
element: string
The name of the element
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
Returns
-------
result : string
List of properties
"""
self._logger.info(
'Listing properties of element {} from pipeline {}'.format(
element, pipe_name))
parameters = self._check_parameters([pipe_name, element], [str, str])
result = self._send_cmd_line(['list_properties'] + parameters)
return result['response']['nodes']
def list_signals(self, pipe_name, element):
"""
List the signals of an element in a given pipeline.
Parameters
----------
pipe_name: string
The name of the pipeline
element: string
The name of the element
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
Returns
-------
result : string
List of signals
"""
self._logger.info(
'Listing signals of element {} from pipeline {}'.format(
element, pipe_name))
parameters = self._check_parameters([pipe_name, element], [str, str])
result = self._send_cmd_line(['list_signals'] + parameters)
return result['response']['nodes']
def pipeline_create(self, pipe_name, pipe_desc):
"""
Create a new pipeline based on the name and description.
Parameters
----------
pipe_name: string
The name of the pipeline
pipe_desc: string
Pipeline description (same as gst-launch-1.0)
"""
self._logger.info(
'Creating pipeline {} with description "{}"'.format(
pipe_name, pipe_desc))
parameters = self._check_parameters([pipe_name, pipe_desc], [str, str])
self._send_cmd_line(['pipeline_create'] + parameters)
def pipeline_create_ref(self, pipe_name, pipe_desc):
"""
Create a new pipeline based on the name and description using refcount.
The refcount works similarly to GObject references. If the command
is called but the refcount is greater than 0 nothing will happen
and the refcount will increment.
Parameters
----------
pipe_name: string
The name of the pipeline
pipe_desc: string
Pipeline description (same as gst-launch-1.0)
"""
self._logger.info(
'Creating pipeline by reference {} with description "{}"'.format(
pipe_name, pipe_desc))
parameters = self._check_parameters([pipe_name, pipe_desc], [str, str])
self._send_cmd_line(['pipeline_create_ref'] + parameters)
def pipeline_delete(self, pipe_name):
"""
Delete the pipeline with the given name.
Parameters
----------
pipe_name: string
The name of the pipeline
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info('Deleting pipeline {}'.format(pipe_name))
parameters = self._check_parameters([pipe_name], [str])
self._send_cmd_line(['pipeline_delete'] + parameters)
def pipeline_delete_ref(self, pipe_name):
"""
Delete the pipeline with the given name using refcount.
The refcount works similarly to GObject references. If the command
is called but the refcount is greater than 1 nothing will happen
and the refcount will decrement.
Parameters
----------
pipe_name: string
The name of the pipeline
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info(
'Deleting pipeline by reference {}'.format(pipe_name))
parameters = self._check_parameters([pipe_name], [str])
self._send_cmd_line(['pipeline_delete_ref'] + parameters)
def pipeline_pause(self, pipe_name):
"""
Set the pipeline to paused.
Parameters
----------
pipe_name: string
The name of the pipeline
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info('Pausing pipeline {}'.format(pipe_name))
parameters = self._check_parameters([pipe_name], [str])
self._send_cmd_line(['pipeline_pause'] + parameters)
def pipeline_play(self, pipe_name):
"""
Set the pipeline to playing.
Parameters
----------
pipe_name: string
The name of the pipeline
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info('Playing pipeline {}'.format(pipe_name))
parameters = self._check_parameters([pipe_name], [str])
self._send_cmd_line(['pipeline_play'] + parameters)
def pipeline_play_ref(self, pipe_name):
"""
Set the pipeline to playing using refcount.
The refcount works similarly to GObject references. If the command
is called but the refcount is greater than 0 nothing will happen
and the refcount will increment.
Parameters
----------
pipe_name: string
The name of the pipeline
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info('Playing pipeline by reference {}'.format(pipe_name))
parameters = self._check_parameters([pipe_name], [str])
self._send_cmd_line(['pipeline_play_ref'] + parameters)
def pipeline_stop(self, pipe_name):
"""
Set the pipeline to null.
Parameters
----------
pipe_name: string
The name of the pipeline
Raises
------
GstdError
Error is triggered when Gstd IPC fails
GstcError
Error is triggered when the Gstd python client fails internally
"""
self._logger.info('Stoping pipeline {}'.format(pipe_name))
parameters = self._check_parameters([pipe_name], [str])
self._send_cmd_line(['pipeline_stop'] + parameters)