haikuwebkit/Source/WebCore/platform/OrientationNotifier.h

106 lines
3.1 KiB
C
Raw Permalink Normal View History

getUserMedia video streams should follow device orientation https://bugs.webkit.org/show_bug.cgi?id=171284 Patch by Youenn Fablet <youenn@apple.com> on 2017-04-28 Reviewed by Eric Carlson. Source/WebCore: Only really affects AVVideoCaptureSource on iOS. Manually testing the following cases: - Mac: no change of behavior - iOS: page loaded in portrait, video is portrait. page loaded in landscape, video is landscape - iOS: changing the device orientation makes the video samples to be moved to landscape/portrait. - Same tests as above with peer connection. Making Document having an OrientationNotifier that AVVideoCaptureSources get registered to. Making AVVideoCaptureSource an OrientationNotifier::Observer so that it can changes width/height if needed. Refactoring to specialize CaptureFactory in VideoCaptureFactory and AudioCaptureFactory. Refactoring to return a CaptureSourceOrError instead of passing an out parameter plus returning a RefPtr. * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::allow): * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::orientationChanged): * dom/Document.h: * page/Frame.cpp: (WebCore::Frame::orientationChanged): * platform/OrientationNotifer.h: Copied from Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h. (WebCore::OrientationNotifier::Observer::setNotifier): (WebCore::OrientationNotifier::Observer::~Observer): (WebCore::OrientationNotifier::orientationChanged): (WebCore::OrientationNotifier::addObserver): (WebCore::OrientationNotifier::removeObserver): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::monitorOrientation): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/RealtimeMediaSource.h: (WebCore::CaptureSourceOrError::CaptureSourceOrError): (WebCore::CaptureSourceOrError::operator bool): (WebCore::CaptureSourceOrError::source): * platform/mediastream/RealtimeMediaSourceCenter.cpp: (WebCore::RealtimeMediaSourceCenter::setAudioFactory): (WebCore::RealtimeMediaSourceCenter::unsetAudioFactory): (WebCore::RealtimeMediaSourceCenter::setVideoFactory): (WebCore::RealtimeMediaSourceCenter::unsetVideoFactory): * platform/mediastream/RealtimeMediaSourceCenter.h: (WebCore::RealtimeMediaSourceCenter::defaultAudioFactory): (WebCore::RealtimeMediaSourceCenter::defaultVideoFactory): (WebCore::RealtimeMediaSourceCenter::audioFactory): (WebCore::RealtimeMediaSourceCenter::videoFactory): * platform/mediastream/mac/AVAudioCaptureSource.h: * platform/mediastream/mac/AVAudioCaptureSource.mm: (WebCore::AVAudioCaptureSource::create): (WebCore::AVAudioCaptureSource::factory): * platform/mediastream/mac/AVVideoCaptureSource.h: * platform/mediastream/mac/AVVideoCaptureSource.mm: (WebCore::AVVideoCaptureSource::create): (WebCore::AVVideoCaptureSource::factory): (WebCore::AVVideoCaptureSource::monitorOrientation): (WebCore::AVVideoCaptureSource::orientationChanged): (WebCore::AVVideoCaptureSource::processNewFrame): * platform/mediastream/mac/CoreAudioCaptureSource.cpp: (WebCore::CoreAudioCaptureSource::create): (WebCore::CoreAudioCaptureSource::factory): * platform/mediastream/mac/CoreAudioCaptureSource.h: * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm: (WebCore::MockRealtimeAudioSource::create): * platform/mediastream/mac/MockRealtimeVideoSourceMac.h: * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm: (WebCore::MockRealtimeVideoSource::create): (WebCore::MockRealtimeVideoSourceMac::orientationChanged): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: (WebCore::RealtimeMediaSourceCenterMac::createMediaStream): (WebCore::RealtimeMediaSourceCenterMac::bestSourcesForTypeAndConstraints): (WebCore::RealtimeMediaSourceCenterMac::defaultAudioFactory): (WebCore::RealtimeMediaSourceCenterMac::defaultVideoFactory): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.h: * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp: (WebCore::RealtimeMediaSourceCenterOwr::createMediaStream): * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.h: * platform/mock/MockRealtimeAudioSource.cpp: (WebCore::MockRealtimeAudioSource::create): (WebCore::MockRealtimeAudioSource::factory): * platform/mock/MockRealtimeAudioSource.h: * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::validateRequestConstraints): (WebCore::MockRealtimeMediaSourceCenter::createMediaStream): (WebCore::MockRealtimeMediaSourceCenter::defaultAudioFactory): (WebCore::MockRealtimeMediaSourceCenter::defaultVideoFactory): * platform/mock/MockRealtimeMediaSourceCenter.h: * platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::create): (WebCore::MockRealtimeVideoSource::factory): * platform/mock/MockRealtimeVideoSource.h: Source/WebKit2: Refactoring to specialize CaptureFactory in VideoCaptureFactory and AudioCaptureFactory. Refactoring to return a CaptureSourceOrError instead of passing an out parameter in addition to returning a RefPtr. * Shared/WebCoreArgumentCoders.h: * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: (WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints): * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h: * UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in: * WebProcess/cocoa/UserMediaCaptureManager.cpp: (WebKit::UserMediaCaptureManager::createCaptureSource): (WebKit::UserMediaCaptureManager::createMediaSourceForCaptureDeviceWithConstraints): Deleted. * WebProcess/cocoa/UserMediaCaptureManager.h: Canonical link: https://commits.webkit.org/188348@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215955 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-28 23:26:31 +00:00
/*
* Copyright (C) 2017 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
*/
#pragma once
[MediaStream] Remove AVMediaCaptureSource https://bugs.webkit.org/show_bug.cgi?id=189159 Reviewed by Youenn Fablet. No new tests, no change in functionality. Refactor video capture to get rid of a base class we don't need any more. * WebCore.xcodeproj/project.pbxproj: * platform/mediastream/mac/AVMediaCaptureSource.h: Removed. * platform/mediastream/mac/AVMediaCaptureSource.mm: Removed. * platform/mediastream/mac/AVVideoCaptureSource.h: (WebCore::AVVideoCaptureSource::session const): (WebCore::AVVideoCaptureSource::device const): * platform/mediastream/mac/AVVideoCaptureSource.mm: (WebCore::globaVideoCaptureSerialQueue): (WebCore::AVVideoCaptureSource::AVVideoCaptureSource): (WebCore::AVVideoCaptureSource::~AVVideoCaptureSource): (WebCore::AVVideoCaptureSource::startProducingData): (WebCore::AVVideoCaptureSource::stopProducingData): (WebCore::AVVideoCaptureSource::beginConfiguration): (WebCore::AVVideoCaptureSource::commitConfiguration): (WebCore::AVVideoCaptureSource::settingsDidChange): (WebCore::AVVideoCaptureSource::settings const): (WebCore::AVVideoCaptureSource::capabilities const): (WebCore::AVVideoCaptureSource::setPreset): (WebCore::AVVideoCaptureSource::setupSession): (WebCore::AVVideoCaptureSource::setupCaptureSession): (WebCore::AVVideoCaptureSource::captureSessionIsRunningDidChange): (WebCore::AVVideoCaptureSource::interrupted const): (WebCore::AVVideoCaptureSource::captureSessionRuntimeError): (WebCore::AVVideoCaptureSource::captureSessionBeginInterruption): (WebCore::AVVideoCaptureSource::captureSessionEndInterruption): (-[WebCoreAVVideoCaptureSourceObserver initWithCallback:]): (-[WebCoreAVVideoCaptureSourceObserver disconnect]): (-[WebCoreAVVideoCaptureSourceObserver addNotificationObservers]): (-[WebCoreAVVideoCaptureSourceObserver removeNotificationObservers]): (-[WebCoreAVVideoCaptureSourceObserver captureOutput:didOutputSampleBuffer:fromConnection:]): (-[WebCoreAVVideoCaptureSourceObserver observeValueForKeyPath:ofObject:change:context:]): (-[WebCoreAVVideoCaptureSourceObserver sessionRuntimeError:]): (-[WebCoreAVVideoCaptureSourceObserver beginSessionInterrupted:]): (-[WebCoreAVVideoCaptureSourceObserver endSessionInterrupted:]): (WebCore::AVVideoCaptureSource::initializeCapabilities): Deleted. (WebCore::AVVideoCaptureSource::initializeSupportedConstraints): Deleted. (WebCore::AVVideoCaptureSource::updateSettings): Deleted. Canonical link: https://commits.webkit.org/204198@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235549 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-08-31 12:43:31 +00:00
#include <wtf/Vector.h>
getUserMedia video streams should follow device orientation https://bugs.webkit.org/show_bug.cgi?id=171284 Patch by Youenn Fablet <youenn@apple.com> on 2017-04-28 Reviewed by Eric Carlson. Source/WebCore: Only really affects AVVideoCaptureSource on iOS. Manually testing the following cases: - Mac: no change of behavior - iOS: page loaded in portrait, video is portrait. page loaded in landscape, video is landscape - iOS: changing the device orientation makes the video samples to be moved to landscape/portrait. - Same tests as above with peer connection. Making Document having an OrientationNotifier that AVVideoCaptureSources get registered to. Making AVVideoCaptureSource an OrientationNotifier::Observer so that it can changes width/height if needed. Refactoring to specialize CaptureFactory in VideoCaptureFactory and AudioCaptureFactory. Refactoring to return a CaptureSourceOrError instead of passing an out parameter plus returning a RefPtr. * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::allow): * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::orientationChanged): * dom/Document.h: * page/Frame.cpp: (WebCore::Frame::orientationChanged): * platform/OrientationNotifer.h: Copied from Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h. (WebCore::OrientationNotifier::Observer::setNotifier): (WebCore::OrientationNotifier::Observer::~Observer): (WebCore::OrientationNotifier::orientationChanged): (WebCore::OrientationNotifier::addObserver): (WebCore::OrientationNotifier::removeObserver): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::monitorOrientation): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/RealtimeMediaSource.h: (WebCore::CaptureSourceOrError::CaptureSourceOrError): (WebCore::CaptureSourceOrError::operator bool): (WebCore::CaptureSourceOrError::source): * platform/mediastream/RealtimeMediaSourceCenter.cpp: (WebCore::RealtimeMediaSourceCenter::setAudioFactory): (WebCore::RealtimeMediaSourceCenter::unsetAudioFactory): (WebCore::RealtimeMediaSourceCenter::setVideoFactory): (WebCore::RealtimeMediaSourceCenter::unsetVideoFactory): * platform/mediastream/RealtimeMediaSourceCenter.h: (WebCore::RealtimeMediaSourceCenter::defaultAudioFactory): (WebCore::RealtimeMediaSourceCenter::defaultVideoFactory): (WebCore::RealtimeMediaSourceCenter::audioFactory): (WebCore::RealtimeMediaSourceCenter::videoFactory): * platform/mediastream/mac/AVAudioCaptureSource.h: * platform/mediastream/mac/AVAudioCaptureSource.mm: (WebCore::AVAudioCaptureSource::create): (WebCore::AVAudioCaptureSource::factory): * platform/mediastream/mac/AVVideoCaptureSource.h: * platform/mediastream/mac/AVVideoCaptureSource.mm: (WebCore::AVVideoCaptureSource::create): (WebCore::AVVideoCaptureSource::factory): (WebCore::AVVideoCaptureSource::monitorOrientation): (WebCore::AVVideoCaptureSource::orientationChanged): (WebCore::AVVideoCaptureSource::processNewFrame): * platform/mediastream/mac/CoreAudioCaptureSource.cpp: (WebCore::CoreAudioCaptureSource::create): (WebCore::CoreAudioCaptureSource::factory): * platform/mediastream/mac/CoreAudioCaptureSource.h: * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm: (WebCore::MockRealtimeAudioSource::create): * platform/mediastream/mac/MockRealtimeVideoSourceMac.h: * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm: (WebCore::MockRealtimeVideoSource::create): (WebCore::MockRealtimeVideoSourceMac::orientationChanged): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: (WebCore::RealtimeMediaSourceCenterMac::createMediaStream): (WebCore::RealtimeMediaSourceCenterMac::bestSourcesForTypeAndConstraints): (WebCore::RealtimeMediaSourceCenterMac::defaultAudioFactory): (WebCore::RealtimeMediaSourceCenterMac::defaultVideoFactory): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.h: * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp: (WebCore::RealtimeMediaSourceCenterOwr::createMediaStream): * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.h: * platform/mock/MockRealtimeAudioSource.cpp: (WebCore::MockRealtimeAudioSource::create): (WebCore::MockRealtimeAudioSource::factory): * platform/mock/MockRealtimeAudioSource.h: * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::validateRequestConstraints): (WebCore::MockRealtimeMediaSourceCenter::createMediaStream): (WebCore::MockRealtimeMediaSourceCenter::defaultAudioFactory): (WebCore::MockRealtimeMediaSourceCenter::defaultVideoFactory): * platform/mock/MockRealtimeMediaSourceCenter.h: * platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::create): (WebCore::MockRealtimeVideoSource::factory): * platform/mock/MockRealtimeVideoSource.h: Source/WebKit2: Refactoring to specialize CaptureFactory in VideoCaptureFactory and AudioCaptureFactory. Refactoring to return a CaptureSourceOrError instead of passing an out parameter in addition to returning a RefPtr. * Shared/WebCoreArgumentCoders.h: * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: (WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints): * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h: * UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in: * WebProcess/cocoa/UserMediaCaptureManager.cpp: (WebKit::UserMediaCaptureManager::createCaptureSource): (WebKit::UserMediaCaptureManager::createMediaSourceForCaptureDeviceWithConstraints): Deleted. * WebProcess/cocoa/UserMediaCaptureManager.h: Canonical link: https://commits.webkit.org/188348@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215955 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-28 23:26:31 +00:00
namespace WebCore {
class OrientationNotifier {
public:
explicit OrientationNotifier(int orientation) { m_orientation = orientation; }
~OrientationNotifier();
void orientationChanged(int orientation);
class Observer {
public:
virtual ~Observer();
virtual void orientationChanged(int orientation) = 0;
void setNotifier(OrientationNotifier*);
getUserMedia video streams should follow device orientation https://bugs.webkit.org/show_bug.cgi?id=171284 Patch by Youenn Fablet <youenn@apple.com> on 2017-04-28 Reviewed by Eric Carlson. Source/WebCore: Only really affects AVVideoCaptureSource on iOS. Manually testing the following cases: - Mac: no change of behavior - iOS: page loaded in portrait, video is portrait. page loaded in landscape, video is landscape - iOS: changing the device orientation makes the video samples to be moved to landscape/portrait. - Same tests as above with peer connection. Making Document having an OrientationNotifier that AVVideoCaptureSources get registered to. Making AVVideoCaptureSource an OrientationNotifier::Observer so that it can changes width/height if needed. Refactoring to specialize CaptureFactory in VideoCaptureFactory and AudioCaptureFactory. Refactoring to return a CaptureSourceOrError instead of passing an out parameter plus returning a RefPtr. * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::allow): * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::orientationChanged): * dom/Document.h: * page/Frame.cpp: (WebCore::Frame::orientationChanged): * platform/OrientationNotifer.h: Copied from Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h. (WebCore::OrientationNotifier::Observer::setNotifier): (WebCore::OrientationNotifier::Observer::~Observer): (WebCore::OrientationNotifier::orientationChanged): (WebCore::OrientationNotifier::addObserver): (WebCore::OrientationNotifier::removeObserver): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::monitorOrientation): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/RealtimeMediaSource.h: (WebCore::CaptureSourceOrError::CaptureSourceOrError): (WebCore::CaptureSourceOrError::operator bool): (WebCore::CaptureSourceOrError::source): * platform/mediastream/RealtimeMediaSourceCenter.cpp: (WebCore::RealtimeMediaSourceCenter::setAudioFactory): (WebCore::RealtimeMediaSourceCenter::unsetAudioFactory): (WebCore::RealtimeMediaSourceCenter::setVideoFactory): (WebCore::RealtimeMediaSourceCenter::unsetVideoFactory): * platform/mediastream/RealtimeMediaSourceCenter.h: (WebCore::RealtimeMediaSourceCenter::defaultAudioFactory): (WebCore::RealtimeMediaSourceCenter::defaultVideoFactory): (WebCore::RealtimeMediaSourceCenter::audioFactory): (WebCore::RealtimeMediaSourceCenter::videoFactory): * platform/mediastream/mac/AVAudioCaptureSource.h: * platform/mediastream/mac/AVAudioCaptureSource.mm: (WebCore::AVAudioCaptureSource::create): (WebCore::AVAudioCaptureSource::factory): * platform/mediastream/mac/AVVideoCaptureSource.h: * platform/mediastream/mac/AVVideoCaptureSource.mm: (WebCore::AVVideoCaptureSource::create): (WebCore::AVVideoCaptureSource::factory): (WebCore::AVVideoCaptureSource::monitorOrientation): (WebCore::AVVideoCaptureSource::orientationChanged): (WebCore::AVVideoCaptureSource::processNewFrame): * platform/mediastream/mac/CoreAudioCaptureSource.cpp: (WebCore::CoreAudioCaptureSource::create): (WebCore::CoreAudioCaptureSource::factory): * platform/mediastream/mac/CoreAudioCaptureSource.h: * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm: (WebCore::MockRealtimeAudioSource::create): * platform/mediastream/mac/MockRealtimeVideoSourceMac.h: * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm: (WebCore::MockRealtimeVideoSource::create): (WebCore::MockRealtimeVideoSourceMac::orientationChanged): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: (WebCore::RealtimeMediaSourceCenterMac::createMediaStream): (WebCore::RealtimeMediaSourceCenterMac::bestSourcesForTypeAndConstraints): (WebCore::RealtimeMediaSourceCenterMac::defaultAudioFactory): (WebCore::RealtimeMediaSourceCenterMac::defaultVideoFactory): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.h: * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp: (WebCore::RealtimeMediaSourceCenterOwr::createMediaStream): * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.h: * platform/mock/MockRealtimeAudioSource.cpp: (WebCore::MockRealtimeAudioSource::create): (WebCore::MockRealtimeAudioSource::factory): * platform/mock/MockRealtimeAudioSource.h: * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::validateRequestConstraints): (WebCore::MockRealtimeMediaSourceCenter::createMediaStream): (WebCore::MockRealtimeMediaSourceCenter::defaultAudioFactory): (WebCore::MockRealtimeMediaSourceCenter::defaultVideoFactory): * platform/mock/MockRealtimeMediaSourceCenter.h: * platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::create): (WebCore::MockRealtimeVideoSource::factory): * platform/mock/MockRealtimeVideoSource.h: Source/WebKit2: Refactoring to specialize CaptureFactory in VideoCaptureFactory and AudioCaptureFactory. Refactoring to return a CaptureSourceOrError instead of passing an out parameter in addition to returning a RefPtr. * Shared/WebCoreArgumentCoders.h: * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: (WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints): * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h: * UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in: * WebProcess/cocoa/UserMediaCaptureManager.cpp: (WebKit::UserMediaCaptureManager::createCaptureSource): (WebKit::UserMediaCaptureManager::createMediaSourceForCaptureDeviceWithConstraints): Deleted. * WebProcess/cocoa/UserMediaCaptureManager.h: Canonical link: https://commits.webkit.org/188348@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215955 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-28 23:26:31 +00:00
private:
OrientationNotifier* m_notifier { nullptr };
};
void addObserver(Observer&);
void removeObserver(Observer&);
int orientation() const { return m_orientation; }
private:
Vector<std::reference_wrapper<Observer>> m_observers;
int m_orientation;
};
inline OrientationNotifier::~OrientationNotifier()
{
for (Observer& observer : m_observers)
observer.setNotifier(nullptr);
}
inline OrientationNotifier::Observer::~Observer()
{
if (m_notifier)
m_notifier->removeObserver(*this);
}
inline void OrientationNotifier::Observer::setNotifier(OrientationNotifier* notifier)
{
if (m_notifier == notifier)
return;
if (m_notifier && notifier)
m_notifier->removeObserver(*this);
ASSERT(!m_notifier || !notifier);
m_notifier = notifier;
}
getUserMedia video streams should follow device orientation https://bugs.webkit.org/show_bug.cgi?id=171284 Patch by Youenn Fablet <youenn@apple.com> on 2017-04-28 Reviewed by Eric Carlson. Source/WebCore: Only really affects AVVideoCaptureSource on iOS. Manually testing the following cases: - Mac: no change of behavior - iOS: page loaded in portrait, video is portrait. page loaded in landscape, video is landscape - iOS: changing the device orientation makes the video samples to be moved to landscape/portrait. - Same tests as above with peer connection. Making Document having an OrientationNotifier that AVVideoCaptureSources get registered to. Making AVVideoCaptureSource an OrientationNotifier::Observer so that it can changes width/height if needed. Refactoring to specialize CaptureFactory in VideoCaptureFactory and AudioCaptureFactory. Refactoring to return a CaptureSourceOrError instead of passing an out parameter plus returning a RefPtr. * Modules/mediastream/UserMediaRequest.cpp: (WebCore::UserMediaRequest::allow): * WebCore.xcodeproj/project.pbxproj: * dom/Document.cpp: (WebCore::Document::orientationChanged): * dom/Document.h: * page/Frame.cpp: (WebCore::Frame::orientationChanged): * platform/OrientationNotifer.h: Copied from Source/WebKit2/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h. (WebCore::OrientationNotifier::Observer::setNotifier): (WebCore::OrientationNotifier::Observer::~Observer): (WebCore::OrientationNotifier::orientationChanged): (WebCore::OrientationNotifier::addObserver): (WebCore::OrientationNotifier::removeObserver): * platform/mediastream/MediaStreamPrivate.cpp: (WebCore::MediaStreamPrivate::monitorOrientation): * platform/mediastream/MediaStreamPrivate.h: * platform/mediastream/RealtimeMediaSource.h: (WebCore::CaptureSourceOrError::CaptureSourceOrError): (WebCore::CaptureSourceOrError::operator bool): (WebCore::CaptureSourceOrError::source): * platform/mediastream/RealtimeMediaSourceCenter.cpp: (WebCore::RealtimeMediaSourceCenter::setAudioFactory): (WebCore::RealtimeMediaSourceCenter::unsetAudioFactory): (WebCore::RealtimeMediaSourceCenter::setVideoFactory): (WebCore::RealtimeMediaSourceCenter::unsetVideoFactory): * platform/mediastream/RealtimeMediaSourceCenter.h: (WebCore::RealtimeMediaSourceCenter::defaultAudioFactory): (WebCore::RealtimeMediaSourceCenter::defaultVideoFactory): (WebCore::RealtimeMediaSourceCenter::audioFactory): (WebCore::RealtimeMediaSourceCenter::videoFactory): * platform/mediastream/mac/AVAudioCaptureSource.h: * platform/mediastream/mac/AVAudioCaptureSource.mm: (WebCore::AVAudioCaptureSource::create): (WebCore::AVAudioCaptureSource::factory): * platform/mediastream/mac/AVVideoCaptureSource.h: * platform/mediastream/mac/AVVideoCaptureSource.mm: (WebCore::AVVideoCaptureSource::create): (WebCore::AVVideoCaptureSource::factory): (WebCore::AVVideoCaptureSource::monitorOrientation): (WebCore::AVVideoCaptureSource::orientationChanged): (WebCore::AVVideoCaptureSource::processNewFrame): * platform/mediastream/mac/CoreAudioCaptureSource.cpp: (WebCore::CoreAudioCaptureSource::create): (WebCore::CoreAudioCaptureSource::factory): * platform/mediastream/mac/CoreAudioCaptureSource.h: * platform/mediastream/mac/MockRealtimeAudioSourceMac.mm: (WebCore::MockRealtimeAudioSource::create): * platform/mediastream/mac/MockRealtimeVideoSourceMac.h: * platform/mediastream/mac/MockRealtimeVideoSourceMac.mm: (WebCore::MockRealtimeVideoSource::create): (WebCore::MockRealtimeVideoSourceMac::orientationChanged): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.cpp: (WebCore::RealtimeMediaSourceCenterMac::createMediaStream): (WebCore::RealtimeMediaSourceCenterMac::bestSourcesForTypeAndConstraints): (WebCore::RealtimeMediaSourceCenterMac::defaultAudioFactory): (WebCore::RealtimeMediaSourceCenterMac::defaultVideoFactory): * platform/mediastream/mac/RealtimeMediaSourceCenterMac.h: * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.cpp: (WebCore::RealtimeMediaSourceCenterOwr::createMediaStream): * platform/mediastream/openwebrtc/RealtimeMediaSourceCenterOwr.h: * platform/mock/MockRealtimeAudioSource.cpp: (WebCore::MockRealtimeAudioSource::create): (WebCore::MockRealtimeAudioSource::factory): * platform/mock/MockRealtimeAudioSource.h: * platform/mock/MockRealtimeMediaSourceCenter.cpp: (WebCore::MockRealtimeMediaSourceCenter::validateRequestConstraints): (WebCore::MockRealtimeMediaSourceCenter::createMediaStream): (WebCore::MockRealtimeMediaSourceCenter::defaultAudioFactory): (WebCore::MockRealtimeMediaSourceCenter::defaultVideoFactory): * platform/mock/MockRealtimeMediaSourceCenter.h: * platform/mock/MockRealtimeVideoSource.cpp: (WebCore::MockRealtimeVideoSource::create): (WebCore::MockRealtimeVideoSource::factory): * platform/mock/MockRealtimeVideoSource.h: Source/WebKit2: Refactoring to specialize CaptureFactory in VideoCaptureFactory and AudioCaptureFactory. Refactoring to return a CaptureSourceOrError instead of passing an out parameter in addition to returning a RefPtr. * Shared/WebCoreArgumentCoders.h: * UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp: (WebKit::UserMediaCaptureManagerProxy::createMediaSourceForCaptureDeviceWithConstraints): * UIProcess/Cocoa/UserMediaCaptureManagerProxy.h: * UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in: * WebProcess/cocoa/UserMediaCaptureManager.cpp: (WebKit::UserMediaCaptureManager::createCaptureSource): (WebKit::UserMediaCaptureManager::createMediaSourceForCaptureDeviceWithConstraints): Deleted. * WebProcess/cocoa/UserMediaCaptureManager.h: Canonical link: https://commits.webkit.org/188348@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@215955 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-04-28 23:26:31 +00:00
inline void OrientationNotifier::orientationChanged(int orientation)
{
m_orientation = orientation;
for (Observer& observer : m_observers)
observer.orientationChanged(orientation);
}
inline void OrientationNotifier::addObserver(Observer& observer)
{
m_observers.append(observer);
observer.setNotifier(this);
}
inline void OrientationNotifier::removeObserver(Observer& observer)
{
m_observers.removeFirstMatching([&observer](auto item) {
if (&observer != &item.get())
return false;
observer.setNotifier(nullptr);
return true;
});
}
}