Unreviewed, reverting r258391.
authorryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Mar 2020 20:22:17 +0000 (20:22 +0000)
committerryanhaddad@apple.com <ryanhaddad@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 Mar 2020 20:22:17 +0000 (20:22 +0000)
Breaks internal builds.

Reverted changeset:

"Apply rotation at source level if WebRTC sink ask so"
https://bugs.webkit.org/show_bug.cgi?id=205645
https://trac.webkit.org/changeset/258391

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258424 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
LayoutTests/ChangeLog
LayoutTests/webrtc/video-rotation-no-cvo-expected.txt [deleted file]
LayoutTests/webrtc/video-rotation-no-cvo.html [deleted file]
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/platform/graphics/cv/ImageRotationSessionVT.h
Source/WebCore/platform/graphics/cv/ImageRotationSessionVT.mm
Source/WebCore/platform/mediastream/RealtimeMediaSource.h
Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.cpp
Source/WebCore/platform/mediastream/RealtimeOutgoingVideoSource.h
Source/WebKit/ChangeLog
Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.cpp
Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.h
Source/WebKit/UIProcess/Cocoa/UserMediaCaptureManagerProxy.messages.in
Source/WebKit/WebProcess/cocoa/UserMediaCaptureManager.cpp

index 6161719..ea2e4c1 100644 (file)
@@ -1,3 +1,15 @@
+2020-03-13  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, reverting r258391.
+
+        Breaks internal builds.
+
+        Reverted changeset:
+
+        "Apply rotation at source level if WebRTC sink ask so"
+        https://bugs.webkit.org/show_bug.cgi?id=205645
+        https://trac.webkit.org/changeset/258391
+
 2020-03-13  Chris Dumez  <cdumez@apple.com>
 
         [Mac wk2 ] fast/dom/attr_dead_doc.html is flaky failing.
diff --git a/LayoutTests/webrtc/video-rotation-no-cvo-expected.txt b/LayoutTests/webrtc/video-rotation-no-cvo-expected.txt
deleted file mode 100644 (file)
index d29e8ba..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-  
-
-PASS Testing video exchange with rotation applied before transmission 
-
diff --git a/LayoutTests/webrtc/video-rotation-no-cvo.html b/LayoutTests/webrtc/video-rotation-no-cvo.html
deleted file mode 100644 (file)
index d4d97f1..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-<!-- webkit-test-runner [ enableCaptureVideoInUIProcess=true ] -->
-<!doctype html>
-<html>
-    <head>
-        <meta charset="utf-8">
-        <title>Testing video rotation without CVO</title>
-        <script src="../resources/testharness.js"></script>
-        <script src="../resources/testharnessreport.js"></script>
-    </head>
-    <body>
-        <video id="localVideo" autoplay playsInline width="320" height="240"></video>
-        <video id="remoteVideo" autoplay playsInline width="320" height="240"></video>
-        <script src ="routines.js"></script>
-        <script>
-promise_test(async (test) => {
-    const localStream = await navigator.mediaDevices.getUserMedia({ video: { width: 320, height: 240 } });
-    if (window.testRunner)
-        window.testRunner.setMockCameraOrientation(90);
-
-    localVideo.srcObject = localStream;
-    const remoteStream = await new Promise((resolve, reject) => {
-        track = localStream.getVideoTracks()[0];
-
-        createConnections((firstConnection) => {
-            firstConnection.addTrack(track, localStream);
-            if (window.internals)
-                internals.applyRotationForOutgoingVideoSources(firstConnection);
-        }, (secondConnection) => {
-            secondConnection.ontrack = (trackEvent) => {
-                resolve(trackEvent.streams[0]);
-            };
-        });
-        setTimeout(() => reject("Test timed out"), 5000);
-    });
-
-    remoteVideo.srcObject = remoteStream;
-    await remoteVideo.play();
-    await waitForVideoSize(remoteVideo, 240, 320);
-}, "Testing video exchange with rotation applied before transmission");
-        </script>
-    </body>
-</html>
index ff7cc13..be5eea9 100644 (file)
@@ -1,3 +1,15 @@
+2020-03-13  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, reverting r258391.
+
+        Breaks internal builds.
+
+        Reverted changeset:
+
+        "Apply rotation at source level if WebRTC sink ask so"
+        https://bugs.webkit.org/show_bug.cgi?id=205645
+        https://trac.webkit.org/changeset/258391
+
 2020-03-13  Kate Cheney  <katherine_cheney@apple.com>
 
         Report all third party loads on a per-page basis
index bf73a0a..f0ec3a9 100644 (file)
@@ -513,7 +513,7 @@ void LibWebRTCPeerConnectionBackend::applyRotationForOutgoingVideoSources()
     for (auto& transceiver : m_peerConnection.currentTransceivers()) {
         if (!transceiver->sender().isStopped()) {
             if (auto* videoSource = backendFromRTPSender(transceiver->sender()).videoSource())
-                videoSource->applyRotation();
+                videoSource->setApplyRotation(true);
         }
     }
 }
index b8475f3..6e1971b 100644 (file)
                CD1E7347167BC78E009A885D /* TextTrackRepresentation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD1E7346167BC78E009A885D /* TextTrackRepresentation.cpp */; };
                CD225C0B1C46FBF400140761 /* WebCoreNSURLSession.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD225C091C46FBF400140761 /* WebCoreNSURLSession.mm */; };
                CD225C0C1C46FBF400140761 /* WebCoreNSURLSession.h in Headers */ = {isa = PBXBuildFile; fileRef = CD225C0A1C46FBF400140761 /* WebCoreNSURLSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               CD27AE5022A9868700947FF9 /* ImageRotationSessionVT.h in Headers */ = {isa = PBXBuildFile; fileRef = CD27AE4E22A9868700947FF9 /* ImageRotationSessionVT.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               CD27AE5022A9868700947FF9 /* ImageRotationSessionVT.h in Headers */ = {isa = PBXBuildFile; fileRef = CD27AE4E22A9868700947FF9 /* ImageRotationSessionVT.h */; };
                CD27AE5122A9868700947FF9 /* ImageRotationSessionVT.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD27AE4F22A9868700947FF9 /* ImageRotationSessionVT.mm */; };
                CD2F4A2418D89F700063746D /* AudioHardwareListener.h in Headers */ = {isa = PBXBuildFile; fileRef = CD2F4A2218D89F700063746D /* AudioHardwareListener.h */; settings = {ATTRIBUTES = (Private, ); }; };
                CD2F4A2818D8A3490063746D /* AudioHardwareListenerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = CD2F4A2618D8A3490063746D /* AudioHardwareListenerMac.h */; };
index 2ddf496..6001bb7 100644 (file)
@@ -36,8 +36,6 @@ typedef struct __CVPixelBufferPool* CVPixelBufferPoolRef;
 
 namespace WebCore {
 
-class MediaSample;
-
 class ImageRotationSessionVT final {
     WTF_MAKE_FAST_ALLOCATED;
 public:
@@ -54,9 +52,8 @@ public:
         Yes,
     };
 
-    ImageRotationSessionVT(AffineTransform&&, FloatSize, OSType, IsCGImageCompatible);
-    ImageRotationSessionVT(const RotationProperties&, FloatSize, OSType, IsCGImageCompatible);
-    ImageRotationSessionVT() = default;
+    ImageRotationSessionVT(AffineTransform&&, FloatSize, OSType pixelFormat, IsCGImageCompatible);
+    ImageRotationSessionVT(RotationProperties&&, FloatSize, OSType pixelFormat, IsCGImageCompatible);
 
     const Optional<AffineTransform>& transform() const { return m_transform; }
     const RotationProperties& rotationProperties() const { return m_rotationProperties; }
@@ -64,13 +61,8 @@ public:
     const FloatSize& rotatedSize() { return m_rotatedSize; }
 
     RetainPtr<CVPixelBufferRef> rotate(CVPixelBufferRef);
-    WEBCORE_EXPORT RetainPtr<CVPixelBufferRef> rotate(MediaSample&, const RotationProperties&, IsCGImageCompatible);
-
-    bool isMatching(MediaSample&, const RotationProperties&);
 
 private:
-    void initialize(const RotationProperties&, FloatSize, OSType pixelFormat, IsCGImageCompatible);
-
     Optional<AffineTransform> m_transform;
     RotationProperties m_rotationProperties;
     FloatSize m_size;
@@ -79,16 +71,6 @@ private:
     RetainPtr<CVPixelBufferPoolRef> m_rotationPool;
 };
 
-inline bool operator==(const ImageRotationSessionVT::RotationProperties& rotation1, const ImageRotationSessionVT::RotationProperties& rotation2)
-{
-    return rotation1.flipX == rotation2.flipX && rotation1.flipY == rotation2.flipY && rotation1.angle == rotation2.angle;
-}
-
-inline bool operator!=(const ImageRotationSessionVT::RotationProperties& rotation1, const ImageRotationSessionVT::RotationProperties& rotation2)
-{
-    return !(rotation1 == rotation2);
-}
-
 }
 
 #endif
index 47dbecd..88a5db5 100644 (file)
@@ -27,7 +27,6 @@
 #include "ImageRotationSessionVT.h"
 
 #include "AffineTransform.h"
-#include "MediaSample.h"
 
 #include "CoreVideoSoftLink.h"
 #include "VideoToolboxSoftLink.h"
@@ -65,16 +64,11 @@ ImageRotationSessionVT::ImageRotationSessionVT(AffineTransform&& transform, Floa
     m_transform = WTFMove(transform);
 }
 
-ImageRotationSessionVT::ImageRotationSessionVT(const RotationProperties& rotation, FloatSize size, OSType pixelFormat, IsCGImageCompatible cvImageCompatibility)
-{
-    initialize(rotation, size, pixelFormat, cvImageCompatibility);
-}
 
-void ImageRotationSessionVT::initialize(const RotationProperties& rotation, FloatSize size, OSType pixelFormat, IsCGImageCompatible cvImageCompatibility)
+ImageRotationSessionVT::ImageRotationSessionVT(RotationProperties&& rotation, FloatSize size, OSType pixelFormat, IsCGImageCompatible cvImageCompatibility)
+    : m_rotationProperties(WTFMove(rotation))
+    , m_size(size)
 {
-    m_rotationProperties = rotation;
-    m_size = size;
-
     if (m_rotationProperties.angle == 90 || m_rotationProperties.angle == 270)
         size = size.transposedSize();
 
@@ -95,7 +89,6 @@ void ImageRotationSessionVT::initialize(const RotationProperties& rotation, Floa
         (__bridge NSString *)kCVPixelBufferHeightKey: @(m_rotatedSize.height()),
         (__bridge NSString *)kCVPixelBufferPixelFormatTypeKey: @(pixelFormat),
         (__bridge NSString *)kCVPixelBufferCGImageCompatibilityKey: (cvImageCompatibility == IsCGImageCompatible::Yes ? @YES : @NO),
-        (__bridge NSString *)kCVPixelBufferIOSurfacePropertiesKey : @{ }
     };
     CVPixelBufferPoolRef rawPool = nullptr;
     if (auto err = CVPixelBufferPoolCreate(kCFAllocatorDefault, nullptr, (__bridge CFDictionaryRef)pixelAttributes, &rawPool); err != noErr)
@@ -113,20 +106,6 @@ RetainPtr<CVPixelBufferRef> ImageRotationSessionVT::rotate(CVPixelBufferRef pixe
     return nullptr;
 }
 
-RetainPtr<CVPixelBufferRef> ImageRotationSessionVT::rotate(MediaSample& sample, const RotationProperties& rotation, IsCGImageCompatible cvImageCompatibility)
-{
-    auto pixelBuffer = static_cast<CVPixelBufferRef>(CMSampleBufferGetImageBuffer(sample.platformSample().sample.cmSampleBuffer));
-    ASSERT(pixelBuffer);
-    if (!pixelBuffer)
-        return nullptr;
-
-    IntSize size { (int)CVPixelBufferGetWidth(pixelBuffer), (int)CVPixelBufferGetHeight(pixelBuffer) };
-    if (rotation != m_rotationProperties || m_size != size)
-        initialize(rotation, size, CVPixelBufferGetPixelFormatType(pixelBuffer), cvImageCompatibility);
-
-    return rotate(pixelBuffer);
-}
-
 }
 
 #endif
index 1b9d6a2..39b9976 100644 (file)
@@ -200,8 +200,6 @@ public:
     virtual void delaySamples(Seconds) { };
     void setInterruptedForTesting(bool);
 
-    virtual bool setShouldApplyRotation(bool) { return false; }
-
 protected:
     RealtimeMediaSource(Type, String&& name, String&& deviceID = { }, String&& hashSalt = { });
 
index 81c6a9a..d9a77a8 100644 (file)
@@ -80,21 +80,6 @@ void RealtimeOutgoingVideoSource::setSource(Ref<MediaStreamTrackPrivate>&& newSo
 {
     ASSERT(!m_videoSource->hasObserver(*this));
     m_videoSource = WTFMove(newSource);
-
-    if (!m_areSinksAskingToApplyRotation)
-        return;
-    if (!m_videoSource->source().setShouldApplyRotation(true))
-        m_shouldApplyRotation = true;
-}
-
-void RealtimeOutgoingVideoSource::applyRotation()
-{
-    if (m_areSinksAskingToApplyRotation)
-        return;
-
-    m_areSinksAskingToApplyRotation = true;
-    if (!m_videoSource->source().setShouldApplyRotation(true))
-        m_shouldApplyRotation = true;
 }
 
 void RealtimeOutgoingVideoSource::stop()
@@ -150,7 +135,7 @@ void RealtimeOutgoingVideoSource::AddOrUpdateSink(rtc::VideoSinkInterface<webrtc
     ASSERT(!sinkWants.black_frames);
 
     if (sinkWants.rotation_applied)
-        applyRotation();
+        m_shouldApplyRotation = true;
 
     auto locker = holdLock(m_sinksLock);
     m_sinks.add(sink);
index a6656ce..e2a48d0 100644 (file)
@@ -71,7 +71,7 @@ public:
         return rtc::RefCountReleaseStatus::kOtherRefsRemained;
     }
 
-    void applyRotation();
+    void setApplyRotation(bool shouldApplyRotation) { m_shouldApplyRotation = shouldApplyRotation; }
 
 protected:
     explicit RealtimeOutgoingVideoSource(Ref<MediaStreamTrackPrivate>&&);
@@ -134,7 +134,6 @@ private:
 
     mutable RecursiveLock m_sinksLock;
     HashSet<rtc::VideoSinkInterface<webrtc::VideoFrame>*> m_sinks;
-    bool m_areSinksAskingToApplyRotation { false };
 
     bool m_enabled { true };
     bool m_muted { false };
index c906e7f..82fcc30 100644 (file)
@@ -1,3 +1,15 @@
+2020-03-13  Ryan Haddad  <ryanhaddad@apple.com>
+
+        Unreviewed, reverting r258391.
+
+        Breaks internal builds.
+
+        Reverted changeset:
+
+        "Apply rotation at source level if WebRTC sink ask so"
+        https://bugs.webkit.org/show_bug.cgi?id=205645
+        https://trac.webkit.org/changeset/258391
+
 2020-03-13  Kate Cheney  <katherine_cheney@apple.com>
 
         Report all third party loads on a per-page basis
index 7663df5..afd1c60 100644 (file)
@@ -35,7 +35,6 @@
 #include "WebProcessProxy.h"
 #include <WebCore/AudioSession.h>
 #include <WebCore/CARingBuffer.h>
-#include <WebCore/ImageRotationSessionVT.h>
 #include <WebCore/MediaConstraints.h>
 #include <WebCore/RealtimeMediaSourceCenter.h>
 #include <WebCore/RemoteVideoSample.h>
@@ -97,8 +96,6 @@ public:
         m_source->requestToEnd(*this);
     }
 
-    void setShouldApplyRotation(bool shouldApplyRotation) { m_shouldApplyRotation = true; }
-
 private:
     void sourceStopped() final {
         if (m_source->captureDidFail()) {
@@ -138,12 +135,7 @@ private:
     void videoSampleAvailable(MediaSample& sample) final
     {
 #if HAVE(IOSURFACE)
-        std::unique_ptr<RemoteVideoSample> remoteSample;
-        if (m_shouldApplyRotation && sample.videoRotation() != MediaSample::VideoRotation::None) {
-            auto pixelBuffer = rotatePixelBuffer(sample);
-            remoteSample = RemoteVideoSample::create(pixelBuffer.get(), sample.presentationTime());
-        } else
-            remoteSample = RemoteVideoSample::create(sample);
+        auto remoteSample = RemoteVideoSample::create(sample);
         if (remoteSample)
             m_connection->send(Messages::UserMediaCaptureManager::RemoteVideoSampleAvailable(m_id, WTFMove(*remoteSample)), 0);
 #else
@@ -151,30 +143,6 @@ private:
 #endif
     }
 
-    RetainPtr<CVPixelBufferRef> rotatePixelBuffer(MediaSample& sample)
-    {
-        if (!m_rotationSession)
-            m_rotationSession = makeUnique<ImageRotationSessionVT>();
-
-        ImageRotationSessionVT::RotationProperties rotation;
-        switch (sample.videoRotation()) {
-        case MediaSample::VideoRotation::None:
-            ASSERT_NOT_REACHED();
-            rotation.angle = 0;
-            break;
-        case MediaSample::VideoRotation::UpsideDown:
-            rotation.angle = 180;
-            break;
-        case MediaSample::VideoRotation::Right:
-            rotation.angle = 90;
-            break;
-        case MediaSample::VideoRotation::Left:
-            rotation.angle = 270;
-            break;
-        }
-        return m_rotationSession->rotate(sample, rotation, ImageRotationSessionVT::IsCGImageCompatible::No);
-    }
-
     void storageChanged(SharedMemory* storage) final {
         SharedMemory::Handle handle;
         if (storage)
@@ -196,8 +164,6 @@ private:
     CAAudioStreamDescription m_description { };
     int64_t m_numberOfFrames { 0 };
     bool m_isEnded { false };
-    std::unique_ptr<ImageRotationSessionVT> m_rotationSession;
-    bool m_shouldApplyRotation { false };
 };
 
 UserMediaCaptureManagerProxy::UserMediaCaptureManagerProxy(UniqueRef<ConnectionProxy>&& connectionProxy)
@@ -312,12 +278,6 @@ void UserMediaCaptureManagerProxy::requestToEnd(RealtimeMediaSourceIdentifier so
         proxy->requestToEnd();
 }
 
-void UserMediaCaptureManagerProxy::setShouldApplyRotation(RealtimeMediaSourceIdentifier sourceID, bool shouldApplyRotation)
-{
-    if (auto* proxy = m_proxies.get(sourceID))
-        proxy->setShouldApplyRotation(shouldApplyRotation);
-}
-
 void UserMediaCaptureManagerProxy::clear()
 {
     m_proxies.clear();
index f5df4d2..79498ee 100644 (file)
@@ -79,7 +79,6 @@ private:
     void applyConstraints(WebCore::RealtimeMediaSourceIdentifier, const WebCore::MediaConstraints&);
     void clone(WebCore::RealtimeMediaSourceIdentifier clonedID, WebCore::RealtimeMediaSourceIdentifier cloneID);
     void requestToEnd(WebCore::RealtimeMediaSourceIdentifier);
-    void setShouldApplyRotation(WebCore::RealtimeMediaSourceIdentifier, bool shouldApplyRotation);
 
     class SourceProxy;
     friend class SourceProxy;
index 2571632..c4d5db6 100644 (file)
@@ -32,7 +32,6 @@ messages -> UserMediaCaptureManagerProxy NotRefCounted {
     ApplyConstraints(WebCore::RealtimeMediaSourceIdentifier id, struct WebCore::MediaConstraints constraints)
     Clone(WebCore::RealtimeMediaSourceIdentifier clonedID, WebCore::RealtimeMediaSourceIdentifier cloneID)
     RequestToEnd(WebCore::RealtimeMediaSourceIdentifier sourceID)
-    SetShouldApplyRotation(WebCore::RealtimeMediaSourceIdentifier sourceID, bool shouldApplyRotation)
 }
 
 #endif
index 052b955..bd43df5 100644 (file)
@@ -249,8 +249,6 @@ private:
     // RealtimeMediaSource
     void beginConfiguration() final { }
     void commitConfiguration() final { }
-    bool setShouldApplyRotation(bool /* shouldApplyRotation */) final;
-
 
     void applyConstraints(const WebCore::MediaConstraints&, ApplyConstraintsHandler&&) final;
 
@@ -431,12 +429,6 @@ void UserMediaCaptureManager::Source::stopProducingData()
     connection()->send(Messages::UserMediaCaptureManagerProxy::StopProducingData(m_id), 0);
 }
 
-bool UserMediaCaptureManager::Source::setShouldApplyRotation(bool shouldApplyRotation)
-{
-    connection()->send(Messages::UserMediaCaptureManagerProxy::SetShouldApplyRotation(m_id, shouldApplyRotation), 0);
-    return true;
-}
-
 const WebCore::RealtimeMediaSourceCapabilities& UserMediaCaptureManager::Source::capabilities()
 {
     return m_capabilities;