tagging audio streams and changing audio sink to pulseaudio 37/3237/1
authorJaska Uimonen <jaska.uimonen@helsinki.fi>
Wed, 6 Mar 2013 13:33:53 +0000 (15:33 +0200)
committerJaska Uimonen <jaska.uimonen@helsinki.fi>
Thu, 28 Mar 2013 12:34:00 +0000 (14:34 +0200)
Source/WebCore/platform/audio/gstreamer/AudioDestinationGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
Source/WebCore/platform/mediastream/tizen/MediaStreamPlayer.cpp

index 9b6e2e7..95db688 100755 (executable)
@@ -165,9 +165,11 @@ AudioDestinationGStreamer::~AudioDestinationGStreamer()
 
 void AudioDestinationGStreamer::finishBuildingPipelineAfterWavParserPadReady(GstPad* pad)
 {
+    GstStructure *props;
+
     ASSERT(m_wavParserAvailable);
 
-    GRefPtr<GstElement> audioSink = gst_element_factory_make("autoaudiosink", 0);
+    GRefPtr<GstElement> audioSink = gst_element_factory_make("pulsesink", 0);
     m_audioSinkAvailable = audioSink;
 
     if (!audioSink) {
@@ -175,6 +177,10 @@ void AudioDestinationGStreamer::finishBuildingPipelineAfterWavParserPadReady(Gst
         return;
     }
 
+    props = gst_structure_from_string("props,media.role=music", NULL);
+    g_object_set(audioSink.get(), "stream-properties", props, NULL);
+    gst_structure_free(props);
+
     // Autoaudiosink does the real sink detection in the GST_STATE_NULL->READY transition
     // so it's best to roll it to READY as soon as possible to ensure the underlying platform
     // audiosink was loaded correctly.
index b2f8f50..642c3b3 100755 (executable)
@@ -1906,11 +1906,35 @@ void MediaPlayerPrivateGStreamer::setPreload(MediaPlayer::Preload preload)
     }
 }
 
+const char * MediaPlayerPrivateGStreamer::mediaClass() const
+{
+    static const gchar *default_media_class = "music";
+
+    return default_media_class;
+}
+
 void MediaPlayerPrivateGStreamer::createGSTPlayBin()
 {
     ASSERT(!m_playBin);
+    const gchar *media_class = mediaClass();
+
     m_playBin = gst_element_factory_make(gPlaybinName, "play");
 
+    GstElement *sink = gst_element_factory_make("pulsesink", "audio-sink");
+    if (sink != NULL) {
+        GstStructure *props;
+        gchar prop_str[256] = "props,media.role=";
+
+        strncat(prop_str, media_class, sizeof(prop_str));
+       prop_str[sizeof(prop_str)-1] = 0;
+
+        props = gst_structure_from_string(prop_str, NULL);
+        g_object_set(sink, "stream-properties", props, NULL);
+        gst_structure_free(props);
+
+        g_object_set(m_playBin, "audio-sink", sink, NULL);
+    }
+
 #ifndef GST_API_VERSION_1
     m_gstGWorld = GStreamerGWorld::createGWorld(m_playBin);
 #endif
index 6299ac7..7534986 100644 (file)
@@ -181,6 +181,8 @@ class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface
 
             virtual String engineDescription() const { return "GStreamer"; }
 
+           const char * mediaClass() const;
+
         private:
             MediaPlayer* m_player;
             GstElement* m_playBin;
index 3877713..7a1f9cc 100644 (file)
@@ -248,6 +248,12 @@ void MediaStreamPlayer::createPipeline()
             m_afilter = gst_element_factory_make("capsfilter", 0);
             m_asink = gst_element_factory_make("pulsesink", 0);
 
+           if (m_asink != NULL) {
+               props = gst_structure_from_string("props,media.role=camera", NULL);
+               g_object_set(G_OBJECT(m_asink), "stream-properties", props, NULL);
+               gst_structure_free(props);
+           }
+
             caps = gst_caps_from_string(ACAPS);
             g_object_set(G_OBJECT(m_afilter), "caps", caps, NULL);
             gst_caps_unref(caps);