Skip to content
Permalink
Browse files
[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):


Canonical link: https://commits.webkit.org/169251@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192174 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
eric-carlson committed Nov 9, 2015
1 parent fb9b96a commit c6d3e7da1d431f4e3946eec617df563e5f408b24
Showing 15 changed files with 1,150 additions and 134 deletions.
@@ -2302,7 +2302,10 @@ set(WebCore_SOURCES
platform/mock/DeviceOrientationClientMock.cpp
platform/mock/GeolocationClientMock.cpp
platform/mock/MediaConstraintsMock.cpp
platform/mock/MockRealtimeAudioSource.cpp
platform/mock/MockRealtimeMediaSource.cpp
platform/mock/MockRealtimeMediaSourceCenter.cpp
platform/mock/MockRealtimeVideoSource.cpp
platform/mock/RTCDTMFSenderHandlerMock.cpp
platform/mock/RTCDataChannelHandlerMock.cpp
platform/mock/RTCNotifiersMock.cpp
@@ -1,3 +1,108 @@
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):

2015-11-09 Nan Wang <n_wang@apple.com>

AX: Input type: time is not accessible on iOS
@@ -107,6 +107,7 @@ list(APPEND WebCore_INCLUDE_DIRECTORIES
"${WEBCORE_DIR}/platform/graphics/opengl"
"${WEBCORE_DIR}/platform/graphics/mac"
"${WEBCORE_DIR}/platform/mac"
"${WEBCORE_DIR}/platform/mediastream/mac"
"${WEBCORE_DIR}/platform/network/cocoa"
"${WEBCORE_DIR}/platform/network/cf"
"${WEBCORE_DIR}/platform/network/mac"
@@ -497,6 +498,8 @@ list(APPEND WebCore_SOURCES
platform/mac/WebWindowAnimation.mm
platform/mac/WidgetMac.mm

platform/mediastream/mac/MockRealtimeVideoSourceMac.mm

platform/network/cf/AuthenticationCF.cpp
platform/network/cf/CookieJarCFNet.cpp
platform/network/cf/CookieStorageCFNet.cpp

0 comments on commit c6d3e7d

Please sign in to comment.