Commit 8f10d46f authored by philn@webkit.org's avatar philn@webkit.org

[GStreamer] Audio/Video sink management is incoherent

https://bugs.webkit.org/show_bug.cgi?id=125304

Reviewed by Gustavo Noronha Silva.

Allow subclasses of MediaPlayerPrivateGStreamerBase to create
custom audio/video sinks in a coherent manner using
create{Audio,Video}Sink methods. Convenience getters are also
available. Also removed some un-needed member variables in the
playbin-based player.

No new tests, existing media tests cover this change.

* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer):
(WebCore::MediaPlayerPrivateGStreamer::updateStates):
(WebCore::MediaPlayerPrivateGStreamer::createAudioSink):
(WebCore::MediaPlayerPrivateGStreamer::audioSink):
(WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
(WebCore::MediaPlayerPrivateGStreamerBase::createAudioSink):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160214 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent c3101eb3
2013-12-05 Philippe Normand <pnormand@igalia.com>
[GStreamer] Audio/Video sink management is incoherent
https://bugs.webkit.org/show_bug.cgi?id=125304
Reviewed by Gustavo Noronha Silva.
Allow subclasses of MediaPlayerPrivateGStreamerBase to create
custom audio/video sinks in a coherent manner using
create{Audio,Video}Sink methods. Convenience getters are also
available. Also removed some un-needed member variables in the
playbin-based player.
No new tests, existing media tests cover this change.
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer):
(WebCore::MediaPlayerPrivateGStreamer::updateStates):
(WebCore::MediaPlayerPrivateGStreamer::createAudioSink):
(WebCore::MediaPlayerPrivateGStreamer::audioSink):
(WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.cpp:
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamerBase.h:
(WebCore::MediaPlayerPrivateGStreamerBase::createAudioSink):
2013-12-05 Gyuyoung Kim <gyuyoung.kim@samsung.com>
Introduce IMAGE_TYPE_CASTS, and use it
......@@ -268,7 +268,6 @@ MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer(MediaPlayer* player)
, m_videoTimerHandler(0)
, m_videoCapsTimerHandler(0)
, m_readyTimerHandler(0)
, m_webkitAudioSink(0)
, m_totalBytes(-1)
, m_preservesPitch(false)
, m_requestedState(GST_STATE_VOID_PENDING)
......@@ -1252,20 +1251,6 @@ unsigned MediaPlayerPrivateGStreamer::totalBytes() const
return m_totalBytes;
}
void MediaPlayerPrivateGStreamer::updateAudioSink()
{
if (!m_playBin)
return;
m_webkitAudioSink.clear();
g_object_get(m_playBin.get(), "audio-sink", &m_webkitAudioSink.outPtr(), NULL);
}
GstElement* MediaPlayerPrivateGStreamer::audioSink() const
{
return m_webkitAudioSink.get();
}
void MediaPlayerPrivateGStreamer::sourceChanged()
{
m_source.clear();
......@@ -1390,9 +1375,6 @@ void MediaPlayerPrivateGStreamer::updateStates()
// Sync states where needed.
if (state == GST_STATE_PAUSED) {
if (!m_webkitAudioSink)
updateAudioSink();
if (!m_volumeAndMuteInitialized) {
notifyPlayerOfVolumeChange();
notifyPlayerOfMute();
......@@ -1813,42 +1795,43 @@ void MediaPlayerPrivateGStreamer::setPreload(MediaPlayer::Preload preload)
}
}
void MediaPlayerPrivateGStreamer::createAudioSink()
GstElement* MediaPlayerPrivateGStreamer::createAudioSink()
{
// Construct audio sink if pitch preserving is enabled.
if (!m_preservesPitch)
return;
m_autoAudioSink = gst_element_factory_make("autoaudiosink", 0);
g_signal_connect(m_autoAudioSink.get(), "child-added", G_CALLBACK(setAudioStreamPropertiesCallback), this);
if (!m_playBin)
return;
// Construct audio sink only if pitch preserving is enabled.
if (!m_preservesPitch)
return m_autoAudioSink.get();
GstElement* scale = gst_element_factory_make("scaletempo", 0);
if (!scale) {
GST_WARNING("Failed to create scaletempo");
return;
return m_autoAudioSink.get();
}
GstElement* audioSinkBin = gst_bin_new("audio-sink");
GstElement* convert = gst_element_factory_make("audioconvert", 0);
GstElement* resample = gst_element_factory_make("audioresample", 0);
GstElement* sink = gst_element_factory_make("autoaudiosink", 0);
m_autoAudioSink = sink;
g_signal_connect(sink, "child-added", G_CALLBACK(setAudioStreamPropertiesCallback), this);
gst_bin_add_many(GST_BIN(audioSinkBin), scale, convert, resample, m_autoAudioSink.get(), NULL);
GstElement* audioSink = gst_bin_new("audio-sink");
gst_bin_add_many(GST_BIN(audioSink), scale, convert, resample, sink, NULL);
if (!gst_element_link_many(scale, convert, resample, sink, NULL)) {
if (!gst_element_link_many(scale, convert, resample, m_autoAudioSink.get(), NULL)) {
GST_WARNING("Failed to link audio sink elements");
gst_object_unref(audioSink);
return;
gst_object_unref(audioSinkBin);
return m_autoAudioSink.get();
}
GRefPtr<GstPad> pad = adoptGRef(gst_element_get_static_pad(scale, "sink"));
gst_element_add_pad(audioSink, gst_ghost_pad_new("sink", pad.get()));
gst_element_add_pad(audioSinkBin, gst_ghost_pad_new("sink", pad.get()));
return audioSinkBin;
}
g_object_set(m_playBin.get(), "audio-sink", audioSink, NULL);
GstElement* MediaPlayerPrivateGStreamer::audioSink() const
{
GstElement* sink;
g_object_get(m_playBin.get(), "audio-sink", &sink, nullptr);
return sink;
}
void MediaPlayerPrivateGStreamer::createGSTPlayBin()
......@@ -1890,13 +1873,11 @@ void MediaPlayerPrivateGStreamer::createGSTPlayBin()
}
#endif
g_object_set(m_playBin.get(), "video-sink", createVideoSink(), nullptr);
g_object_set(m_playBin.get(), "video-sink", createVideoSink(), "audio-sink", createAudioSink(), nullptr);
GRefPtr<GstPad> videoSinkPad = adoptGRef(gst_element_get_static_pad(m_webkitVideoSink.get(), "sink"));
if (videoSinkPad)
g_signal_connect(videoSinkPad.get(), "notify::caps", G_CALLBACK(mediaPlayerPrivateVideoSinkCapsChangedCallback), this);
createAudioSink();
}
void MediaPlayerPrivateGStreamer::simulateAudioInterruption()
......
......@@ -127,8 +127,7 @@ private:
static bool isAvailable();
void updateAudioSink();
void createAudioSink();
GstElement* createAudioSink();
float playbackPosition() const;
......@@ -191,7 +190,6 @@ private:
guint m_videoTimerHandler;
guint m_videoCapsTimerHandler;
guint m_readyTimerHandler;
GRefPtr<GstElement> m_webkitAudioSink;
mutable long m_totalBytes;
URL m_url;
bool m_preservesPitch;
......
......@@ -103,10 +103,12 @@ public:
protected:
MediaPlayerPrivateGStreamerBase(MediaPlayer*);
GstElement* createVideoSink();
virtual GstElement* createVideoSink();
GRefPtr<GstCaps> currentVideoSinkCaps() const;
void setStreamVolumeElement(GstStreamVolume*);
virtual GstElement* createAudioSink() { return 0; }
virtual GstElement* audioSink() const { return 0; }
GRefPtr<GstCaps> currentVideoSinkCaps() const;
MediaPlayer* m_player;
GRefPtr<GstStreamVolume> m_volumeElement;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment