gst-switch python API¶
gstswitch Package¶
Python API for gst-switch
connection Module¶
connection deals with all low level method calls over dbus The Connection object is capable of invoking remote methods over dbus
- class gstswitch.connection.Connection(address='unix:abstract=gstswitch', bus_name='info.duzy.gst.switch.SwitchController', object_path='/info/duzy/gst/switch/SwitchController', default_interface='info.duzy.gst.switch.SwitchControllerInterface')[source]¶
Bases: object
Class which makes all remote object class. Deals with lower level connection and remote method invoking
Default bus-address: unix:abstract=gstswitch Param: None - CONNECTION_FLAGS = 1¶
- adjust_pip(xpos, ypos, width, height)[source]¶
- adjust_pip(in i dx,
- in i dy, in i dw, in i dh, out u result);
Calls adjust_pip remotely
Parameters: - xpos – the X position of the PIP
- ypos – the Y position of the PIP
- width – the width of the PIP
- height – the height of the PIP
Returns: tuple with first element as result -
PIP has been changed succefully
- click_video(xpos, ypos, width, height)[source]¶
- click_video(in i x,
- in i y, in i fw, in i fh, out b result);
Calls click_video remotely
Parameters: - xpos –
- ypos –
- width –
- height –
Returns: tuple with first element True if requested
- connect_dbus()[source]¶
Make a new connection using the parameters belonging to the class to the gst-switch-srv over dbus. Sets the self.connection
Params: None Returns: Nothing Raises ConnectionError: GError occurs while making a connection
- get_audio_port()[source]¶
get_audio_port(out i port); Calls get_audio_port remotely
Param: None Returns: tuple wit first element audio port number
- get_compose_port()[source]¶
get_compose_port(out i port); Calls get_compose_port remotely
Param: None Returns: tuple with first element compose port number
- get_encode_port()[source]¶
get_encode_port(out i port); Calls get_encode_port remotely
Param: None Returns: tuple with first element encode port number
- get_preview_ports()[source]¶
get_preview_ports(out s ports); Calls get_preview_ports remotely
Param: None Returns: tuple with first element a string in the form of ‘[(3002, 1, 7), (3003, 1, 8)]’
- mark_face(faces)[source]¶
mark_face(in a(iiii) faces); Calls mark_face remotely
Parameters: faces – tuple having four elements Returns: tuple with first element True if requested
- mark_tracking(faces)[source]¶
mark_tracking(in a(iiii) faces); Calls mark_tracking remotely
Parameters: faces – tuple having four elements Returns: tuple with first element True if requested
- new_record()[source]¶
new_record(out b result); Calls new_record remotely
Param: None: returns: tuple with first element True if requested
- set_composite_mode(mode)[source]¶
- set_composite_mode(in i channel,
- out b result);
Calls set_composite_mode remotely
Parameters: mode – new composite mode Returns: tuple with first element True if requested
controller Module¶
The controller is the interface for all remote method calls over dbus. The Controller class creates the controller, which can be used to invoke the remote methods.
- class gstswitch.controller.Controller(address='unix:abstract=gstswitch', bus_name='info.duzy.gst.switch.SwitchController', object_path='/info/duzy/gst/switch/SwitchController', default_interface='info.duzy.gst.switch.SwitchControllerInterface')[source]¶
Bases: object
A Class to control all interactions with the gst-switch-srv over dbus. Provides the interface for higher level interactions
Param: None - adjust_pip(xpos, ypos, width, height)[source]¶
Change the PIP position and size
Parameters: - xpos – the x position of the PIP
- ypos – the y position of the PIP
- width – the width of the PIP
- height – the height of the PIP
Returns: result - PIP has been changed succefully
- click_video(xpos, ypos, width, height)[source]¶
User click on the video
Parameters: - xpos –
- ypos –
- width –
- height –
Returns: True when requested
- establish_connection()[source]¶
Establishes a fresh connection to the dbus Connection stored as self.connection
Param: None Returns: None
- mark_face(faces)[source]¶
Mark faces
Parameters: faces – tuple having four elements Returns: True when requested
- mark_tracking(faces)[source]¶
Mark tracking
Parameters: faces – tuple having four elements Returns: True when requested
- set_composite_mode(mode)[source]¶
Set the current composite mode. Modes between 0 and 3 are allowed.
Parameters: mode – new composite mode Returns: True when requested
exception Module¶
All custom exceptions come here
- exception gstswitch.exception.BaseError[source]¶
Bases: exceptions.Exception
docstring for BaseError
- exception gstswitch.exception.PathError[source]¶
Bases: gstswitch.exception.BaseError
docstring for PathError
- exception gstswitch.exception.ServerProcessError[source]¶
Bases: gstswitch.exception.BaseError
docstring for ServerProcessError
- exception gstswitch.exception.ConnectionError[source]¶
Bases: gstswitch.exception.BaseError
docstring for ConnectionError
- exception gstswitch.exception.ConnectionReturnError[source]¶
Bases: gstswitch.exception.BaseError
docstring for ConnectionReturnError
- exception gstswitch.exception.RangeError[source]¶
Bases: gstswitch.exception.BaseError
docstring for RangeError
- exception gstswitch.exception.InvalidIndexError[source]¶
Bases: gstswitch.exception.BaseError
docstring for InvalidIndexError
helpers Module¶
Has helper classes which create test video and audio sources. It is also possible to create a preview out source showing the compose port output.
- class gstswitch.helpers.TestSources(video_port=None, audio_port=None)[source]¶
Bases: object
A Controller of test sources feeding into the gst-switch-srv :param width: The width of the output video :param height: The height of the output video :param pattern: The videotestsrc pattern of the output video :param timeoverlay: True to enable a running time over video :param clockoverlay: True to enable current clock time over video
- get_test_audio()[source]¶
Returns a list of processes acting as audio test sources running :returns: A list containing all audio test sources running
- get_test_video()[source]¶
Returns a list of processes acting as video test sources running :returns: A list containing all video test sources running
- new_test_audio(freq=110, wave=None)[source]¶
Start a new test audio :param port: The port of where the TCP stream will be sent Should be same as audio port of gst-switch-src :param width: The width of the output audio :param height: The height of the output audio :param pattern: The audiotestsrc pattern of the output audio :param timeoverlay: True to enable a running time over audio :param clockoverlay: True to enable current clock time over audio
- new_test_video(width=300, height=200, pattern=None, timeoverlay=False, clockoverlay=False)[source]¶
Start a new test video :param port: The port of where the TCP stream will be sent Should be same as video port of gst-switch-src :param width: The width of the output video :param height: The height of the output video :param pattern: The videotestsrc pattern of the output video :param timeoverlay: True to enable a running time over video :param clockoverlay: True to enable current clock time over video
- terminate_index_audio(index)[source]¶
Terminate audio test source specified by index :param index: The index of the audio source to terminate Use get_test_audio for finding the index
server Module¶
The server deals with all operations controlling gst-switch-srv These include all OS related tasks
- class gstswitch.server.Server(path=None, video_port=3000, audio_port=4000, control_port=5000, record_file=False)[source]¶
Bases: object
Control all server related operations
Parameters: path – Path where the executable gst-switch-srv is located. Provide the full path. By default looks in the current $PATH. :param video_port: The video port number - default = 3000 :param audio_port: The audio port number - default = 4000 :param control_port: The control port number - default = 5000 :param record_file: The record file format :returns: nothing
- SLEEP_TIME = 0.5¶
- gcov_flush()[source]¶
Generate gcov coverage by sending the signal SIGUSR1 The generated gcda files are dumped in tools directory. Does not kill the process
Param: None
Returns: True when success
Raises: - ServerProcessError – If Server is not running
- ServerProcessError – Unable to send signal
- kill(cov=False)[source]¶
Kill the server process by sending signal.SIGKILL self.proc is made None on success
Param: None
Returns: True when success
Raises: - ServerProcessError – Process does not exist
- ServerProcessError – Cannot kill process
- classmethod make_coverage()[source]¶
Generate coverage Calls ‘make coverage’ to generate coverage in .gcov files
- run(gst_option='')[source]¶
Launch the server process
Param: None Gst-option: Any gstreamer option. Refer to http://www.linuxmanpages.com/man1/gst-launch-0.8.1.php#lbAF. Multiple can be added separated by spaces :returns: nothing :raises IOError: Fail to open /dev/null (os.devnull) :raises PathError: Unable to find gst-switch-srv at path specified :raises ServerProcessError: Running gst-switch-srv gives a OS based error.
testsource Module¶
The testsource contains all gstreamer pipelines It provides the abse for all the other gstreamer components are build upon.
- class gstswitch.testsource.Preview(port)[source]¶
Bases: object
A Preview Element :param port: The preview port
- class gstswitch.testsource.VideoSrc(port, width=300, height=200, pattern=None, timeoverlay=False, clockoverlay=False)[source]¶
Bases: object
A Test Video Source :param width: The width of the output video :param height: The height of the output video :param pattern: The videotestsrc pattern of the output video None for random :param timeoverlay: True to enable a running time over video :param clockoverlay: True to enable current clock time over video
- HOST = 'localhost'¶