https://bugs.webkit.org/show_bug.cgi?id=78095
Reviewed by Martin Robinson.
Moved the GStreamer initialization logic to a new
GStreamerUtilities module, used by the MediaPlayer and the
AudioContext. I also removed the static variables as
gst_init_check already handles cases where it's called multiple
times.
* GNUmakefile.list.am:
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::constructCommon):
* platform/audio/gstreamer/AudioDestinationGStreamer.cpp:
(WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer):
* platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:
(WebCore::AudioFileReader::createBus):
* platform/graphics/gstreamer/GRefPtrGStreamer.cpp:
(WTF::adoptGRef):
(WTF):
(WTF::GstElementFactory):
* platform/graphics/gstreamer/GRefPtrGStreamer.h:
(WTF):
* platform/graphics/gstreamer/GStreamerUtilities.cpp: Added.
(WebCore):
(WebCore::initializeGStreamer):
* platform/graphics/gstreamer/GStreamerUtilities.h: Added.
(WebCore):
* platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
(WebCore::doGstInit):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114269
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2012-04-11 Philippe Normand <pnormand@igalia.com>
+
+ [GStreamer] HRTFDatabaseLoader conflicts with AudioFileReader
+ https://bugs.webkit.org/show_bug.cgi?id=78095
+
+ Reviewed by Martin Robinson.
+
+ Moved the GStreamer initialization logic to a new
+ GStreamerUtilities module, used by the MediaPlayer and the
+ AudioContext. I also removed the static variables as
+ gst_init_check already handles cases where it's called multiple
+ times.
+
+ * GNUmakefile.list.am:
+ * Modules/webaudio/AudioContext.cpp:
+ (WebCore::AudioContext::constructCommon):
+ * platform/audio/gstreamer/AudioDestinationGStreamer.cpp:
+ (WebCore::AudioDestinationGStreamer::AudioDestinationGStreamer):
+ * platform/audio/gstreamer/AudioFileReaderGStreamer.cpp:
+ (WebCore::AudioFileReader::createBus):
+ * platform/graphics/gstreamer/GRefPtrGStreamer.cpp:
+ (WTF::adoptGRef):
+ (WTF):
+ (WTF::GstElementFactory):
+ * platform/graphics/gstreamer/GRefPtrGStreamer.h:
+ (WTF):
+ * platform/graphics/gstreamer/GStreamerUtilities.cpp: Added.
+ (WebCore):
+ (WebCore::initializeGStreamer):
+ * platform/graphics/gstreamer/GStreamerUtilities.h: Added.
+ (WebCore):
+ * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:
+ (WebCore::doGstInit):
+
2012-04-16 ChangSeok Oh <shivamidow@gmail.com>
Update GraphicsContext3DOpenGLES.cpp and fix some issues to build with GLES.
Source/WebCore/platform/cairo/WidgetBackingStore.h \
Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp \
Source/WebCore/platform/graphics/cairo/GraphicsContextPlatformPrivateCairo.h \
- Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp \
- Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h \
Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp \
Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.h \
- Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp \
- Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h \
Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp \
Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h \
Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp \
$(WebCore)/Modules/webaudio/WaveTable.idl
endif
+if USE_GSTREAMER
+webcore_sources += \
+ Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp \
+ Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h \
+ Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp \
+ Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h \
+ Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp \
+ Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h
+endif
# ----
# Web Sockets Support
#include <stdio.h>
#endif
+#if USE(GSTREAMER)
+#include "GStreamerUtilities.h"
+#endif
+
#include <wtf/ArrayBuffer.h>
#include <wtf/Atomics.h>
#include <wtf/MainThread.h>
void AudioContext::constructCommon()
{
+#if USE(GSTREAMER)
+ initializeGStreamer();
+#endif
+
FFTFrame::initialize();
m_listener = AudioListener::create();
LIST(APPEND WebCore_SOURCES
platform/graphics/gstreamer/GRefPtrGStreamer.cpp
platform/graphics/gstreamer/GStreamerGWorld.cpp
+ platform/graphics/gstreamer/GStreamerUtilities.cpp
platform/graphics/gstreamer/GStreamerVersioning.cpp
platform/graphics/gstreamer/ImageGStreamerCairo.cpp
platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
HEADERS += \
platform/graphics/gstreamer/GRefPtrGStreamer.h \
platform/graphics/gstreamer/GStreamerGWorld.h \
+ platform/graphics/gstreamer/GStreamerUtilities.h \
platform/graphics/gstreamer/GStreamerVersioning.h \
platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h \
platform/graphics/gstreamer/VideoSinkGStreamer.h \
SOURCES += \
platform/graphics/gstreamer/GRefPtrGStreamer.cpp \
platform/graphics/gstreamer/GStreamerGWorld.cpp \
+ platform/graphics/gstreamer/GStreamerUtilities.cpp \
platform/graphics/gstreamer/GStreamerVersioning.cpp \
platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp \
platform/graphics/gstreamer/VideoSinkGStreamer.cpp \
, m_sampleRate(sampleRate)
, m_isPlaying(false)
{
- static bool gstInitialized = false;
- if (!gstInitialized)
- gstInitialized = gst_init_check(0, 0, 0);
- ASSERT_WITH_MESSAGE(gstInitialized, "GStreamer initialization failed");
-
m_pipeline = gst_pipeline_new("play");
GstElement* webkitAudioSrc = reinterpret_cast<GstElement*>(g_object_new(WEBKIT_TYPE_WEB_AUDIO_SRC,
{
m_sampleRate = sampleRate;
- static bool gstInitialized = false;
- if (!gstInitialized)
- gstInitialized = gst_init_check(0, 0, 0);
-
- if (!gstInitialized)
- return nullptr;
-
m_frontLeftBuffers = gst_buffer_list_new();
m_frontLeftBuffersIterator = gst_buffer_list_iterate(m_frontLeftBuffers);
gst_buffer_list_iterator_add_group(m_frontLeftBuffersIterator);
gst_object_unref(ptr);
}
+template <> GRefPtr<GstElementFactory> adoptGRef(GstElementFactory* ptr)
+{
+ ASSERT(!GST_OBJECT_IS_FLOATING(GST_OBJECT(ptr)));
+ return GRefPtr<GstElementFactory>(ptr, GRefPtrAdopt);
+}
+
+template <> GstElementFactory* refGPtr<GstElementFactory>(GstElementFactory* ptr)
+{
+ if (ptr)
+ webkitGstObjectRefSink(GST_OBJECT(ptr));
+
+ return ptr;
+}
+
+template <> void derefGPtr<GstElementFactory>(GstElementFactory* ptr)
+{
+ if (ptr)
+ gst_object_unref(ptr);
+}
+
}
#endif // USE(GSTREAMER)
typedef struct _GstCaps GstCaps;
typedef struct _GstTask GstTask;
typedef struct _GstBus GstBus;
+typedef struct _GstElementFactory GstElementFactory;
namespace WTF {
template<> GstBus* refGPtr<GstBus>(GstBus* ptr);
template<> void derefGPtr<GstBus>(GstBus* ptr);
+template<> GRefPtr<GstElementFactory> adoptGRef(GstElementFactory* ptr);
+template<> GstElementFactory* refGPtr<GstElementFactory>(GstElementFactory* ptr);
+template<> void derefGPtr<GstElementFactory>(GstElementFactory* ptr);
+
}
#endif // USE(GSTREAMER)
--- /dev/null
+/*
+ * Copyright (C) 2012 Igalia S.L
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+#include "config.h"
+#include "GStreamerUtilities.h"
+
+#include <gst/gst.h>
+#include <wtf/gobject/GOwnPtr.h>
+
+#if USE(GSTREAMER)
+
+namespace WebCore {
+
+bool initializeGStreamer()
+{
+ GOwnPtr<GError> error;
+ // FIXME: We should probably pass the arguments from the command line.
+ bool gstInitialized = gst_init_check(0, 0, &error.outPtr());
+ ASSERT_WITH_MESSAGE(gstInitialized, "GStreamer initialization failed: %s", error ? error->message : "unknown error occurred");
+ return gstInitialized;
+}
+
+}
+
+#endif // ENABLE(WEB_AUDIO) && USE(GSTREAMER)
--- /dev/null
+/*
+ * Copyright (C) 2012 Igalia S.L
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+
+namespace WebCore {
+bool initializeGStreamer();
+}
#include "Frame.h"
#include "FrameView.h"
#include "GStreamerGWorld.h"
+#include "GStreamerUtilities.h"
#include "GStreamerVersioning.h"
#include "GraphicsContext.h"
#include "GraphicsTypes.h"
registrar(create, getSupportedTypes, supportsType, 0, 0, 0);
}
-static bool gstInitialized = false;
-
-static bool doGstInit()
+bool initializeGStreamerAndRegisterWebKitElements()
{
- // FIXME: We should pass the arguments from the command line
- if (!gstInitialized) {
- GOwnPtr<GError> error;
- gstInitialized = gst_init_check(0, 0, &error.outPtr());
- if (!gstInitialized)
- LOG_VERBOSE(Media, "Could not initialize GStreamer: %s",
- error ? error->message : "unknown error occurred");
- else
- gst_element_register(0, "webkitwebsrc", GST_RANK_PRIMARY + 100,
- WEBKIT_TYPE_WEB_SRC);
- }
- return gstInitialized;
+ if (!initializeGStreamer())
+ return false;
+
+ GRefPtr<GstElementFactory> srcFactory = gst_element_factory_find("webkitwebsrc");
+ if (!srcFactory)
+ return gst_element_register(0, "webkitwebsrc", GST_RANK_PRIMARY + 100, WEBKIT_TYPE_WEB_SRC);
+
+ return true;
}
bool MediaPlayerPrivateGStreamer::isAvailable()
{
- if (!doGstInit())
+ if (!initializeGStreamerAndRegisterWebKitElements())
return false;
- GstElementFactory* factory = gst_element_factory_find(gPlaybinName);
- if (factory) {
- gst_object_unref(GST_OBJECT(factory));
- return true;
- }
- return false;
+ GRefPtr<GstElementFactory> factory = gst_element_factory_find(gPlaybinName);
+ return factory;
}
MediaPlayerPrivateGStreamer::MediaPlayerPrivateGStreamer(MediaPlayer* player)
, m_videoTimerHandler(0)
, m_webkitAudioSink(0)
{
- if (doGstInit())
+ if (initializeGStreamerAndRegisterWebKitElements())
createGSTPlayBin();
}
static HashSet<String> mimeTypeCache()
{
- doGstInit();
+ initializeGStreamerAndRegisterWebKitElements();
DEFINE_STATIC_LOCAL(HashSet<String>, cache, ());
static bool typeListInitialized = false;