def _newDecodedPadCb(self, unused_element, pad, is_last): self.info("pad:%s caps:%s is_last:%s", pad, pad.get_caps(), is_last) caps_str = str(pad.get_caps()) if caps_str.startswith("video/x-raw"): self._newVideoPadCb(pad) else: self._newPadCb(pad) # try to get the duration self._maybeQueryDuration(pad) caps = pad.props.caps if caps is not None and caps.is_fixed(): self.debug("got fixed caps for pad %s", pad) stream = self._addStreamFromPad(pad) if isinstance(stream, VideoStream): stream.thumbnail = self.thumbnails[pad] else: # add the stream once the caps are fixed if gst.version() < (0, 10, 21, 1) and \ isinstance(pad, gst.GhostPad): # see #564863 for the version check # the isinstance check is there so that we don't have to create # ghost pads in the tests pad.get_target().connect("notify::caps", self._capsNotifyCb, pad) else: pad.connect("notify::caps", self._capsNotifyCb) self.unfixed_pads += 1 self.debug("unfixed pads %d", self.unfixed_pads)
def get_gst_version(): """Return :mod:`gst` version number as string or ``None``.""" try: import gst return ".".join(map(str, gst.version())) except Exception: return None
def _makeBin(self, *args): s = self.settings b = gst.Bin() self.debug("Creating muxer") mux = gst.element_factory_make(s.muxer) for k, v in s.muxersettings.iteritems(): mux.set_property(k, v) b.add(mux) self.debug("Ghosting source pad") gsrc = gst.GhostPad("src", mux.get_pad("src")) gsrc.set_active(True) b.add_pad(gsrc) i = 0 # add all the encoders for setting in s.settings: self.debug("Creating encoder %d", i) b2 = EncoderFactory(setting).makeBin() b.add(b2) src2 = b2.get_pad("src") # request a compatible pad from the muxer n2 = get_compatible_sink_pad(s.muxer, src2.get_caps()) if n2 == None: raise Exception("can't find a compatible pad") # FIXME : We're assuming it's a request pad p2 = mux.get_request_pad(n2) if gst.version() < (0, 10, 22, 1): segment_eater = NewsegmentEater() b.add(segment_eater) segment_eater.get_pad('src').link(p2) p2 = segment_eater.get_pad('sink') src2.link(p2) # expose encoder sink pad gsink = gst.GhostPad("sink_%d" % i, b2.get_pad("sink")) gsink.set_active(True) b.add_pad(gsink) i += 1 self.debug("Done") return b
def load_default_channel_list (self): filename = os.getenv("GST_DVB_CHANNELS_CONF") if not filename: gstversion = gst.version() filename = os.path.expanduser( "~/.gstreamer-%d.%d/dvb-channels.conf" % (gstversion[0], gstversion[1])) if os.path.exists(filename): f = open(filename, "r") while True: line = f.readline() if not line: break if line[0] != '#': params = line.split(":") if len(params) == 13: sid = int(params[12]); c = { "name":params[0] } t = { "frequency":int(params[1]) } self.update_channel (sid, c, t) f.close()
def do_check(self): def checkSignal(fact): fact = fact.load() signals = gobject.signal_list_names(fact.get_element_type()) return 'block' in signals def cb(result): for m in result.messages: self.addMessage(m) return result.value self.debug("checking for input-selector element") if gst.version() >= (0, 10, 32, 0): # In release 0.10.32 input-selector was moved to coreelements. d = check.checkPlugin('coreelements', 'gst-plugins', (0, 10, 5, 2), 'input-selector', checkSignal) else: d = check.checkPlugin('selector', 'gst-plugins-bad', (0, 10, 5, 2), 'input-selector', checkSignal) d.addCallback(cb) return d
def load_default_channel_list(self): filename = os.getenv("GST_DVB_CHANNELS_CONF") if not filename: gstversion = gst.version() filename = os.path.expanduser( "~/.gstreamer-%d.%d/dvb-channels.conf" % (gstversion[0], gstversion[1])) if os.path.exists(filename): f = open(filename, "r") while True: line = f.readline() if not line: break if line[0] != '#': params = line.split(":") if len(params) == 13: sid = int(params[12]) c = {"name": params[0]} t = {"frequency": int(params[1])} self.update_channel(sid, c, t) f.close()
# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # import pygst pygst.require("0.10") import gst import ocv_constants gstver = gst.version() if ocv_constants.USE_AUDIORATE is None: if gstver[2] > 10: ocv_constants.USE_AUDIORATE = True else: ocv_constants.USE_AUDIORATE = False if ocv_constants.HAVE_SCHRO is None: ocv_constants.HAVE_SCHRO = False if gstver[2] > 10: schrofac = gst.element_factory_find("schroenc") if schrofac is not None: if schrofac.check_version(0,10,14): print "Schrödinger encoder found, using"
__version__ = '$Revision$' __date__ = '$Date$' __copyright__ = 'Copyright (c) 2012 Ángel Guzmán Maeso' __license__ = 'GPL' import gtk import pygtk pygtk.require('2.0') #import gobject import pygst pygst.require('0.10') import gst import os, sys print gst.version_string() print gst.version() print gst.__file__ class Video: def __init__(self): def on_message(bus, message): if message.type == gst.MESSAGE_EOS: # End of Stream player.set_state(gst.STATE_NULL) elif message.type == gst.MESSAGE_ERROR: player.set_state(gst.STATE_NULL) (err, debug) = message.parse_error() print "Error: %s" % err, debug
def output_results(self): filename = os.getenv("GST_DVB_CHANNELS_CONF") if not filename: gstversion = gst.version() filename = os.path.expanduser( "~/.gstreamer-%d.%d/dvb-channels.conf" % (gstversion[0], gstversion[1])) print "Filename: %s" % filename file = open(filename, "w") lines = [] for sid in self.channels.keys(): chan = self.channels[sid] tuningparams = None line = "" #print "%s:::::::::" % chan["name"] if chan.has_key("name") and chan["name"]: line = "%s:" % chan["name"] else: line = "[%d]:" % sid if chan.has_key("transport-stream-id"): tuningparams = \ self.transport_streams[chan["transport-stream-id"]] else: continue if self.adaptertype == "DVB-T": line = "%s%d:INVERSION_AUTO:" % (line, tuningparams["frequency"]) line = "%sBANDWIDTH_%s_MHZ:" % (line, tuningparams["bandwidth"]) fecstr = "" if tuningparams["code-rate-hp"] == "1/2": fecstr = "FEC_1_2" elif tuningparams["code-rate-hp"] == "2/3": fecstr = "FEC_2_3" elif tuningparams["code-rate-hp"] == "3/4": fecstr = "FEC_3_4" elif tuningparams["code-rate-hp"] == "5/6": fecstr = "FEC_5_6" elif tuningparams["code-rate-hp"] == "7/8": fecstr = "FEC_7_8" else: fecstr = "FEC_AUTO" line = "%s%s:" % (line, fecstr) if tuningparams["code-rate-lp"] == "1/2": fecstr = "FEC_1_2" elif tuningparams["code-rate-lp"] == "2/3": fecstr = "FEC_2_3" elif tuningparams["code-rate-lp"] == "3/4": fecstr = "FEC_3_4" elif tuningparams["code-rate-lp"] == "5/6": fecstr = "FEC_5_6" elif tuningparams["code-rate-lp"] == "7/8": fecstr = "FEC_7_8" else: fecstr = "FEC_AUTO" line = "%s%s:" % (line, fecstr) constellation = "" if tuningparams["constellation"] == "QPSK": constellation = "QPSK" elif tuningparams["constellation"] == "QAM16": constellation = "QAM_16" else: constellation = "QAM_64" line = "%s%s:" % (line, constellation) if tuningparams["transmission-mode"] == "2k": line = "%sTRANSMISSION_MODE_2K:" % line else: line = "%sTRANSMISSION_MODE_8K:" % line line = "%sGUARD_INTEVAL_1_%d:" % (line, tuningparams["guard-interval"]) if tuningparams["hierarchy"] == 0: line = "%sHIERARCHY_NONE:" % line else: line = "%sHIERARCHY_%d:" % (line, tuningparams["hierarchy"]) line = "%s0:0:%d\n" % (line, sid) elif self.adaptertype == "DVB-S": line = "%s%d:%s:0:%d:0:0:%d\n" % (line, tuningparams["frequency"]/1000, tuningparams["polarization"][0], tuningparams["symbol-rate"], sid) elif self.adaptertype == "DVB-C": fecstr = "" if tuningparams["inner-fec"] == "1/2": fecstr = "FEC_1_2" elif tuningparams["inner-fec"] == "2/3": fecstr = "FEC_2_3" elif tuningparams["inner-fec"] == "3/4": fecstr = "FEC_3_4" elif tuningparams["inner-fec"] == "5/6": fecstr = "FEC_5_6" elif tuningparams["inner-fec"] == "7/8": fecstr = "FEC_7_8" else: fecstr = "FEC_AUTO" modulation = "" if tuningparams["modulation"] == "QAM16": modulation = "QAM_16" elif tuningparams["modulation"] == "QAM32": modulation = "QAM_32" elif tuningparams["modulation"] == "QAM64": modulation = "QAM_64" elif tuningparams["modulation"] == "QAM128": modulation = "QAM_128" elif tuningparams["modulation"] == "QAM256": modulation = "QAM_256" else: modulation = "QAM_64" line = "%s%d:INVERSION_AUTO:%d:%s:%s:0:0:%d\n" % (line, tuningparams["frequency"], tuningparams["symbol-rate"], fecstr, modulation, sid) lines.append(line) print line file.writelines(lines) file.close()
def gstreamerVersion(): import gst return _versionify(gst.version())
END=Last song from playlist SPACE=Pause/Start LEFT/RIGHT=+/-10 Seconds UP/DOWN=Next/Previous Song ESC/Q=Quit F=Fullscreen/Window' ''') print " " print "dacapo Version: %s" %(fver(oConfig.getConfig('version', ' ', ' '))) print " " print "Python Version: %s" %(fver(version_info)) print " " print "GTK+: %s.%s.%s" %(Gtk.MAJOR_VERSION, Gtk.MINOR_VERSION, Gtk.MICRO_VERSION) print " " print "GStreamer: %s / PyGSt: %s" % ( fver(gst.version()), fver(gst.pygst_version)) print " " print "pyGame Version: %s / SDL: %s" % ( pygame.version.ver, fver(pygame.get_sdl_version())) print " " return def fver(tup): return ".".join(map(str, tup)) # -------------------- showPicsHelp() ----------------------------------------------------------------- def showPicsHelp(): ''' <!-- showPics: Bilder anzeigen? Mögliche Werte: NO = Keine Bilder anzeigen, nur metadata
SPACE=Pause/Start LEFT/RIGHT=+/-10 Seconds UP/DOWN=Next/Previous Song ESC/Q=Quit F=Fullscreen/Window' ''') print " " print "dacapo Version: %s" % (fver(oConfig.getConfig('version', ' ', ' '))) print " " print "Python Version: %s" % (fver(version_info)) print " " print "GTK+: %s.%s.%s" % (Gtk.MAJOR_VERSION, Gtk.MINOR_VERSION, Gtk.MICRO_VERSION) print " " print "GStreamer: %s / PyGSt: %s" % (fver( gst.version()), fver(gst.pygst_version)) print " " print "pyGame Version: %s / SDL: %s" % (pygame.version.ver, fver(pygame.get_sdl_version())) print " " return def fver(tup): return ".".join(map(str, tup)) # -------------------- showPicsHelp() ----------------------------------------------------------------- def showPicsHelp():
def output_results(self): filename = os.getenv("GST_DVB_CHANNELS_CONF") if not filename: gstversion = gst.version() filename = os.path.expanduser( "~/.gstreamer-%d.%d/dvb-channels.conf" % (gstversion[0], gstversion[1])) print "Filename: %s" % filename file = open(filename, "w") lines = [] for sid in self.channels.keys(): chan = self.channels[sid] tuningparams = None line = "" #print "%s:::::::::" % chan["name"] if chan.has_key("name") and chan["name"]: line = "%s:" % chan["name"] else: line = "[%d]:" % sid if chan.has_key("transport-stream-id"): tuningparams = \ self.transport_streams[chan["transport-stream-id"]] else: continue if self.adaptertype == "DVB-T": line = "%s%d:INVERSION_AUTO:" % (line, tuningparams["frequency"]) line = "%sBANDWIDTH_%s_MHZ:" % (line, tuningparams["bandwidth"]) fecstr = "" if tuningparams["code-rate-hp"] == "1/2": fecstr = "FEC_1_2" elif tuningparams["code-rate-hp"] == "2/3": fecstr = "FEC_2_3" elif tuningparams["code-rate-hp"] == "3/4": fecstr = "FEC_3_4" elif tuningparams["code-rate-hp"] == "5/6": fecstr = "FEC_5_6" elif tuningparams["code-rate-hp"] == "7/8": fecstr = "FEC_7_8" else: fecstr = "FEC_AUTO" line = "%s%s:" % (line, fecstr) if tuningparams["code-rate-lp"] == "1/2": fecstr = "FEC_1_2" elif tuningparams["code-rate-lp"] == "2/3": fecstr = "FEC_2_3" elif tuningparams["code-rate-lp"] == "3/4": fecstr = "FEC_3_4" elif tuningparams["code-rate-lp"] == "5/6": fecstr = "FEC_5_6" elif tuningparams["code-rate-lp"] == "7/8": fecstr = "FEC_7_8" else: fecstr = "FEC_AUTO" line = "%s%s:" % (line, fecstr) constellation = "" if tuningparams["constellation"] == "QPSK": constellation = "QPSK" elif tuningparams["constellation"] == "QAM16": constellation = "QAM_16" else: constellation = "QAM_64" line = "%s%s:" % (line, constellation) if tuningparams["transmission-mode"] == "2k": line = "%sTRANSMISSION_MODE_2K:" % line else: line = "%sTRANSMISSION_MODE_8K:" % line line = "%sGUARD_INTEVAL_1_%d:" % ( line, tuningparams["guard-interval"]) if tuningparams["hierarchy"] == 0: line = "%sHIERARCHY_NONE:" % line else: line = "%sHIERARCHY_%d:" % (line, tuningparams["hierarchy"]) line = "%s0:0:%d\n" % (line, sid) elif self.adaptertype == "DVB-S": line = "%s%d:%s:0:%d:0:0:%d\n" % ( line, tuningparams["frequency"] / 1000, tuningparams["polarization"][0], tuningparams["symbol-rate"], sid) elif self.adaptertype == "DVB-C": fecstr = "" if tuningparams["inner-fec"] == "1/2": fecstr = "FEC_1_2" elif tuningparams["inner-fec"] == "2/3": fecstr = "FEC_2_3" elif tuningparams["inner-fec"] == "3/4": fecstr = "FEC_3_4" elif tuningparams["inner-fec"] == "5/6": fecstr = "FEC_5_6" elif tuningparams["inner-fec"] == "7/8": fecstr = "FEC_7_8" else: fecstr = "FEC_AUTO" modulation = "" if tuningparams["modulation"] == "QAM16": modulation = "QAM_16" elif tuningparams["modulation"] == "QAM32": modulation = "QAM_32" elif tuningparams["modulation"] == "QAM64": modulation = "QAM_64" elif tuningparams["modulation"] == "QAM128": modulation = "QAM_128" elif tuningparams["modulation"] == "QAM256": modulation = "QAM_256" else: modulation = "QAM_64" line = "%s%d:INVERSION_AUTO:%d:%s:%s:0:0:%d\n" % ( line, tuningparams["frequency"], tuningparams["symbol-rate"], fecstr, modulation, sid) lines.append(line) print line file.writelines(lines) file.close()
def _computeAndSetValues(self): """ Calculate the new values to set on capsfilter and videobox. """ if self.widthin == -1 or self.heightin == -1 or self.widthout == -1 or self.heightout == -1: # FIXME : should we reset videobox/capsfilter properties here ? self.error("We don't have input and output caps, we can't calculate videobox values") return self.log("incoming width/height/PAR/DAR : %d/%d/%r/%r" % (self.widthin, self.heightin, self.parin, self.darin)) self.log("outgoing width/height/PAR/DAR : %d/%d/%r/%r" % (self.widthout, self.heightout, self.parout, self.darout)) # for core <= 0.10.22 we always set caps != any, see 574805 for the # details if self.darin == self.darout and gst.version() >= (0, 10, 23): self.log("We have same input and output caps, resetting capsfilter and videobox settings") # same DAR, set inputcaps on capsfilter, reset videobox values astr = "width=%d,height=%d" % (self.widthout, self.heightout) caps = gst.caps_from_string("video/x-raw-yuv,%s;video/x-raw-rgb,%s" % (astr, astr)) left = 0 right = 0 top = 0 bottom = 0 else: par = self.parout dar = self.darin if float(self.darin) > float(self.darout): self.log("incoming DAR is greater that ougoing DAR. Adding top/bottom borders") # width, PAR stays the same as output # calculate newheight = (PAR * widthout) / DAR newheight = (par.num * self.widthout * dar.denom) / (par.denom * dar.num) self.log("newheight should be %d" % newheight) extra = self.heightout - newheight top = extra / 2 bottom = extra - top # compensate for odd extra left = right = 0 # calculate filter caps astr = "width=%d,height=%d" % (self.widthout, newheight) else: self.log("incoming DAR is smaller than outgoing DAR. Adding left/right borders") # height, PAR stays the same as output # calculate newwidth = (DAR * heightout) / PAR newwidth = (dar.num * self.heightout * par.denom) / (dar.denom * par.num) self.log("newwidth should be %d" % newwidth) extra = self.widthout - newwidth left = extra / 2 right = extra - left # compensate for odd extra top = bottom = 0 # calculate filter caps astr = "width=%d,height=%d" % (newwidth, self.heightout) caps = gst.caps_from_string("video/x-raw-yuv,%s;video/x-raw-rgb,%s" % (astr, astr)) # set properties on elements self.debug("About to set left/right/top/bottom : %d/%d/%d/%d" % (-left, -right, -top, -bottom)) self.videobox.props.left = -left self.videobox.props.right = -right self.videobox.props.top = -top self.videobox.props.bottom = -bottom self.debug("Settings filter caps %s" % caps.to_string()) self.capsfilter.props.caps = caps self.debug("done")