<!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>[192174] 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/192174">192174</a></dd>
<dt>Author</dt> <dd>eric.carlson@apple.com</dd>
<dt>Date</dt> <dd>2015-11-09 13:20:08 -0800 (Mon, 09 Nov 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>[MediaStream] Add mock audio and video sources
https://bugs.webkit.org/show_bug.cgi?id=150997
<rdar://problem/23453358>
Reviewed by Jer Noble.
Create basic mock audio and video realtime media source classes so we can test MediaStream
API without requiring test machines to have audio/video input hardware. No new tests added
yet, thoe will follow.
No new tests, these changes will allow us to write MediaStream tests.
* CMakeLists.txt: Add MockRealtimeAudioSource.cpp, MockRealtimeMediaSource.cpp, and
MockRealtimeVideoSource.cpp
* PlatformMac.cmake: Add MockRealtimeVideoSourceMac.mm
* WebCore.xcodeproj/project.pbxproj: Add new files.
* platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
(WebCore::MediaPlayerPrivateMediaStreamAVFObjC::createPreviewLayers): Don't set autoresizingMask,
it isn't necessary.
* platform/mediastream/mac/AVCaptureDeviceManager.mm:
(WebCore::refreshCaptureDeviceList): AVCaptureDevice -> getAVCaptureDeviceClass()
(WebCore::AVCaptureDeviceManager::bestDeviceForFacingMode): Ditto.
(WebCore::AVCaptureDeviceManager::sourceWithUID): Ditto.
Mac class implements RealtimeVideoSource::platformLayer, returns a CALayer which uses the
GraphicsContext as contents.
* platform/mediastream/mac/MockRealtimeVideoSourceMac.h: Added.
* platform/mediastream/mac/MockRealtimeVideoSourceMac.mm: Added.
(WebCore::MockRealtimeVideoSource::create):
(WebCore::MockRealtimeVideoSourceMac::MockRealtimeVideoSourceMac):
(WebCore::MockRealtimeVideoSourceMac::platformLayer):
(WebCore::MockRealtimeVideoSourceMac::updatePlatformLayer):
Mock audio source. Doesn't provide data yet, only provides states and capabilities.
* platform/mock/MockRealtimeAudioSource.cpp: Added.
(WebCore::MockRealtimeAudioSource::create):
(WebCore::MockRealtimeAudioSource::MockRealtimeAudioSource):
(WebCore::MockRealtimeAudioSource::updateStates):
(WebCore::MockRealtimeAudioSource::initializeCapabilities):
* platform/mock/MockRealtimeAudioSource.h: Added.
(WebCore::MockRealtimeAudioSource::~MockRealtimeAudioSource):
Mock source base class, sets persistent ID and updates states and capabilities.
* platform/mock/MockRealtimeMediaSource.cpp: Added.
(WebCore::MockRealtimeMediaSource::mockAudioPersistentID):
(WebCore::MockRealtimeMediaSource::mockVideoPersistentID):
(WebCore::MockRealtimeMediaSource::MockRealtimeMediaSource):
(WebCore::MockRealtimeMediaSource::capabilities):
(WebCore::MockRealtimeMediaSource::states):
* platform/mock/MockRealtimeMediaSource.h: Added.
(WebCore::MockRealtimeMediaSource::mockAudioSourcePersistentID):
(WebCore::MockRealtimeMediaSource::mockAudioSourceName):
(WebCore::MockRealtimeMediaSource::mockVideoSourcePersistentID):
(WebCore::MockRealtimeMediaSource::mockVideoSourceName):
(WebCore::MockRealtimeMediaSource::trackSourceWithUID):
(WebCore::MockRealtimeMediaSource::~MockRealtimeMediaSource):
(WebCore::MockRealtimeMediaSource::currentStates):
(WebCore::MockRealtimeMediaSource::constraints):
Use new mock source classes. Create a new source instance for each request instead of reusing the
same sources each time.
* platform/mock/MockRealtimeMediaSourceCenter.cpp:
(WebCore::mockSourceMap):
(WebCore::MockRealtimeMediaSourceCenter::registerMockRealtimeMediaSourceCenter):
(WebCore::MockRealtimeMediaSourceCenter::validateRequestConstraints):
(WebCore::MockRealtimeMediaSourceCenter::createMediaStream):
(WebCore::MockRealtimeMediaSourceCenter::getMediaStreamTrackSources):
(WebCore::MockSource::MockSource): Deleted.
(WebCore::MockSource::~MockSource): Deleted.
(WebCore::MockSource::capabilities): Deleted.
(WebCore::MockSource::states): Deleted.
(WebCore::mockAudioSourceID): Deleted.
(WebCore::mockVideoSourceID): Deleted.
(WebCore::initializeMockSources): Deleted.
Mock video source. Generate bip-bop inspired frames with burned in state information.
* platform/mock/MockRealtimeVideoSource.cpp: Added.
(WebCore::MockRealtimeVideoSource::create):
(WebCore::MockRealtimeVideoSource::MockRealtimeVideoSource):
(WebCore::MockRealtimeVideoSource::startProducingData):
(WebCore::MockRealtimeVideoSource::stopProducingData):
(WebCore::MockRealtimeVideoSource::elapsedTime):
(WebCore::MockRealtimeVideoSource::updateStates):
(WebCore::MockRealtimeVideoSource::initializeCapabilities):
(WebCore::MockRealtimeVideoSource::setFacingMode):
(WebCore::MockRealtimeVideoSource::setFrameRate):
(WebCore::MockRealtimeVideoSource::setSize):
(WebCore::MockRealtimeVideoSource::drawAnimation):
(WebCore::MockRealtimeVideoSource::drawBoxes):
(WebCore::MockRealtimeVideoSource::drawText):
(WebCore::MockRealtimeVideoSource::generateFrame):
(WebCore::MockRealtimeVideoSource::imageBuffer):
(WebCore::MockRealtimeVideoSource::paintCurrentFrameInContext):
(WebCore::MockRealtimeVideoSource::currentFrameImage):
* platform/mock/MockRealtimeVideoSource.h: Added.
(WebCore::MockRealtimeVideoSource::~MockRealtimeVideoSource):
(WebCore::MockRealtimeVideoSource::size):
(WebCore::MockRealtimeVideoSource::updatePlatformLayer):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreCMakeListstxt">trunk/Source/WebCore/CMakeLists.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformMaccmake">trunk/Source/WebCore/PlatformMac.cmake</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateMediaStreamAVFObjCmm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacAVCaptureDeviceManagermm">trunk/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmockMockRealtimeMediaSourceCentercpp">trunk/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformmediastreammacMockRealtimeVideoSourceMach">trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmediastreammacMockRealtimeVideoSourceMacmm">trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmockMockRealtimeAudioSourcecpp">trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmockMockRealtimeAudioSourceh">trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmockMockRealtimeMediaSourcecpp">trunk/Source/WebCore/platform/mock/MockRealtimeMediaSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmockMockRealtimeMediaSourceh">trunk/Source/WebCore/platform/mock/MockRealtimeMediaSource.h</a></li>
<li><a href="#trunkSourceWebCoreplatformmockMockRealtimeVideoSourcecpp">trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmockMockRealtimeVideoSourceh">trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreCMakeListstxt"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/CMakeLists.txt (192173 => 192174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/CMakeLists.txt        2015-11-09 21:16:14 UTC (rev 192173)
+++ trunk/Source/WebCore/CMakeLists.txt        2015-11-09 21:20:08 UTC (rev 192174)
</span><span class="lines">@@ -2302,7 +2302,10 @@
</span><span class="cx"> platform/mock/DeviceOrientationClientMock.cpp
</span><span class="cx"> platform/mock/GeolocationClientMock.cpp
</span><span class="cx"> platform/mock/MediaConstraintsMock.cpp
</span><ins>+ platform/mock/MockRealtimeAudioSource.cpp
+ platform/mock/MockRealtimeMediaSource.cpp
</ins><span class="cx"> platform/mock/MockRealtimeMediaSourceCenter.cpp
</span><ins>+ platform/mock/MockRealtimeVideoSource.cpp
</ins><span class="cx"> platform/mock/RTCDTMFSenderHandlerMock.cpp
</span><span class="cx"> platform/mock/RTCDataChannelHandlerMock.cpp
</span><span class="cx"> platform/mock/RTCNotifiersMock.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (192173 => 192174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-11-09 21:16:14 UTC (rev 192173)
+++ trunk/Source/WebCore/ChangeLog        2015-11-09 21:20:08 UTC (rev 192174)
</span><span class="lines">@@ -1,3 +1,108 @@
</span><ins>+2015-11-09 Eric Carlson <eric.carlson@apple.com>
+
+ [MediaStream] Add mock audio and video sources
+ https://bugs.webkit.org/show_bug.cgi?id=150997
+ <rdar://problem/23453358>
+
+ Reviewed by Jer Noble.
+
+ Create basic mock audio and video realtime media source classes so we can test MediaStream
+ API without requiring test machines to have audio/video input hardware. No new tests added
+ yet, thoe will follow.
+
+ No new tests, these changes will allow us to write MediaStream tests.
+
+ * CMakeLists.txt: Add MockRealtimeAudioSource.cpp, MockRealtimeMediaSource.cpp, and
+ MockRealtimeVideoSource.cpp
+
+ * PlatformMac.cmake: Add MockRealtimeVideoSourceMac.mm
+
+ * WebCore.xcodeproj/project.pbxproj: Add new files.
+
+ * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm:
+ (WebCore::MediaPlayerPrivateMediaStreamAVFObjC::createPreviewLayers): Don't set autoresizingMask,
+ it isn't necessary.
+
+ * platform/mediastream/mac/AVCaptureDeviceManager.mm:
+ (WebCore::refreshCaptureDeviceList): AVCaptureDevice -> getAVCaptureDeviceClass()
+ (WebCore::AVCaptureDeviceManager::bestDeviceForFacingMode): Ditto.
+ (WebCore::AVCaptureDeviceManager::sourceWithUID): Ditto.
+
+ Mac class implements RealtimeVideoSource::platformLayer, returns a CALayer which uses the
+ GraphicsContext as contents.
+ * platform/mediastream/mac/MockRealtimeVideoSourceMac.h: Added.
+ * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm: Added.
+ (WebCore::MockRealtimeVideoSource::create):
+ (WebCore::MockRealtimeVideoSourceMac::MockRealtimeVideoSourceMac):
+ (WebCore::MockRealtimeVideoSourceMac::platformLayer):
+ (WebCore::MockRealtimeVideoSourceMac::updatePlatformLayer):
+
+ Mock audio source. Doesn't provide data yet, only provides states and capabilities.
+ * platform/mock/MockRealtimeAudioSource.cpp: Added.
+ (WebCore::MockRealtimeAudioSource::create):
+ (WebCore::MockRealtimeAudioSource::MockRealtimeAudioSource):
+ (WebCore::MockRealtimeAudioSource::updateStates):
+ (WebCore::MockRealtimeAudioSource::initializeCapabilities):
+ * platform/mock/MockRealtimeAudioSource.h: Added.
+ (WebCore::MockRealtimeAudioSource::~MockRealtimeAudioSource):
+
+ Mock source base class, sets persistent ID and updates states and capabilities.
+ * platform/mock/MockRealtimeMediaSource.cpp: Added.
+ (WebCore::MockRealtimeMediaSource::mockAudioPersistentID):
+ (WebCore::MockRealtimeMediaSource::mockVideoPersistentID):
+ (WebCore::MockRealtimeMediaSource::MockRealtimeMediaSource):
+ (WebCore::MockRealtimeMediaSource::capabilities):
+ (WebCore::MockRealtimeMediaSource::states):
+ * platform/mock/MockRealtimeMediaSource.h: Added.
+ (WebCore::MockRealtimeMediaSource::mockAudioSourcePersistentID):
+ (WebCore::MockRealtimeMediaSource::mockAudioSourceName):
+ (WebCore::MockRealtimeMediaSource::mockVideoSourcePersistentID):
+ (WebCore::MockRealtimeMediaSource::mockVideoSourceName):
+ (WebCore::MockRealtimeMediaSource::trackSourceWithUID):
+ (WebCore::MockRealtimeMediaSource::~MockRealtimeMediaSource):
+ (WebCore::MockRealtimeMediaSource::currentStates):
+ (WebCore::MockRealtimeMediaSource::constraints):
+
+ Use new mock source classes. Create a new source instance for each request instead of reusing the
+ same sources each time.
+ * platform/mock/MockRealtimeMediaSourceCenter.cpp:
+ (WebCore::mockSourceMap):
+ (WebCore::MockRealtimeMediaSourceCenter::registerMockRealtimeMediaSourceCenter):
+ (WebCore::MockRealtimeMediaSourceCenter::validateRequestConstraints):
+ (WebCore::MockRealtimeMediaSourceCenter::createMediaStream):
+ (WebCore::MockRealtimeMediaSourceCenter::getMediaStreamTrackSources):
+ (WebCore::MockSource::MockSource): Deleted.
+ (WebCore::MockSource::~MockSource): Deleted.
+ (WebCore::MockSource::capabilities): Deleted.
+ (WebCore::MockSource::states): Deleted.
+ (WebCore::mockAudioSourceID): Deleted.
+ (WebCore::mockVideoSourceID): Deleted.
+ (WebCore::initializeMockSources): Deleted.
+
+ Mock video source. Generate bip-bop inspired frames with burned in state information.
+ * platform/mock/MockRealtimeVideoSource.cpp: Added.
+ (WebCore::MockRealtimeVideoSource::create):
+ (WebCore::MockRealtimeVideoSource::MockRealtimeVideoSource):
+ (WebCore::MockRealtimeVideoSource::startProducingData):
+ (WebCore::MockRealtimeVideoSource::stopProducingData):
+ (WebCore::MockRealtimeVideoSource::elapsedTime):
+ (WebCore::MockRealtimeVideoSource::updateStates):
+ (WebCore::MockRealtimeVideoSource::initializeCapabilities):
+ (WebCore::MockRealtimeVideoSource::setFacingMode):
+ (WebCore::MockRealtimeVideoSource::setFrameRate):
+ (WebCore::MockRealtimeVideoSource::setSize):
+ (WebCore::MockRealtimeVideoSource::drawAnimation):
+ (WebCore::MockRealtimeVideoSource::drawBoxes):
+ (WebCore::MockRealtimeVideoSource::drawText):
+ (WebCore::MockRealtimeVideoSource::generateFrame):
+ (WebCore::MockRealtimeVideoSource::imageBuffer):
+ (WebCore::MockRealtimeVideoSource::paintCurrentFrameInContext):
+ (WebCore::MockRealtimeVideoSource::currentFrameImage):
+ * platform/mock/MockRealtimeVideoSource.h: Added.
+ (WebCore::MockRealtimeVideoSource::~MockRealtimeVideoSource):
+ (WebCore::MockRealtimeVideoSource::size):
+ (WebCore::MockRealtimeVideoSource::updatePlatformLayer):
+
</ins><span class="cx"> 2015-11-09 Nan Wang <n_wang@apple.com>
</span><span class="cx">
</span><span class="cx"> AX: Input type: time is not accessible on iOS
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformMaccmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformMac.cmake (192173 => 192174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformMac.cmake        2015-11-09 21:16:14 UTC (rev 192173)
+++ trunk/Source/WebCore/PlatformMac.cmake        2015-11-09 21:20:08 UTC (rev 192174)
</span><span class="lines">@@ -107,6 +107,7 @@
</span><span class="cx"> "${WEBCORE_DIR}/platform/graphics/opengl"
</span><span class="cx"> "${WEBCORE_DIR}/platform/graphics/mac"
</span><span class="cx"> "${WEBCORE_DIR}/platform/mac"
</span><ins>+ "${WEBCORE_DIR}/platform/mediastream/mac"
</ins><span class="cx"> "${WEBCORE_DIR}/platform/network/cocoa"
</span><span class="cx"> "${WEBCORE_DIR}/platform/network/cf"
</span><span class="cx"> "${WEBCORE_DIR}/platform/network/mac"
</span><span class="lines">@@ -497,6 +498,8 @@
</span><span class="cx"> platform/mac/WebWindowAnimation.mm
</span><span class="cx"> platform/mac/WidgetMac.mm
</span><span class="cx">
</span><ins>+ platform/mediastream/mac/MockRealtimeVideoSourceMac.mm
+
</ins><span class="cx"> platform/network/cf/AuthenticationCF.cpp
</span><span class="cx"> platform/network/cf/CookieJarCFNet.cpp
</span><span class="cx"> platform/network/cf/CookieStorageCFNet.cpp
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (192173 => 192174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-11-09 21:16:14 UTC (rev 192173)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-11-09 21:20:08 UTC (rev 192174)
</span><span class="lines">@@ -335,6 +335,10 @@
</span><span class="cx">                 07D07B141834158800ABDD3C /* JSRTCSessionDescriptionCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07D07B131834158800ABDD3C /* JSRTCSessionDescriptionCustom.cpp */; };
</span><span class="cx">                 07D637401BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h in Headers */ = {isa = PBXBuildFile; fileRef = 07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h */; };
</span><span class="cx">                 07D637411BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07D6373F1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.mm */; };
</span><ins>+                07D6A4EF1BECF2D200174146 /* MockRealtimeMediaSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07D6A4ED1BECF2D200174146 /* MockRealtimeMediaSource.cpp */; settings = {ASSET_TAGS = (); }; };
+                07D6A4F01BECF2D200174146 /* MockRealtimeMediaSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 07D6A4EE1BECF2D200174146 /* MockRealtimeMediaSource.h */; settings = {ASSET_TAGS = (); }; };
+                07D6A4F31BED5F8800174146 /* MockRealtimeAudioSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07D6A4F11BED5F8800174146 /* MockRealtimeAudioSource.cpp */; settings = {ASSET_TAGS = (); }; };
+                07D6A4F41BED5F8800174146 /* MockRealtimeAudioSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 07D6A4F21BED5F8800174146 /* MockRealtimeAudioSource.h */; settings = {ASSET_TAGS = (); }; };
</ins><span class="cx">                 07DC5FD417D3EEE90099F890 /* JSRTCStatsResponseCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07DC5FD317D3EEE90099F890 /* JSRTCStatsResponseCustom.cpp */; };
</span><span class="cx">                 07E116B11489C9A100EC5ACE /* JSTextTrackCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07E116B01489C9A100EC5ACE /* JSTextTrackCustom.cpp */; };
</span><span class="cx">                 07E117071489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07E117061489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp */; };
</span><span class="lines">@@ -342,6 +346,10 @@
</span><span class="cx">                 07E9E12E18F5E2760011A3A4 /* InbandMetadataTextTrackPrivateAVF.h in Headers */ = {isa = PBXBuildFile; fileRef = 07E9E12D18F5E2760011A3A4 /* InbandMetadataTextTrackPrivateAVF.h */; };
</span><span class="cx">                 07E9E13018F62B370011A3A4 /* InbandMetadataTextTrackPrivateAVF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07E9E12F18F62B370011A3A4 /* InbandMetadataTextTrackPrivateAVF.cpp */; };
</span><span class="cx">                 07EDC3EE1AACB75D00983EB5 /* MediaSessionManagerMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07EDC3ED1AACB75D00983EB5 /* MediaSessionManagerMac.cpp */; };
</span><ins>+                07EE76EB1BE96DB000F89133 /* MockRealtimeVideoSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07EE76E91BE96DB000F89133 /* MockRealtimeVideoSource.cpp */; settings = {ASSET_TAGS = (); }; };
+                07EE76EC1BE96DB000F89133 /* MockRealtimeVideoSource.h in Headers */ = {isa = PBXBuildFile; fileRef = 07EE76EA1BE96DB000F89133 /* MockRealtimeVideoSource.h */; settings = {ASSET_TAGS = (); }; };
+                07EE76EF1BEA619800F89133 /* MockRealtimeVideoSourceMac.h in Headers */ = {isa = PBXBuildFile; fileRef = 07EE76ED1BEA619800F89133 /* MockRealtimeVideoSourceMac.h */; settings = {ASSET_TAGS = (); }; };
+                07EE76F01BEA619800F89133 /* MockRealtimeVideoSourceMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 07EE76EE1BEA619800F89133 /* MockRealtimeVideoSourceMac.mm */; settings = {ASSET_TAGS = (); }; };
</ins><span class="cx">                 07F0B97A1AC5DB3300E535D9 /* AVKitSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F0B9791AC5DB3300E535D9 /* AVKitSPI.h */; };
</span><span class="cx">                 07F0B97C1AC5DB4600E535D9 /* AVFoundationSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F0B97B1AC5DB4600E535D9 /* AVFoundationSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 07F876841AD580F900905849 /* MediaPlaybackTargetContext.h in Headers */ = {isa = PBXBuildFile; fileRef = 07F876831AD4A94500905849 /* MediaPlaybackTargetContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -7586,6 +7594,10 @@
</span><span class="cx">                 07D07B131834158800ABDD3C /* JSRTCSessionDescriptionCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRTCSessionDescriptionCustom.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAudioSourceProviderAVFObjC.h; sourceTree = "<group>"; };
</span><span class="cx">                 07D6373F1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebAudioSourceProviderAVFObjC.mm; sourceTree = "<group>"; };
</span><ins>+                07D6A4ED1BECF2D200174146 /* MockRealtimeMediaSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockRealtimeMediaSource.cpp; sourceTree = "<group>"; };
+                07D6A4EE1BECF2D200174146 /* MockRealtimeMediaSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockRealtimeMediaSource.h; sourceTree = "<group>"; };
+                07D6A4F11BED5F8800174146 /* MockRealtimeAudioSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockRealtimeAudioSource.cpp; sourceTree = "<group>"; };
+                07D6A4F21BED5F8800174146 /* MockRealtimeAudioSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockRealtimeAudioSource.h; sourceTree = "<group>"; };
</ins><span class="cx">                 07DC5FD317D3EEE90099F890 /* JSRTCStatsResponseCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSRTCStatsResponseCustom.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 07E116B01489C9A100EC5ACE /* JSTextTrackCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextTrackCustom.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 07E117061489EBEB00EC5ACE /* JSTextTrackCueCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSTextTrackCueCustom.cpp; sourceTree = "<group>"; };
</span><span class="lines">@@ -7593,6 +7605,10 @@
</span><span class="cx">                 07E9E12D18F5E2760011A3A4 /* InbandMetadataTextTrackPrivateAVF.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InbandMetadataTextTrackPrivateAVF.h; sourceTree = "<group>"; };
</span><span class="cx">                 07E9E12F18F62B370011A3A4 /* InbandMetadataTextTrackPrivateAVF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InbandMetadataTextTrackPrivateAVF.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 07EDC3ED1AACB75D00983EB5 /* MediaSessionManagerMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaSessionManagerMac.cpp; sourceTree = "<group>"; };
</span><ins>+                07EE76E91BE96DB000F89133 /* MockRealtimeVideoSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MockRealtimeVideoSource.cpp; sourceTree = "<group>"; };
+                07EE76EA1BE96DB000F89133 /* MockRealtimeVideoSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockRealtimeVideoSource.h; sourceTree = "<group>"; };
+                07EE76ED1BEA619800F89133 /* MockRealtimeVideoSourceMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MockRealtimeVideoSourceMac.h; sourceTree = "<group>"; };
+                07EE76EE1BEA619800F89133 /* MockRealtimeVideoSourceMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MockRealtimeVideoSourceMac.mm; sourceTree = "<group>"; };
</ins><span class="cx">                 07F0B9791AC5DB3300E535D9 /* AVKitSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVKitSPI.h; sourceTree = "<group>"; };
</span><span class="cx">                 07F0B97B1AC5DB4600E535D9 /* AVFoundationSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AVFoundationSPI.h; sourceTree = "<group>"; };
</span><span class="cx">                 07F876831AD4A94500905849 /* MediaPlaybackTargetContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPlaybackTargetContext.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -15217,6 +15233,8 @@
</span><span class="cx">                                 070363DD181A1CDC00C074A5 /* AVMediaCaptureSource.mm */,
</span><span class="cx">                                 070363DE181A1CDC00C074A5 /* AVVideoCaptureSource.h */,
</span><span class="cx">                                 070363DF181A1CDC00C074A5 /* AVVideoCaptureSource.mm */,
</span><ins>+                                07EE76ED1BEA619800F89133 /* MockRealtimeVideoSourceMac.h */,
+                                07EE76EE1BEA619800F89133 /* MockRealtimeVideoSourceMac.mm */,
</ins><span class="cx">                                 4A0FFAA31AAF5EF60062803B /* RealtimeMediaSourceCenterMac.cpp */,
</span><span class="cx">                                 4A0FFAA41AAF5EF60062803B /* RealtimeMediaSourceCenterMac.h */,
</span><span class="cx">                                 07D6373E1BB0B11300256CE9 /* WebAudioSourceProviderAVFObjC.h */,
</span><span class="lines">@@ -17077,6 +17095,12 @@
</span><span class="cx">                                 59309A1211F4AE6A00250603 /* DeviceOrientationClientMock.h */,
</span><span class="cx">                                 073794DF19EE2D1B00E5A045 /* MediaConstraintsMock.cpp */,
</span><span class="cx">                                 073794E019EE2D1B00E5A045 /* MediaConstraintsMock.h */,
</span><ins>+                                07D6A4F11BED5F8800174146 /* MockRealtimeAudioSource.cpp */,
+                                07D6A4F21BED5F8800174146 /* MockRealtimeAudioSource.h */,
+                                07D6A4ED1BECF2D200174146 /* MockRealtimeMediaSource.cpp */,
+                                07D6A4EE1BECF2D200174146 /* MockRealtimeMediaSource.h */,
+                                07EE76E91BE96DB000F89133 /* MockRealtimeVideoSource.cpp */,
+                                07EE76EA1BE96DB000F89133 /* MockRealtimeVideoSource.h */,
</ins><span class="cx">                                 4A0FFA9B1AAF5E6C0062803B /* MockRealtimeMediaSourceCenter.cpp */,
</span><span class="cx">                                 4A0FFA9C1AAF5E6C0062803B /* MockRealtimeMediaSourceCenter.h */,
</span><span class="cx">                                 AAE27B7416CBFC0D00623043 /* PlatformSpeechSynthesizerMock.cpp */,
</span><span class="lines">@@ -25555,7 +25579,9 @@
</span><span class="cx">                                 A80D67080E9E9DEB00E420F0 /* GraphicsContextPlatformPrivateCG.h in Headers */,
</span><span class="cx">                                 0F580B0D0F12A2690051D689 /* GraphicsLayer.h in Headers */,
</span><span class="cx">                                 499B3ED7128CD31400E726C2 /* GraphicsLayerCA.h in Headers */,
</span><ins>+                                07D6A4F01BECF2D200174146 /* MockRealtimeMediaSource.h in Headers */,
</ins><span class="cx">                                 0F580B0E0F12A2690051D689 /* GraphicsLayerClient.h in Headers */,
</span><ins>+                                07D6A4F41BED5F8800174146 /* MockRealtimeAudioSource.h in Headers */,
</ins><span class="cx">                                 1AC69593161A1E53003732CB /* GraphicsLayerFactory.h in Headers */,
</span><span class="cx">                                 0FA24D7A162DF91900A3F4C0 /* GraphicsLayerUpdater.h in Headers */,
</span><span class="cx">                                 CEC337AF1A46086D009B8523 /* GraphicsServicesSPI.h in Headers */,
</span><span class="lines">@@ -26559,6 +26585,7 @@
</span><span class="cx">                                 49D5DC2C0F423A73008F20FD /* Matrix3DTransformOperation.h in Headers */,
</span><span class="cx">                                 49E911C70EF86D47009D0CAF /* MatrixTransformOperation.h in Headers */,
</span><span class="cx">                                 5CBC8DAD1AAA302200E1C803 /* MediaAccessibilitySoftLink.h in Headers */,
</span><ins>+                                07EE76EF1BEA619800F89133 /* MockRealtimeVideoSourceMac.h in Headers */,
</ins><span class="cx">                                 931BCC611124DFCB00BE70DD /* MediaCanStartListener.h in Headers */,
</span><span class="cx">                                 078E093A17D16E1C00420AA1 /* MediaConstraints.h in Headers */,
</span><span class="cx">                                 078E091417D14D1C00420AA1 /* MediaConstraintsImpl.h in Headers */,
</span><span class="lines">@@ -27715,6 +27742,7 @@
</span><span class="cx">                                 1C18DA59181AF6A500C4EF22 /* TextPainter.h in Headers */,
</span><span class="cx">                                 E4C91A0E1802343100A17F6D /* TextPaintStyle.h in Headers */,
</span><span class="cx">                                 93F198F608245E59001E9ABC /* TextResourceDecoder.h in Headers */,
</span><ins>+                                07EE76EC1BE96DB000F89133 /* MockRealtimeVideoSource.h in Headers */,
</ins><span class="cx">                                 A824B4650E2EF2EA0081A7B7 /* TextRun.h in Headers */,
</span><span class="cx">                                 448B1B7A0F3A2F9B0047A9E2 /* TextSizeAdjustment.h in Headers */,
</span><span class="cx">                                 B2C3DA4B0D006C1D00EF6F26 /* TextStream.h in Headers */,
</span><span class="lines">@@ -28967,6 +28995,7 @@
</span><span class="cx">                                 85ACA99D0A9B575900671E90 /* DOMText.mm in Sources */,
</span><span class="cx">                                 933A14AA0B7D1D0900A53FFD /* DOMTextEvent.mm in Sources */,
</span><span class="cx">                                 188604B30F2E654A000B6443 /* DOMTimer.cpp in Sources */,
</span><ins>+                                07EE76F01BEA619800F89133 /* MockRealtimeVideoSourceMac.mm in Sources */,
</ins><span class="cx">                                 76FC2B0B12370DA0006A991A /* DOMTokenList.cpp in Sources */,
</span><span class="cx">                                 0F54DCD61880F867003EEDBB /* DOMTouch.mm in Sources */,
</span><span class="cx">                                 0F54DCD81880F867003EEDBB /* DOMTouchEvent.mm in Sources */,
</span><span class="lines">@@ -29822,6 +29851,7 @@
</span><span class="cx">                                 073BE34017D17E01002BD431 /* JSNavigatorUserMedia.cpp in Sources */,
</span><span class="cx">                                 073BE34817D17E7A002BD431 /* JSNavigatorUserMediaError.cpp in Sources */,
</span><span class="cx">                                 14DC0D3709FED073007B0235 /* JSNode.cpp in Sources */,
</span><ins>+                                07D6A4EF1BECF2D200174146 /* MockRealtimeMediaSource.cpp in Sources */,
</ins><span class="cx">                                 BCD9C2640C17AA67005C90A2 /* JSNodeCustom.cpp in Sources */,
</span><span class="cx">                                 14115B7209F84CD600CA4FC1 /* JSNodeFilter.cpp in Sources */,
</span><span class="cx">                                 83F1206B1B8C104700D75F63 /* JSNodeFilterCustom.cpp in Sources */,
</span><span class="lines">@@ -30037,6 +30067,7 @@
</span><span class="cx">                                 B2FA3DDE0AB75A6F000E5AC4 /* JSSVGPathSegMovetoRel.cpp in Sources */,
</span><span class="cx">                                 B2FA3DE00AB75A6F000E5AC4 /* JSSVGPatternElement.cpp in Sources */,
</span><span class="cx">                                 8542A7960AE5C94200DF58DF /* JSSVGPoint.cpp in Sources */,
</span><ins>+                                07D6A4F31BED5F8800174146 /* MockRealtimeAudioSource.cpp in Sources */,
</ins><span class="cx">                                 B2FA3DE20AB75A6F000E5AC4 /* JSSVGPointList.cpp in Sources */,
</span><span class="cx">                                 B2FA3DE50AB75A6F000E5AC4 /* JSSVGPolygonElement.cpp in Sources */,
</span><span class="cx">                                 B2FA3DE70AB75A6F000E5AC4 /* JSSVGPolylineElement.cpp in Sources */,
</span><span class="lines">@@ -30066,6 +30097,7 @@
</span><span class="cx">                                 B2FA3E140AB75A6F000E5AC4 /* JSSVGUseElement.cpp in Sources */,
</span><span class="cx">                                 B2FA3E160AB75A6F000E5AC4 /* JSSVGViewElement.cpp in Sources */,
</span><span class="cx">                                 7118FED415685CC60030B79A /* JSSVGViewSpec.cpp in Sources */,
</span><ins>+                                07EE76EB1BE96DB000F89133 /* MockRealtimeVideoSource.cpp in Sources */,
</ins><span class="cx">                                 8485227D1190162C006EDC7F /* JSSVGVKernElement.cpp in Sources */,
</span><span class="cx">                                 71DCB7011568197600862271 /* JSSVGZoomAndPan.cpp in Sources */,
</span><span class="cx">                                 B2FA3E180AB75A6F000E5AC4 /* JSSVGZoomEvent.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaPlayerPrivateMediaStreamAVFObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm (192173 => 192174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm        2015-11-09 21:16:14 UTC (rev 192173)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaStreamAVFObjC.mm        2015-11-09 21:20:08 UTC (rev 192174)
</span><span class="lines">@@ -120,10 +120,11 @@
</span><span class="cx"> {
</span><span class="cx"> LOG(Media, "MediaPlayerPrivateMediaStreamAVFObjC::load(%p)", this);
</span><span class="cx">
</span><ins>+ m_previewLayer = nullptr;
+ m_intrinsicSize = FloatSize();
+
</ins><span class="cx"> m_mediaStreamPrivate = &stream;
</span><span class="cx"> m_mediaStreamPrivate->addObserver(*this);
</span><del>-
- m_previewLayer = nullptr;
</del><span class="cx"> m_ended = !m_mediaStreamPrivate->active();
</span><span class="cx">
</span><span class="cx"> scheduleDeferredTask([this] {
</span><span class="lines">@@ -358,16 +359,11 @@
</span><span class="cx"> return;
</span><span class="cx">
</span><span class="cx"> m_videoBackgroundLayer = adoptNS([[CALayer alloc] init]);
</span><del>-#ifndef NDEBUG
</del><span class="cx"> m_videoBackgroundLayer.get().name = @"MediaPlayerPrivateMediaStreamAVFObjC preview background layer";
</span><del>-#endif
</del><span class="cx">
</span><span class="cx"> m_previewLayer = m_mediaStreamPrivate->platformLayer();
</span><span class="cx"> m_previewLayer.get().contentsGravity = kCAGravityResize;
</span><span class="cx"> m_previewLayer.get().anchorPoint = CGPointZero;
</span><del>-#if !PLATFORM(IOS)
- m_previewLayer.get().autoresizingMask = kCALayerWidthSizable | kCALayerHeightSizable;
-#endif
</del><span class="cx"> if (!m_playing)
</span><span class="cx"> m_previewLayer.get().hidden = true;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacAVCaptureDeviceManagermm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm (192173 => 192174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm        2015-11-09 21:16:14 UTC (rev 192173)
+++ trunk/Source/WebCore/platform/mediastream/mac/AVCaptureDeviceManager.mm        2015-11-09 21:20:08 UTC (rev 192174)
</span><span class="lines">@@ -141,7 +141,7 @@
</span><span class="cx"> {
</span><span class="cx"> Vector<CaptureDevice>& devices = captureDeviceList();
</span><span class="cx">
</span><del>- for (AVCaptureDeviceType *device in [AVCaptureDevice devices]) {
</del><ins>+ for (AVCaptureDeviceType *device in [getAVCaptureDeviceClass() devices]) {
</ins><span class="cx"> CaptureDevice source;
</span><span class="cx">
</span><span class="cx"> if (![device isConnected])
</span><span class="lines">@@ -254,7 +254,7 @@
</span><span class="cx">
</span><span class="cx"> size_t count = devices.size();
</span><span class="cx"> for (size_t i = 0; i < count; ++i) {
</span><del>- AVCaptureDeviceType *device = [AVCaptureDevice deviceWithUniqueID:devices[i].m_captureDeviceID];
</del><ins>+ AVCaptureDeviceType *device = [getAVCaptureDeviceClass() deviceWithUniqueID:devices[i].m_captureDeviceID];
</ins><span class="cx"> ASSERT(device);
</span><span class="cx">
</span><span class="cx"> if (device && deviceSupportsFacingMode(device, facingMode))
</span><span class="lines">@@ -428,7 +428,7 @@
</span><span class="cx"> if (type == RealtimeMediaSource::Video && captureDevice.m_videoSourceId.isEmpty())
</span><span class="cx"> continue;
</span><span class="cx">
</span><del>- AVCaptureDeviceType *device = [AVCaptureDevice deviceWithUniqueID:captureDevice.m_captureDeviceID];
</del><ins>+ AVCaptureDeviceType *device = [getAVCaptureDeviceClass() deviceWithUniqueID:captureDevice.m_captureDeviceID];
</ins><span class="cx"> ASSERT(device);
</span><span class="cx">
</span><span class="cx"> RefPtr<AVMediaCaptureSource> captureSource;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacMockRealtimeVideoSourceMach"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.h (0 => 192174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.h         (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.h        2015-11-09 21:20:08 UTC (rev 192174)
</span><span class="lines">@@ -0,0 +1,62 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Ericsson nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MockRealtimeVideoSourceMac_h
+#define MockRealtimeVideoSourceMac_h
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "FontCascade.h"
+#include "MockRealtimeVideoSource.h"
+#include <wtf/RunLoop.h>
+
+namespace WebCore {
+
+class MockRealtimeVideoSourceMac final : public MockRealtimeVideoSource {
+public:
+
+ virtual ~MockRealtimeVideoSourceMac() { }
+
+private:
+ friend class MockRealtimeVideoSource;
+ MockRealtimeVideoSourceMac();
+
+ PlatformLayer* platformLayer() const override;
+ void updatePlatformLayer() const override;
+
+ mutable RetainPtr<CGImageRef> m_previewImage;
+ mutable RetainPtr<PlatformLayer> m_previewLayer;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
+
+#endif // MockRealtimeVideoSourceMac_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmediastreammacMockRealtimeVideoSourceMacmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm (0 => 192174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm         (rev 0)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockRealtimeVideoSourceMac.mm        2015-11-09 21:20:08 UTC (rev 192174)
</span><span class="lines">@@ -0,0 +1,102 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Google Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "MockRealtimeVideoSourceMac.h"
+
+#if ENABLE(MEDIA_STREAM)
+#import "GraphicsContextCG.h"
+#import "ImageBuffer.h"
+#import "MediaConstraints.h"
+#import "NotImplemented.h"
+#import "PlatformLayer.h"
+#import "RealtimeMediaSourceStates.h"
+#import <QuartzCore/CALayer.h>
+#import <QuartzCore/CATransaction.h>
+#import <objc/runtime.h>
+
+namespace WebCore {
+
+RefPtr<MockRealtimeVideoSource> MockRealtimeVideoSource::create()
+{
+ return adoptRef(new MockRealtimeVideoSourceMac());
+}
+
+MockRealtimeVideoSourceMac::MockRealtimeVideoSourceMac()
+ : MockRealtimeVideoSource()
+{
+}
+
+PlatformLayer* MockRealtimeVideoSourceMac::platformLayer() const
+{
+ if (m_previewLayer)
+ return m_previewLayer.get();
+
+ m_previewLayer = adoptNS([[CALayer alloc] init]);
+ m_previewLayer.get().name = @"MockRealtimeVideoSourceMac preview layer";
+ m_previewLayer.get().contentsGravity = kCAGravityResizeAspect;
+ m_previewLayer.get().anchorPoint = CGPointZero;
+ m_previewLayer.get().needsDisplayOnBoundsChange = YES;
+#if !PLATFORM(IOS)
+ m_previewLayer.get().autoresizingMask = kCALayerWidthSizable | kCALayerHeightSizable;
+#endif
+
+ updatePlatformLayer();
+
+ return m_previewLayer.get();
+}
+
+void MockRealtimeVideoSourceMac::updatePlatformLayer() const
+{
+ if (!m_previewLayer)
+ return;
+
+ [CATransaction begin];
+ [CATransaction setAnimationDuration:0];
+ [CATransaction setDisableActions:YES];
+
+ do {
+ RefPtr<Image> image = imageBuffer()->copyImage();
+ if (!image)
+ break;
+
+ m_previewImage = image->getCGImageRef();
+ if (!m_previewImage)
+ break;
+
+ m_previewLayer.get().contents = (NSObject*)(m_previewImage.get());
+ } while (0);
+
+ [CATransaction commit];
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmockMockRealtimeAudioSourcecpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp (0 => 192174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.cpp        2015-11-09 21:20:08 UTC (rev 192174)
</span><span class="lines">@@ -0,0 +1,67 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Google Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MockRealtimeAudioSource.h"
+
+#if ENABLE(MEDIA_STREAM)
+#include "Logging.h"
+#include "MediaConstraints.h"
+#include "NotImplemented.h"
+#include "RealtimeMediaSourceStates.h"
+#include "UUID.h"
+
+namespace WebCore {
+
+RefPtr<MockRealtimeAudioSource> MockRealtimeAudioSource::create()
+{
+ return adoptRef(new MockRealtimeAudioSource());
+}
+
+MockRealtimeAudioSource::MockRealtimeAudioSource()
+ : MockRealtimeMediaSource(createCanonicalUUIDString(), RealtimeMediaSource::Audio, mockAudioSourceName())
+{
+}
+
+void MockRealtimeAudioSource::updateStates()
+{
+ RealtimeMediaSourceStates* states = currentStates();
+ states->setSourceType(RealtimeMediaSourceStates::Microphone);
+ states->setVolume(50);
+}
+
+void MockRealtimeAudioSource::initializeCapabilities(RealtimeMediaSourceCapabilities& capabilities)
+{
+ capabilities.setVolumeRange(RealtimeMediaSourceCapabilityRange(0UL, 100UL, true));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmockMockRealtimeAudioSourceh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.h (0 => 192174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.h         (rev 0)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeAudioSource.h        2015-11-09 21:20:08 UTC (rev 192174)
</span><span class="lines">@@ -0,0 +1,62 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Ericsson nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MockRealtimeAudioSource_h
+#define MockRealtimeAudioSource_h
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "FontCascade.h"
+#include "ImageBuffer.h"
+#include "MockRealtimeMediaSource.h"
+#include <wtf/RunLoop.h>
+
+namespace WebCore {
+
+class MockRealtimeAudioSource : public MockRealtimeMediaSource {
+public:
+
+ static RefPtr<MockRealtimeAudioSource> create();
+
+ virtual ~MockRealtimeAudioSource() { }
+
+protected:
+ MockRealtimeAudioSource();
+
+private:
+ void updateStates() override;
+ void initializeCapabilities(RealtimeMediaSourceCapabilities&) override;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
+
+#endif // MockRealtimeAudioSource_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmockMockRealtimeMediaSourcecpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mock/MockRealtimeMediaSource.cpp (0 => 192174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/MockRealtimeMediaSource.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeMediaSource.cpp        2015-11-09 21:20:08 UTC (rev 192174)
</span><span class="lines">@@ -0,0 +1,117 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Google Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MockRealtimeMediaSource.h"
+
+#if ENABLE(MEDIA_STREAM)
+#include "Logging.h"
+#include "MediaConstraints.h"
+#include "MediaStreamTrackSourcesRequestClient.h"
+#include "NotImplemented.h"
+#include "RealtimeMediaSourceStates.h"
+#include <math.h>
+#include <wtf/CurrentTime.h>
+#include <wtf/NeverDestroyed.h>
+#include <wtf/text/StringView.h>
+
+namespace WebCore {
+
+const AtomicString& MockRealtimeMediaSource::mockAudioSourcePersistentID()
+{
+ static NeverDestroyed<AtomicString> id("239c24b1-2b15-11e3-8224-0800200c9a66", AtomicString::ConstructFromLiteral);
+ return id;
+}
+
+const AtomicString& MockRealtimeMediaSource::mockVideoSourcePersistentID()
+{
+ static NeverDestroyed<AtomicString> id("239c24b0-2b15-11e3-8224-0800200c9a66", AtomicString::ConstructFromLiteral);
+ return id;
+}
+
+const AtomicString& MockRealtimeMediaSource::mockAudioSourceName()
+{
+ static NeverDestroyed<AtomicString> name("Mock audio device", AtomicString::ConstructFromLiteral);
+ return name;
+}
+
+const AtomicString& MockRealtimeMediaSource::mockVideoSourceName()
+{
+ static NeverDestroyed<AtomicString> name("Mock video device", AtomicString::ConstructFromLiteral);
+ return name;
+}
+
+RefPtr<TrackSourceInfo> MockRealtimeMediaSource::trackSourceWithUID(const String& id, MediaConstraints*)
+{
+ // FIXME: validate constraints.
+
+ if (mockAudioSourcePersistentID() == id)
+ return TrackSourceInfo::create(mockAudioSourcePersistentID(), TrackSourceInfo::Audio, "Mock audio device");
+
+ if (mockVideoSourcePersistentID() == id)
+ return TrackSourceInfo::create(mockVideoSourcePersistentID(), TrackSourceInfo::Video, "Mock video device");
+
+ return nullptr;
+}
+
+#if 0
+
+#endif
+
+MockRealtimeMediaSource::MockRealtimeMediaSource(const String& id, RealtimeMediaSource::Type type, const String& name)
+ : RealtimeMediaSource(id, type, name)
+{
+ if (type == RealtimeMediaSource::Audio)
+ setPersistentID(mockAudioSourcePersistentID());
+ else
+ setPersistentID(mockVideoSourcePersistentID());
+}
+
+RefPtr<RealtimeMediaSourceCapabilities> MockRealtimeMediaSource::capabilities()
+{
+ if (!m_capabilities) {
+ m_capabilities = RealtimeMediaSourceCapabilities::create();
+ m_capabilities->setSourceId(m_currentStates.sourceId());
+ initializeCapabilities(*m_capabilities.get());
+ }
+ return m_capabilities;
+}
+
+const RealtimeMediaSourceStates& MockRealtimeMediaSource::states()
+{
+ m_currentStates.setSourceId(id());
+ updateStates();
+
+ return m_currentStates;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmockMockRealtimeMediaSourceh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mock/MockRealtimeMediaSource.h (0 => 192174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/MockRealtimeMediaSource.h         (rev 0)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeMediaSource.h        2015-11-09 21:20:08 UTC (rev 192174)
</span><span class="lines">@@ -0,0 +1,86 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Ericsson nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MockRealtimeMediaSource_h
+#define MockRealtimeMediaSource_h
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "RealtimeMediaSource.h"
+#include <wtf/RunLoop.h>
+
+namespace WebCore {
+
+class FloatRect;
+class GraphicsContext;
+class TrackSourceInfo;
+
+class MockRealtimeMediaSource : public RealtimeMediaSource {
+public:
+ virtual ~MockRealtimeMediaSource() { }
+
+ static const AtomicString& mockAudioSourcePersistentID();
+ static const AtomicString& mockAudioSourceName();
+
+ static const AtomicString& mockVideoSourcePersistentID();
+ static const AtomicString& mockVideoSourceName();
+
+ static RefPtr<TrackSourceInfo> trackSourceWithUID(const String&, MediaConstraints*);
+
+protected:
+ MockRealtimeMediaSource(const String& id, Type, const String& name);
+
+ virtual void updateStates() = 0;
+ virtual void initializeCapabilities(RealtimeMediaSourceCapabilities&) = 0;
+
+ void startProducingData() override { m_isProducingData = true; }
+ void stopProducingData() override { m_isProducingData = false; }
+
+ RefPtr<RealtimeMediaSourceCapabilities> capabilities() override;
+ const RealtimeMediaSourceStates& states() override;
+
+ RealtimeMediaSourceStates* currentStates() { return &m_currentStates; }
+ MediaConstraints* constraints() { return m_constraints.get(); }
+
+private:
+
+ bool isProducingData() const override { return m_isProducingData; }
+
+ RealtimeMediaSourceStates m_currentStates;
+ RefPtr<RealtimeMediaSourceCapabilities> m_capabilities;
+ RefPtr<MediaConstraints> m_constraints;
+ bool m_isProducingData { false };
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
+
+#endif // MockRealtimeMediaSource_h
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmockMockRealtimeMediaSourceCentercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp (192173 => 192174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp        2015-11-09 21:16:14 UTC (rev 192173)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp        2015-11-09 21:20:08 UTC (rev 192174)
</span><span class="lines">@@ -26,9 +26,9 @@
</span><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> #include "config.h"
</span><ins>+#include "MockRealtimeMediaSourceCenter.h"
</ins><span class="cx">
</span><span class="cx"> #if ENABLE(MEDIA_STREAM)
</span><del>-#include "MockRealtimeMediaSourceCenter.h"
</del><span class="cx">
</span><span class="cx"> #include "MediaConstraintsMock.h"
</span><span class="cx"> #include "MediaStream.h"
</span><span class="lines">@@ -36,86 +36,16 @@
</span><span class="cx"> #include "MediaStreamPrivate.h"
</span><span class="cx"> #include "MediaStreamTrack.h"
</span><span class="cx"> #include "MediaStreamTrackSourcesRequestClient.h"
</span><ins>+#include "MockRealtimeAudioSource.h"
+#include "MockRealtimeMediaSource.h"
+#include "MockRealtimeVideoSource.h"
</ins><span class="cx"> #include "RealtimeMediaSource.h"
</span><span class="cx"> #include "RealtimeMediaSourceCapabilities.h"
</span><ins>+#include "UUID.h"
</ins><span class="cx"> #include <wtf/NeverDestroyed.h>
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-class MockSource : public RealtimeMediaSource {
-public:
- MockSource(const AtomicString& id, const AtomicString& name, RealtimeMediaSource::Type type)
- : RealtimeMediaSource(id, type, name)
- {
- }
-
- virtual ~MockSource() { }
-
- virtual RefPtr<RealtimeMediaSourceCapabilities> capabilities() { return m_capabilities; }
- virtual const RealtimeMediaSourceStates& states() { return m_currentStates; }
-
- RefPtr<RealtimeMediaSourceCapabilities> m_capabilities;
- RealtimeMediaSourceStates m_currentStates;
-};
-
-typedef HashMap<String, RefPtr<MockSource>> MockSourceMap;
-
-static MockSourceMap& mockSourceMap()
-{
- DEPRECATED_DEFINE_STATIC_LOCAL(MockSourceMap, mockSourceMap, ());
- return mockSourceMap;
-}
-
-static const AtomicString& mockAudioSourceID()
-{
- static NeverDestroyed<AtomicString> id("239c24b1-2b15-11e3-8224-0800200c9a66", AtomicString::ConstructFromLiteral);
- return id;
-}
-
-static const AtomicString& mockVideoSourceID()
-{
- static NeverDestroyed<AtomicString> id("239c24b0-2b15-11e3-8224-0800200c9a66", AtomicString::ConstructFromLiteral);
- return id;
-}
-
-static void initializeMockSources()
-{
- RefPtr<MockSource> mockSource1 = adoptRef(new MockSource(mockVideoSourceID(), "Mock video device", RealtimeMediaSource::Video));
- mockSource1->m_capabilities = RealtimeMediaSourceCapabilities::create();
- mockSource1->m_capabilities->setSourceId(mockSource1->id());
- mockSource1->m_capabilities->addSourceType(RealtimeMediaSourceStates::Camera);
- mockSource1->m_capabilities->addSourceType(RealtimeMediaSourceStates::Microphone);
- mockSource1->m_capabilities->addFacingMode(RealtimeMediaSourceStates::User);
- mockSource1->m_capabilities->addFacingMode(RealtimeMediaSourceStates::Environment);
- mockSource1->m_capabilities->setWidthRange(RealtimeMediaSourceCapabilityRange(320UL, 1920UL, true));
- mockSource1->m_capabilities->setHeightRange(RealtimeMediaSourceCapabilityRange(240UL, 1080UL, true));
- mockSource1->m_capabilities->setFrameRateRange(RealtimeMediaSourceCapabilityRange(15.0f, 60.0f, true));
- mockSource1->m_capabilities->setAspectRatioRange(RealtimeMediaSourceCapabilityRange(4 / 3.0f, 16 / 9.0f, true));
- mockSource1->m_capabilities->setVolumeRange(RealtimeMediaSourceCapabilityRange(10UL, 90UL, true));
-
- mockSource1->m_currentStates.setSourceType(RealtimeMediaSourceStates::Camera);
- mockSource1->m_currentStates.setSourceId(mockSource1->id());
- mockSource1->m_currentStates.setFacingMode(RealtimeMediaSourceStates::User);
- mockSource1->m_currentStates.setWidth(1920);
- mockSource1->m_currentStates.setHeight(1080);
- mockSource1->m_currentStates.setFrameRate(30);
- mockSource1->m_currentStates.setAspectRatio(16 / 9.0f);
- mockSource1->m_currentStates.setVolume(70);
- String mockSource1id = mockSource1->id();
- mockSourceMap().add(mockSource1id, mockSource1.release());
-
- RefPtr<MockSource> mockSource2 = adoptRef(new MockSource(mockAudioSourceID(), "Mock audio device", RealtimeMediaSource::Audio));
- mockSource2->m_capabilities = RealtimeMediaSourceCapabilities::create();
- mockSource2->m_capabilities->setSourceId(mockSource2->id());
- mockSource2->m_capabilities->setVolumeRange(RealtimeMediaSourceCapabilityRange(0UL, 100UL, true));
-
- mockSource2->m_currentStates.setSourceType(RealtimeMediaSourceStates::Microphone);
- mockSource2->m_currentStates.setSourceId(mockSource2->id());
- mockSource2->m_currentStates.setVolume(50);
- String mockSource2id = mockSource2->id();
- mockSourceMap().add(mockSource2id, mockSource2.release());
-}
-
</del><span class="cx"> void MockRealtimeMediaSourceCenter::registerMockRealtimeMediaSourceCenter()
</span><span class="cx"> {
</span><span class="cx"> DEPRECATED_DEFINE_STATIC_LOCAL(MockRealtimeMediaSourceCenter, center, ());
</span><span class="lines">@@ -123,7 +53,6 @@
</span><span class="cx"> if (!registered) {
</span><span class="cx"> registered = true;
</span><span class="cx"> RealtimeMediaSourceCenter::setSharedStreamCenter(&center);
</span><del>- initializeMockSources();
</del><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -133,7 +62,6 @@
</span><span class="cx">
</span><span class="cx"> Vector<RefPtr<RealtimeMediaSource>> audioSources;
</span><span class="cx"> Vector<RefPtr<RealtimeMediaSource>> videoSources;
</span><del>- MockSourceMap& map = mockSourceMap();
</del><span class="cx">
</span><span class="cx"> if (audioConstraints) {
</span><span class="cx"> String invalidQuery = MediaConstraintsMock::verifyConstraints(audioConstraints);
</span><span class="lines">@@ -142,11 +70,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- MockSourceMap::iterator it = map.find(mockAudioSourceID());
- ASSERT(it != map.end());
-
- RefPtr<RealtimeMediaSource> audioSource = it->value;
- audioSource->reset();
</del><ins>+ RefPtr<RealtimeMediaSource> audioSource = MockRealtimeAudioSource::create();
</ins><span class="cx"> audioSources.append(audioSource.release());
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -157,11 +81,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- MockSourceMap::iterator it = map.find(mockVideoSourceID());
- ASSERT(it != map.end());
-
- RefPtr<RealtimeMediaSource> videoSource = it->value;
- videoSource->reset();
</del><ins>+ RefPtr<RealtimeMediaSource> videoSource = MockRealtimeVideoSource::create();
</ins><span class="cx"> videoSources.append(videoSource.release());
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -176,7 +96,6 @@
</span><span class="cx">
</span><span class="cx"> Vector<RefPtr<RealtimeMediaSource>> audioSources;
</span><span class="cx"> Vector<RefPtr<RealtimeMediaSource>> videoSources;
</span><del>- MockSourceMap& map = mockSourceMap();
</del><span class="cx">
</span><span class="cx"> if (audioConstraints) {
</span><span class="cx"> String invalidQuery = MediaConstraintsMock::verifyConstraints(audioConstraints);
</span><span class="lines">@@ -185,11 +104,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- MockSourceMap::iterator it = map.find(mockAudioSourceID());
- ASSERT(it != map.end());
-
- RefPtr<RealtimeMediaSource> audioSource = it->value;
- audioSource->reset();
</del><ins>+ RefPtr<RealtimeMediaSource> audioSource = MockRealtimeAudioSource::create();
</ins><span class="cx"> audioSources.append(audioSource.release());
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -200,11 +115,7 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- MockSourceMap::iterator it = map.find(mockVideoSourceID());
- ASSERT(it != map.end());
-
- RefPtr<RealtimeMediaSource> videoSource = it->value;
- videoSource->reset();
</del><ins>+ RefPtr<RealtimeMediaSource> videoSource = MockRealtimeVideoSource::create();
</ins><span class="cx"> videoSources.append(videoSource.release());
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -216,22 +127,13 @@
</span><span class="cx"> ASSERT(client);
</span><span class="cx"> Vector<RefPtr<RealtimeMediaSource>> audioSources;
</span><span class="cx"> Vector<RefPtr<RealtimeMediaSource>> videoSources;
</span><del>- MockSourceMap& map = mockSourceMap();
</del><span class="cx">
</span><del>- if (!audioDeviceID.isEmpty()) {
- MockSourceMap::iterator it = map.find(mockAudioSourceID());
- ASSERT(it != map.end());
-
- RefPtr<RealtimeMediaSource> audioSource = it->value;
- audioSource->reset();
</del><ins>+ if (!audioDeviceID.isEmpty() && audioDeviceID == MockRealtimeMediaSource::mockAudioSourcePersistentID()) {
+ RefPtr<RealtimeMediaSource> audioSource = MockRealtimeAudioSource::create();
</ins><span class="cx"> audioSources.append(audioSource.release());
</span><span class="cx"> }
</span><del>- if (!videoDeviceID.isEmpty()) {
- MockSourceMap::iterator it = map.find(mockVideoSourceID());
- ASSERT(it != map.end());
-
- RefPtr<RealtimeMediaSource> videoSource = it->value;
- videoSource->reset();
</del><ins>+ if (!videoDeviceID.isEmpty() && videoDeviceID == MockRealtimeMediaSource::mockVideoSourcePersistentID()) {
+ RefPtr<RealtimeMediaSource> videoSource = MockRealtimeVideoSource::create();
</ins><span class="cx"> videoSources.append(videoSource.release());
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -243,25 +145,19 @@
</span><span class="cx"> RefPtr<MediaStreamTrackSourcesRequestClient> requestClient = prpClient;
</span><span class="cx"> TrackSourceInfoVector sources;
</span><span class="cx">
</span><del>- MockSourceMap& map = mockSourceMap();
- MockSourceMap::iterator end = map.end();
- for (MockSourceMap::iterator it = map.begin(); it != end; ++it) {
- MockSource* source = it->value.get();
</del><ins>+ sources.append(MockRealtimeMediaSource::trackSourceWithUID(MockRealtimeMediaSource::mockAudioSourcePersistentID(), nullptr));
+ sources.append(MockRealtimeMediaSource::trackSourceWithUID(MockRealtimeMediaSource::mockVideoSourcePersistentID(), nullptr));
</ins><span class="cx">
</span><del>- sources.append(TrackSourceInfo::create(source->id(), source->type() == RealtimeMediaSource::Video ? TrackSourceInfo::Video : TrackSourceInfo::Audio, source->name()));
- }
</del><ins>+ callOnMainThread([this, requestClient, sources] {
+ requestClient->didCompleteRequest(sources);
+ });
</ins><span class="cx">
</span><del>- requestClient->didCompleteRequest(sources);
</del><span class="cx"> return true;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<TrackSourceInfo> MockRealtimeMediaSourceCenter::sourceWithUID(const String& UID, RealtimeMediaSource::Type, MediaConstraints*)
</del><ins>+RefPtr<TrackSourceInfo> MockRealtimeMediaSourceCenter::sourceWithUID(const String& UID, RealtimeMediaSource::Type, MediaConstraints* constraints)
</ins><span class="cx"> {
</span><del>- for (auto& source : mockSourceMap()) {
- if (source.value->id() == UID)
- return TrackSourceInfo::create(source.value->id(), source.value->type() == RealtimeMediaSource::Video ? TrackSourceInfo::Video : TrackSourceInfo::Audio, source.value->name());
- }
- return nullptr;
</del><ins>+ return MockRealtimeMediaSource::trackSourceWithUID(UID, constraints);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockMockRealtimeVideoSourcecpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp (0 => 192174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.cpp        2015-11-09 21:20:08 UTC (rev 192174)
</span><span class="lines">@@ -0,0 +1,373 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Google Inc. nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "MockRealtimeVideoSource.h"
+
+#if ENABLE(MEDIA_STREAM)
+#include "GraphicsContext.h"
+#include "ImageBuffer.h"
+#include "IntRect.h"
+#include "Logging.h"
+#include "MediaConstraints.h"
+#include "NotImplemented.h"
+#include "PlatformLayer.h"
+#include "RealtimeMediaSourceStates.h"
+#include "UUID.h"
+#include <math.h>
+#include <wtf/CurrentTime.h>
+#include <wtf/text/StringView.h>
+
+namespace WebCore {
+
+#if !PLATFORM(MAC) && !PLATFORM(IOS)
+RefPtr<MockRealtimeVideoSource> MockRealtimeVideoSource::create()
+{
+ return adoptRef(new MockRealtimeVideoSource());
+}
+#endif
+
+MockRealtimeVideoSource::MockRealtimeVideoSource()
+ : MockRealtimeMediaSource(createCanonicalUUIDString(), RealtimeMediaSource::Video, mockVideoSourceName())
+ , m_timer(RunLoop::main(), this, &MockRealtimeVideoSource::generateFrame)
+{
+ m_dashWidths.reserveInitialCapacity(2);
+ m_dashWidths.uncheckedAppend(6);
+ m_dashWidths.uncheckedAppend(6);
+}
+
+void MockRealtimeVideoSource::startProducingData()
+{
+ MockRealtimeMediaSource::startProducingData();
+ if (m_size.isEmpty())
+ setSize(IntSize(640, 480));
+
+ m_startTime = monotonicallyIncreasingTime();
+ m_timer.startRepeating(std::chrono::milliseconds(lround(1000 / m_frameRate)));
+}
+
+void MockRealtimeVideoSource::stopProducingData()
+{
+ MockRealtimeMediaSource::startProducingData();
+ m_timer.stop();
+ m_elapsedTime += monotonicallyIncreasingTime() - m_startTime;
+ m_startTime = NAN;
+}
+
+double MockRealtimeVideoSource::elapsedTime()
+{
+ if (std::isnan(m_startTime))
+ return m_elapsedTime;
+
+ return m_elapsedTime + (monotonicallyIncreasingTime() - m_startTime);
+}
+
+void MockRealtimeVideoSource::updateStates()
+{
+ RealtimeMediaSourceStates* states = currentStates();
+
+ states->setFacingMode(RealtimeMediaSourceStates::User);
+ states->setFrameRate(m_frameRate);
+ states->setWidth(m_size.width());
+ states->setHeight(m_size.height());
+ states->setAspectRatio(static_cast<float>(m_size.width()) / m_size.height());
+}
+
+void MockRealtimeVideoSource::initializeCapabilities(RealtimeMediaSourceCapabilities& capabilities)
+{
+ capabilities.addSourceType(RealtimeMediaSourceStates::Camera);
+ capabilities.addFacingMode(RealtimeMediaSourceStates::User);
+ capabilities.addFacingMode(RealtimeMediaSourceStates::Environment);
+ capabilities.setWidthRange(RealtimeMediaSourceCapabilityRange(320UL, 1920UL, true));
+ capabilities.setHeightRange(RealtimeMediaSourceCapabilityRange(240UL, 1080UL, true));
+ capabilities.setFrameRateRange(RealtimeMediaSourceCapabilityRange(15.0f, 60.0f, true));
+ capabilities.setAspectRatioRange(RealtimeMediaSourceCapabilityRange(4 / 3.0f, 16 / 9.0f, true));
+}
+
+void MockRealtimeVideoSource::setFacingMode(RealtimeMediaSourceStates::VideoFacingMode mode)
+{
+ RealtimeMediaSourceStates* states = currentStates();
+
+ if (states->facingMode() == mode)
+ return;
+
+ states->setFacingMode(mode);
+
+ statesDidChanged();
+}
+
+void MockRealtimeVideoSource::setFrameRate(float rate)
+{
+ if (m_frameRate == rate)
+ return;
+
+ m_frameRate = rate;
+ if (m_timer.isActive())
+ m_timer.startRepeating(std::chrono::milliseconds(lround(1000 / m_frameRate)));
+
+ statesDidChanged();
+}
+
+void MockRealtimeVideoSource::setSize(const IntSize& size)
+{
+ if (size == m_size)
+ return;
+
+ m_size = size;
+
+ m_baseFontSize = m_size.height() * .08;
+ FontCascadeDescription fontDescription;
+ fontDescription.setOneFamily("Courier");
+ fontDescription.setSpecifiedSize(m_baseFontSize);
+ fontDescription.setComputedSize(m_baseFontSize);
+ fontDescription.setWeight(FontWeight500);
+
+ m_timeFont = FontCascade(fontDescription, 0, 0);
+ m_timeFont.update(nullptr);
+
+ m_bipBopFontSize = m_baseFontSize * 2.5;
+ fontDescription.setSpecifiedSize(m_bipBopFontSize);
+ fontDescription.setComputedSize(m_bipBopFontSize);
+ m_bipBopFont = FontCascade(fontDescription, 0, 0);
+ m_bipBopFont.update(nullptr);
+
+ m_statsFontSize = m_baseFontSize * .5;
+ fontDescription.setSpecifiedSize(m_statsFontSize);
+ fontDescription.setComputedSize(m_statsFontSize);
+ m_statsFont = FontCascade(fontDescription, 0, 0);
+ m_statsFont.update(nullptr);
+
+ m_imageBuffer = nullptr;
+ updatePlatformLayer();
+
+ statesDidChanged();
+}
+
+void MockRealtimeVideoSource::drawAnimation(GraphicsContext& context)
+{
+ float radius = m_size.width() * .09;
+ FloatPoint location(m_size.width() * .8, m_size.height() * .3);
+
+ m_path.clear();
+ m_path.moveTo(location);
+ m_path.addArc(location, radius, 0, 2 * piFloat, false);
+ m_path.closeSubpath();
+ context.setFillColor(Color::white);
+ context.setFillRule(RULE_NONZERO);
+ context.fillPath(m_path);
+
+ float endAngle = piFloat * (((fmod(m_frameNumber, m_frameRate) + 0.5) * (2.0 / m_frameRate)) + 1);
+ m_path.clear();
+ m_path.moveTo(location);
+ m_path.addArc(location, radius, 1.5 * piFloat, endAngle, false);
+ m_path.closeSubpath();
+ context.setFillColor(Color::gray);
+ context.setFillRule(RULE_NONZERO);
+ context.fillPath(m_path);
+}
+
+void MockRealtimeVideoSource::drawBoxes(GraphicsContext& context)
+{
+ static const RGBA32 magenta = 0xffff00ff;
+ static const RGBA32 yellow = 0xffffff00;
+ static const RGBA32 blue = 0xff0000ff;
+ static const RGBA32 red = 0xffff0000;
+ static const RGBA32 green = 0xff008000;
+
+ float boxSize = m_size.width() * .035;
+ float boxTop = m_size.height() * .6;
+
+ m_path.clear();
+ FloatRect frameRect(2, 2, m_size.width() - 3, m_size.height() - 3);
+ context.setStrokeColor(Color::white);
+ context.setStrokeThickness(3);
+ context.setLineDash(m_dashWidths, 0);
+ m_path.addRect(frameRect);
+ m_path.closeSubpath();
+ context.strokePath(m_path);
+
+ context.setLineDash(DashArray(), 0);
+ m_path.clear();
+ m_path.moveTo(FloatPoint(0, boxTop + boxSize));
+ m_path.addLineTo(FloatPoint(m_size.width(), boxTop + boxSize));
+ m_path.closeSubpath();
+ context.setStrokeColor(Color::white);
+ context.setStrokeThickness(2);
+ context.strokePath(m_path);
+
+ context.setStrokeThickness(1);
+ float boxLeft = boxSize;
+ m_path.clear();
+ for (unsigned i = 0; i < boxSize / 4; i++) {
+ m_path.moveTo(FloatPoint(boxLeft + 4 * i, boxTop));
+ m_path.addLineTo(FloatPoint(boxLeft + 4 * i, boxTop + boxSize));
+ }
+ boxLeft += boxSize + 2;
+ for (unsigned i = 0; i < boxSize / 4; i++) {
+ m_path.moveTo(FloatPoint(boxLeft, boxTop + 4 * i));
+ m_path.addLineTo(FloatPoint(boxLeft + boxSize - 1, boxTop + 4 * i));
+ }
+ context.setStrokeThickness(3);
+ boxLeft += boxSize + 2;
+ for (unsigned i = 0; i < boxSize / 8; i++) {
+ m_path.moveTo(FloatPoint(boxLeft + 8 * i, boxTop));
+ m_path.addLineTo(FloatPoint(boxLeft + 8 * i, boxTop + boxSize - 1));
+ }
+ boxLeft += boxSize + 2;
+ for (unsigned i = 0; i < boxSize / 8; i++) {
+ m_path.moveTo(FloatPoint(boxLeft, boxTop + 8 * i));
+ m_path.addLineTo(FloatPoint(boxLeft + boxSize - 1, boxTop + 8 * i));
+ }
+
+ boxTop += boxSize + 2;
+ boxLeft = boxSize;
+ Color boxColors[] = { Color::white, yellow, Color::cyan, green, magenta, red, blue };
+ for (unsigned i = 0; i < sizeof(boxColors) / sizeof(boxColors[0]); i++) {
+ context.fillRect(FloatRect(boxLeft, boxTop, boxSize + 1, boxSize + 1), boxColors[i]);
+ boxLeft += boxSize + 1;
+ }
+ context.strokePath(m_path);
+}
+
+void MockRealtimeVideoSource::drawText(GraphicsContext& context)
+{
+ unsigned milliseconds = lround(elapsedTime() * 1000);
+ unsigned seconds = milliseconds / 1000 % 60;
+ unsigned minutes = seconds / 60 % 60;
+ unsigned hours = minutes / 60 % 60;
+
+ FloatPoint timeLocation(m_size.width() * .05, m_size.height() * .15);
+ context.setFillColor(Color::white);
+ context.setTextDrawingMode(TextModeFill);
+ String string = String::format("%02u:%02u:%02u.%03u", hours, minutes, seconds, milliseconds % 1000);
+ context.drawText(m_timeFont, TextRun((StringView(string))), timeLocation, 0, -1);
+
+ string = String::format("%06u", m_frameNumber++);
+ timeLocation.move(0, m_baseFontSize);
+ context.drawText(m_timeFont, TextRun((StringView(string))), timeLocation, 0, -1);
+
+ FloatPoint statsLocation(m_size.width() * .65, m_size.height() * .75);
+ string = String::format("Frame rate: %ufps", m_frameRate);
+ context.drawText(m_statsFont, TextRun((StringView(string))), statsLocation, 0, -1);
+
+ string = String::format("Size: %u x %u", m_size.width(), m_size.height());
+ statsLocation.move(0, m_statsFontSize);
+ context.drawText(m_statsFont, TextRun((StringView(string))), statsLocation, 0, -1);
+
+ const char* camera;
+ switch (states().facingMode()) {
+ case RealtimeMediaSourceStates::User:
+ camera = "User facing";
+ break;
+ case RealtimeMediaSourceStates::Environment:
+ camera = "Environment facing";
+ break;
+ case RealtimeMediaSourceStates::Left:
+ camera = "Left facing";
+ break;
+ case RealtimeMediaSourceStates::Right:
+ camera = "Right facing";
+ break;
+ case RealtimeMediaSourceStates::Unknown:
+ camera = "Unknown";
+ break;
+ }
+ string = String::format("Camera: %s", camera);
+ statsLocation.move(0, m_statsFontSize);
+ context.drawText(m_statsFont, TextRun((StringView(string))), statsLocation, 0, -1);
+
+ FloatPoint bipBopLocation(m_size.width() * .6, m_size.height() * .6);
+ unsigned frameMod = m_frameNumber % 60;
+ if (frameMod <= 15) {
+ context.setFillColor(Color::gray);
+ TextRun run(StringView("Bip"));
+ context.drawText(m_bipBopFont, run, bipBopLocation, 0, -1);
+ } else if (frameMod > 30 && frameMod <= 45) {
+ context.setFillColor(Color::white);
+ TextRun run(StringView("Bop"));
+ context.drawText(m_bipBopFont, run, bipBopLocation, 0, -1);
+ }
+}
+
+void MockRealtimeVideoSource::generateFrame()
+{
+ GraphicsContext& context = imageBuffer()->context();
+ GraphicsContextStateSaver stateSaver(context);
+
+ FloatRect frameRect(FloatPoint(), m_size);
+ context.fillRect(FloatRect(FloatPoint(), m_size), Color::black);
+
+ drawText(context);
+ drawAnimation(context);
+ drawBoxes(context);
+
+ updatePlatformLayer();
+}
+
+ImageBuffer* MockRealtimeVideoSource::imageBuffer() const
+{
+ if (m_imageBuffer)
+ return m_imageBuffer.get();
+
+ m_imageBuffer = ImageBuffer::create(m_size, Unaccelerated);
+ if (!m_imageBuffer)
+ return nullptr;
+
+ m_imageBuffer->context().setImageInterpolationQuality(InterpolationDefault);
+ m_imageBuffer->context().setStrokeThickness(1);
+
+ return m_imageBuffer.get();
+}
+
+void MockRealtimeVideoSource::paintCurrentFrameInContext(GraphicsContext& context, const FloatRect& rect)
+{
+ if (context.paintingDisabled() || !imageBuffer())
+ return;
+
+ GraphicsContextStateSaver stateSaver(context);
+// context.translate(rect.x(), rect.y() + rect.height());
+ context.setImageInterpolationQuality(InterpolationLow);
+ IntRect paintRect(IntPoint(0, 0), IntSize(rect.width(), rect.height()));
+
+ context.drawImage(*m_imageBuffer->copyImage(DontCopyBackingStore), rect);
+}
+
+RefPtr<Image> MockRealtimeVideoSource::currentFrameImage()
+{
+ if (!imageBuffer())
+ return nullptr;
+
+ return m_imageBuffer->copyImage(DontCopyBackingStore);
+}
+
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformmockMockRealtimeVideoSourceh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h (0 => 192174)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h         (rev 0)
+++ trunk/Source/WebCore/platform/mock/MockRealtimeVideoSource.h        2015-11-09 21:20:08 UTC (rev 192174)
</span><span class="lines">@@ -0,0 +1,112 @@
</span><ins>+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name of Ericsson nor the names of its contributors
+ * may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef MockRealtimeVideoSource_h
+#define MockRealtimeVideoSource_h
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "FontCascade.h"
+#include "ImageBuffer.h"
+#include "MockRealtimeMediaSource.h"
+#include <wtf/RunLoop.h>
+
+namespace WebCore {
+
+class FloatRect;
+class GraphicsContext;
+
+class MockRealtimeVideoSource : public MockRealtimeMediaSource {
+public:
+
+ static RefPtr<MockRealtimeVideoSource> create();
+
+ virtual ~MockRealtimeVideoSource() { }
+
+ void setSize(const IntSize&);
+ const IntSize& size() const { return m_size; }
+
+ void setFacingMode(RealtimeMediaSourceStates::VideoFacingMode);
+ void setFrameRate(float);
+
+protected:
+ MockRealtimeVideoSource();
+ virtual void updatePlatformLayer() const { }
+
+ ImageBuffer* imageBuffer() const;
+
+private:
+ void updateStates() override;
+ void initializeCapabilities(RealtimeMediaSourceCapabilities&) override;
+
+ void startProducingData() override;
+ void stopProducingData() override;
+
+ void drawAnimation(GraphicsContext&);
+ void drawText(GraphicsContext&);
+ void drawBoxes(GraphicsContext&);
+
+ PlatformLayer* platformLayer() const override { return nullptr; }
+ RefPtr<Image> currentFrameImage() override;
+ void paintCurrentFrameInContext(GraphicsContext&, const FloatRect&) override;
+
+ void generateFrame();
+
+ double elapsedTime();
+
+ float m_baseFontSize { 0 };
+ FontCascade m_timeFont;
+
+ float m_bipBopFontSize { 0 };
+ FontCascade m_bipBopFont;
+
+ float m_statsFontSize { 0 };
+ FontCascade m_statsFont;
+
+ mutable std::unique_ptr<ImageBuffer> m_imageBuffer;
+
+ IntSize m_size;
+ Path m_path;
+ DashArray m_dashWidths;
+
+ double m_startTime { NAN };
+ double m_elapsedTime { 0 };
+
+ unsigned m_frameRate { 30 };
+ unsigned m_frameNumber { 0 };
+
+ RunLoop::Timer<MockRealtimeVideoSource> m_timer;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
+
+#endif // MockRealtimeVideoSource_h
</ins></span></pre>
</div>
</div>
</body>
</html>