Title: [273455] branches/safari-611-branch/Source/WebCore
Revision
273455
Author
alanc...@apple.com
Date
2021-02-24 16:37:42 -0800 (Wed, 24 Feb 2021)

Log Message

Cherry-pick r272544. rdar://problem/74409562

    [Cocoa] Encrypted media segments should generate a parser error if no encrypted media handler is present.
    https://bugs.webkit.org/show_bug.cgi?id=221496

    Reviewed by Eric Carlson.

    The WebM format reader does not support encrypted media parsing, so the parser must generate an error rather
    than continuing to parse encrypted media data.

    * platform/graphics/cocoa/SourceBufferParserWebM.cpp:
    (WebCore::SourceBufferParserWebM::OnElementEnd):
    (WebCore::SourceBufferParserWebM::OnTrackEntry):
    * platform/graphics/cocoa/SourceBufferParserWebM.h:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272544 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-611-branch/Source/WebCore/ChangeLog (273454 => 273455)


--- branches/safari-611-branch/Source/WebCore/ChangeLog	2021-02-25 00:37:38 UTC (rev 273454)
+++ branches/safari-611-branch/Source/WebCore/ChangeLog	2021-02-25 00:37:42 UTC (rev 273455)
@@ -1,5 +1,40 @@
 2021-02-24  Russell Epstein  <repst...@apple.com>
 
+        Cherry-pick r272544. rdar://problem/74409562
+
+    [Cocoa] Encrypted media segments should generate a parser error if no encrypted media handler is present.
+    https://bugs.webkit.org/show_bug.cgi?id=221496
+    
+    Reviewed by Eric Carlson.
+    
+    The WebM format reader does not support encrypted media parsing, so the parser must generate an error rather
+    than continuing to parse encrypted media data.
+    
+    * platform/graphics/cocoa/SourceBufferParserWebM.cpp:
+    (WebCore::SourceBufferParserWebM::OnElementEnd):
+    (WebCore::SourceBufferParserWebM::OnTrackEntry):
+    * platform/graphics/cocoa/SourceBufferParserWebM.h:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@272544 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-02-08  Jer Noble  <jer.no...@apple.com>
+
+            [Cocoa] Encrypted media segments should generate a parser error if no encrypted media handler is present.
+            https://bugs.webkit.org/show_bug.cgi?id=221496
+
+            Reviewed by Eric Carlson.
+
+            The WebM format reader does not support encrypted media parsing, so the parser must generate an error rather
+            than continuing to parse encrypted media data.
+
+            * platform/graphics/cocoa/SourceBufferParserWebM.cpp:
+            (WebCore::SourceBufferParserWebM::OnElementEnd):
+            (WebCore::SourceBufferParserWebM::OnTrackEntry):
+            * platform/graphics/cocoa/SourceBufferParserWebM.h:
+
+2021-02-24  Russell Epstein  <repst...@apple.com>
+
         Cherry-pick r272359. rdar://problem/74451201
 
     [MSE] Move the call to didParseInitializationDataCallback() from the beginning of a cluster to the end of "tracks" element

Modified: branches/safari-611-branch/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp (273454 => 273455)


--- branches/safari-611-branch/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp	2021-02-25 00:37:38 UTC (rev 273454)
+++ branches/safari-611-branch/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.cpp	2021-02-25 00:37:42 UTC (rev 273455)
@@ -41,6 +41,7 @@
 #include "VideoTrackPrivateWebM.h"
 #include "WebMAudioUtilitiesCocoa.h"
 #include <_javascript_Core/DataView.h>
+#include <_javascript_Core/GenericTypedArrayViewInlines.h>
 #include <webm/webm_parser.h>
 #include <wtf/Algorithms.h>
 #include <wtf/LoggerHelper.h>
@@ -775,6 +776,11 @@
     INFO_LOG_IF_POSSIBLE(LOGIDENTIFIER, "state(", oldState, "->", m_state, "), id(", metadata.id, "), size(", metadata.size, ")");
 
     if (metadata.id == Id::kTracks) {
+        if (!m_keyIds.isEmpty() && !m_didProvideContentKeyRequestInitializationDataForTrackIDCallback) {
+            ERROR_LOG_IF_POSSIBLE(LOGIDENTIFIER, "Encountered encrypted content without an key request callback");
+            return Status(Status::Code(ErrorCode::ContentEncrypted));
+        }
+
         if (m_initializationSegmentEncountered && m_didParseInitializationDataCallback) {
             m_callOnClientThreadCallback([this, protectedThis = makeRef(*this), initializationSegment = WTFMove(*m_initializationSegment)]() mutable {
                 m_didParseInitializationDataCallback(WTFMove(initializationSegment));
@@ -782,6 +788,12 @@
         }
         m_initializationSegmentEncountered = false;
         m_initializationSegment = nullptr;
+
+        if (!m_keyIds.isEmpty()) {
+            for (auto& keyIdPair : m_keyIds)
+                m_didProvideContentKeyRequestInitializationDataForTrackIDCallback(WTFMove(keyIdPair.second), keyIdPair.first);
+        }
+        m_keyIds.clear();
     }
 
     return Status(Status::kOkCompleted);
@@ -886,6 +898,25 @@
         m_initializationSegment->audioTracks.append({ MediaDescriptionWebM::create(TrackEntry(trackEntry)), WTFMove(track) });
     }
 
+    if (trackEntry.content_encodings.is_present() && !trackEntry.content_encodings.value().encodings.empty()) {
+        ALWAYS_LOG_IF_POSSIBLE(LOGIDENTIFIER, "content_encodings detected:");
+        for (auto& encoding : trackEntry.content_encodings.value().encodings) {
+            if (!encoding.is_present())
+                continue;
+
+            auto& encryption = encoding.value().encryption;
+            if (!encryption.is_present())
+                continue;
+
+            auto& keyIdElement = encryption.value().key_id;
+            if (!keyIdElement.is_present())
+                continue;
+
+            auto& keyId = keyIdElement.value();
+            m_keyIds.append(std::make_pair(trackEntry.track_uid.value(), Uint8Array::create(keyId.data(), keyId.size())));
+        }
+    }
+
     StringView codecString { trackEntry.codec_id.value().data(), (unsigned)trackEntry.codec_id.value().length() };
 #if ENABLE(VP9)
     if (codecString == "V_VP9" && isVP9DecoderAvailable()) {

Modified: branches/safari-611-branch/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.h (273454 => 273455)


--- branches/safari-611-branch/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.h	2021-02-25 00:37:38 UTC (rev 273454)
+++ branches/safari-611-branch/Source/WebCore/platform/graphics/cocoa/SourceBufferParserWebM.h	2021-02-25 00:37:42 UTC (rev 273455)
@@ -97,6 +97,7 @@
         ReceivedEbmlInsideSegment,
         UnsupportedVideoCodec,
         UnsupportedAudioCodec,
+        ContentEncrypted,
     };
 
     enum class State : uint8_t {
@@ -249,6 +250,7 @@
     webm::Status OnFrame(const webm::FrameMetadata&, webm::Reader*, uint64_t* bytesRemaining) final;
 
     std::unique_ptr<InitializationSegment> m_initializationSegment;
+    Vector<std::pair<uint64_t, Ref<Uint8Array>>> m_keyIds;
     webm::Status m_status;
     std::unique_ptr<webm::WebmParser> m_parser;
     bool m_initializationSegmentEncountered { false };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to