diff -r 36ec036ad04d -r 9d39369e1b4c mozilla-gstreamer-760140.patch --- a/mozilla-gstreamer-760140.patch Fri Jan 11 15:58:38 2013 +0100 +++ b/mozilla-gstreamer-760140.patch Wed Jan 16 23:09:49 2013 +0100 @@ -4,7 +4,7 @@ diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp --- a/content/base/src/nsContentUtils.cpp +++ b/content/base/src/nsContentUtils.cpp -@@ -147,16 +147,19 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_ +@@ -143,16 +143,19 @@ #include "xpcprivate.h" // nsXPConnect #include "nsScriptSecurityManager.h" #include "nsIChannelPolicy.h" @@ -14,7 +14,7 @@ #ifdef MOZ_MEDIA #include "nsHTMLMediaElement.h" +#ifdef MOZ_GSTREAMER -+#include "nsGStreamerDecoder.h" ++#include "GStreamerDecoder.h" +#endif #endif #include "nsDOMTouchEvent.h" @@ -27,7 +27,7 @@ diff --git a/content/html/content/public/nsHTMLMediaElement.h b/content/html/content/public/nsHTMLMediaElement.h --- a/content/html/content/public/nsHTMLMediaElement.h +++ b/content/html/content/public/nsHTMLMediaElement.h -@@ -263,17 +263,19 @@ public: +@@ -259,17 +259,19 @@ public: void UpdateMediaSize(nsIntSize size); // Returns the CanPlayStatus indicating if we can handle this @@ -48,30 +48,29 @@ // Returns true if we should handle this MIME type when it appears // as an or as a toplevel page. If, in practice, our support // for the type is more limited than appears in the wild, we should return -@@ -305,19 +307,16 @@ public: +@@ -292,18 +294,16 @@ public: + #ifdef MOZ_WEBM static bool IsWebMType(const nsACString& aType); static const char gWebMTypes[2][11]; static char const *const gWebMCodecs[4]; #endif #ifdef MOZ_GSTREAMER - static bool IsGStreamerEnabled(); static bool IsGStreamerSupportedType(const nsACString& aType); - static bool IsH264Type(const nsACString& aType); - static const char gH264Types[3][16]; -- static char const *const gH264Codecs[7]; #endif #ifdef MOZ_WIDGET_GONK - static bool IsOmxEnabled(); static bool IsOmxSupportedType(const nsACString& aType); static const char gOmxTypes[5][16]; - static char const *const gH264Codecs[7]; #endif + + #if defined(MOZ_GSTREAMER) || defined(MOZ_WIDGET_GONK) diff --git a/content/html/content/src/nsHTMLMediaElement.cpp b/content/html/content/src/nsHTMLMediaElement.cpp --- a/content/html/content/src/nsHTMLMediaElement.cpp +++ b/content/html/content/src/nsHTMLMediaElement.cpp -@@ -2128,51 +2128,34 @@ nsHTMLMediaElement::IsWebMType(const nsA +@@ -2213,50 +2213,29 @@ nsHTMLMediaElement::IsWebMType(const nsA return true; } } @@ -82,30 +81,26 @@ -#if defined(MOZ_GSTREAMER) || defined(MOZ_WIDGET_GONK) +#ifdef MOZ_WIDGET_GONK - char const *const nsHTMLMediaElement::gH264Codecs[7] = { - "avc1.42E01E", - "avc1.42001E", - "avc1.58A01E", - "avc1.4D401E", - "avc1.64001E", - "mp4a.40.2", + char const *const nsHTMLMediaElement::gH264Codecs[9] = { + "avc1.42E01E", // H.264 Constrained Baseline Profile Level 3.0 + "avc1.42001E", // H.264 Baseline Profile Level 3.0 + "avc1.58A01E", // H.264 Extended Profile Level 3.0 + "avc1.4D401E", // H.264 Main Profile Level 3.0 + "avc1.64001E", // H.264 High Profile Level 3.0 + "avc1.64001F", // H.264 High Profile Level 3.1 + "mp4v.20.3", // 3GPP + "mp4a.40.2", // AAC-LC nullptr }; - #endif - - #ifdef MOZ_GSTREAMER +-#endif +- +-#ifdef MOZ_GSTREAMER -const char nsHTMLMediaElement::gH264Types[3][16] = { - "video/mp4", - "video/3gpp", - "video/quicktime", -}; - - bool - nsHTMLMediaElement::IsGStreamerEnabled() - { - return Preferences::GetBool("media.gstreamer.enabled"); - } -- -bool -nsHTMLMediaElement::IsH264Type(const nsACString& aType) -{ @@ -116,22 +111,26 @@ - } - return false; -} - #endif - - #ifdef MOZ_WIDGET_GONK +-#endif +- +-#ifdef MOZ_WIDGET_GONK ++ const char nsHTMLMediaElement::gOmxTypes[5][16] = { "audio/mpeg", "audio/mp4", "video/mp4", "video/3gpp", -@@ -2257,18 +2240,22 @@ nsHTMLMediaElement::IsDASHMPDType(const + "video/quicktime", + }; + +@@ -2319,18 +2298,22 @@ nsHTMLMediaElement::IsDASHMPDType(const return false; } #endif /* static */ - nsHTMLMediaElement::CanPlayStatus + nsHTMLMediaElement::CanPlayStatus nsHTMLMediaElement::CanHandleMediaType(const char* aMIMEType, - char const *const ** aCodecList) + const char *aCodecs, @@ -148,7 +147,7 @@ #endif #ifdef MOZ_OGG if (IsOggType(nsDependentCString(aMIMEType))) { -@@ -2292,20 +2279,22 @@ nsHTMLMediaElement::CanHandleMediaType(c +@@ -2354,20 +2337,22 @@ nsHTMLMediaElement::CanHandleMediaType(c if (IsDASHMPDType(nsDependentCString(aMIMEType))) { // DASH manifest uses WebM codecs only. *aCodecList = gWebMCodecs; @@ -165,7 +164,7 @@ + *aCheckCodecList = false; + if (aCodecList) + *aCodecList = nullptr; -+ if (nsGStreamerDecoder::CanHandleMediaType(aMIMEType, aCodecs)) ++ if (GStreamerDecoder::CanHandleMediaType(aMIMEType, aCodecs)) + return CANPLAY_YES; #endif #ifdef MOZ_WIDGET_GONK @@ -175,7 +174,7 @@ } #endif #ifdef MOZ_MEDIA_PLUGINS -@@ -2326,17 +2315,17 @@ bool nsHTMLMediaElement::ShouldHandleMed +@@ -2388,17 +2373,17 @@ bool nsHTMLMediaElement::ShouldHandleMed if (IsOggType(nsDependentCString(aMIMEType))) return true; #endif @@ -185,7 +184,7 @@ #endif #ifdef MOZ_GSTREAMER - if (IsH264Type(nsDependentCString(aMIMEType))) -+ if (nsGStreamerDecoder::CanHandleMediaType(aMIMEType, nullptr)) ++ if (GStreamerDecoder::CanHandleMediaType(aMIMEType, nullptr)) return true; #endif #ifdef MOZ_WIDGET_GONK @@ -194,7 +193,7 @@ } #endif #ifdef MOZ_MEDIA_PLUGINS -@@ -2367,26 +2356,31 @@ nsHTMLMediaElement::GetCanPlay(const nsA +@@ -2429,26 +2414,31 @@ nsHTMLMediaElement::GetCanPlay(const nsA { nsContentTypeParser parser(aType); nsAutoString mimeType; @@ -231,20 +230,20 @@ // of the 'codecs' parameter nsCharSeparatedTokenizer tokenizer(codecs, ','); bool expectMoreTokens = false; -@@ -2425,46 +2419,41 @@ nsHTMLMediaElement::CanPlayType(const ns +@@ -2487,43 +2477,39 @@ nsHTMLMediaElement::CanPlayType(const ns } #ifdef MOZ_GSTREAMER bool nsHTMLMediaElement::IsGStreamerSupportedType(const nsACString& aMimeType) { - if (!IsGStreamerEnabled()) + if (!MediaDecoder::IsGStreamerEnabled()) return false; - if (IsH264Type(aMimeType)) + + const char *type; + NS_CStringGetData(aMimeType, &type, nullptr); -+ if (nsGStreamerDecoder::CanHandleMediaType(type, nullptr)) ++ if (GStreamerDecoder::CanHandleMediaType(type, nullptr)) return true; - if (!Preferences::GetBool("media.prefer-gstreamer", false)) - return false; @@ -261,81 +260,115 @@ } #endif - already_AddRefed + already_AddRefed nsHTMLMediaElement::CreateDecoder(const nsACString& aType) { + #ifdef MOZ_GSTREAMER // When enabled, use GStreamer for H.264, but not for codecs handled by our // bundled decoders, unless the "media.prefer-gstreamer" pref is set. - if (IsGStreamerSupportedType(aType)) { -- nsRefPtr decoder = new nsGStreamerDecoder(); +- nsRefPtr decoder = new GStreamerDecoder(); - if (decoder->Init(this)) { - return decoder.forget(); + if (!Preferences::GetBool("media.prefer-gstreamer", false)) { + if (IsGStreamerSupportedType(aType)) { -+ nsRefPtr decoder = new nsGStreamerDecoder(); ++ nsRefPtr decoder = new GStreamerDecoder(); + if (decoder->Init(this)) { + return decoder.forget(); + } } } #endif -- + #ifdef MOZ_RAW if (IsRawType(aType)) { - nsRefPtr decoder = new nsRawDecoder(); + nsRefPtr decoder = new RawDecoder(); if (decoder->Init(this)) { - return decoder.forget(); - } - } - #endif -@@ -2503,25 +2492,33 @@ nsHTMLMediaElement::CreateDecoder(const - #ifdef MOZ_WEBM - if (IsWebMType(aType)) { - nsRefPtr decoder = new nsWebMDecoder(); +@@ -2576,16 +2562,26 @@ nsHTMLMediaElement::CreateDecoder(const + if (IsDASHMPDType(aType)) { + nsRefPtr decoder = new DASHDecoder(); if (decoder->Init(this)) { return decoder.forget(); } } #endif -- - #ifdef MOZ_DASH - if (IsDASHMPDType(aType)) { - nsRefPtr decoder = new nsDASHDecoder(); - if (decoder->Init(this)) { - return decoder.forget(); - } - } - #endif + +#ifdef MOZ_GSTREAMER + // use GStreamer as fallback if not preferred + if (IsGStreamerSupportedType(aType)) { -+ nsRefPtr decoder = new nsGStreamerDecoder(); ++ nsRefPtr decoder = new GStreamerDecoder(); + if (decoder->Init(this)) { + return decoder.forget(); + } + } +#endif - ++ return nullptr; } - nsresult nsHTMLMediaElement::InitializeDecoderAsClone(nsMediaDecoder* aOriginal) + nsresult nsHTMLMediaElement::InitializeDecoderAsClone(MediaDecoder* aOriginal) { NS_ASSERTION(mLoadingSrc, "mLoadingSrc must already be set"); NS_ASSERTION(mDecoder == nullptr, "Shouldn't have a decoder"); + +diff --git a/content/media/gstreamer/GStreamerDecoder.cpp b/content/media/gstreamer/GStreamerDecoder.cpp +--- a/content/media/gstreamer/GStreamerDecoder.cpp ++++ b/content/media/gstreamer/GStreamerDecoder.cpp +@@ -2,18 +2,23 @@ + /* vim:set ts=2 sw=2 sts=2 et cindent: */ + /* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at http://mozilla.org/MPL/2.0/. */ + + #include "MediaDecoderStateMachine.h" + #include "GStreamerReader.h" + #include "GStreamerDecoder.h" ++#include "nsGStreamerFormatHelper.h" + + namespace mozilla { + + MediaDecoderStateMachine* GStreamerDecoder::CreateStateMachine() + { + return new MediaDecoderStateMachine(this, new GStreamerReader(this)); + } + ++bool GStreamerDecoder::CanHandleMediaType(const char* aMIMEType, ++ const char* aCodecs) { ++ return GStreamerFormatHelper::Instance()->CanHandleMediaType(aMIMEType, aCodecs); ++} + } // namespace mozilla + +diff --git a/content/media/gstreamer/GStreamerDecoder.h b/content/media/gstreamer/GStreamerDecoder.h +--- a/content/media/gstreamer/GStreamerDecoder.h ++++ b/content/media/gstreamer/GStreamerDecoder.h +@@ -11,13 +11,14 @@ + + namespace mozilla { + + class GStreamerDecoder : public MediaDecoder + { + public: + virtual MediaDecoder* Clone() { return new GStreamerDecoder(); } + virtual MediaDecoderStateMachine* CreateStateMachine(); ++ static bool CanHandleMediaType(const char* aMIMEType, const char* aCodecs); + }; + + } // namespace mozilla + + #endif diff --git a/content/media/gstreamer/Makefile.in b/content/media/gstreamer/Makefile.in --- a/content/media/gstreamer/Makefile.in +++ b/content/media/gstreamer/Makefile.in @@ -17,16 +17,17 @@ LIBXUL_LIBRARY = 1 EXPORTS += \ - nsGStreamerDecoder.h \ + GStreamerDecoder.h \ $(NULL) CPPSRCS = \ - nsGStreamerReader.cpp \ - nsGStreamerDecoder.cpp \ + GStreamerReader.cpp \ + GStreamerDecoder.cpp \ + nsGStreamerFormatHelper.cpp \ $(NULL) @@ -345,45 +378,6 @@ CFLAGS += $(GSTREAMER_CFLAGS) CXXFLAGS += $(GSTREAMER_CFLAGS) -diff --git a/content/media/gstreamer/nsGStreamerDecoder.cpp b/content/media/gstreamer/nsGStreamerDecoder.cpp ---- a/content/media/gstreamer/nsGStreamerDecoder.cpp -+++ b/content/media/gstreamer/nsGStreamerDecoder.cpp -@@ -2,13 +2,19 @@ - /* vim:set ts=2 sw=2 sts=2 et cindent: */ - /* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - - #include "nsBuiltinDecoderStateMachine.h" - #include "nsGStreamerReader.h" - #include "nsGStreamerDecoder.h" -+#include "nsGStreamerFormatHelper.h" - - nsDecoderStateMachine* nsGStreamerDecoder::CreateStateMachine() - { - return new nsBuiltinDecoderStateMachine(this, new nsGStreamerReader(this)); - } -+ -+bool nsGStreamerDecoder::CanHandleMediaType(const char* aMIMEType, -+ const char* aCodecs) { -+ return nsGStreamerFormatHelper::Instance()->CanHandleMediaType(aMIMEType, aCodecs); -+} -diff --git a/content/media/gstreamer/nsGStreamerDecoder.h b/content/media/gstreamer/nsGStreamerDecoder.h ---- a/content/media/gstreamer/nsGStreamerDecoder.h -+++ b/content/media/gstreamer/nsGStreamerDecoder.h -@@ -9,11 +9,12 @@ - - #include "nsBuiltinDecoder.h" - - class nsGStreamerDecoder : public nsBuiltinDecoder - { - public: - virtual nsMediaDecoder* Clone() { return new nsGStreamerDecoder(); } - virtual nsDecoderStateMachine* CreateStateMachine(); -+ static bool CanHandleMediaType(const char* aMIMEType, const char* aCodecs); - }; - - #endif diff --git a/content/media/gstreamer/nsGStreamerFormatHelper.cpp b/content/media/gstreamer/nsGStreamerFormatHelper.cpp new file mode 100644 --- /dev/null @@ -402,18 +396,18 @@ +#define ENTRY_FORMAT(entry) entry[0] +#define ENTRY_CAPS(entry) entry[1] + -+nsGStreamerFormatHelper* nsGStreamerFormatHelper::gInstance = nullptr; ++GStreamerFormatHelper* GStreamerFormatHelper::gInstance = nullptr; + -+nsGStreamerFormatHelper *nsGStreamerFormatHelper::Instance() { ++GStreamerFormatHelper *GStreamerFormatHelper::Instance() { + if (!gInstance) { + gst_init(nullptr, nullptr); -+ gInstance = new nsGStreamerFormatHelper(); ++ gInstance = new GStreamerFormatHelper(); + } + + return gInstance; +} + -+nsGStreamerFormatHelper::nsGStreamerFormatHelper() ++GStreamerFormatHelper::GStreamerFormatHelper() + : mFactories(nullptr), + mCookie(0) +{ @@ -436,12 +430,12 @@ + memcpy(mCodecs, codecs, sizeof(codecs)); +} + -+nsGStreamerFormatHelper::~nsGStreamerFormatHelper() { ++GStreamerFormatHelper::~GStreamerFormatHelper() { + if (mFactories) + g_list_free(mFactories); +} + -+bool nsGStreamerFormatHelper::CanHandleMediaType(const char* aMIMEType, ++bool GStreamerFormatHelper::CanHandleMediaType(const char* aMIMEType, + const char *aCodecs) { + GstCaps *caps = ConvertFormatsToCaps(aMIMEType, aCodecs); + if (!caps) { @@ -454,7 +448,7 @@ + return ret; +} + -+GstCaps *nsGStreamerFormatHelper::ConvertFormatsToCaps(const char *aMIMEType, ++GstCaps *GStreamerFormatHelper::ConvertFormatsToCaps(const char *aMIMEType, + const char *aCodecs) { + unsigned int i; + @@ -504,7 +498,7 @@ + return caps; +} + -+bool nsGStreamerFormatHelper::HaveElementsToProcessCaps(GstCaps *aCaps) { ++bool GStreamerFormatHelper::HaveElementsToProcessCaps(GstCaps *aCaps) { + + GList *factories = GetFactories(); + @@ -526,7 +520,7 @@ + return true; +} + -+GList * nsGStreamerFormatHelper::GetFactories() { ++GList * GStreamerFormatHelper::GetFactories() { + uint32_t cookie = gst_default_registry_get_feature_list_cookie (); + if (cookie != mCookie) { + g_list_free(mFactories); @@ -555,23 +549,23 @@ +#include +#include + -+class nsGStreamerFormatHelper { ++class GStreamerFormatHelper { + public: -+ static nsGStreamerFormatHelper *Instance(); -+ ~nsGStreamerFormatHelper(); ++ static GStreamerFormatHelper *Instance(); ++ ~GStreamerFormatHelper(); + + bool CanHandleMediaType(const char *aMIMEType, + const char *aCodecs); + + private: -+ nsGStreamerFormatHelper(); ++ GStreamerFormatHelper(); + GstCaps *ConvertFormatsToCaps(const char *aMIMEType, + const char *aCodecs); + char * const *CodecListFromCaps(GstCaps *aCaps); + bool HaveElementsToProcessCaps(GstCaps *aCaps); + GList *GetFactories(); + -+ static nsGStreamerFormatHelper *gInstance; ++ static GStreamerFormatHelper *gInstance; + + const char *mContainers[3][2]; + const char *mCodecs[7][2];