Beginning with some code

June 7, 2013 - 3 minute read -
gsoc timvideos python

Finally getting some fingers moving. I am pushing code at here. Worked out an initial class structure for getting the things working. I am trying to put in little bit of documentation in the function itself.
Currently there are three main classes: Server, UI and Controller.

The Server

The Server is the interaction module with gst-switch-srv. It is capable of controlling the server. The Server class has a contructor where the user can specify the video port, audio port, control port and the output record file.

		from gstswitch import *		#importing all modules
	
		server = Server()			#simple enough thing, gets the server running with default parameters.
	
The server can be started off forking a new process and can safely be killed. Connection to the controller can be made by invoking the Controller class.
		control = server.connectController()
	
If a connection does not exist a new connection should be made to the Controller. Now that the server is running, there should be some input to the server! These are the videotestsrc elements of gstreamer. I have added options where the user can select what pattern, height, width etc can be specified. The width of the input stream should be 300 and height should be 200 always, else it might result in some strange unclear patterns coming up. If no pattern is specified a random one gets selected.
		server.newTestVideo() 		#adds a new test source to the gst-switch
		server.getAllTestVideo() 	#displays all test sources feeding in the gst-switch
	
The Server and the test sources can be easily killed off by invoking like this. I was earlier facing a problem where the subprocess.Popen() command was making two processes. Now, while killing only one gets killed, whereas the other one was still remaining. I was using an option shell=True as an argument to the Popen command. Changing this option to shell=False allowed me to control the server class more easily as in this case only one process gets created!
		server.end() 				#kills off the server process
		server.endAllTestVideo() 	#kills off all test videos that have been defined. server.end() takes care of this
	
Currently the video sources are being fed by creating new processes. I will modify these using the Gstreamer 1.0 Python Bindings defined under gi.repository.Gst

The UI

Now the server is running and the input sources have been specified, we need to view the output that is getting generated. For this the gst-switch-ui can be invoked. Simply the UI is run using:

		ui = UI()
	
The UI process is ended simply using ui.end() method. Once the controller is ready, the compose port can be used to view the output of the gst-switch server directly eliminating the need of the UI.

Comments Section

Feel free to comment on the post but keep it clean and on topic.

blog comments powered by Disqus