<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[169838] tags/Safari-538.39.41/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/169838">169838</a></dd>
<dt>Author</dt> <dd>dburkart@apple.com</dd>
<dt>Date</dt> <dd>2014-06-11 14:32:53 -0700 (Wed, 11 Jun 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Merge <a href="http://trac.webkit.org/projects/webkit/changeset/169830">r169830</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#tagsSafari5383941SourceWebCoreChangeLog">tags/Safari-538.39.41/Source/WebCore/ChangeLog</a></li>
<li><a href="#tagsSafari5383941SourceWebCoreModulesencryptedmediaMediaKeySessioncpp">tags/Safari-538.39.41/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp</a></li>
<li><a href="#tagsSafari5383941SourceWebCoreModulesencryptedmediaMediaKeySessionh">tags/Safari-538.39.41/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h</a></li>
<li><a href="#tagsSafari5383941SourceWebCoreModulesmediasourceSourceBuffercpp">tags/Safari-538.39.41/Source/WebCore/Modules/mediasource/SourceBuffer.cpp</a></li>
<li><a href="#tagsSafari5383941SourceWebCoreModulesmediasourceSourceBufferh">tags/Safari-538.39.41/Source/WebCore/Modules/mediasource/SourceBuffer.h</a></li>
<li><a href="#tagsSafari5383941SourceWebCoreplatformgraphicsCDMSessionh">tags/Safari-538.39.41/Source/WebCore/platform/graphics/CDMSession.h</a></li>
<li><a href="#tagsSafari5383941SourceWebCoreplatformgraphicsSourceBufferPrivateClienth">tags/Safari-538.39.41/Source/WebCore/platform/graphics/SourceBufferPrivateClient.h</a></li>
<li><a href="#tagsSafari5383941SourceWebCoreplatformgraphicsavfoundationobjcCDMSessionMediaSourceAVFObjCh">tags/Safari-538.39.41/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h</a></li>
<li><a href="#tagsSafari5383941SourceWebCoreplatformgraphicsavfoundationobjcCDMSessionMediaSourceAVFObjCmm">tags/Safari-538.39.41/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm</a></li>
<li><a href="#tagsSafari5383941SourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCh">tags/Safari-538.39.41/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h</a></li>
<li><a href="#tagsSafari5383941SourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCmm">tags/Safari-538.39.41/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="tagsSafari5383941SourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.39.41/Source/WebCore/ChangeLog (169837 => 169838)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.39.41/Source/WebCore/ChangeLog        2014-06-11 21:29:50 UTC (rev 169837)
+++ tags/Safari-538.39.41/Source/WebCore/ChangeLog        2014-06-11 21:32:53 UTC (rev 169838)
</span><span class="lines">@@ -1,3 +1,57 @@
</span><ins>+2014-06-11 Dana Burkart <dburkart@apple.com>
+
+ Merge r169830.
+
+ 2014-06-11 Jer Noble <jer.noble@apple.com>
+
+ [EME][Mac] Propagate errors from AVSampleBufferDisplayLayer through to MSE
+ https://bugs.webkit.org/show_bug.cgi?id=133747
+
+ Reviewed by Eric Carlson.
+
+ Abstract out the delivery of errors in MediaKeySession into its own method, which can be triggered by
+ CDMSession objects through the CDMSessionClient interface:
+ * Modules/encryptedmedia/MediaKeySession.cpp:
+ (WebCore::MediaKeySession::keyRequestTimerFired):
+ (WebCore::MediaKeySession::addKeyTimerFired):
+ (WebCore::MediaKeySession::sendMessage):
+ (WebCore::MediaKeySession::sendError):
+ * Modules/encryptedmedia/MediaKeySession.h:
+ * Modules/mediasource/SourceBuffer.cpp:
+ (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveRenderingError):
+ * Modules/mediasource/SourceBuffer.h:
+ * platform/graphics/SourceBufferPrivateClient.h:
+ * platform/graphics/CDMSession.h:
+
+ Add an Objective-C object which can listen for error KVO notifications:
+ * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
+ (WebCore::SourceBufferPrivateAVFObjCErrorClient::~SourceBufferPrivateAVFObjCErrorClient):
+ * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+ (-[WebAVSampleBufferErrorListener initWithParent:WebCore::]):
+ (-[WebAVSampleBufferErrorListener dealloc]):
+ (-[WebAVSampleBufferErrorListener invalidate]):
+ (-[WebAVSampleBufferErrorListener beginObservingLayer:]):
+ (-[WebAVSampleBufferErrorListener stopObservingLayer:]):
+ (-[WebAVSampleBufferErrorListener beginObservingRenderer:]):
+ (-[WebAVSampleBufferErrorListener stopObservingRenderer:]):
+ (-[WebAVSampleBufferErrorListener observeValueForKeyPath:ofObject:change:context:]):
+ (-[WebAVSampleBufferErrorListener layerFailedToDecode:]):
+ (WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC):
+ (WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled):
+ (WebCore::SourceBufferPrivateAVFObjC::registerForErrorNotifications):
+ (WebCore::SourceBufferPrivateAVFObjC::unregisterForErrorNotifications):
+ (WebCore::SourceBufferPrivateAVFObjC::layerDidReceiveError):
+ (WebCore::SourceBufferPrivateAVFObjC::rendererDidReceiveError):
+
+ Register for the new error notifications:
+ * platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h:
+ (WebCore::CDMSessionMediaSourceAVFObjC::~CDMSessionMediaSourceAVFObjC): Moved to source file.
+ * platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm:
+ (WebCore::CDMSessionMediaSourceAVFObjC::CDMSessionMediaSourceAVFObjC): Register for error notifications.
+ (WebCore::CDMSessionMediaSourceAVFObjC::~CDMSessionMediaSourceAVFObjC): Unregister for error notifications.
+ (WebCore::CDMSessionMediaSourceAVFObjC::layerDidReceiveError): Pass through to CDMSessionClient.
+ (WebCore::CDMSessionMediaSourceAVFObjC::rendererDidReceiveError): Ditto.
+
</ins><span class="cx"> 2014-06-10 Matthew Hanson <matthew_hanson@apple.com>
</span><span class="cx">
</span><span class="cx"> Merge r169681.
</span></span></pre></div>
<a id="tagsSafari5383941SourceWebCoreModulesencryptedmediaMediaKeySessioncpp"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.39.41/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp (169837 => 169838)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.39.41/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp        2014-06-11 21:29:50 UTC (rev 169837)
+++ tags/Safari-538.39.41/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp        2014-06-11 21:32:53 UTC (rev 169838)
</span><span class="lines">@@ -112,16 +112,9 @@
</span><span class="cx"> // 3.1. Create a new MediaKeyError object with the following attributes:
</span><span class="cx"> // code = the appropriate MediaKeyError code
</span><span class="cx"> // systemCode = a Key System-specific value, if provided, and 0 otherwise
</span><del>- RefPtr<MediaKeyError> error = MediaKeyError::create(errorCode, systemCode).get();
-
</del><span class="cx"> // 3.2. Set the MediaKeySession object's error attribute to the error object created in the previous step.
</span><del>- setError(error.get());
-
</del><span class="cx"> // 3.3. queue a task to fire a simple event named keyerror at the MediaKeySession object.
</span><del>- RefPtr<Event> event = Event::create(eventNames().webkitkeyerrorEvent, false, false);
- event->setTarget(this);
- m_asyncEventQueue.enqueueEvent(event.release());
-
</del><ins>+ sendError(errorCode, systemCode);
</ins><span class="cx"> // 3.4. Abort the task.
</span><span class="cx"> continue;
</span><span class="cx"> }
</span><span class="lines">@@ -130,14 +123,7 @@
</span><span class="cx"> // The event is of type MediaKeyMessageEvent and has:
</span><span class="cx"> // message = key request
</span><span class="cx"> // destinationURL = destinationURL
</span><del>- MediaKeyMessageEventInit init;
- init.bubbles = false;
- init.cancelable = false;
- init.message = keyRequest;
- init.destinationURL = destinationURL;
- RefPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::create(eventNames().webkitkeymessageEvent, init);
- event->setTarget(this);
- m_asyncEventQueue.enqueueEvent(event.release());
</del><ins>+ sendMessage(keyRequest.get(), destinationURL);
</ins><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -184,15 +170,8 @@
</span><span class="cx"> // The event is of type MediaKeyMessageEvent and has:
</span><span class="cx"> // message = next message
</span><span class="cx"> // destinationURL = null
</span><del>- if (nextMessage) {
- MediaKeyMessageEventInit init;
- init.bubbles = false;
- init.cancelable = false;
- init.message = nextMessage;
- RefPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::create(eventNames().webkitkeymessageEvent, init);
- event->setTarget(this);
- m_asyncEventQueue.enqueueEvent(event.release());
- }
</del><ins>+ if (nextMessage)
+ sendMessage(nextMessage.get(), emptyString());
</ins><span class="cx">
</span><span class="cx"> // 2.7. If did store key is true, queue a task to fire a simple event named keyadded at the MediaKeySession object.
</span><span class="cx"> if (didStoreKey) {
</span><span class="lines">@@ -206,22 +185,37 @@
</span><span class="cx"> // 2.8.1. Create a new MediaKeyError object with the following attributes:
</span><span class="cx"> // code = the appropriate MediaKeyError code
</span><span class="cx"> // systemCode = a Key System-specific value, if provided, and 0 otherwise
</span><del>- RefPtr<MediaKeyError> error = MediaKeyError::create(errorCode, systemCode).get();
-
</del><span class="cx"> // 2.8.2. Set the MediaKeySession object's error attribute to the error object created in the previous step.
</span><del>- setError(error.get());
-
</del><span class="cx"> // 2.8.3. queue a task to fire a simple event named keyerror at the MediaKeySession object.
</span><del>- RefPtr<Event> keyerrorEvent = Event::create(eventNames().webkitkeyerrorEvent, false, false);
- keyerrorEvent->setTarget(this);
- m_asyncEventQueue.enqueueEvent(keyerrorEvent.release());
-
</del><ins>+ sendError(errorCode, systemCode);
</ins><span class="cx"> // 2.8.4. Abort the task.
</span><span class="cx"> // NOTE: no-op
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void MediaKeySession::sendMessage(Uint8Array* message, String destinationURL)
+{
+ MediaKeyMessageEventInit init;
+ init.bubbles = false;
+ init.cancelable = false;
+ init.message = message;
+ init.destinationURL = destinationURL;
+ RefPtr<MediaKeyMessageEvent> event = MediaKeyMessageEvent::create(eventNames().webkitkeymessageEvent, init);
+ event->setTarget(this);
+ m_asyncEventQueue.enqueueEvent(event.release());
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+void MediaKeySession::sendError(CDMSessionClient::MediaKeyErrorCode errorCode, unsigned long systemCode)
+{
+ RefPtr<MediaKeyError> error = MediaKeyError::create(errorCode, systemCode).get();
+ setError(error.get());
+
+ RefPtr<Event> keyerrorEvent = Event::create(eventNames().webkitkeyerrorEvent, false, false);
+ keyerrorEvent->setTarget(this);
+ m_asyncEventQueue.enqueueEvent(keyerrorEvent.release());
+}
+
+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="tagsSafari5383941SourceWebCoreModulesencryptedmediaMediaKeySessionh"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.39.41/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h (169837 => 169838)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.39.41/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h        2014-06-11 21:29:50 UTC (rev 169837)
+++ tags/Safari-538.39.41/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h        2014-06-11 21:32:53 UTC (rev 169838)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #if ENABLE(ENCRYPTED_MEDIA_V2)
</span><span class="cx">
</span><span class="cx"> #include "ActiveDOMObject.h"
</span><ins>+#include "CDMSession.h"
</ins><span class="cx"> #include "EventTarget.h"
</span><span class="cx"> #include "ExceptionCode.h"
</span><span class="cx"> #include "GenericEventQueue.h"
</span><span class="lines">@@ -43,9 +44,8 @@
</span><span class="cx">
</span><span class="cx"> class MediaKeyError;
</span><span class="cx"> class MediaKeys;
</span><del>-class CDMSession;
</del><span class="cx">
</span><del>-class MediaKeySession final : public RefCounted<MediaKeySession>, public EventTargetWithInlineData, public ActiveDOMObject {
</del><ins>+class MediaKeySession final : public RefCounted<MediaKeySession>, public EventTargetWithInlineData, public ActiveDOMObject, public CDMSessionClient {
</ins><span class="cx"> public:
</span><span class="cx"> static PassRefPtr<MediaKeySession> create(ScriptExecutionContext*, MediaKeys*, const String& keySystem);
</span><span class="cx"> ~MediaKeySession();
</span><span class="lines">@@ -85,6 +85,10 @@
</span><span class="cx"> void keyRequestTimerFired(Timer<MediaKeySession>&);
</span><span class="cx"> void addKeyTimerFired(Timer<MediaKeySession>&);
</span><span class="cx">
</span><ins>+ // CDMSessionClient
+ virtual void sendMessage(Uint8Array*, String destinationURL);
+ virtual void sendError(MediaKeyErrorCode, unsigned long systemCode);
+
</ins><span class="cx"> MediaKeys* m_keys;
</span><span class="cx"> String m_keySystem;
</span><span class="cx"> String m_sessionId;
</span></span></pre></div>
<a id="tagsSafari5383941SourceWebCoreModulesmediasourceSourceBuffercpp"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.39.41/Source/WebCore/Modules/mediasource/SourceBuffer.cpp (169837 => 169838)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.39.41/Source/WebCore/Modules/mediasource/SourceBuffer.cpp        2014-06-11 21:29:50 UTC (rev 169837)
+++ tags/Safari-538.39.41/Source/WebCore/Modules/mediasource/SourceBuffer.cpp        2014-06-11 21:32:53 UTC (rev 169838)
</span><span class="lines">@@ -535,6 +535,11 @@
</span><span class="cx"> reportExtraMemoryCost();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void SourceBuffer::sourceBufferPrivateDidReceiveRenderingError(SourceBufferPrivate*, int)
+{
+ m_source->streamEndedWithError(decodeError(), IgnorableExceptionCode());
+}
+
</ins><span class="cx"> void SourceBuffer::removeCodedFrames(const MediaTime& start, const MediaTime& end)
</span><span class="cx"> {
</span><span class="cx"> // 3.5.9 Coded Frame Removal Algorithm
</span></span></pre></div>
<a id="tagsSafari5383941SourceWebCoreModulesmediasourceSourceBufferh"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.39.41/Source/WebCore/Modules/mediasource/SourceBuffer.h (169837 => 169838)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.39.41/Source/WebCore/Modules/mediasource/SourceBuffer.h        2014-06-11 21:29:50 UTC (rev 169837)
+++ tags/Safari-538.39.41/Source/WebCore/Modules/mediasource/SourceBuffer.h        2014-06-11 21:32:53 UTC (rev 169838)
</span><span class="lines">@@ -119,6 +119,7 @@
</span><span class="cx"> virtual void sourceBufferPrivateSeekToTime(SourceBufferPrivate*, const MediaTime&);
</span><span class="cx"> virtual MediaTime sourceBufferPrivateFastSeekTimeForMediaTime(SourceBufferPrivate*, const MediaTime&, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold);
</span><span class="cx"> virtual void sourceBufferPrivateAppendComplete(SourceBufferPrivate*, AppendResult) override;
</span><ins>+ virtual void sourceBufferPrivateDidReceiveRenderingError(SourceBufferPrivate*, int errorCode) override;
</ins><span class="cx">
</span><span class="cx"> // AudioTrackClient
</span><span class="cx"> virtual void audioTrackEnabledChanged(AudioTrack*) override;
</span></span></pre></div>
<a id="tagsSafari5383941SourceWebCoreplatformgraphicsCDMSessionh"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.39.41/Source/WebCore/platform/graphics/CDMSession.h (169837 => 169838)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.39.41/Source/WebCore/platform/graphics/CDMSession.h        2014-06-11 21:29:50 UTC (rev 169837)
+++ tags/Safari-538.39.41/Source/WebCore/platform/graphics/CDMSession.h        2014-06-11 21:32:53 UTC (rev 169838)
</span><span class="lines">@@ -39,6 +39,17 @@
</span><span class="cx"> public:
</span><span class="cx"> virtual ~CDMSessionClient() { };
</span><span class="cx"> virtual void sendMessage(Uint8Array*, String destinationURL) = 0;
</span><ins>+
+ enum {
+ MediaKeyErrorUnknown = 1,
+ MediaKeyErrorClient,
+ MediaKeyErrorService,
+ MediaKeyErrorOutput,
+ MediaKeyErrorHardwareChange,
+ MediaKeyErrorDomain,
+ };
+ typedef unsigned short MediaKeyErrorCode;
+ virtual void sendError(MediaKeyErrorCode, unsigned long systemCode) = 0;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> class CDMSession {
</span></span></pre></div>
<a id="tagsSafari5383941SourceWebCoreplatformgraphicsSourceBufferPrivateClienth"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.39.41/Source/WebCore/platform/graphics/SourceBufferPrivateClient.h (169837 => 169838)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.39.41/Source/WebCore/platform/graphics/SourceBufferPrivateClient.h        2014-06-11 21:29:50 UTC (rev 169837)
+++ tags/Safari-538.39.41/Source/WebCore/platform/graphics/SourceBufferPrivateClient.h        2014-06-11 21:32:53 UTC (rev 169838)
</span><span class="lines">@@ -84,6 +84,7 @@
</span><span class="cx"> ParsingFailed,
</span><span class="cx"> };
</span><span class="cx"> virtual void sourceBufferPrivateAppendComplete(SourceBufferPrivate*, AppendResult) = 0;
</span><ins>+ virtual void sourceBufferPrivateDidReceiveRenderingError(SourceBufferPrivate*, int errocCode) = 0;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="tagsSafari5383941SourceWebCoreplatformgraphicsavfoundationobjcCDMSessionMediaSourceAVFObjCh"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.39.41/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h (169837 => 169838)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.39.41/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h        2014-06-11 21:29:50 UTC (rev 169837)
+++ tags/Safari-538.39.41/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h        2014-06-11 21:32:53 UTC (rev 169838)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #define CDMSessionMediaSourceAVFObjC_h
</span><span class="cx">
</span><span class="cx"> #include "CDMSession.h"
</span><ins>+#include "SourceBufferPrivateAVFObjC.h"
</ins><span class="cx"> #include <wtf/PassOwnPtr.h>
</span><span class="cx"> #include <wtf/RetainPtr.h>
</span><span class="cx">
</span><span class="lines">@@ -34,12 +35,10 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-class SourceBufferPrivateAVFObjC;
-
-class CDMSessionMediaSourceAVFObjC : public CDMSession {
</del><ins>+class CDMSessionMediaSourceAVFObjC : public CDMSession, public SourceBufferPrivateAVFObjCErrorClient {
</ins><span class="cx"> public:
</span><span class="cx"> CDMSessionMediaSourceAVFObjC(SourceBufferPrivateAVFObjC* parent);
</span><del>- virtual ~CDMSessionMediaSourceAVFObjC() { }
</del><ins>+ virtual ~CDMSessionMediaSourceAVFObjC();
</ins><span class="cx">
</span><span class="cx"> virtual void setClient(CDMSessionClient* client) override { m_client = client; }
</span><span class="cx"> virtual const String& sessionId() const override { return m_sessionId; }
</span><span class="lines">@@ -47,8 +46,11 @@
</span><span class="cx"> virtual void releaseKeys() override;
</span><span class="cx"> virtual bool update(Uint8Array*, RefPtr<Uint8Array>& nextMessage, unsigned short& errorCode, unsigned long& systemCode) override;
</span><span class="cx">
</span><ins>+ virtual void layerDidReceiveError(AVSampleBufferDisplayLayer *, NSError *);
+ virtual void rendererDidReceiveError(AVSampleBufferAudioRenderer *, NSError *);
+
</ins><span class="cx"> protected:
</span><del>- SourceBufferPrivateAVFObjC* m_parent;
</del><ins>+ RefPtr<SourceBufferPrivateAVFObjC> m_parent;
</ins><span class="cx"> CDMSessionClient* m_client;
</span><span class="cx"> RefPtr<Uint8Array> m_initData;
</span><span class="cx"> RefPtr<Uint8Array> m_certificate;
</span></span></pre></div>
<a id="tagsSafari5383941SourceWebCoreplatformgraphicsavfoundationobjcCDMSessionMediaSourceAVFObjCmm"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.39.41/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm (169837 => 169838)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.39.41/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm        2014-06-11 21:29:50 UTC (rev 169837)
+++ tags/Safari-538.39.41/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm        2014-06-11 21:32:53 UTC (rev 169838)
</span><span class="lines">@@ -58,8 +58,16 @@
</span><span class="cx"> , m_client(nullptr)
</span><span class="cx"> , m_sessionId(createCanonicalUUIDString())
</span><span class="cx"> {
</span><ins>+ ASSERT(parent);
+ parent->registerForErrorNotifications(this);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+CDMSessionMediaSourceAVFObjC::~CDMSessionMediaSourceAVFObjC()
+{
+ m_parent->unregisterForErrorNotifications(this);
+ m_client = nullptr;
+}
+
</ins><span class="cx"> PassRefPtr<Uint8Array> CDMSessionMediaSourceAVFObjC::generateKeyRequest(const String& mimeType, Uint8Array* initData, String& destinationURL, unsigned short& errorCode, unsigned long& systemCode)
</span><span class="cx"> {
</span><span class="cx"> UNUSED_PARAM(mimeType);
</span><span class="lines">@@ -137,6 +145,22 @@
</span><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void CDMSessionMediaSourceAVFObjC::layerDidReceiveError(AVSampleBufferDisplayLayer *, NSError *error)
+{
+ if (!m_client)
+ return;
+
+ m_client->sendError(CDMSessionClient::MediaKeyErrorDomain, [error code]);
</ins><span class="cx"> }
</span><span class="cx">
</span><ins>+void CDMSessionMediaSourceAVFObjC::rendererDidReceiveError(AVSampleBufferAudioRenderer *, NSError *error)
+{
+ if (!m_client)
+ return;
+
+ m_client->sendError(CDMSessionClient::MediaKeyErrorDomain, [error code]);
+}
+
+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="tagsSafari5383941SourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCh"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.39.41/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h (169837 => 169838)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.39.41/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h        2014-06-11 21:29:50 UTC (rev 169837)
+++ tags/Safari-538.39.41/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h        2014-06-11 21:32:53 UTC (rev 169838)
</span><span class="lines">@@ -47,6 +47,8 @@
</span><span class="cx"> OBJC_CLASS NSError;
</span><span class="cx"> OBJC_CLASS NSObject;
</span><span class="cx"> OBJC_CLASS WebAVStreamDataParserListener;
</span><ins>+OBJC_CLASS WebAVSampleBufferErrorListener;
+
</ins><span class="cx"> typedef struct opaqueCMSampleBuffer *CMSampleBufferRef;
</span><span class="cx"> typedef const struct opaqueCMFormatDescription *CMFormatDescriptionRef;
</span><span class="cx">
</span><span class="lines">@@ -59,6 +61,13 @@
</span><span class="cx"> class AudioTrackPrivateMediaSourceAVFObjC;
</span><span class="cx"> class VideoTrackPrivateMediaSourceAVFObjC;
</span><span class="cx">
</span><ins>+class SourceBufferPrivateAVFObjCErrorClient {
+public:
+ virtual ~SourceBufferPrivateAVFObjCErrorClient() { }
+ virtual void layerDidReceiveError(AVSampleBufferDisplayLayer *, NSError *) = 0;
+ virtual void rendererDidReceiveError(AVSampleBufferAudioRenderer *, NSError *) = 0;
+};
+
</ins><span class="cx"> class SourceBufferPrivateAVFObjC final : public SourceBufferPrivate {
</span><span class="cx"> public:
</span><span class="cx"> static RefPtr<SourceBufferPrivateAVFObjC> create(MediaSourcePrivateAVFObjC*);
</span><span class="lines">@@ -88,6 +97,11 @@
</span><span class="cx"> int protectedTrackID() const { return m_protectedTrackID; }
</span><span class="cx"> AVStreamDataParser* parser() const { return m_parser.get(); }
</span><span class="cx">
</span><ins>+ void registerForErrorNotifications(SourceBufferPrivateAVFObjCErrorClient*);
+ void unregisterForErrorNotifications(SourceBufferPrivateAVFObjCErrorClient*);
+ void layerDidReceiveError(AVSampleBufferDisplayLayer *, NSError *);
+ void rendererDidReceiveError(AVSampleBufferAudioRenderer *, NSError *);
+
</ins><span class="cx"> private:
</span><span class="cx"> explicit SourceBufferPrivateAVFObjC(MediaSourcePrivateAVFObjC*);
</span><span class="cx">
</span><span class="lines">@@ -118,6 +132,7 @@
</span><span class="cx">
</span><span class="cx"> Vector<RefPtr<VideoTrackPrivateMediaSourceAVFObjC>> m_videoTracks;
</span><span class="cx"> Vector<RefPtr<AudioTrackPrivateMediaSourceAVFObjC>> m_audioTracks;
</span><ins>+ Vector<SourceBufferPrivateAVFObjCErrorClient*> m_errorClients;
</ins><span class="cx">
</span><span class="cx"> WeakPtrFactory<SourceBufferPrivateAVFObjC> m_weakFactory;
</span><span class="cx">
</span><span class="lines">@@ -126,6 +141,7 @@
</span><span class="cx"> RetainPtr<AVSampleBufferDisplayLayer> m_displayLayer;
</span><span class="cx"> std::map<int, RetainPtr<AVSampleBufferAudioRenderer>> m_audioRenderers;
</span><span class="cx"> RetainPtr<WebAVStreamDataParserListener> m_delegate;
</span><ins>+ RetainPtr<WebAVSampleBufferErrorListener> m_errorListener;
</ins><span class="cx">
</span><span class="cx"> MediaSourcePrivateAVFObjC* m_mediaSource;
</span><span class="cx"> SourceBufferPrivateClient* m_client;
</span></span></pre></div>
<a id="tagsSafari5383941SourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCmm"></a>
<div class="modfile"><h4>Modified: tags/Safari-538.39.41/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (169837 => 169838)</h4>
<pre class="diff"><span>
<span class="info">--- tags/Safari-538.39.41/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm        2014-06-11 21:29:50 UTC (rev 169837)
+++ tags/Safari-538.39.41/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm        2014-06-11 21:32:53 UTC (rev 169838)
</span><span class="lines">@@ -79,6 +79,8 @@
</span><span class="cx"> SOFT_LINK_CONSTANT(AVFoundation, AVMediaCharacteristicVisual, NSString*)
</span><span class="cx"> SOFT_LINK_CONSTANT(AVFoundation, AVMediaCharacteristicAudible, NSString*)
</span><span class="cx"> SOFT_LINK_CONSTANT(AVFoundation, AVMediaCharacteristicLegible, NSString*)
</span><ins>+SOFT_LINK_CONSTANT(AVFoundation, AVSampleBufferDisplayLayerFailedToDecodeNotification, NSString*)
+SOFT_LINK_CONSTANT(AVFoundation, AVSampleBufferDisplayLayerFailedToDecodeNotificationErrorKey, NSString*)
</ins><span class="cx">
</span><span class="cx"> SOFT_LINK(CoreMedia, CMFormatDescriptionGetMediaType, CMMediaType, (CMFormatDescriptionRef desc), (desc))
</span><span class="cx"> SOFT_LINK(CoreMedia, CMSampleBufferCreate, OSStatus, (CFAllocatorRef allocator, CMBlockBufferRef dataBuffer, Boolean dataReady, CMSampleBufferMakeDataReadyCallback makeDataReadyCallback, void *makeDataReadyRefcon, CMFormatDescriptionRef formatDescription, CMItemCount numSamples, CMItemCount numSampleTimingEntries, const CMSampleTimingInfo *sampleTimingArray, CMItemCount numSampleSizeEntries, const size_t *sampleSizeArray, CMSampleBufferRef *sBufOut), (allocator, dataBuffer, dataReady, makeDataReadyCallback, makeDataReadyRefcon, formatDescription, numSamples, numSampleTimingEntries, sampleTimingArray, numSampleSizeEntries, sampleSizeArray, sBufOut))
</span><span class="lines">@@ -97,6 +99,8 @@
</span><span class="cx"> #define AVMediaTypeVideo getAVMediaTypeVideo()
</span><span class="cx"> #define AVMediaTypeAudio getAVMediaTypeAudio()
</span><span class="cx"> #define AVMediaTypeText getAVMediaTypeText()
</span><ins>+#define AVSampleBufferDisplayLayerFailedToDecodeNotification getAVSampleBufferDisplayLayerFailedToDecodeNotification()
+#define AVSampleBufferDisplayLayerFailedToDecodeNotificationErrorKey getAVSampleBufferDisplayLayerFailedToDecodeNotificationErrorKey()
</ins><span class="cx"> #define kCMTimeZero getkCMTimeZero()
</span><span class="cx"> #define kCMTimeInvalid getkCMTimeInvalid()
</span><span class="cx"> #define kCMSampleAttachmentKey_NotSync getkCMSampleAttachmentKey_NotSync()
</span><span class="lines">@@ -279,6 +283,137 @@
</span><span class="cx"> }
</span><span class="cx"> @end
</span><span class="cx">
</span><ins>+@interface WebAVSampleBufferErrorListener : NSObject
+- (id)initWithParent:(WebCore::SourceBufferPrivateAVFObjC*)parent;
+- (void)invalidate;
+- (void)beginObservingLayer:(AVSampleBufferDisplayLayer *)layer;
+- (void)stopObservingLayer:(AVSampleBufferDisplayLayer *)layer;
+- (void)beginObservingRenderer:(AVSampleBufferAudioRenderer *)renderer;
+- (void)stopObservingRenderer:(AVSampleBufferAudioRenderer *)renderer;
+@end
+
+@implementation WebAVSampleBufferErrorListener {
+ WebCore::SourceBufferPrivateAVFObjC* _parent;
+ Vector<RetainPtr<AVSampleBufferDisplayLayer>> _layers;
+ Vector<RetainPtr<AVSampleBufferAudioRenderer>> _renderers;
+}
+
+- (id)initWithParent:(WebCore::SourceBufferPrivateAVFObjC*)parent
+{
+ if (!(self = [super init]))
+ return nil;
+
+ _parent = parent;
+ return self;
+}
+
+- (void)dealloc
+{
+ [self invalidate];
+ [super dealloc];
+}
+
+- (void)invalidate
+{
+ if (!_parent && !_layers.size() && !_renderers.size())
+ return;
+
+ for (auto& layer : _layers)
+ [layer removeObserver:self forKeyPath:@"error"];
+ _layers.clear();
+
+ for (auto& renderer : _renderers)
+ [renderer removeObserver:self forKeyPath:@"error"];
+ _renderers.clear();
+
+ [[NSNotificationCenter defaultCenter] removeObserver:self];
+
+ _parent = nullptr;
+}
+
+- (void)beginObservingLayer:(AVSampleBufferDisplayLayer*)layer
+{
+ ASSERT(_parent);
+ ASSERT(!_layers.contains(layer));
+
+ _layers.append(layer);
+ [layer addObserver:self forKeyPath:@"error" options:NSKeyValueObservingOptionNew context:nullptr];
+ [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(layerFailedToDecode:) name:AVSampleBufferDisplayLayerFailedToDecodeNotification object:layer];
+}
+
+- (void)stopObservingLayer:(AVSampleBufferDisplayLayer*)layer
+{
+ ASSERT(_parent);
+ ASSERT(_layers.contains(layer));
+
+ [layer removeObserver:self forKeyPath:@"error"];
+ _layers.remove(_layers.find(layer));
+
+ [[NSNotificationCenter defaultCenter] removeObserver:self name:AVSampleBufferDisplayLayerFailedToDecodeNotification object:layer];
+}
+
+- (void)beginObservingRenderer:(AVSampleBufferAudioRenderer*)renderer
+{
+ ASSERT(_parent);
+ ASSERT(!_renderers.contains(renderer));
+
+ _renderers.append(renderer);
+ [renderer addObserver:self forKeyPath:@"error" options:NSKeyValueObservingOptionNew context:nullptr];
+}
+
+- (void)stopObservingRenderer:(AVSampleBufferAudioRenderer*)renderer
+{
+ ASSERT(_parent);
+ ASSERT(_renderers.contains(renderer));
+
+ [renderer removeObserver:self forKeyPath:@"error"];
+ _renderers.remove(_renderers.find(renderer));
+}
+
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
+{
+ UNUSED_PARAM(context);
+ ASSERT(_parent);
+
+ RetainPtr<WebAVSampleBufferErrorListener> strongSelf = self;
+ if ([object isKindOfClass:getAVSampleBufferDisplayLayerClass()]) {
+ RetainPtr<AVSampleBufferDisplayLayer> layer = (AVSampleBufferDisplayLayer *)object;
+ RetainPtr<NSError> error = [change valueForKey:NSKeyValueChangeNewKey];
+
+ ASSERT(_layers.contains(layer.get()));
+ ASSERT([keyPath isEqualTo:@"error"]);
+
+ callOnMainThread([strongSelf, layer, error] {
+ strongSelf->_parent->layerDidReceiveError(layer.get(), error.get());
+ });
+ } else if ([object isKindOfClass:getAVSampleBufferAudioRendererClass()]) {
+ RetainPtr<AVSampleBufferAudioRenderer> renderer = (AVSampleBufferAudioRenderer *)object;
+ RetainPtr<NSError> error = [change valueForKey:NSKeyValueChangeNewKey];
+
+ ASSERT(_renderers.contains(renderer.get()));
+ ASSERT([keyPath isEqualTo:@"error"]);
+
+ callOnMainThread([strongSelf, renderer, error] {
+ strongSelf->_parent->rendererDidReceiveError(renderer.get(), error.get());
+ });
+ } else
+ ASSERT_NOT_REACHED();
+}
+
+- (void)layerFailedToDecode:(NSNotification*)note
+{
+ RetainPtr<AVSampleBufferDisplayLayer> layer = (AVSampleBufferDisplayLayer *)[note object];
+ ASSERT(_layers.contains(layer.get()));
+
+ RetainPtr<NSError> error = [[note userInfo] valueForKey:AVSampleBufferDisplayLayerFailedToDecodeNotificationErrorKey];
+
+ RetainPtr<WebAVSampleBufferErrorListener> strongSelf = self;
+ callOnMainThread([strongSelf, layer, error] {
+ strongSelf->_parent->layerDidReceiveError(layer.get(), error.get());
+ });
+}
+@end
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><span class="cx"> #pragma mark -
</span><span class="lines">@@ -400,6 +535,7 @@
</span><span class="cx"> : m_weakFactory(this)
</span><span class="cx"> , m_parser(adoptNS([[getAVStreamDataParserClass() alloc] init]))
</span><span class="cx"> , m_delegate(adoptNS([[WebAVStreamDataParserListener alloc] initWithParser:m_parser.get() parent:createWeakPtr()]))
</span><ins>+ , m_errorListener(adoptNS([[WebAVSampleBufferErrorListener alloc] initWithParent:this]))
</ins><span class="cx"> , m_mediaSource(parent)
</span><span class="cx"> , m_client(0)
</span><span class="cx"> , m_parsingSucceeded(true)
</span><span class="lines">@@ -659,6 +795,7 @@
</span><span class="cx"> [m_displayLayer requestMediaDataWhenReadyOnQueue:dispatch_get_main_queue() usingBlock:^{
</span><span class="cx"> didBecomeReadyForMoreSamples(trackID);
</span><span class="cx"> }];
</span><ins>+ [m_errorListener beginObservingLayer:m_displayLayer.get()];
</ins><span class="cx"> }
</span><span class="cx"> if (m_mediaSource)
</span><span class="cx"> m_mediaSource->player()->addDisplayLayer(m_displayLayer.get());
</span><span class="lines">@@ -683,6 +820,7 @@
</span><span class="cx"> didBecomeReadyForMoreSamples(trackID);
</span><span class="cx"> }];
</span><span class="cx"> m_audioRenderers[trackID] = renderer;
</span><ins>+ [m_errorListener beginObservingRenderer:renderer.get()];
</ins><span class="cx"> } else
</span><span class="cx"> renderer = m_audioRenderers[trackID].get();
</span><span class="cx">
</span><span class="lines">@@ -691,6 +829,37 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void SourceBufferPrivateAVFObjC::registerForErrorNotifications(SourceBufferPrivateAVFObjCErrorClient* client)
+{
+ ASSERT(!m_errorClients.contains(client));
+ m_errorClients.append(client);
+}
+
+void SourceBufferPrivateAVFObjC::unregisterForErrorNotifications(SourceBufferPrivateAVFObjCErrorClient* client)
+{
+ ASSERT(m_errorClients.contains(client));
+ m_errorClients.remove(m_errorClients.find(client));
+}
+
+void SourceBufferPrivateAVFObjC::layerDidReceiveError(AVSampleBufferDisplayLayer *layer, NSError *error)
+{
+ LOG(Media, "SourceBufferPrivateAVFObjC::layerDidReceiveError(%p): layer(%p), error(%@)", this, layer, [error description]);
+ for (auto& client : m_errorClients)
+ client->layerDidReceiveError(layer, error);
+
+ int errorCode = [[[error userInfo] valueForKey:@"OSStatus"] intValue];
+
+ if (m_client)
+ m_client->sourceBufferPrivateDidReceiveRenderingError(this, errorCode);
+}
+
+void SourceBufferPrivateAVFObjC::rendererDidReceiveError(AVSampleBufferAudioRenderer *renderer, NSError *error)
+{
+ LOG(Media, "SourceBufferPrivateAVFObjC::rendererDidReceiveError(%p): renderer(%p), error(%@)", this, renderer, [error description]);
+ for (auto& client : m_errorClients)
+ client->rendererDidReceiveError(renderer, error);
+}
+
</ins><span class="cx"> static RetainPtr<CMSampleBufferRef> createNonDisplayingCopy(CMSampleBufferRef sampleBuffer)
</span><span class="cx"> {
</span><span class="cx"> CMSampleBufferRef newSampleBuffer = 0;
</span></span></pre>
</div>
</div>
</body>
</html>