2 Bug 760140 - Query the GstRegistry for the required demuxers/decoders from canPlayType |
2 Bug 760140 - Query the GstRegistry for the required demuxers/decoders from canPlayType |
3 |
3 |
4 diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp |
4 diff --git a/content/base/src/nsContentUtils.cpp b/content/base/src/nsContentUtils.cpp |
5 --- a/content/base/src/nsContentUtils.cpp |
5 --- a/content/base/src/nsContentUtils.cpp |
6 +++ b/content/base/src/nsContentUtils.cpp |
6 +++ b/content/base/src/nsContentUtils.cpp |
7 @@ -137,16 +137,19 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_ |
7 @@ -147,16 +147,19 @@ static NS_DEFINE_CID(kXTFServiceCID, NS_ |
8 #include "xpcprivate.h" // nsXPConnect |
8 #include "xpcprivate.h" // nsXPConnect |
9 #include "nsScriptSecurityManager.h" |
9 #include "nsScriptSecurityManager.h" |
10 #include "nsIChannelPolicy.h" |
10 #include "nsIChannelPolicy.h" |
11 #include "nsChannelPolicy.h" |
11 #include "nsChannelPolicy.h" |
12 #include "nsIContentSecurityPolicy.h" |
12 #include "nsIContentSecurityPolicy.h" |
22 #include "nsIObjectLoadingContent.h" |
22 #include "nsIObjectLoadingContent.h" |
23 #include "nsCCUncollectableMarker.h" |
23 #include "nsCCUncollectableMarker.h" |
24 #include "mozilla/Base64.h" |
24 #include "mozilla/Base64.h" |
25 #include "mozilla/Preferences.h" |
25 #include "mozilla/Preferences.h" |
26 #include "nsDOMMutationObserver.h" |
26 #include "nsDOMMutationObserver.h" |
27 @@ -6580,26 +6583,23 @@ nsContentUtils::FindInternalContentViewe |
27 @@ -6706,26 +6709,23 @@ nsContentUtils::FindInternalContentViewe |
28 } |
28 } |
29 return docFactory.forget(); |
29 return docFactory.forget(); |
30 } |
30 } |
31 } |
31 } |
32 } |
32 } |
58 nsHTMLMediaElement::IsMediaPluginsType(nsDependentCString(aType))) { |
58 nsHTMLMediaElement::IsMediaPluginsType(nsDependentCString(aType))) { |
59 docFactory = do_GetService("@mozilla.org/content/document-loader-factory;1"); |
59 docFactory = do_GetService("@mozilla.org/content/document-loader-factory;1"); |
60 diff --git a/content/html/content/public/nsHTMLMediaElement.h b/content/html/content/public/nsHTMLMediaElement.h |
60 diff --git a/content/html/content/public/nsHTMLMediaElement.h b/content/html/content/public/nsHTMLMediaElement.h |
61 --- a/content/html/content/public/nsHTMLMediaElement.h |
61 --- a/content/html/content/public/nsHTMLMediaElement.h |
62 +++ b/content/html/content/public/nsHTMLMediaElement.h |
62 +++ b/content/html/content/public/nsHTMLMediaElement.h |
63 @@ -256,17 +256,19 @@ public: |
63 @@ -263,17 +263,19 @@ public: |
64 void UpdateMediaSize(nsIntSize size); |
64 void UpdateMediaSize(nsIntSize size); |
65 |
65 |
66 // Returns the CanPlayStatus indicating if we can handle this |
66 // Returns the CanPlayStatus indicating if we can handle this |
67 // MIME type. The MIME type should not include the codecs parameter. |
67 // MIME type. The MIME type should not include the codecs parameter. |
68 // If it returns anything other than CANPLAY_NO then it also |
68 // If it returns anything other than CANPLAY_NO then it also |
79 static CanPlayStatus GetCanPlay(const nsAString& aType); |
79 static CanPlayStatus GetCanPlay(const nsAString& aType); |
80 |
80 |
81 // Returns true if we should handle this MIME type when it appears |
81 // Returns true if we should handle this MIME type when it appears |
82 // as an <object> or as a toplevel page. If, in practice, our support |
82 // as an <object> or as a toplevel page. If, in practice, our support |
83 // for the type is more limited than appears in the wild, we should return |
83 // for the type is more limited than appears in the wild, we should return |
84 @@ -296,20 +298,17 @@ public: |
84 @@ -303,20 +305,17 @@ public: |
85 #ifdef MOZ_WEBM |
85 #ifdef MOZ_WEBM |
86 static bool IsWebMEnabled(); |
86 static bool IsWebMEnabled(); |
87 static bool IsWebMType(const nsACString& aType); |
87 static bool IsWebMType(const nsACString& aType); |
88 static const char gWebMTypes[2][11]; |
88 static const char gWebMTypes[2][11]; |
89 static char const *const gWebMCodecs[4]; |
89 static char const *const gWebMCodecs[4]; |
95 - static const char gH264Types[3][16]; |
95 - static const char gH264Types[3][16]; |
96 - static char const *const gH264Codecs[7]; |
96 - static char const *const gH264Codecs[7]; |
97 + static bool IsGStreamerEnabled(); |
97 + static bool IsGStreamerEnabled(); |
98 #endif |
98 #endif |
99 |
99 |
100 #ifdef MOZ_MEDIA_PLUGINS |
100 #ifdef MOZ_WIDGET_GONK |
101 static bool IsMediaPluginsEnabled(); |
101 static bool IsOmxEnabled(); |
102 static bool IsMediaPluginsType(const nsACString& aType); |
102 static bool IsOmxSupportedType(const nsACString& aType); |
103 #endif |
103 static const char gOmxTypes[5][16]; |
104 |
104 static char const *const gH264Codecs[7]; |
105 /** |
105 #endif |
106 diff --git a/content/html/content/src/nsHTMLMediaElement.cpp b/content/html/content/src/nsHTMLMediaElement.cpp |
106 diff --git a/content/html/content/src/nsHTMLMediaElement.cpp b/content/html/content/src/nsHTMLMediaElement.cpp |
107 --- a/content/html/content/src/nsHTMLMediaElement.cpp |
107 --- a/content/html/content/src/nsHTMLMediaElement.cpp |
108 +++ b/content/html/content/src/nsHTMLMediaElement.cpp |
108 +++ b/content/html/content/src/nsHTMLMediaElement.cpp |
109 @@ -2112,52 +2112,20 @@ nsHTMLMediaElement::IsWebMType(const nsA |
109 @@ -2128,55 +2128,32 @@ nsHTMLMediaElement::IsWebMType(const nsA |
|
110 return true; |
110 } |
111 } |
111 } |
112 } |
112 |
113 |
113 return false; |
114 return false; |
114 } |
115 } |
|
116 #endif |
|
117 |
|
118 -#if defined(MOZ_GSTREAMER) || defined(MOZ_WIDGET_GONK) |
|
119 +#ifdef MOZ_WIDGET_GONK |
|
120 char const *const nsHTMLMediaElement::gH264Codecs[7] = { |
|
121 "avc1.42E01E", |
|
122 "avc1.42001E", |
|
123 "avc1.58A01E", |
|
124 "avc1.4D401E", |
|
125 "avc1.64001E", |
|
126 "mp4a.40.2", |
|
127 nullptr |
|
128 }; |
115 #endif |
129 #endif |
116 |
130 |
117 #ifdef MOZ_GSTREAMER |
131 #ifdef MOZ_GSTREAMER |
118 -const char nsHTMLMediaElement::gH264Types[3][16] = { |
132 -const char nsHTMLMediaElement::gH264Types[3][16] = { |
119 - "video/mp4", |
133 - "video/mp4", |
120 - "video/3gpp", |
134 - "video/3gpp", |
121 - "video/quicktime", |
135 - "video/quicktime", |
122 -}; |
136 -}; |
123 - |
137 - |
124 -char const *const nsHTMLMediaElement::gH264Codecs[7] = { |
138 -bool |
125 - "avc1.42E01E", |
|
126 - "avc1.42001E", |
|
127 - "avc1.58A01E", |
|
128 - "avc1.4D401E", |
|
129 - "avc1.64001E", |
|
130 - "mp4a.40.2", |
|
131 - nullptr |
|
132 -}; |
|
133 - |
|
134 bool |
|
135 -nsHTMLMediaElement::IsH264Enabled() |
139 -nsHTMLMediaElement::IsH264Enabled() |
136 +nsHTMLMediaElement::IsGStreamerEnabled() |
140 +bool nsHTMLMediaElement::IsGStreamerEnabled() |
137 { |
141 { |
138 - return Preferences::GetBool("media.h264.enabled"); |
142 - return Preferences::GetBool("media.h264.enabled"); |
139 -} |
143 -} |
140 - |
144 - |
141 -bool |
145 -bool |
154 - return false; |
158 - return false; |
155 + return Preferences::GetBool("media.gstreamer.enabled"); |
159 + return Preferences::GetBool("media.gstreamer.enabled"); |
156 } |
160 } |
157 #endif |
161 #endif |
158 |
162 |
159 #ifdef MOZ_MEDIA_PLUGINS |
163 #ifdef MOZ_WIDGET_GONK |
160 bool |
164 const char nsHTMLMediaElement::gOmxTypes[5][16] = { |
161 nsHTMLMediaElement::IsMediaPluginsEnabled() |
165 "audio/mpeg", |
162 { |
166 "audio/mp4", |
163 return Preferences::GetBool("media.plugins.enabled"); |
167 "video/mp4", |
164 @@ -2180,18 +2148,22 @@ nsHTMLMediaElement::IsMediaPluginsType(c |
168 @@ -2262,18 +2239,22 @@ nsHTMLMediaElement::IsDASHMPDType(const |
165 } |
169 |
166 return false; |
170 return false; |
167 } |
171 } |
168 #endif |
172 #endif |
169 |
173 |
170 /* static */ |
174 /* static */ |
183 return CANPLAY_MAYBE; |
187 return CANPLAY_MAYBE; |
184 } |
188 } |
185 #endif |
189 #endif |
186 #ifdef MOZ_OGG |
190 #ifdef MOZ_OGG |
187 if (IsOggType(nsDependentCString(aMIMEType))) { |
191 if (IsOggType(nsDependentCString(aMIMEType))) { |
188 @@ -2208,20 +2180,22 @@ nsHTMLMediaElement::CanHandleMediaType(c |
192 @@ -2297,20 +2278,22 @@ nsHTMLMediaElement::CanHandleMediaType(c |
189 #ifdef MOZ_WEBM |
193 if (IsDASHMPDType(nsDependentCString(aMIMEType))) { |
190 if (IsWebMType(nsDependentCString(aMIMEType))) { |
194 // DASH manifest uses WebM codecs only. |
191 *aCodecList = gWebMCodecs; |
195 *aCodecList = gWebMCodecs; |
192 return CANPLAY_YES; |
196 return CANPLAY_YES; |
193 } |
197 } |
194 #endif |
198 #endif |
195 |
199 |
203 + if (aCodecList) |
207 + if (aCodecList) |
204 + *aCodecList = nullptr; |
208 + *aCodecList = nullptr; |
205 + if (nsGStreamerDecoder::CanHandleMediaType(aMIMEType, aCodecs)) |
209 + if (nsGStreamerDecoder::CanHandleMediaType(aMIMEType, aCodecs)) |
206 + return CANPLAY_YES; |
210 + return CANPLAY_YES; |
207 #endif |
211 #endif |
|
212 #ifdef MOZ_WIDGET_GONK |
|
213 if (IsOmxSupportedType(nsDependentCString(aMIMEType))) { |
|
214 *aCodecList = gH264Codecs; |
|
215 return CANPLAY_MAYBE; |
|
216 } |
|
217 #endif |
208 #ifdef MOZ_MEDIA_PLUGINS |
218 #ifdef MOZ_MEDIA_PLUGINS |
209 if (IsMediaPluginsEnabled() && GetMediaPluginHost()->FindDecoder(nsDependentCString(aMIMEType), aCodecList)) |
219 @@ -2331,17 +2314,17 @@ bool nsHTMLMediaElement::ShouldHandleMed |
210 return CANPLAY_MAYBE; |
|
211 #endif |
|
212 return CANPLAY_NO; |
|
213 } |
|
214 |
|
215 @@ -2236,17 +2210,17 @@ bool nsHTMLMediaElement::ShouldHandleMed |
|
216 if (IsOggType(nsDependentCString(aMIMEType))) |
220 if (IsOggType(nsDependentCString(aMIMEType))) |
217 return true; |
221 return true; |
218 #endif |
222 #endif |
219 #ifdef MOZ_WEBM |
223 #ifdef MOZ_WEBM |
220 if (IsWebMType(nsDependentCString(aMIMEType))) |
224 if (IsWebMType(nsDependentCString(aMIMEType))) |
223 #ifdef MOZ_GSTREAMER |
227 #ifdef MOZ_GSTREAMER |
224 - if (IsH264Type(nsDependentCString(aMIMEType))) |
228 - if (IsH264Type(nsDependentCString(aMIMEType))) |
225 + if (nsGStreamerDecoder::CanHandleMediaType(aMIMEType, nullptr)) |
229 + if (nsGStreamerDecoder::CanHandleMediaType(aMIMEType, nullptr)) |
226 return true; |
230 return true; |
227 #endif |
231 #endif |
|
232 #ifdef MOZ_WIDGET_GONK |
|
233 if (IsOmxSupportedType(nsDependentCString(aMIMEType))) { |
|
234 return true; |
|
235 } |
|
236 #endif |
228 #ifdef MOZ_MEDIA_PLUGINS |
237 #ifdef MOZ_MEDIA_PLUGINS |
229 if (IsMediaPluginsEnabled() && GetMediaPluginHost()->FindDecoder(nsDependentCString(aMIMEType), NULL)) |
238 @@ -2372,26 +2355,31 @@ nsHTMLMediaElement::GetCanPlay(const nsA |
230 return true; |
|
231 #endif |
|
232 // We should not return true for Wave types, since there are some |
|
233 // Wave codecs actually in use in the wild that we don't support, and |
|
234 @@ -2272,26 +2246,31 @@ nsHTMLMediaElement::GetCanPlay(const nsA |
|
235 { |
239 { |
236 nsContentTypeParser parser(aType); |
240 nsContentTypeParser parser(aType); |
237 nsAutoString mimeType; |
241 nsAutoString mimeType; |
238 nsresult rv = parser.GetType(mimeType); |
242 nsresult rv = parser.GetType(mimeType); |
239 if (NS_FAILED(rv)) |
243 if (NS_FAILED(rv)) |
266 CanPlayStatus result = CANPLAY_YES; |
270 CanPlayStatus result = CANPLAY_YES; |
267 // See http://www.rfc-editor.org/rfc/rfc4281.txt for the description |
271 // See http://www.rfc-editor.org/rfc/rfc4281.txt for the description |
268 // of the 'codecs' parameter |
272 // of the 'codecs' parameter |
269 nsCharSeparatedTokenizer tokenizer(codecs, ','); |
273 nsCharSeparatedTokenizer tokenizer(codecs, ','); |
270 bool expectMoreTokens = false; |
274 bool expectMoreTokens = false; |
271 @@ -2369,17 +2348,19 @@ nsHTMLMediaElement::CreateDecoder(const |
275 @@ -2486,17 +2474,19 @@ nsHTMLMediaElement::CreateDecoder(const |
272 nsRefPtr<nsWebMDecoder> decoder = new nsWebMDecoder(); |
276 nsRefPtr<nsDASHDecoder> decoder = new nsDASHDecoder(); |
273 if (decoder->Init(this)) { |
277 if (decoder->Init(this)) { |
274 return decoder.forget(); |
278 return decoder.forget(); |
275 } |
279 } |
276 } |
280 } |
277 #endif |
281 #endif |
546 + |
550 + |
547 +#endif |
551 +#endif |
548 diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js |
552 diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js |
549 --- a/modules/libpref/src/init/all.js |
553 --- a/modules/libpref/src/init/all.js |
550 +++ b/modules/libpref/src/init/all.js |
554 +++ b/modules/libpref/src/init/all.js |
551 @@ -165,17 +165,17 @@ pref("media.opus.enabled", true); |
555 @@ -164,17 +164,17 @@ pref("media.wave.enabled", true); |
552 #endif |
|
553 #ifdef MOZ_WAVE |
|
554 pref("media.wave.enabled", true); |
|
555 #endif |
556 #endif |
556 #ifdef MOZ_WEBM |
557 #ifdef MOZ_WEBM |
557 pref("media.webm.enabled", true); |
558 pref("media.webm.enabled", true); |
|
559 #endif |
|
560 #ifdef MOZ_DASH |
|
561 pref("media.dash.enabled", true); |
558 #endif |
562 #endif |
559 #ifdef MOZ_GSTREAMER |
563 #ifdef MOZ_GSTREAMER |
560 -pref("media.h264.enabled", true); |
564 -pref("media.h264.enabled", true); |
561 +pref("media.gstreamer.enabled", true); |
565 +pref("media.gstreamer.enabled", true); |
562 #endif |
566 #endif |
563 #ifdef MOZ_WEBRTC |
567 #ifdef MOZ_WEBRTC |
564 pref("media.navigator.enabled", false); |
568 pref("media.navigator.enabled", false); |
|
569 pref("media.peerconnection.enabled", false); |
|
570 pref("media.navigator.permission.disabled", false); |
565 #else |
571 #else |
566 #ifdef ANDROID |
572 #ifdef ANDROID |
567 pref("media.navigator.enabled", true); |
573 pref("media.navigator.enabled", true); |
568 #endif |
|
569 #endif |
|