diff --git a/src/freeseer/framework/multimedia.py b/src/freeseer/framework/multimedia.py index 325e93bc..8c9437d5 100644 --- a/src/freeseer/framework/multimedia.py +++ b/src/freeseer/framework/multimedia.py @@ -25,12 +25,14 @@ import datetime import logging import os +import sys -import gobject -gobject.threads_init() -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst, GstVideo + +GObject.threads_init() +Gst.init(None) from freeseer.framework.presentation import Presentation from freeseer.framework.plugin import IOutput @@ -58,7 +60,7 @@ def __init__(self, config, plugman, window_id=None, audio_feedback=None, cli=Fal self.current_state = Multimedia.NULL # Initialize Player - self.player = gst.Pipeline('player') + self.player = Gst.Pipeline() bus = self.player.get_bus() bus.add_signal_watch() bus.enable_sync_message_emission() @@ -66,8 +68,8 @@ def __init__(self, config, plugman, window_id=None, audio_feedback=None, cli=Fal bus.connect('sync-message::element', self.on_sync_message) # Initialize Entry Points - self.audio_tee = gst.element_factory_make('tee', 'audio_tee') - self.video_tee = gst.element_factory_make('tee', 'video_tee') + self.audio_tee = Gst.ElementFactory.make('tee', None) + self.video_tee = Gst.ElementFactory.make('tee', None) self.player.add(self.audio_tee) self.player.add(self.video_tee) @@ -77,38 +79,42 @@ def __init__(self, config, plugman, window_id=None, audio_feedback=None, cli=Fal ## GST Player Functions ## def on_message(self, bus, message): + # This mothod never seems to be run in Windows + # print "This message came from on_message" + # print t t = message.type - - if t == gst.MESSAGE_EOS: + if t == Gst.MessageType.EOS: self.stop() - elif t == gst.MESSAGE_ERROR: + elif t == Gst.MessageType.ERROR: err, debug = message.parse_error() log.error(str(err) + str(debug)) - elif message.structure is not None: - s = message.structure.get_name() - + elif message.get_structure() is not None: + s = message.get_structure().get_name() if s == 'level' and self.audio_feedback_event is not None: - msg = message.structure.to_string() - rms_dB = float(msg.split(',')[6].split('{')[1].rstrip('}')) - - # This is an inaccurate representation of decibels into percent - # conversion, this code should be revisited. - try: - percent = (int(round(rms_dB)) + 50) * 2 - except OverflowError: - percent = 0 - self.audio_feedback_event(percent) + msg = message.get_structure().get_name() + #This code causes Linux to throw errors + # rms_dB = float(msg.split(',')[6].split('{')[1].rstrip('}')) + + # # This is an inaccurate representation of decibels into percent + # # conversion, this code should be revisited. + # try: + # percent = (int(round(rms_dB)) + 50) * 2 + # except OverflowError: + # percent = 0 + # self.audio_feedback_event(percent) def on_sync_message(self, bus, message): - if message.structure is None: + if message.get_structure() is None: return - message_name = message.structure.get_name() - if message_name == 'prepare-xwindow-id' and self.window_id is not None: + message_name = message.get_structure().get_name() + # print "This message came from on_sync_message" + # print message_name + if message_name == 'prepare-window-handle' and self.window_id is not None: imagesink = message.src imagesink.set_property('force-aspect-ratio', True) - imagesink.set_xwindow_id(int(self.window_id)) + imagesink.set_window_handle(int(self.window_id)) log.debug("Preview loaded into window.") def set_window_id(self, window_id): @@ -126,7 +132,7 @@ def record(self): """ Start recording. """ - self.player.set_state(gst.STATE_PLAYING) + self.player.set_state(Gst.State.PLAYING) self.current_state = Multimedia.RECORD log.debug("Recording started.") @@ -134,7 +140,7 @@ def pause(self): """ Pause recording. """ - self.player.set_state(gst.STATE_PAUSED) + self.player.set_state(Gst.State.PAUSED) self.current_state = Multimedia.PAUSE log.debug("Gstreamer paused.") @@ -143,7 +149,7 @@ def stop(self): Stop recording. """ if self.current_state != Multimedia.NULL and self.current_state != Multimedia.STOP: - self.player.set_state(gst.STATE_NULL) + self.player.set_state(Gst.State.NULL) self.unload_audiomixer() self.unload_videomixer() @@ -299,9 +305,9 @@ def load_output_plugins(self, plugins, record_audio, record_video, metadata): elif type == IOutput.BOTH: self.player.add(bin) if record_audio: - self.audio_tee.link_pads("src%d", bin, "audiosink") + self.audio_tee.link_pads("src_%u", bin, "audiosink") if record_video: - self.video_tee.link_pads("src%d", bin, "videosink") + self.video_tee.link_pads("src_%u", bin, "videosink") self.output_plugins.append(bin) return True @@ -362,4 +368,4 @@ def unload_videomixer(self): self.player.remove(plugin) self.videomixer.unlink(self.video_tee) - self.player.remove(self.videomixer) + self.player.remove(self.videomixer) \ No newline at end of file diff --git a/src/freeseer/plugins/audioinput/alsasrc/__init__.py b/src/freeseer/plugins/audioinput/alsasrc/__init__.py index f2cfb3c2..737ddfc6 100644 --- a/src/freeseer/plugins/audioinput/alsasrc/__init__.py +++ b/src/freeseer/plugins/audioinput/alsasrc/__init__.py @@ -28,9 +28,9 @@ @author: Thanh Ha ''' -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst from freeseer.framework.plugin import IAudioInput @@ -40,14 +40,14 @@ class ALSASrc(IAudioInput): os = ["linux", "linux2"] def get_audioinput_bin(self): - bin = gst.Bin() # Do not pass a name so that we can load this input more than once. + bin = Gst.Bin() # Do not pass a name so that we can load this input more than once. - audiosrc = gst.element_factory_make("alsasrc", "audiosrc") + audiosrc = Gst.ElementFactory.make("alsasrc", "audiosrc") bin.add(audiosrc) # Setup ghost pad - pad = audiosrc.get_pad("src") - ghostpad = gst.GhostPad("audiosrc", pad) + pad = audiosrc.get_static_pad("src") + ghostpad = Gst.GhostPad.new("audiosrc", pad) bin.add_pad(ghostpad) return bin diff --git a/src/freeseer/plugins/audioinput/audiotestsrc/__init__.py b/src/freeseer/plugins/audioinput/audiotestsrc/__init__.py index e210ea95..27123e15 100644 --- a/src/freeseer/plugins/audioinput/audiotestsrc/__init__.py +++ b/src/freeseer/plugins/audioinput/audiotestsrc/__init__.py @@ -29,9 +29,9 @@ @author: Thanh Ha ''' -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst from freeseer.framework.plugin import IAudioInput @@ -41,14 +41,14 @@ class AudioTestSrc(IAudioInput): os = ["linux", "linux2", "win32", "cygwin", "darwin"] def get_audioinput_bin(self): - bin = gst.Bin() # Do not pass a name so that we can load this input more than once. + bin = Gst.Bin() # Do not pass a name so that we can load this input more than once. - audiosrc = gst.element_factory_make("audiotestsrc", "audiosrc") + audiosrc = Gst.ElementFactory.make("audiotestsrc", "audiosrc") bin.add(audiosrc) # Setup ghost pad - pad = audiosrc.get_pad("src") - ghostpad = gst.GhostPad("audiosrc", pad) + pad = audiosrc.get_static_pad("src") + ghostpad = Gst.GhostPad.new("audiosrc", pad) bin.add_pad(ghostpad) return bin diff --git a/src/freeseer/plugins/audioinput/autoaudiosrc/__init__.py b/src/freeseer/plugins/audioinput/autoaudiosrc/__init__.py index 0251ba59..3d869230 100644 --- a/src/freeseer/plugins/audioinput/autoaudiosrc/__init__.py +++ b/src/freeseer/plugins/audioinput/autoaudiosrc/__init__.py @@ -28,10 +28,11 @@ @author: Thanh Ha ''' +import sys -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst from freeseer.framework.plugin import IAudioInput @@ -41,14 +42,20 @@ class AutoAudioSrc(IAudioInput): os = ["linux", "linux2", "win32", "cygwin", "darwin"] def get_audioinput_bin(self): - bin = gst.Bin() # Do not pass a name so that we can load this input more than once. + bin = Gst.Bin() # Do not pass a name so that we can load this input more than once. + if sys.platform.startswith("linux"): + audiosrc = Gst.ElementFactory.make("autoaudiosrc", None) - audiosrc = gst.element_factory_make("autoaudiosrc", "audiosrc") + elif sys.platform in ["win32", "cygwin"]: + # autoaudiosrc causes python to lock up in Windows + audiosrc = Gst.ElementFactory.make("audiotestsrc", None) + + bin.add(audiosrc) # Setup ghost pad - pad = audiosrc.get_pad("src") - ghostpad = gst.GhostPad("audiosrc", pad) + pad = audiosrc.get_static_pad("src") + ghostpad = Gst.GhostPad.new("audiosrc", pad) bin.add_pad(ghostpad) return bin diff --git a/src/freeseer/plugins/audioinput/jackaudiosrc/__init__.py b/src/freeseer/plugins/audioinput/jackaudiosrc/__init__.py index 49334cb9..e9a8440b 100644 --- a/src/freeseer/plugins/audioinput/jackaudiosrc/__init__.py +++ b/src/freeseer/plugins/audioinput/jackaudiosrc/__init__.py @@ -32,9 +32,9 @@ import ConfigParser # GStreamer -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst # PyQt from PyQt4.QtCore import SIGNAL @@ -57,14 +57,14 @@ class JackAudioSrc(IAudioInput): clientname = "" def get_audioinput_bin(self): - bin = gst.Bin() # Do not pass a name so that we can load this input more than once. + bin = Gst.Bin() # Do not pass a name so that we can load this input more than once. - audiosrc = gst.element_factory_make("jackaudiosrc", "audiosrc") + audiosrc = Gst.ElementFactory.make("jackaudiosrc", "audiosrc") bin.add(audiosrc) # Setup ghost pad - pad = audiosrc.get_pad("src") - ghostpad = gst.GhostPad("audiosrc", pad) + pad = audiosrc.get_static_pad("src") + ghostpad = Gst.GhostPad.new("audiosrc", pad) bin.add_pad(ghostpad) return bin diff --git a/src/freeseer/plugins/audioinput/pulsesrc/__init__.py b/src/freeseer/plugins/audioinput/pulsesrc/__init__.py index 5c5b40ab..19d7a7bb 100644 --- a/src/freeseer/plugins/audioinput/pulsesrc/__init__.py +++ b/src/freeseer/plugins/audioinput/pulsesrc/__init__.py @@ -33,9 +33,9 @@ import logging # GStreamer -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst # PyQt from PyQt4.QtCore import SIGNAL @@ -57,17 +57,17 @@ class PulseSrc(IAudioInput): source = '' def get_audioinput_bin(self): - bin = gst.Bin() # Do not pass a name so that we can load this input more than once. + bin = Gst.Bin() # Do not pass a name so that we can load this input more than once. - audiosrc = gst.element_factory_make("pulsesrc", "audiosrc") + audiosrc = Gst.ElementFactory.make("pulsesrc", "audiosrc") if self.source != '': audiosrc.set_property('device', self.source) log.debug('Pulseaudio source is set to %s' % str(audiosrc.get_property('device'))) bin.add(audiosrc) # Setup ghost pad - pad = audiosrc.get_pad("src") - ghostpad = gst.GhostPad("audiosrc", pad) + pad = audiosrc.get_static_pad("src") + ghostpad = Gst.GhostPad.new("audiosrc", pad) bin.add_pad(ghostpad) return bin @@ -77,7 +77,7 @@ def __get_sources(self): Get a list of pairs in the form (name, description) for each pulseaudio source. """ result = [] - audiosrc = gst.element_factory_make("pulsesrc", "audiosrc") + audiosrc = Gst.ElementFactory.make("pulsesrc", "audiosrc") audiosrc.probe_property_name('device') names = audiosrc.probe_get_values_name('device') #should be getting actual device description, but .get_property('device-name') does not work diff --git a/src/freeseer/plugins/audiomixer/audiopassthrough/__init__.py b/src/freeseer/plugins/audiomixer/audiopassthrough/__init__.py index 375bfbad..9b38b6bb 100644 --- a/src/freeseer/plugins/audiomixer/audiopassthrough/__init__.py +++ b/src/freeseer/plugins/audiomixer/audiopassthrough/__init__.py @@ -34,9 +34,9 @@ import ConfigParser # GStreamer -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst # PyQt from PyQt4.QtCore import SIGNAL @@ -55,18 +55,18 @@ class AudioPassthrough(IAudioMixer): widget = None def get_audiomixer_bin(self): - bin = gst.Bin() + bin = Gst.Bin() - audiomixer = gst.element_factory_make("adder", "audiomixer") + audiomixer = Gst.ElementFactory.make("adder", "audiomixer") bin.add(audiomixer) # Setup ghost pad - sinkpad = audiomixer.get_pad("sink%d") - sink_ghostpad = gst.GhostPad("sink", sinkpad) + sinkpad = audiomixer.get_request_pad("sink_%u") + sink_ghostpad = Gst.GhostPad.new("sink", sinkpad) bin.add_pad(sink_ghostpad) - srcpad = audiomixer.get_pad("src") - src_ghostpad = gst.GhostPad("src", srcpad) + srcpad = audiomixer.get_static_pad("src") + src_ghostpad = Gst.GhostPad.new("src", srcpad) bin.add_pad(src_ghostpad) return bin diff --git a/src/freeseer/plugins/audiomixer/multiaudio/__init__.py b/src/freeseer/plugins/audiomixer/multiaudio/__init__.py index 780c86dd..b0736192 100644 --- a/src/freeseer/plugins/audiomixer/multiaudio/__init__.py +++ b/src/freeseer/plugins/audiomixer/multiaudio/__init__.py @@ -32,9 +32,9 @@ import ConfigParser # GStreamer -import pygst -pygst.require('0.10') -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst # PyQt from PyQt4.QtCore import SIGNAL @@ -54,22 +54,22 @@ class MultiAudio(IAudioMixer): widget = None def get_audiomixer_bin(self): - mixerbin = gst.Bin() + mixerbin = Gst.Bin() - audiomixer = gst.element_factory_make('adder', 'audiomixer') + audiomixer = Gst.ElementFactory.make('adder', 'audiomixer') mixerbin.add(audiomixer) # ghost pads - sinkpad1 = audiomixer.get_pad('sink%d') - sink_ghostpad1 = gst.GhostPad('sink1', sinkpad1) + sinkpad1 = audiomixer.get_static_pad('sink%d') + sink_ghostpad1 = Gst.GhostPad.new('sink1', sinkpad1) mixerbin.add_pad(sink_ghostpad1) - sinkpad2 = audiomixer.get_pad('sink%d') - sink_ghostpad2 = gst.GhostPad('sink2', sinkpad2) + sinkpad2 = audiomixer.get_static_pad('sink%d') + sink_ghostpad2 = Gst.GhostPad.new('sink2', sinkpad2) mixerbin.add_pad(sink_ghostpad2) - srcpad = audiomixer.get_pad('src') - src_ghostpad = gst.GhostPad('src', srcpad) + srcpad = audiomixer.get_static_pad('src') + src_ghostpad = Gst.GhostPad.new('src', srcpad) mixerbin.add_pad(src_ghostpad) return mixerbin diff --git a/src/freeseer/plugins/output/audiofeedback/__init__.py b/src/freeseer/plugins/output/audiofeedback/__init__.py index 3fd50cd5..79bcbcac 100644 --- a/src/freeseer/plugins/output/audiofeedback/__init__.py +++ b/src/freeseer/plugins/output/audiofeedback/__init__.py @@ -33,9 +33,9 @@ import ConfigParser # GStreamer -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst # PyQt from PyQt4.QtCore import SIGNAL @@ -57,17 +57,17 @@ class AudioFeedback(IOutput): feedbacksink = "autoaudiosink" def get_output_bin(self, audio=True, video=False, metadata=None): - bin = gst.Bin() + bin = Gst.Bin() - audioqueue = gst.element_factory_make("queue", "audioqueue") + audioqueue = Gst.ElementFactory.make("queue", "audioqueue") bin.add(audioqueue) - audiosink = gst.element_factory_make(self.feedbacksink, "audiosink") + audiosink = Gst.ElementFactory.make(self.feedbacksink, "audiosink") bin.add(audiosink) # Setup ghost pad - pad = audioqueue.get_pad("sink") - ghostpad = gst.GhostPad("sink", pad) + pad = audioqueue.get_static_pad("sink") + ghostpad = Gst.GhostPad.new("sink", pad) bin.add_pad(ghostpad) audioqueue.link(audiosink) diff --git a/src/freeseer/plugins/output/ogg_icecast/__init__.py b/src/freeseer/plugins/output/ogg_icecast/__init__.py index 35f8b794..334d01ad 100644 --- a/src/freeseer/plugins/output/ogg_icecast/__init__.py +++ b/src/freeseer/plugins/output/ogg_icecast/__init__.py @@ -32,9 +32,9 @@ import ConfigParser # GStreamer -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst # PyQt from PyQt4.QtCore import SIGNAL @@ -61,16 +61,16 @@ class OggIcecast(IOutput): mount = "stream.ogg" def get_output_bin(self, audio=True, video=True, metadata=None): - bin = gst.Bin() + bin = Gst.Bin() if metadata is not None: self.set_metadata(metadata) # Muxer - muxer = gst.element_factory_make("oggmux", "muxer") + muxer = Gst.ElementFactory.make("oggmux", "muxer") bin.add(muxer) - icecast = gst.element_factory_make("shout2send", "icecast") + icecast = Gst.ElementFactory.make("shout2send", "icecast") icecast.set_property("ip", self.ip) icecast.set_property("port", self.port) icecast.set_property("password", self.password) @@ -81,19 +81,19 @@ def get_output_bin(self, audio=True, video=True, metadata=None): # Setup Audio Pipeline # if audio: - audioqueue = gst.element_factory_make("queue", "audioqueue") + audioqueue = Gst.ElementFactory.make("queue", "audioqueue") bin.add(audioqueue) - audioconvert = gst.element_factory_make("audioconvert", "audioconvert") + audioconvert = Gst.ElementFactory.make("audioconvert", "audioconvert") bin.add(audioconvert) - audiocodec = gst.element_factory_make("vorbisenc", "audiocodec") + audiocodec = Gst.ElementFactory.make("vorbisenc", "audiocodec") bin.add(audiocodec) # Setup metadata - vorbistag = gst.element_factory_make("vorbistag", "vorbistag") + vorbistag = Gst.ElementFactory.make("vorbistag", "vorbistag") # set tag merge mode to GST_TAG_MERGE_REPLACE - merge_mode = gst.TagMergeMode.__enum_values__[2] + merge_mode = Gst.TagMergeMode.__enum_values__[2] if metadata is not None: # Only set tag if metadata is set @@ -102,8 +102,8 @@ def get_output_bin(self, audio=True, video=True, metadata=None): bin.add(vorbistag) # Setup ghost pads - audiopad = audioqueue.get_pad("sink") - audio_ghostpad = gst.GhostPad("audiosink", audiopad) + audiopad = audioqueue.get_static_pad("sink") + audio_ghostpad = Gst.GhostPad.new("audiosink", audiopad) bin.add_pad(audio_ghostpad) # Link elements @@ -116,14 +116,14 @@ def get_output_bin(self, audio=True, video=True, metadata=None): # Setup Video Pipeline # if video: - videoqueue = gst.element_factory_make("queue", "videoqueue") + videoqueue = Gst.ElementFactory.make("queue", "videoqueue") bin.add(videoqueue) - videocodec = gst.element_factory_make("theoraenc", "videocodec") + videocodec = Gst.ElementFactory.make("theoraenc", "videocodec") bin.add(videocodec) - videopad = videoqueue.get_pad("sink") - video_ghostpad = gst.GhostPad("videosink", videopad) + videopad = videoqueue.get_static_pad("sink") + video_ghostpad = Gst.GhostPad.new("videosink", videopad) bin.add_pad(video_ghostpad) videoqueue.link(videocodec) @@ -141,10 +141,10 @@ def set_metadata(self, data): Populate global tag list variable with file metadata for vorbistag audio element ''' - self.tags = gst.TagList() + self.tags = Gst.TagList() for tag in data.keys(): - if(gst.tag_exists(tag)): + if(Gst.tag_exists(tag)): self.tags[tag] = data[tag] else: #self.core.logger.log.debug("WARNING: Tag \"" + str(tag) + "\" is not registered with gstreamer.") diff --git a/src/freeseer/plugins/output/ogg_output/__init__.py b/src/freeseer/plugins/output/ogg_output/__init__.py index 3b6b8fe0..e41102b4 100644 --- a/src/freeseer/plugins/output/ogg_output/__init__.py +++ b/src/freeseer/plugins/output/ogg_output/__init__.py @@ -32,10 +32,12 @@ # python-libs import ConfigParser + # GStreamer -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst, GstTag +from gi.repository import GLib # PyQt from PyQt4.QtCore import SIGNAL @@ -61,7 +63,7 @@ class OggOutput(IOutput): video_bitrate = 2400 def get_output_bin(self, audio=True, video=True, metadata=None): - bin = gst.Bin() + bin = Gst.Bin() if metadata is not None: self.set_metadata(metadata) @@ -69,11 +71,11 @@ def get_output_bin(self, audio=True, video=True, metadata=None): self.generate_xml_metadata(metadata).write(self.location + ".xml") # Muxer - muxer = gst.element_factory_make("oggmux", "muxer") + muxer = Gst.ElementFactory.make("oggmux", None) bin.add(muxer) # File sink - filesink = gst.element_factory_make('filesink', 'filesink') + filesink = Gst.ElementFactory.make('filesink', None) filesink.set_property('location', self.location) bin.add(filesink) @@ -81,57 +83,61 @@ def get_output_bin(self, audio=True, video=True, metadata=None): # Setup Audio Pipeline if Audio Recording is Enabled # if audio: - audioqueue = gst.element_factory_make("queue", "audioqueue") - bin.add(audioqueue) - - audioconvert = gst.element_factory_make("audioconvert", "audioconvert") - bin.add(audioconvert) - - audiolevel = gst.element_factory_make('level', 'audiolevel') + + #Create audio elements + q1 = Gst.ElementFactory.make('queue', None) + enc = Gst.ElementFactory.make('vorbisenc', None) + enc.set_property("quality", float(self.audio_quality)) + q2 = Gst.ElementFactory.make('queue', None) + audioconvert = Gst.ElementFactory.make("audioconvert", None) + audiolevel = Gst.ElementFactory.make('level', None) audiolevel.set_property('interval', 20000000) - bin.add(audiolevel) - - audiocodec = gst.element_factory_make("vorbisenc", "audiocodec") - audiocodec.set_property("quality", float(self.audio_quality)) - bin.add(audiocodec) - # Setup metadata - vorbistag = gst.element_factory_make("vorbistag", "vorbistag") - # set tag merge mode to GST_TAG_MERGE_REPLACE - merge_mode = gst.TagMergeMode.__enum_values__[2] + # # Setup metadata + vorbistag = Gst.ElementFactory.make("vorbistag", None) + #set tag merge mode to GST_TAG_MERGE_REPLACE + merge_mode = Gst.TagMergeMode.__enum_values__[2] if metadata is not None: # Only set tag if metadata is set vorbistag.merge_tags(self.tags, merge_mode) vorbistag.set_tag_merge_mode(merge_mode) + + #Add the audio elements to the bin + bin.add(q1) + bin.add(audiolevel) + bin.add(audioconvert) + bin.add(enc) bin.add(vorbistag) + bin.add(q2) + + #link the audio elements + q1.link(audiolevel) + audiolevel.link(audioconvert) + audioconvert.link(enc) + enc.link(vorbistag) + vorbistag.link(q2) + q2.link(muxer) # Setup ghost pads - audiopad = audioqueue.get_pad("sink") - audio_ghostpad = gst.GhostPad("audiosink", audiopad) + audiopad = q1.get_static_pad("sink") + audio_ghostpad = Gst.GhostPad.new("audiosink", audiopad) bin.add_pad(audio_ghostpad) - # Link Elements - audioqueue.link(audioconvert) - audioconvert.link(audiolevel) - audiolevel.link(audiocodec) - audiocodec.link(vorbistag) - vorbistag.link(muxer) - # # Setup Video Pipeline # if video: - videoqueue = gst.element_factory_make("queue", "videoqueue") + videoqueue = Gst.ElementFactory.make("queue", None) bin.add(videoqueue) - videocodec = gst.element_factory_make("theoraenc", "videocodec") + videocodec = Gst.ElementFactory.make("theoraenc", None) videocodec.set_property("bitrate", int(self.video_bitrate)) bin.add(videocodec) # Setup ghost pads - videopad = videoqueue.get_pad("sink") - video_ghostpad = gst.GhostPad("videosink", videopad) + videopad = videoqueue.get_static_pad("sink") + video_ghostpad = Gst.GhostPad.new("videosink", videopad) bin.add_pad(video_ghostpad) # Link Elements @@ -142,7 +148,6 @@ def get_output_bin(self, audio=True, video=True, metadata=None): # Link muxer to filesink # muxer.link(filesink) - return bin def set_metadata(self, data): @@ -150,13 +155,22 @@ def set_metadata(self, data): Populate global tag list variable with file metadata for vorbistag audio element ''' - self.tags = gst.TagList() + self.tags = Gst.TagList.new_empty() + merge_mode = Gst.TagMergeMode.__enum_values__[2] for tag in data.keys(): - if(gst.tag_exists(tag)): - self.tags[tag] = data[tag] + if(Gst.tag_exists(tag)): + if tag == "date": + s_date = data[tag].split("-") + Tag_date = GLib.Date() + Tag_date.set_day(int(s_date[2])) + Tag_date.set_month(s_date[1]) + Tag_date.set_year(int(s_date[0])) + self.tags.add_value(merge_mode, tag, Tag_date) + else: + self.tags.add_value(merge_mode, tag, str(data[tag])) else: - #self.core.logger.log.debug("WARNING: Tag \"" + str(tag) + "\" is not registered with gstreamer.") + self.core.logger.log.debug("WARNING: Tag \"" + str(tag) + "\" is not registered with gstreamer.") pass def load_config(self, plugman): diff --git a/src/freeseer/plugins/output/rtmp_streaming/__init__.py b/src/freeseer/plugins/output/rtmp_streaming/__init__.py index 543fadd4..4d3369b7 100644 --- a/src/freeseer/plugins/output/rtmp_streaming/__init__.py +++ b/src/freeseer/plugins/output/rtmp_streaming/__init__.py @@ -85,9 +85,9 @@ import webbrowser # GStreamer libs -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst # Qt libs from PyQt4 import QtGui, QtCore @@ -161,17 +161,17 @@ class RTMPOutput(IOutput): # Streams flv content to [self.url] # TODO - Error handling - verify pad setup def get_output_bin(self, audio=True, video=True, metadata=None): - bin = gst.Bin() + bin = Gst.Bin() if metadata is not None: self.set_metadata(metadata) # Muxer - muxer = gst.element_factory_make("flvmux", "muxer") + muxer = Gst.ElementFactory.make("flvmux", "muxer") # Setup metadata # set tag merge mode to GST_TAG_MERGE_REPLACE - merge_mode = gst.TagMergeMode.__enum_values__[2] + merge_mode = Gst.TagMergeMode.__enum_values__[2] if metadata is not None: # Only set tag if metadata is set @@ -184,7 +184,7 @@ def get_output_bin(self, audio=True, video=True, metadata=None): audio_codec = self.audio_codec # RTMP sink - rtmpsink = gst.element_factory_make('rtmpsink', 'rtmpsink') + rtmpsink = Gst.ElementFactory.make('rtmpsink', 'rtmpsink') rtmpsink.set_property('location', url) bin.add(rtmpsink) @@ -192,17 +192,17 @@ def get_output_bin(self, audio=True, video=True, metadata=None): # Setup Audio Pipeline if Audio Recording is Enabled # if audio: - audioqueue = gst.element_factory_make("queue", "audioqueue") + audioqueue = Gst.ElementFactory.make("queue", "audioqueue") bin.add(audioqueue) - audioconvert = gst.element_factory_make("audioconvert", "audioconvert") + audioconvert = Gst.ElementFactory.make("audioconvert", "audioconvert") bin.add(audioconvert) - audiolevel = gst.element_factory_make('level', 'audiolevel') + audiolevel = Gst.ElementFactory.make('level', 'audiolevel') audiolevel.set_property('interval', 20000000) bin.add(audiolevel) - audiocodec = gst.element_factory_make(audio_codec, "audiocodec") + audiocodec = Gst.ElementFactory.make(audio_codec, "audiocodec") if 'quality' in audiocodec.get_property_names(): audiocodec.set_property("quality", int(self.audio_quality)) @@ -212,8 +212,8 @@ def get_output_bin(self, audio=True, video=True, metadata=None): bin.add(audiocodec) # Setup ghost pads - audiopad = audioqueue.get_pad("sink") - audio_ghostpad = gst.GhostPad("audiosink", audiopad) + audiopad = audioqueue.get_static_pad("sink") + audio_ghostpad = Gst.GhostPad.new("audiosink", audiopad) bin.add_pad(audio_ghostpad) # Link Elements @@ -226,18 +226,18 @@ def get_output_bin(self, audio=True, video=True, metadata=None): # Setup Video Pipeline # if video: - videoqueue = gst.element_factory_make("queue", "videoqueue") + videoqueue = Gst.ElementFactory.make("queue", "videoqueue") bin.add(videoqueue) - videocodec = gst.element_factory_make("x264enc", "videocodec") + videocodec = Gst.ElementFactory.make("x264enc", "videocodec") videocodec.set_property("bitrate", int(self.video_bitrate)) if self.video_tune != 'none': videocodec.set_property('tune', self.video_tune) bin.add(videocodec) # Setup ghost pads - videopad = videoqueue.get_pad("sink") - video_ghostpad = gst.GhostPad("videosink", videopad) + videopad = videoqueue.get_static_pad("sink") + video_ghostpad = Gst.GhostPad.new("videosink", videopad) bin.add_pad(video_ghostpad) # Link Elements @@ -270,10 +270,10 @@ def set_metadata(self, data): Populate global tag list variable with file metadata for vorbistag audio element ''' - self.tags = gst.TagList() + self.tags = Gst.TagList() for tag in data.keys(): - if(gst.tag_exists(tag)): + if(Gst.tag_exists(tag)): self.tags[tag] = data[tag] else: #self.core.logger.log.debug("WARNING: Tag \"" + str(tag) + "\" is not registered with gstreamer.") diff --git a/src/freeseer/plugins/output/videopreview/__init__.py b/src/freeseer/plugins/output/videopreview/__init__.py index 09965344..1095c125 100644 --- a/src/freeseer/plugins/output/videopreview/__init__.py +++ b/src/freeseer/plugins/output/videopreview/__init__.py @@ -33,9 +33,9 @@ import ConfigParser # GStreamer -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst # PyQT from PyQt4.QtCore import SIGNAL @@ -61,22 +61,22 @@ class VideoPreview(IOutput): LEAKY_VALUES = ["no", "upstream", "downstream"] def get_output_bin(self, audio=False, video=True, metadata=None): - bin = gst.Bin() + bin = Gst.Bin() # Leaky queue necessary to work with rtmp streaming - videoqueue = gst.element_factory_make("queue", "videoqueue") + videoqueue = Gst.ElementFactory.make("queue", "videoqueue") videoqueue.set_property("leaky", self.leakyqueue) bin.add(videoqueue) - cspace = gst.element_factory_make("ffmpegcolorspace", "cspace") + cspace = Gst.ElementFactory.make("videoconvert", "cspace") bin.add(cspace) - videosink = gst.element_factory_make(self.previewsink, "videosink") + videosink = Gst.ElementFactory.make(self.previewsink, "videosink") bin.add(videosink) # Setup ghost pad - pad = videoqueue.get_pad("sink") - ghostpad = gst.GhostPad("sink", pad) + pad = videoqueue.get_static_pad("sink") + ghostpad = Gst.GhostPad.new("sink", pad) bin.add_pad(ghostpad) # Link Elements diff --git a/src/freeseer/plugins/output/webm_output/__init__.py b/src/freeseer/plugins/output/webm_output/__init__.py index 63e0b847..c9912505 100644 --- a/src/freeseer/plugins/output/webm_output/__init__.py +++ b/src/freeseer/plugins/output/webm_output/__init__.py @@ -30,9 +30,9 @@ ''' # GStreamer -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst, GLib # Freeseer from freeseer.framework.plugin import IOutput @@ -47,16 +47,16 @@ class WebMOutput(IOutput): tags = None def get_output_bin(self, audio=True, video=True, metadata=None): - bin = gst.Bin() + bin = Gst.Bin() if metadata is not None: self.set_metadata(metadata) # Muxer - muxer = gst.element_factory_make("webmmux", "muxer") + muxer = Gst.ElementFactory.make("webmmux", "muxer") bin.add(muxer) - filesink = gst.element_factory_make('filesink', 'filesink') + filesink = Gst.ElementFactory.make('filesink', 'filesink') filesink.set_property('location', self.location) bin.add(filesink) @@ -64,54 +64,62 @@ def get_output_bin(self, audio=True, video=True, metadata=None): # Setup Audio Pipeline # if audio: - audioqueue = gst.element_factory_make("queue", "audioqueue") - bin.add(audioqueue) - audioconvert = gst.element_factory_make("audioconvert", "audioconvert") - bin.add(audioconvert) - - audiolevel = gst.element_factory_make('level', 'audiolevel') + #Create audio elements + q1 = Gst.ElementFactory.make('queue', None) + enc = Gst.ElementFactory.make('vorbisenc', None) + q2 = Gst.ElementFactory.make('queue', None) + audioconvert = Gst.ElementFactory.make("audioconvert", None) + audiolevel = Gst.ElementFactory.make('level', None) audiolevel.set_property('interval', 20000000) - bin.add(audiolevel) - audiocodec = gst.element_factory_make("vorbisenc", "audiocodec") - bin.add(audiocodec) - - # Setup metadata - vorbistag = gst.element_factory_make("vorbistag", "vorbistag") - # set tag merge mode to GST_TAG_MERGE_REPLACE - merge_mode = gst.TagMergeMode.__enum_values__[2] + #Setup metadata + vorbistag = Gst.ElementFactory.make("vorbistag", None) + #set tag merge mode to GST_TAG_MERGE_REPLACE + merge_mode = Gst.TagMergeMode.__enum_values__[2] if metadata is not None: # Only set tag if metadata is set vorbistag.merge_tags(self.tags, merge_mode) vorbistag.set_tag_merge_mode(merge_mode) + + + + + #Add the audio elements to the bin + bin.add(q1) + bin.add(audiolevel) + bin.add(audioconvert) + bin.add(enc) bin.add(vorbistag) + bin.add(q2) + + #link the audio elements + q1.link(audiolevel) + audiolevel.link(audioconvert) + audioconvert.link(enc) + enc.link(vorbistag) + vorbistag.link(q2) + q2.link(muxer) # Setup ghost pads - audiopad = audioqueue.get_pad("sink") - audio_ghostpad = gst.GhostPad("audiosink", audiopad) + audiopad = q1.get_static_pad("sink") + audio_ghostpad = Gst.GhostPad.new("audiosink", audiopad) bin.add_pad(audio_ghostpad) - # Link Elements - audioqueue.link(audioconvert) - audioconvert.link(audiolevel) - audiolevel.link(audiocodec) - audiocodec.link(vorbistag) - vorbistag.link(muxer) # # Setup Video Pipeline # if video: - videoqueue = gst.element_factory_make("queue", "videoqueue") + videoqueue = Gst.ElementFactory.make("queue", "videoqueue") bin.add(videoqueue) - videocodec = gst.element_factory_make("vp8enc", "videocodec") + videocodec = Gst.ElementFactory.make("vp8enc", "videocodec") bin.add(videocodec) - videopad = videoqueue.get_pad("sink") - video_ghostpad = gst.GhostPad("videosink", videopad) + videopad = videoqueue.get_static_pad("sink") + video_ghostpad = Gst.GhostPad.new("videosink", videopad) bin.add_pad(video_ghostpad) # Link Elements @@ -130,11 +138,19 @@ def set_metadata(self, data): Populate global tag list variable with file metadata for vorbistag audio element ''' - self.tags = gst.TagList() - + self.tags = Gst.TagList.new_empty() + merge_mode = Gst.TagMergeMode.__enum_values__[2] for tag in data.keys(): - if(gst.tag_exists(tag)): - self.tags[tag] = data[tag] + if(Gst.tag_exists(tag)): + if tag == "date": + s_date = data[tag].split("-") + Tag_date = GLib.Date() + Tag_date.set_day(int(s_date[2])) + Tag_date.set_month(s_date[1]) + Tag_date.set_year(int(s_date[0])) + self.tags.add_value(merge_mode, tag, Tag_date) + else: + self.tags.add_value(merge_mode, tag, str(data[tag])) else: - #self.core.logger.log.debug("WARNING: Tag \"" + str(tag) + "\" is not registered with gstreamer.") + self.core.logger.log.debug("WARNING: Tag \"" + str(tag) + "\" is not registered with gstreamer.") pass diff --git a/src/freeseer/plugins/videoinput/desktop/__init__.py b/src/freeseer/plugins/videoinput/desktop/__init__.py index af2267a8..cb9c4859 100644 --- a/src/freeseer/plugins/videoinput/desktop/__init__.py +++ b/src/freeseer/plugins/videoinput/desktop/__init__.py @@ -34,9 +34,9 @@ import sys # GStreamer modules -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst # PyQt4 modules from PyQt4.QtCore import SIGNAL @@ -71,11 +71,11 @@ def get_videoinput_bin(self): """ Return the video input object in gstreamer bin format. """ - bin = gst.Bin() # Do not pass a name so that we can load this input more than once. + bin = Gst.Bin() # Do not pass a name so that we can load this input more than once. videosrc = None if sys.platform.startswith("linux"): - videosrc = gst.element_factory_make("ximagesrc", "videosrc") + videosrc = Gst.ElementFactory.make("ximagesrc", "videosrc") # Configure coordinates if we're not recording full desktop if self.desktop == "Area": @@ -89,7 +89,11 @@ def get_videoinput_bin(self): videosrc.set_property("xname", self.window) elif sys.platform in ["win32", "cygwin"]: - videosrc = gst.element_factory_make("dx9screencapsrc", "videosrc") + #videosrc = Gst.ElementFactory.make("dx9screencapsrc", "videosrc") + #This is being replaced with the test source as dx9screencaosrc has not been + #ported to GStreamer 1.0.5 + videosrc = Gst.ElementFactory.make("videotestsrc", "videosrc") + print "test source in place of desktop" # Configure coordinates if we're not recording full desktop if self.desktop == "Area": @@ -101,13 +105,21 @@ def get_videoinput_bin(self): bin.add(videosrc) - colorspace = gst.element_factory_make("ffmpegcolorspace", "colorspace") - bin.add(colorspace) - videosrc.link(colorspace) + #Adding a queue before the video ends up in the Videorate Gst element in the + #video processing stage should make this work but does not. + #gst-launch-1.0 -e ximagesrc ! queue ! videorate ! video/x-raw,framerate=4/1 ! videoconvert ! theoraenc ! oggmux ! / + # queue ! filesink location="test-videorate.ogg" + #That pipeline works, which this should replicate. + #If you sub in videotestsrc in place of ximagesrc this this works, if you leave it as it + #then you end up with an "internal data flow error" + q1 = Gst.ElementFactory.make("queue", "q1") + bin.add(q1) + + videosrc.link(q1) # Setup ghost pad - pad = colorspace.get_pad("src") - ghostpad = gst.GhostPad("videosrc", pad) + pad = q1.get_static_pad("src") + ghostpad = Gst.GhostPad.new("videosrc", pad) bin.add_pad(ghostpad) return bin diff --git a/src/freeseer/plugins/videoinput/firewiresrc/__init__.py b/src/freeseer/plugins/videoinput/firewiresrc/__init__.py index cd639412..156677ae 100644 --- a/src/freeseer/plugins/videoinput/firewiresrc/__init__.py +++ b/src/freeseer/plugins/videoinput/firewiresrc/__init__.py @@ -34,9 +34,9 @@ import os # GStreamer modules -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst # PyQt4 modules from PyQt4.QtCore import SIGNAL @@ -70,13 +70,13 @@ def __init__(self): devpath = path + str(i) def get_videoinput_bin(self): - bin = gst.Bin() # Do not pass a name so that we can load this input more than once. + bin = Gst.Bin() # Do not pass a name so that we can load this input more than once. - videosrc = gst.element_factory_make("dv1394src", "videosrc") - dv1394q1 = gst.element_factory_make('queue', 'dv1394q1') - dv1394dvdemux = gst.element_factory_make('dvdemux', 'dv1394dvdemux') - dv1394q2 = gst.element_factory_make('queue', 'dv1394q2') - dv1394dvdec = gst.element_factory_make('dvdec', 'dv1394dvdec') + videosrc = Gst.ElementFactory.make("dv1394src", "videosrc") + dv1394q1 = Gst.ElementFactory.make('queue', 'dv1394q1') + dv1394dvdemux = Gst.ElementFactory.make('dvdemux', 'dv1394dvdemux') + dv1394q2 = Gst.ElementFactory.make('queue', 'dv1394q2') + dv1394dvdec = Gst.ElementFactory.make('dvdec', 'dv1394dvdec') # Add Elements bin.add(videosrc) @@ -92,8 +92,8 @@ def get_videoinput_bin(self): dv1394q2.link(dv1394dvdec) # Setup ghost pad - pad = dv1394dvdec.get_pad("src") - ghostpad = gst.GhostPad("videosrc", pad) + pad = dv1394dvdec.get_static_pad("src") + ghostpad = Gst.GhostPad.new("videosrc", pad) bin.add_pad(ghostpad) return bin diff --git a/src/freeseer/plugins/videoinput/usbsrc/__init__.py b/src/freeseer/plugins/videoinput/usbsrc/__init__.py index 30aeae18..6b2fb8ee 100644 --- a/src/freeseer/plugins/videoinput/usbsrc/__init__.py +++ b/src/freeseer/plugins/videoinput/usbsrc/__init__.py @@ -36,9 +36,9 @@ import sys # GStreamer modules -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst # PyQt modules from PyQt4.QtCore import SIGNAL @@ -67,24 +67,24 @@ def get_videoinput_bin(self): """ Return the video input object in gstreamer bin format. """ - bin = gst.Bin() # Do not pass a name so that we can load this input more than once. + bin = Gst.Bin() # Do not pass a name so that we can load this input more than once. videosrc = None if sys.platform.startswith("linux"): - videosrc = gst.element_factory_make("v4l2src", "videosrc") - videosrc.set_property("device", self.device) + videosrc = Gst.ElementFactory.make("v4l2src", "videosrc") + #videosrc.set_property("device", self.device) elif sys.platform in ["win32", "cygwin"]: - videosrc = gst.element_factory_make("dshowvideosrc", "videosrc") - videosrc.set_property("device-name", self.device) + videosrc = Gst.ElementFactory.make("dshowvideosrc", "videosrc") + #videosrc.set_property("device-name", self.device) bin.add(videosrc) - colorspace = gst.element_factory_make("ffmpegcolorspace", "colorspace") + colorspace = Gst.ElementFactory.make("videoconvert", "colorspace") bin.add(colorspace) videosrc.link(colorspace) # Setup ghost pad - pad = colorspace.get_pad("src") - ghostpad = gst.GhostPad("videosrc", pad) + pad = colorspace.get_static_pad("src") + ghostpad = Gst.GhostPad.new("videosrc", pad) bin.add_pad(ghostpad) return bin @@ -140,21 +140,23 @@ def get_devices(self): devicemap = {} if sys.platform.startswith("linux"): - videosrc = gst.element_factory_make("v4l2src", "videosrc") - videosrc.probe_property_name('device') - devices = videosrc.probe_get_values_name('device') + videosrc = Gst.ElementFactory.make("v4l2src", "videosrc") + #videosrc.probe_property_name('device') + #devices = videosrc.probe_get_values_name('device') - for device in devices: - videosrc.set_property('device', device) - devicemap[videosrc.get_property('device-name')] = device + # for device in devices: + # videosrc.set_property('device', device) + # devicemap[videosrc.get_property('device-name')] = device elif sys.platform in ["win32", "cygwin"]: - videosrc = gst.element_factory_make("dshowvideosrc", "videosrc") - videosrc.probe_property_name('device-name') - devices = videosrc.probe_get_values_name('device-name') - - for device in devices: - devicemap[device] = device + #videosrc = gst.element_factory_make("dshowvideosrc", "videosrc") + #Video source has to be test source as dshowvideosrc is not implemented + videosrc = Gst.ElementFactory.make('videotestsrc', "videosrc") + #videosrc.probe_property_name('device-name') + #devices = videosrc.probe_get_values_name('device-name') + + #for device in devices: + # devicemap[device] = device return devicemap diff --git a/src/freeseer/plugins/videoinput/videotestsrc/__init__.py b/src/freeseer/plugins/videoinput/videotestsrc/__init__.py index 8f1d8162..5a6465c5 100644 --- a/src/freeseer/plugins/videoinput/videotestsrc/__init__.py +++ b/src/freeseer/plugins/videoinput/videotestsrc/__init__.py @@ -33,9 +33,9 @@ import ConfigParser # GStreamer modules -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst # PyQt4 modules from PyQt4.QtCore import SIGNAL @@ -61,16 +61,16 @@ class VideoTestSrc(IVideoInput): "chroma-zone-plate", "ball", "smpte100", "bar"] def get_videoinput_bin(self): - bin = gst.Bin() # Do not pass a name so that we can load this input more than once. + bin = Gst.Bin() # Do not pass a name so that we can load this input more than once. - videosrc = gst.element_factory_make("videotestsrc", "videosrc") + videosrc = Gst.ElementFactory.make("videotestsrc", "videosrc") videosrc.set_property("pattern", self.pattern) videosrc.set_property("is-live", self.live) bin.add(videosrc) # Setup ghost pad - pad = videosrc.get_pad("src") - ghostpad = gst.GhostPad("videosrc", pad) + pad = videosrc.get_static_pad("src") + ghostpad = Gst.GhostPad.new("videosrc", pad) bin.add_pad(ghostpad) return bin diff --git a/src/freeseer/plugins/videomixer/pip/__init__.py b/src/freeseer/plugins/videomixer/pip/__init__.py index 807a6297..4e022741 100644 --- a/src/freeseer/plugins/videomixer/pip/__init__.py +++ b/src/freeseer/plugins/videomixer/pip/__init__.py @@ -33,9 +33,9 @@ import ConfigParser # GStreamer modules -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst # PyQt modules from PyQt4.QtCore import SIGNAL @@ -55,22 +55,22 @@ class PictureInPicture(IVideoMixer): widget = None def get_videomixer_bin(self): - bin = gst.Bin() + bin = Gst.Bin() - videomixer = gst.element_factory_make("videomixer", "videomixer") + videomixer = Gst.ElementFactory.make("videomixer", "videomixer") bin.add(videomixer) - colorspace = gst.element_factory_make("ffmpegcolorspace", "colorspace") + colorspace = Gst.ElementFactory.make("videoconvert", "colorspace") bin.add(colorspace) videomixer.link(colorspace) # Picture-In-Picture - videobox = gst.element_factory_make("videobox", "videobox") + videobox = Gst.ElementFactory.make("videobox", "videobox") bin.add(videobox) videobox.link(videomixer) - videobox2 = gst.element_factory_make("videobox", "videobox2") + videobox2 = Gst.ElementFactory.make("videobox", "videobox2") bin.add(videobox2) videobox2.set_property("alpha", 0.6) @@ -81,16 +81,16 @@ def get_videomixer_bin(self): videobox2.link(videomixer) # Setup ghost pad - sinkpad = videobox.get_pad("sink") - sink_ghostpad = gst.GhostPad("sink_main", sinkpad) + sinkpad = videobox.get_static_pad("sink") + sink_ghostpad = Gst.GhostPad.new("sink_main", sinkpad) bin.add_pad(sink_ghostpad) - pip_sinkpad = videobox2.get_pad("sink") - pip_ghostpad = gst.GhostPad("sink_pip", pip_sinkpad) + pip_sinkpad = videobox2.get_static_pad("sink") + pip_ghostpad = Gst.GhostPad.new("sink_pip", pip_sinkpad) bin.add_pad(pip_ghostpad) - srcpad = colorspace.get_pad("src") - src_ghostpad = gst.GhostPad("src", srcpad) + srcpad = colorspace.get_static_pad("src") + src_ghostpad = Gst.GhostPad.new("src", srcpad) bin.add_pad(src_ghostpad) return bin @@ -102,22 +102,29 @@ def get_inputs(self): def load_inputs(self, player, mixer, inputs): # Load main source input1 = inputs[0] + player.add(input1) # Create videoscale element in order to scale to dimensions not supported by camera - mainsrc_scale = gst.element_factory_make("videoscale", "mainsrc_scale") + mainsrc_scale = Gst.ElementFactory.make("videoscale", "mainsrc_scale") + player.add(mainsrc_scale) # Create ffmpegcolorspace element to convert from what camera supports to rgb - mainsrc_colorspace = gst.element_factory_make("ffmpegcolorspace", "mainsrc_colorspace") + mainsrc_colorspace = Gst.ElementFactory.make("videoconvert", "mainsrc_colorspace") + player.add(mainsrc_colorspace) # Create capsfilter for limiting to x-raw-rgb pixel video format and setting dimensions - mainsrc_capsfilter = gst.element_factory_make("capsfilter", "mainsrc_capsfilter") + mainsrc_capsfilter = Gst.ElementFactory.make("capsfilter", "mainsrc_capsfilter") mainsrc_capsfilter.set_property('caps', - gst.caps_from_string('video/x-raw-rgb, width=640, height=480')) + Gst.caps_from_string('video/x-raw, format=Y444, width=640, height=480')) + player.add(mainsrc_capsfilter) - mainsrc_elements = [input1, mainsrc_scale, mainsrc_capsfilter, mainsrc_colorspace] + #This lambda function causes errors in Windows. Which makes not sense as the second one + #on line 152 works + + #mainsrc_elements = [input1, mainsrc_scale, mainsrc_capsfilter, mainsrc_colorspace] # Add elements to player in list order - map(lambda element: player.add(element), mainsrc_elements) + #map(lambda element: player.add(element), mainsrc_elements) # Link elements in a specific order input1.link(mainsrc_scale) @@ -125,19 +132,19 @@ def load_inputs(self, player, mixer, inputs): mainsrc_capsfilter.link(mainsrc_colorspace) # Link colorspace element to sink pad for pixel format conversion - srcpad = mainsrc_colorspace.get_pad("src") - sinkpad = mixer.get_pad("sink_main") + srcpad = mainsrc_colorspace.get_static_pad("src") + sinkpad = mixer.get_static_pad("sink_main") srcpad.link(sinkpad) # Load the secondary source input2 = inputs[1] # Create gst elements as above, but set smaller dimensions - pipsrc_scale = gst.element_factory_make("videoscale", "pipsrc_scale") - pipsrc_colorspace = gst.element_factory_make("ffmpegcolorspace", "pipsrc_colorspace") - pipsrc_capsfilter = gst.element_factory_make("capsfilter", "pipsrc_capsfilter") + pipsrc_scale = Gst.ElementFactory.make("videoscale", "pipsrc_scale") + pipsrc_colorspace = Gst.ElementFactory.make("videoconvert", "pipsrc_colorspace") + pipsrc_capsfilter = Gst.ElementFactory.make("capsfilter", "pipsrc_capsfilter") pipsrc_capsfilter.set_property('caps', - gst.caps_from_string('video/x-raw-rgb, width=200, height=150')) + Gst.caps_from_string('video/x-raw, format=Y444, width=200, height=150')) pipsrc_elements = [input2, pipsrc_scale, pipsrc_capsfilter, pipsrc_colorspace] @@ -150,8 +157,8 @@ def load_inputs(self, player, mixer, inputs): pipsrc_capsfilter.link(pipsrc_colorspace) # Link colorspace element to sink pad for pixel format conversion - srcpad = pipsrc_colorspace.get_pad("src") - sinkpad = mixer.get_pad("sink_pip") + srcpad = pipsrc_colorspace.get_static_pad("src") + sinkpad = mixer.get_static_pad("sink_pip") srcpad.link(sinkpad) def load_config(self, plugman): diff --git a/src/freeseer/plugins/videomixer/videopassthrough/__init__.py b/src/freeseer/plugins/videomixer/videopassthrough/__init__.py index fe059e73..b6d9b42b 100644 --- a/src/freeseer/plugins/videomixer/videopassthrough/__init__.py +++ b/src/freeseer/plugins/videomixer/videopassthrough/__init__.py @@ -34,9 +34,9 @@ import ConfigParser # GStreamer modules -import pygst -pygst.require("0.10") -import gst +import gi +gi.require_version('Gst', '1.0') +from gi.repository import GObject, Gst # PyQt modules from PyQt4.QtCore import SIGNAL @@ -55,35 +55,35 @@ class VideoPassthrough(IVideoMixer): widget = None # VideoPassthrough variables - input_type = "video/x-raw-rgb" + input_type = "Y444" framerate = 30 resolution = "NOSCALE" def get_videomixer_bin(self): - bin = gst.Bin() + bin = Gst.Bin() # Video Rate - videorate = gst.element_factory_make("videorate", "videorate") + videorate = Gst.ElementFactory.make("videorate", "videorate") bin.add(videorate) - videorate_cap = gst.element_factory_make("capsfilter", + videorate_cap = Gst.ElementFactory.make("capsfilter", "video_rate_cap") videorate_cap.set_property("caps", - gst.caps_from_string("%s, framerate=%d/1" % (self.input_type, self.framerate))) + Gst.caps_from_string("video/x-raw, framerate=%d/1, format=%s" % (self.framerate, self.input_type))) bin.add(videorate_cap) # --- End Video Rate # Video Scaler (Resolution) - videoscale = gst.element_factory_make("videoscale", "videoscale") + videoscale = Gst.ElementFactory.make("videoscale", "videoscale") bin.add(videoscale) - videoscale_cap = gst.element_factory_make("capsfilter", + videoscale_cap = Gst.ElementFactory.make("capsfilter", "videoscale_cap") if self.resolution != "NOSCALE": videoscale_cap.set_property('caps', - gst.caps_from_string('%s, width=640, height=480' % (self.input_type))) + Gst.caps_from_string('%s, width=640, height=480, format=Y444' % (self.input_type))) bin.add(videoscale_cap) # --- End Video Scaler - colorspace = gst.element_factory_make("ffmpegcolorspace", "colorspace") + colorspace = Gst.ElementFactory.make("videoconvert", "colorspace") bin.add(colorspace) # Link Elements @@ -93,12 +93,12 @@ def get_videomixer_bin(self): videoscale_cap.link(colorspace) # Setup ghost pad - sinkpad = videorate.get_pad("sink") - sink_ghostpad = gst.GhostPad("sink", sinkpad) + sinkpad = videorate.get_static_pad("sink") + sink_ghostpad = Gst.GhostPad.new("sink", sinkpad) bin.add_pad(sink_ghostpad) - srcpad = colorspace.get_pad("src") - src_ghostpad = gst.GhostPad("src", srcpad) + srcpad = colorspace.get_static_pad("src") + src_ghostpad = Gst.GhostPad.new("src", srcpad) bin.add_pad(src_ghostpad) return bin diff --git a/src/freeseer/plugins/videomixer/videopassthrough/widget.py b/src/freeseer/plugins/videomixer/videopassthrough/widget.py index 51d599b7..6e3455df 100644 --- a/src/freeseer/plugins/videomixer/videopassthrough/widget.py +++ b/src/freeseer/plugins/videomixer/videopassthrough/widget.py @@ -67,8 +67,9 @@ def __init__(self, parent=None): self.videocolourLabel = QLabel(self.tr("Colour Format")) self.videocolourComboBox = QComboBox() - self.videocolourComboBox.addItem("video/x-raw-rgb") - self.videocolourComboBox.addItem("video/x-raw-yuv") + self.videocolourComboBox.addItem("Y444") + self.videocolourComboBox.addItem("RGBx") + self.videocolourComboBox.addItem("YVYU") self.videocolourComboBox.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum) layout.addRow(self.videocolourLabel, self.videocolourComboBox)