Bug 847809 - Add audio/amr to the supported decode type of OMX, but disable it if this AMR is loaded from Web pages. r=roc

This commit is contained in:
Shelly Lin 2013-03-18 11:33:32 +08:00
parent 5abd5f2f05
commit 980d7af474
3 changed files with 22 additions and 1 deletions

View File

@ -7,6 +7,7 @@
#include "DecoderTraits.h"
#include "MediaDecoder.h"
#include "nsCharSeparatedTokenizer.h"
#include "nsIPrincipal.h"
#ifdef MOZ_MEDIA_PLUGINS
#include "MediaPluginHost.h"
@ -195,9 +196,10 @@ IsGStreamerSupportedType(const nsACString& aMimeType)
#endif
#ifdef MOZ_WIDGET_GONK
static const char* const gOmxTypes[6] = {
static const char* const gOmxTypes[7] = {
"audio/mpeg",
"audio/mp4",
"audio/amr",
"video/mp4",
"video/3gpp",
"video/quicktime",
@ -399,6 +401,21 @@ DecoderTraits::CreateDecoder(const nsACString& aType, MediaDecoderOwner* aOwner)
#endif
#ifdef MOZ_WIDGET_GONK
if (IsOmxSupportedType(aType)) {
// AMR audio is enabled for MMS, but we are discouraging Web and App
// developers from using AMR, thus we only allow AMR to be played on WebApps.
if (aType.EqualsASCII("audio/amr") || aType.EqualsASCII("video/3gpp")) {
nsHTMLMediaElement* element = aOwner->GetMediaElement();
if (!element) {
return nullptr;
}
nsIPrincipal* principal = element->NodePrincipal();
if (!principal) {
return nullptr;
}
if (principal->GetAppStatus() < nsIPrincipal::APP_STATUS_PRIVILEGED) {
return nullptr;
}
}
decoder = new MediaOmxDecoder();
}
#endif

View File

@ -78,6 +78,7 @@
#define AUDIO_WEBM "audio/webm"
#define AUDIO_MP3 "audio/mpeg"
#define AUDIO_MP4 "audio/mp4"
#define AUDIO_AMR "audio/amr"
#define BINARY_OCTET_STREAM "binary/octet-stream"

View File

@ -480,6 +480,9 @@ static nsExtraMimeTypeEntry extraMimeEntries [] =
{ APPLICATION_OGG, "ogg", "Ogg Video"},
{ AUDIO_OGG, "oga", "Ogg Audio" },
{ AUDIO_OGG, "opus", "Opus Audio" },
#ifdef MOZ_WIDGET_GONK
{ AUDIO_AMR, "amr", "Adaptive Multi-Rate Audio" },
#endif
{ VIDEO_WEBM, "webm", "Web Media Video" },
{ AUDIO_WEBM, "webm", "Web Media Audio" },
#ifdef MOZ_DASH