diff options
Diffstat (limited to 'WebCore/platform/graphics/MediaPlayer.cpp')
-rw-r--r-- | WebCore/platform/graphics/MediaPlayer.cpp | 67 |
1 files changed, 54 insertions, 13 deletions
diff --git a/WebCore/platform/graphics/MediaPlayer.cpp b/WebCore/platform/graphics/MediaPlayer.cpp index e72987a..87060a4 100644 --- a/WebCore/platform/graphics/MediaPlayer.cpp +++ b/WebCore/platform/graphics/MediaPlayer.cpp @@ -194,6 +194,24 @@ static void addMediaEngine(CreateMediaEnginePlayer constructor, MediaEngineSuppo installedMediaEngines().append(new MediaPlayerFactory(constructor, getSupportedTypes, supportsType)); } +static const AtomicString& applicationOctetStream() +{ + DEFINE_STATIC_LOCAL(const AtomicString, applicationOctetStream, ("application/octet-stream")); + return applicationOctetStream; +} + +static const AtomicString& textPlain() +{ + DEFINE_STATIC_LOCAL(const AtomicString, textPlain, ("text/plain")); + return textPlain; +} + +static const AtomicString& codecs() +{ + DEFINE_STATIC_LOCAL(const AtomicString, codecs, ("codecs")); + return codecs; +} + static MediaPlayerFactory* chooseBestEngineForTypeAndCodecs(const String& type, const String& codecs) { Vector<MediaPlayerFactory*>& engines = installedMediaEngines(); @@ -201,6 +219,14 @@ static MediaPlayerFactory* chooseBestEngineForTypeAndCodecs(const String& type, if (engines.isEmpty()) return 0; + // 4.8.10.3 MIME types - In the absence of a specification to the contrary, the MIME type "application/octet-stream" + // when used with parameters, e.g. "application/octet-stream;codecs=theora", is a type that the user agent knows + // it cannot render. + if (type == applicationOctetStream()) { + if (!codecs.isEmpty()) + return 0; + } + MediaPlayerFactory* engine = 0; MediaPlayer::SupportsType supported = MediaPlayer::IsNotSupported; @@ -252,11 +278,11 @@ MediaPlayer::~MediaPlayer() void MediaPlayer::load(const String& url, const ContentType& contentType) { - String type = contentType.type(); - String codecs = contentType.parameter("codecs"); + String type = contentType.type().lower(); + String typeCodecs = contentType.parameter(codecs()); - // if we don't know the MIME type, see if the extension can help - if (type.isEmpty() || type == "application/octet-stream" || type == "text/plain") { + // If the MIME type is unhelpful, see if the type registry has a match for the file extension. + if (type.isEmpty() || type == applicationOctetStream() || type == textPlain()) { size_t pos = url.reverseFind('.'); if (pos != notFound) { String extension = url.substring(pos + 1); @@ -268,14 +294,17 @@ void MediaPlayer::load(const String& url, const ContentType& contentType) MediaPlayerFactory* engine = 0; if (!type.isEmpty()) - engine = chooseBestEngineForTypeAndCodecs(type, codecs); + engine = chooseBestEngineForTypeAndCodecs(type, typeCodecs); - // if we didn't find an engine that claims the MIME type, just use the first engine - if (!engine && !installedMediaEngines().isEmpty()) + // If we didn't find an engine and no MIME type is specified, just use the first engine. + if (!engine && type.isEmpty() && !installedMediaEngines().isEmpty()) engine = installedMediaEngines()[0]; - // don't delete and recreate the player unless it comes from a different engine - if (engine && m_currentMediaEngine != engine) { + // Don't delete and recreate the player unless it comes from a different engine + if (!engine) { + m_currentMediaEngine = engine; + m_private.clear(); + } else if (m_currentMediaEngine != engine) { m_currentMediaEngine = engine; m_private.clear(); m_private.set(engine->constructor(this)); @@ -532,14 +561,26 @@ void MediaPlayer::paintCurrentFrameInContext(GraphicsContext* p, const IntRect& MediaPlayer::SupportsType MediaPlayer::supportsType(ContentType contentType) { - String type = contentType.type(); - String codecs = contentType.parameter("codecs"); - MediaPlayerFactory* engine = chooseBestEngineForTypeAndCodecs(type, codecs); + String type = contentType.type().lower(); + String typeCodecs = contentType.parameter(codecs()); + + // 4.8.10.3 MIME types - In the absence of a specification to the contrary, the MIME type "application/octet-stream" + // when used with parameters, e.g. "application/octet-stream;codecs=theora", is a type that the user agent knows + // it cannot render. + if (type == applicationOctetStream()) { + if (!typeCodecs.isEmpty()) + return IsNotSupported; + + // The MIME type "application/octet-stream" with no parameters is never a type that the user agent knows it + // cannot render. + return MayBeSupported; + } + MediaPlayerFactory* engine = chooseBestEngineForTypeAndCodecs(type, typeCodecs); if (!engine) return IsNotSupported; - return engine->supportsTypeAndCodecs(type, codecs); + return engine->supportsTypeAndCodecs(type, typeCodecs); } void MediaPlayer::getSupportedTypes(HashSet<String>& types) |