[Bug 657809] Playback sometimes start without sound

GStreamer (bugzilla.gnome.org) bugzilla at gnome.org
Thu Sep 1 02:34:12 PDT 2011


https://bugzilla.gnome.org/show_bug.cgi?id=657809
  GStreamer | don't know | 0.10.34

--- Comment #7 from Vincent Penquerc'h <vincent.penquerch at collabora.co.uk> 2011-09-01 09:21:39 UTC ---
The above patch exposes the internal type of the stream as a tag on the
relevant source pad. This can then be checked by the playbin2 using code, with
something like this:

    def select_audio(self):
        idx=0
        n_audio = self.player.get_property("n-audio")
        print "Considering %d audio streams:" % (n_audio)
        selected = None
        while idx<n_audio:
          language = None
          audio_type = None
          taglist=self.player.emit("get-audio-tags", idx)
          if taglist != None and ("language-code" in taglist):
              language = taglist["language-code"]
          if taglist != None and ("mpeg-audio-type" in taglist):
              audio_type = taglist["mpeg-audio-type"]
          print "Stream %d has language %s, type %d" % (idx, language,
audio_type)
          if audio_type == 0:
              selected = idx
          idx=idx+1
        if selected != None:
            print "Selecting audio stream %d (from %d)" % (selected,
self.player.get_property("current-audio"))
            self.player.set_property("current-audio", selected)


This can then be called when you get tag updates:

    def on_message(self, bus, message):
        t = message.type
        src = message.src.get_name()
        if t == gst.MESSAGE_TAG:
            self.select_audio()

You can pass the tags to that function here too to avoid getting them again, in
case you do not need to call it anywhere you do not have the tags.

This python snippets were coded on your sample Python player, and tested with
the stream you linked to. Note that the main stream is tagged with 0, which the
spec says is "undefined" (found in 2.6.19 of the spec).

For convenience, I've added code to display the language too, you may want to
favor selecting the language specified in LANG, if any, etc.

-- 
Configure bugmail: https://bugzilla.gnome.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list