<!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>[169830] trunk/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/169830">169830</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2014-06-11 14:02:26 -0700 (Wed, 11 Jun 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>[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.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModulesencryptedmediaMediaKeySessioncpp">trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesencryptedmediaMediaKeySessionh">trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h</a></li>
<li><a href="#trunkSourceWebCoreModulesmediasourceSourceBuffercpp">trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp</a></li>
<li><a href="#trunkSourceWebCoreModulesmediasourceSourceBufferh">trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsCDMSessionh">trunk/Source/WebCore/platform/graphics/CDMSession.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsSourceBufferPrivateClienth">trunk/Source/WebCore/platform/graphics/SourceBufferPrivateClient.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcCDMSessionMediaSourceAVFObjCh">trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcCDMSessionMediaSourceAVFObjCmm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCh">trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCmm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (169829 => 169830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2014-06-11 20:49:42 UTC (rev 169829)
+++ trunk/Source/WebCore/ChangeLog        2014-06-11 21:02:26 UTC (rev 169830)
</span><span class="lines">@@ -1,3 +1,53 @@
</span><ins>+2014-06-11  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        [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-11  Andreas Kling  &lt;akling@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Don't force CharacterData to override getOwnPropertySlot.
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesencryptedmediaMediaKeySessioncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp (169829 => 169830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp        2014-06-11 20:49:42 UTC (rev 169829)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.cpp        2014-06-11 21:02:26 UTC (rev 169830)
</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&lt;MediaKeyError&gt; 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&lt;Event&gt; event = Event::create(eventNames().webkitkeyerrorEvent, false, false);
-            event-&gt;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&lt;MediaKeyMessageEvent&gt; event = MediaKeyMessageEvent::create(eventNames().webkitkeymessageEvent, init);
-        event-&gt;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&lt;MediaKeyMessageEvent&gt; event = MediaKeyMessageEvent::create(eventNames().webkitkeymessageEvent, init);
-            event-&gt;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&lt;MediaKeyError&gt; 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&lt;Event&gt; keyerrorEvent = Event::create(eventNames().webkitkeyerrorEvent, false, false);
-            keyerrorEvent-&gt;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&lt;MediaKeyMessageEvent&gt; event = MediaKeyMessageEvent::create(eventNames().webkitkeymessageEvent, init);
+    event-&gt;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&lt;MediaKeyError&gt; error = MediaKeyError::create(errorCode, systemCode).get();
+    setError(error.get());
+
+    RefPtr&lt;Event&gt; keyerrorEvent = Event::create(eventNames().webkitkeyerrorEvent, false, false);
+    keyerrorEvent-&gt;setTarget(this);
+    m_asyncEventQueue.enqueueEvent(keyerrorEvent.release());
+}
+
+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesencryptedmediaMediaKeySessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h (169829 => 169830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h        2014-06-11 20:49:42 UTC (rev 169829)
+++ trunk/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h        2014-06-11 21:02:26 UTC (rev 169830)
</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 &quot;ActiveDOMObject.h&quot;
</span><ins>+#include &quot;CDMSession.h&quot;
</ins><span class="cx"> #include &quot;EventTarget.h&quot;
</span><span class="cx"> #include &quot;ExceptionCode.h&quot;
</span><span class="cx"> #include &quot;GenericEventQueue.h&quot;
</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&lt;MediaKeySession&gt;, public EventTargetWithInlineData, public ActiveDOMObject {
</del><ins>+class MediaKeySession final : public RefCounted&lt;MediaKeySession&gt;, public EventTargetWithInlineData, public ActiveDOMObject, public CDMSessionClient {
</ins><span class="cx"> public:
</span><span class="cx">     static PassRefPtr&lt;MediaKeySession&gt; create(ScriptExecutionContext*, MediaKeys*, const String&amp; keySystem);
</span><span class="cx">     ~MediaKeySession();
</span><span class="lines">@@ -85,6 +85,10 @@
</span><span class="cx">     void keyRequestTimerFired(Timer&lt;MediaKeySession&gt;&amp;);
</span><span class="cx">     void addKeyTimerFired(Timer&lt;MediaKeySession&gt;&amp;);
</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="trunkSourceWebCoreModulesmediasourceSourceBuffercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp (169829 => 169830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp        2014-06-11 20:49:42 UTC (rev 169829)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp        2014-06-11 21:02:26 UTC (rev 169830)
</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-&gt;streamEndedWithError(decodeError(), IgnorableExceptionCode());
+}
+
</ins><span class="cx"> void SourceBuffer::removeCodedFrames(const MediaTime&amp; start, const MediaTime&amp; end)
</span><span class="cx"> {
</span><span class="cx">     // 3.5.9 Coded Frame Removal Algorithm
</span></span></pre></div>
<a id="trunkSourceWebCoreModulesmediasourceSourceBufferh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h (169829 => 169830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h        2014-06-11 20:49:42 UTC (rev 169829)
+++ trunk/Source/WebCore/Modules/mediasource/SourceBuffer.h        2014-06-11 21:02:26 UTC (rev 169830)
</span><span class="lines">@@ -119,6 +119,7 @@
</span><span class="cx">     virtual void sourceBufferPrivateSeekToTime(SourceBufferPrivate*, const MediaTime&amp;);
</span><span class="cx">     virtual MediaTime sourceBufferPrivateFastSeekTimeForMediaTime(SourceBufferPrivate*, const MediaTime&amp;, const MediaTime&amp; negativeThreshold, const MediaTime&amp; 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="trunkSourceWebCoreplatformgraphicsCDMSessionh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/CDMSession.h (169829 => 169830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/CDMSession.h        2014-06-11 20:49:42 UTC (rev 169829)
+++ trunk/Source/WebCore/platform/graphics/CDMSession.h        2014-06-11 21:02:26 UTC (rev 169830)
</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="trunkSourceWebCoreplatformgraphicsSourceBufferPrivateClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/SourceBufferPrivateClient.h (169829 => 169830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/SourceBufferPrivateClient.h        2014-06-11 20:49:42 UTC (rev 169829)
+++ trunk/Source/WebCore/platform/graphics/SourceBufferPrivateClient.h        2014-06-11 21:02:26 UTC (rev 169830)
</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="trunkSourceWebCoreplatformgraphicsavfoundationobjcCDMSessionMediaSourceAVFObjCh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h (169829 => 169830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h        2014-06-11 20:49:42 UTC (rev 169829)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.h        2014-06-11 21:02:26 UTC (rev 169830)
</span><span class="lines">@@ -27,6 +27,7 @@
</span><span class="cx"> #define CDMSessionMediaSourceAVFObjC_h
</span><span class="cx"> 
</span><span class="cx"> #include &quot;CDMSession.h&quot;
</span><ins>+#include &quot;SourceBufferPrivateAVFObjC.h&quot;
</ins><span class="cx"> #include &lt;wtf/PassOwnPtr.h&gt;
</span><span class="cx"> #include &lt;wtf/RetainPtr.h&gt;
</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&amp; 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&lt;Uint8Array&gt;&amp; nextMessage, unsigned short&amp; errorCode, unsigned long&amp; 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&lt;SourceBufferPrivateAVFObjC&gt; m_parent;
</ins><span class="cx">     CDMSessionClient* m_client;
</span><span class="cx">     RefPtr&lt;Uint8Array&gt; m_initData;
</span><span class="cx">     RefPtr&lt;Uint8Array&gt; m_certificate;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcCDMSessionMediaSourceAVFObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm (169829 => 169830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm        2014-06-11 20:49:42 UTC (rev 169829)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/CDMSessionMediaSourceAVFObjC.mm        2014-06-11 21:02:26 UTC (rev 169830)
</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-&gt;registerForErrorNotifications(this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><ins>+CDMSessionMediaSourceAVFObjC::~CDMSessionMediaSourceAVFObjC()
+{
+    m_parent-&gt;unregisterForErrorNotifications(this);
+    m_client = nullptr;
+}
+
</ins><span class="cx"> PassRefPtr&lt;Uint8Array&gt; CDMSessionMediaSourceAVFObjC::generateKeyRequest(const String&amp; mimeType, Uint8Array* initData, String&amp; destinationURL, unsigned short&amp; errorCode, unsigned long&amp; 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-&gt;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-&gt;sendError(CDMSessionClient::MediaKeyErrorDomain, [error code]);
+}
+
+}
+
</ins><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h (169829 => 169830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h        2014-06-11 20:49:42 UTC (rev 169829)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h        2014-06-11 21:02:26 UTC (rev 169830)
</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&lt;SourceBufferPrivateAVFObjC&gt; 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&lt;RefPtr&lt;VideoTrackPrivateMediaSourceAVFObjC&gt;&gt; m_videoTracks;
</span><span class="cx">     Vector&lt;RefPtr&lt;AudioTrackPrivateMediaSourceAVFObjC&gt;&gt; m_audioTracks;
</span><ins>+    Vector&lt;SourceBufferPrivateAVFObjCErrorClient*&gt; m_errorClients;
</ins><span class="cx"> 
</span><span class="cx">     WeakPtrFactory&lt;SourceBufferPrivateAVFObjC&gt; m_weakFactory;
</span><span class="cx"> 
</span><span class="lines">@@ -126,6 +141,7 @@
</span><span class="cx">     RetainPtr&lt;AVSampleBufferDisplayLayer&gt; m_displayLayer;
</span><span class="cx">     std::map&lt;int, RetainPtr&lt;AVSampleBufferAudioRenderer&gt;&gt; m_audioRenderers;
</span><span class="cx">     RetainPtr&lt;WebAVStreamDataParserListener&gt; m_delegate;
</span><ins>+    RetainPtr&lt;WebAVSampleBufferErrorListener&gt; 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="trunkSourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (169829 => 169830)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm        2014-06-11 20:49:42 UTC (rev 169829)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm        2014-06-11 21:02:26 UTC (rev 169830)
</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&lt;RetainPtr&lt;AVSampleBufferDisplayLayer&gt;&gt; _layers;
+    Vector&lt;RetainPtr&lt;AVSampleBufferAudioRenderer&gt;&gt; _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 &amp;&amp; !_layers.size() &amp;&amp; !_renderers.size())
+        return;
+
+    for (auto&amp; layer : _layers)
+        [layer removeObserver:self forKeyPath:@&quot;error&quot;];
+    _layers.clear();
+
+    for (auto&amp; renderer : _renderers)
+        [renderer removeObserver:self forKeyPath:@&quot;error&quot;];
+    _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:@&quot;error&quot; 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:@&quot;error&quot;];
+    _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:@&quot;error&quot; options:NSKeyValueObservingOptionNew context:nullptr];
+}
+
+- (void)stopObservingRenderer:(AVSampleBufferAudioRenderer*)renderer
+{
+    ASSERT(_parent);
+    ASSERT(_renderers.contains(renderer));
+
+    [renderer removeObserver:self forKeyPath:@&quot;error&quot;];
+    _renderers.remove(_renderers.find(renderer));
+}
+
+- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
+{
+    UNUSED_PARAM(context);
+    ASSERT(_parent);
+
+    RetainPtr&lt;WebAVSampleBufferErrorListener&gt; strongSelf = self;
+    if ([object isKindOfClass:getAVSampleBufferDisplayLayerClass()]) {
+        RetainPtr&lt;AVSampleBufferDisplayLayer&gt; layer = (AVSampleBufferDisplayLayer *)object;
+        RetainPtr&lt;NSError&gt; error = [change valueForKey:NSKeyValueChangeNewKey];
+
+        ASSERT(_layers.contains(layer.get()));
+        ASSERT([keyPath isEqualTo:@&quot;error&quot;]);
+
+        callOnMainThread([strongSelf, layer, error] {
+            strongSelf-&gt;_parent-&gt;layerDidReceiveError(layer.get(), error.get());
+        });
+    } else if ([object isKindOfClass:getAVSampleBufferAudioRendererClass()]) {
+        RetainPtr&lt;AVSampleBufferAudioRenderer&gt; renderer = (AVSampleBufferAudioRenderer *)object;
+        RetainPtr&lt;NSError&gt; error = [change valueForKey:NSKeyValueChangeNewKey];
+
+        ASSERT(_renderers.contains(renderer.get()));
+        ASSERT([keyPath isEqualTo:@&quot;error&quot;]);
+
+        callOnMainThread([strongSelf, renderer, error] {
+            strongSelf-&gt;_parent-&gt;rendererDidReceiveError(renderer.get(), error.get());
+        });
+    } else
+        ASSERT_NOT_REACHED();
+}
+
+- (void)layerFailedToDecode:(NSNotification*)note
+{
+    RetainPtr&lt;AVSampleBufferDisplayLayer&gt; layer = (AVSampleBufferDisplayLayer *)[note object];
+    ASSERT(_layers.contains(layer.get()));
+
+    RetainPtr&lt;NSError&gt; error = [[note userInfo] valueForKey:AVSampleBufferDisplayLayerFailedToDecodeNotificationErrorKey];
+
+    RetainPtr&lt;WebAVSampleBufferErrorListener&gt; strongSelf = self;
+    callOnMainThread([strongSelf, layer, error] {
+        strongSelf-&gt;_parent-&gt;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-&gt;player()-&gt;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, &quot;SourceBufferPrivateAVFObjC::layerDidReceiveError(%p): layer(%p), error(%@)&quot;, this, layer, [error description]);
+    for (auto&amp; client : m_errorClients)
+        client-&gt;layerDidReceiveError(layer, error);
+
+    int errorCode = [[[error userInfo] valueForKey:@&quot;OSStatus&quot;] intValue];
+
+    if (m_client)
+        m_client-&gt;sourceBufferPrivateDidReceiveRenderingError(this, errorCode);
+}
+
+void SourceBufferPrivateAVFObjC::rendererDidReceiveError(AVSampleBufferAudioRenderer *renderer, NSError *error)
+{
+    LOG(Media, &quot;SourceBufferPrivateAVFObjC::rendererDidReceiveError(%p): renderer(%p), error(%@)&quot;, this, renderer, [error description]);
+    for (auto&amp; client : m_errorClients)
+        client-&gt;rendererDidReceiveError(renderer, error);
+}
+
</ins><span class="cx"> static RetainPtr&lt;CMSampleBufferRef&gt; createNonDisplayingCopy(CMSampleBufferRef sampleBuffer)
</span><span class="cx"> {
</span><span class="cx">     CMSampleBufferRef newSampleBuffer = 0;
</span></span></pre>
</div>
</div>

</body>
</html>