Unreviewed, rolling out r218505.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Jun 2017 21:27:05 +0000 (21:27 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 19 Jun 2017 21:27:05 +0000 (21:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173563

"It would break internal builds" (Requested by youenn on
#webkit).

Reverted changeset:

"[WebRTC] Prevent capturing at unconventional resolutions when
using the SW encoder on Mac"
https://bugs.webkit.org/show_bug.cgi?id=172602
http://trac.webkit.org/changeset/218505

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

18 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/mac/webrtc/captureCanvas-webrtc-software-encoder-expected.txt [deleted file]
LayoutTests/platform/mac/webrtc/captureCanvas-webrtc-software-encoder.html [deleted file]
LayoutTests/webrtc/captureCanvas-webrtc-expected.txt
LayoutTests/webrtc/captureCanvas-webrtc.html
LayoutTests/webrtc/routines.js
LayoutTests/webrtc/video.html
Source/ThirdParty/libwebrtc/ChangeLog
Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h
Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.mm
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/CanvasCaptureMediaStreamTrack.cpp
Source/WebCore/platform/mediastream/libwebrtc/H264VideoToolBoxEncoder.h
Source/WebCore/platform/mediastream/libwebrtc/H264VideoToolBoxEncoder.mm
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl

index df0d41b..286ef9c 100644 (file)
@@ -1,3 +1,18 @@
+2017-06-19  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r218505.
+        https://bugs.webkit.org/show_bug.cgi?id=173563
+
+        "It would break internal builds" (Requested by youenn on
+        #webkit).
+
+        Reverted changeset:
+
+        "[WebRTC] Prevent capturing at unconventional resolutions when
+        using the SW encoder on Mac"
+        https://bugs.webkit.org/show_bug.cgi?id=172602
+        http://trac.webkit.org/changeset/218505
+
 2017-06-19  Youenn Fablet  <youenn@apple.com>
 
         [WebRTC] Prevent capturing at unconventional resolutions when using the SW encoder on Mac
index 4704a23..8ea6886 100644 (file)
@@ -98,7 +98,7 @@ http/tests/ssl/media-stream
 imported/w3c/web-platform-tests/webrtc [ Skip ]
 webrtc [ Skip ]
 webrtc/datachannel [ Pass ]
-webrtc/captureCanvas-webrtc.html [ Failure Pass ]
+webrtc/captureCanvas-webrtc.html [ Pass ]
 
 # These tests test the Shadow DOM based HTML form validation UI but Mac WK1 is using native dialogs instead.
 fast/forms/validation-message-on-listbox.html
diff --git a/LayoutTests/platform/mac/webrtc/captureCanvas-webrtc-software-encoder-expected.txt b/LayoutTests/platform/mac/webrtc/captureCanvas-webrtc-software-encoder-expected.txt
deleted file mode 100644 (file)
index 9334707..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-   
-
-PASS captureStream with webrtc 
-
diff --git a/LayoutTests/platform/mac/webrtc/captureCanvas-webrtc-software-encoder.html b/LayoutTests/platform/mac/webrtc/captureCanvas-webrtc-software-encoder.html
deleted file mode 100644 (file)
index 0a5ce25..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html>
-    <head>
-        <canvas id="canvas0" width=320px height=240px></canvas>
-        <canvas id="canvas1" width=100px height=100px></canvas>
-        <video id="video" autoplay width=320px height=240px></video>
-        <canvas id="canvas2" width=320px height=240px></canvas>
-        <script src="../../../resources/testharness.js"></script>
-        <script src="../../../resources/testharnessreport.js"></script>
-        <script src="../../../webrtc/routines.js"></script>
-        <script>
-
-function printRectangle(canvas)
-{
-    var context = canvas.getContext("2d");
-    context.fillStyle = canvas.color;
-    context.fillRect(0, 0, 100, 100);
-    setTimeout(() => printRectangle(canvas), 50);
-}
-
-if (window.internals)
-    internals.setH264HardwareEncoderAllowed(false);
-
-function testCanvas(testName, array1, isSame, count)
-{
-    if (count === undefined)
-        count = 0;
-    canvas2.getContext("2d").drawImage(video, 0 ,0);
-    array2 = canvas2.getContext("2d").getImageData(20, 20, 60, 60).data;
-    var isEqual = true;
-    for (var index = 0; index < array1.length; ++index) {
-        // Rough comparison since we are compressing data.
-        // This test still catches errors since we are going from green to blue to red.
-        if (Math.abs(array1[index] - array2[index]) > 40) {
-            isEqual = false;
-            continue;
-        }
-    }
-    if (isEqual === isSame)
-        return;
-
-    if (count === 20)
-        return Promise.reject(testName + " failed");
-
-    return waitFor(50).then(() => {
-        return testCanvas(testName, array1, isSame, ++count);
-    });
-}
-
-var canvas0Track;
-var sender;
-promise_test((test) => {
-    canvas0.color = "green";
-    printRectangle(canvas0);
-    return new Promise((resolve, reject) => {
-        createConnections((firstConnection) => {
-            var stream = canvas0.captureStream();
-            canvas0Track = stream.getVideoTracks()[0];
-            sender = firstConnection.addTrack(canvas0Track, stream);
-        }, (secondConnection) => {
-            secondConnection.ontrack = (trackEvent) => {
-                resolve(trackEvent.streams[0]);
-            };
-        });
-        setTimeout(() => reject("Test timed out"), 5000);
-    }).then((stream) => {
-        video.srcObject = stream;
-        return video.play();
-    }).then(() => {
-        return testCanvas("test1", canvas0.getContext("2d").getImageData(20 ,20, 60, 60).data, true);
-    }).then(() => {
-        canvas1.color = "blue";
-        printRectangle(canvas1);
-        var stream = canvas1.captureStream();
-        return sender.replaceTrack(stream.getVideoTracks()[0]);
-    }).then(() => {
-        return waitFor(200);
-    }).then(() => {
-        return testCanvas("test2", canvas1.getContext("2d").getImageData(20 ,20, 60, 60).data, false);
-    }).then(() => {
-        return testCanvas("test3", canvas0.getContext("2d").getImageData(20 ,20, 60, 60).data, true);
-    }).then(() => {
-        return sender.replaceTrack(canvas0Track);
-    }).then(() => {
-        canvas0.color = "red";
-        // Let's wait for red color to be printed on canvas0
-        return waitFor(200);
-    }).then(() => {
-        return testCanvas("test4", canvas0.getContext("2d").getImageData(20 ,20, 60, 60).data, true);
-    }).catch((error) => {
-        if (window.internals)
-            internals.setH264HardwareEncoderAllowed(true);
-       return Promise.reject(error);
-    });
-}, "captureStream with webrtc");
-
-        </script>
-    </head>
-</html>
index 7616ec7..36e7e58 100644 (file)
@@ -1,8 +1,7 @@
+   
 
 PASS Setting up the connection 
 PASS Checking canvas is green 
 PASS Checking canvas is red 
 PASS Checking canvas is green again 
-PASS Checking canvas size change 
 
index 298c6c1..50ea4b9 100644 (file)
@@ -1,50 +1,27 @@
 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
 <html>
     <head>
-        <canvas id="canvas1" width=320px height=240px></canvas>
-        <video id="video" autoplay></video>
-        <canvas id="canvas2" width=320px height=240px></canvas>
+        <canvas id="canvas1" width=100px height=100px></canvas>
+        <video id="video" autoplay width=100px height=100px></video>
+        <canvas id="canvas2" width=100px height=100px></canvas>
         <script src="../resources/testharness.js"></script>
         <script src="../resources/testharnessreport.js"></script>
         <script src ="routines.js"></script>
         <script>
 
+var canvas1 = document.getElementById("canvas1");
+var canvas2 = document.getElementById("canvas2");
+var video = document.getElementById("video");
+
 var color = "green";
 function printRectangle()
 {
     var context = canvas1.getContext("2d");
     context.fillStyle = color;
-    context.fillRect(0, 0, 320, 240);
+    context.fillRect(0, 0, 100, 100);
     setTimeout(printRectangle, 50);
 }
 
-function testCanvas(testName, array1, isSame, count)
-{
-    if (count === undefined)
-        count = 0;
-    canvas2.getContext("2d").drawImage(video, 0 ,0);
-    array2 = canvas2.getContext("2d").getImageData(20, 20, 60, 60).data;
-    var isEqual = true;
-    var index = 0;
-    for (index = 0; index < array1.length; ++index) {
-        // Rough comparison since we are compressing data.
-        // This test still catches errors since we are going from green to blue to red.
-        if (Math.abs(array1[index] - array2[index]) > 40) {
-            isEqual = false;
-            continue;
-        }
-    }
-    if (isEqual === isSame)
-        return;
-
-    if (count === 20)
-        return Promise.reject(testName + " failed, expected " + JSON.stringify(array1) + " but got " + JSON.stringify(array2));
-
-    return waitFor(50).then(() => {
-        return testCanvas(testName, array1, isSame, ++count);
-    });
-}
-
 promise_test((test) => {
     printRectangle();
     return new Promise((resolve, reject) => {
@@ -69,14 +46,16 @@ promise_test((test) => {
 
 promise_test((test) => {
     return waitFor(100).then(() => {
-        return testCanvas("test 1", canvas1.getContext("2d").getImageData(20, 20, 60, 60).data, true);
+        canvas2.getContext("2d").drawImage(video, 0 ,0);
+        assert_array_equals(canvas2.getContext("2d").getImageData(20 ,20, 60, 60), canvas1.getContext("2d").getImageData(20, 20, 60, 60));
     });
 }, "Checking canvas is green");
 
 promise_test((test) => {
     color = "red";
     return waitFor(300).then(() => {
-        return testCanvas("test 2", canvas1.getContext("2d").getImageData(20, 20, 60, 60).data, true);
+        canvas2.getContext("2d").drawImage(video, 0 ,0);
+        assert_array_equals(canvas2.getContext("2d").getImageData(20 ,20, 60, 60), canvas1.getContext("2d").getImageData(20, 20, 60, 60));
     });
 }, "Checking canvas is red");
 
@@ -84,15 +63,10 @@ promise_test((test) => {
 promise_test((test) => {
     color = "green";
     return waitFor(300).then(() => {
-        return testCanvas("test 3", canvas1.getContext("2d").getImageData(20, 20, 60, 60).data, true);
+        canvas2.getContext("2d").drawImage(video, 0 ,0);
+        assert_array_equals(canvas2.getContext("2d").getImageData(20 ,20, 60, 60), canvas1.getContext("2d").getImageData(20, 20, 60, 60));
     });
 }, "Checking canvas is green again");
-
-promise_test((test) => {
-        canvas1.width = 640;
-        canvas1.height = 480;
-        return waitForVideoSize(video, 640, 480);
-}, "Checking canvas size change");
         </script>
     </head>
 </html>
index abe3920..9567b38 100644 (file)
@@ -141,7 +141,7 @@ function waitForVideoSize(video, width, height, count)
     if (count === undefined)
         count = 0;
     if (++count > 20)
-        return Promise.reject("waitForVideoSize timed out, expected " + width + "x"+ height + " but got " + video.videoWidth + "x" + video.videoHeight);
+        return Promise.reject("waitForVideoSize timed out");
 
     return waitFor(50).then(() => {
         return waitForVideoSize(video, width, height, count);
index 6d060e6..766a6db 100644 (file)
@@ -43,7 +43,7 @@ promise_test((test) => {
     if (window.testRunner)
         testRunner.setUserMediaPermission(true);
 
-    return navigator.mediaDevices.getUserMedia({video: {advanced: [{width:{min:1280}}, {height:{min:720} } ]}}).then((stream) => {
+    return navigator.mediaDevices.getUserMedia({ video: true}).then((stream) => {
         return new Promise((resolve, reject) => {
             createConnections((firstConnection) => {
                 var track = stream.getVideoTracks()[0];
index 947bb6f..54f67f3 100644 (file)
@@ -1,3 +1,18 @@
+2017-06-19  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r218505.
+        https://bugs.webkit.org/show_bug.cgi?id=173563
+
+        "It would break internal builds" (Requested by youenn on
+        #webkit).
+
+        Reverted changeset:
+
+        "[WebRTC] Prevent capturing at unconventional resolutions when
+        using the SW encoder on Mac"
+        https://bugs.webkit.org/show_bug.cgi?id=172602
+        http://trac.webkit.org/changeset/218505
+
 2017-06-19  Youenn Fablet  <youenn@apple.com>
 
         [WebRTC] Prevent capturing at unconventional resolutions when using the SW encoder on Mac
index b6ef038..52481e2 100644 (file)
@@ -69,12 +69,12 @@ class WEBRTC_DYLIB_EXPORT H264VideoToolboxEncoder : public H264Encoder {
   ScalingSettings GetScalingSettings() const override;
 
  protected:
-  virtual int CreateCompressionSession(VTCompressionSessionRef&, VTCompressionOutputCallback, int32_t width, int32_t height, bool useHardwareAcceleratedVideoEncoder = true);
-  void DestroyCompressionSession();
+  virtual int CreateCompressionSession(VTCompressionSessionRef&, VTCompressionOutputCallback, int32_t width, int32_t height);
 
  private:
   int ResetCompressionSession();
   void ConfigureCompressionSession();
+  void DestroyCompressionSession();
   rtc::scoped_refptr<VideoFrameBuffer> GetScaledBufferOnEncode(
       const rtc::scoped_refptr<VideoFrameBuffer>& frame);
   void SetBitrateBps(uint32_t bitrate_bps);
index 6b2c490..cbd1b92 100644 (file)
@@ -533,7 +533,7 @@ int H264VideoToolboxEncoder::ResetCompressionSession() {
   return WEBRTC_VIDEO_CODEC_OK;
 }
 
-int H264VideoToolboxEncoder::CreateCompressionSession(VTCompressionSessionRef& compressionSession, VTCompressionOutputCallback outputCallback, int32_t width, int32_t height, bool useHardwareAcceleratedVideoEncoder) {
+int H264VideoToolboxEncoder::CreateCompressionSession(VTCompressionSessionRef& compressionSession, VTCompressionOutputCallback outputCallback, int32_t width, int32_t height) {
   // Set source image buffer attributes. These attributes will be present on
   // buffers retrieved from the encoder's pixel buffer pool.
   const size_t attributes_size = 3;
@@ -566,7 +566,7 @@ int H264VideoToolboxEncoder::CreateCompressionSession(VTCompressionSessionRef& c
 
 #if defined(WEBRTC_USE_VTB_HARDWARE_ENCODER)
   CFTypeRef sessionKeys[] = {kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder};
-  CFTypeRef sessionValues[] = {useHardwareAcceleratedVideoEncoder ? kCFBooleanTrue : kCFBooleanFalse};
+  CFTypeRef sessionValues[] = {kCFBooleanTrue};
   CFDictionaryRef encoderSpecification = internal::CreateCFDictionary(sessionKeys, sessionValues, 1);
 #else
   CFDictionaryRef encoderSpecification = nullptr;
index 7beeb8e..0433b33 100644 (file)
@@ -1,3 +1,18 @@
+2017-06-19  Commit Queue  <commit-queue@webkit.org>
+
+        Unreviewed, rolling out r218505.
+        https://bugs.webkit.org/show_bug.cgi?id=173563
+
+        "It would break internal builds" (Requested by youenn on
+        #webkit).
+
+        Reverted changeset:
+
+        "[WebRTC] Prevent capturing at unconventional resolutions when
+        using the SW encoder on Mac"
+        https://bugs.webkit.org/show_bug.cgi?id=172602
+        http://trac.webkit.org/changeset/218505
+
 2017-06-19  Zalan Bujtas  <zalan@apple.com>
 
         Opening certain mails brings up a mail that grows indefinitely.
index 2441ce3..5e05c3e 100644 (file)
@@ -115,8 +115,6 @@ void CanvasCaptureMediaStreamTrack::Source::canvasResized(HTMLCanvasElement& can
 
     m_settings.setWidth(m_canvas->width());
     m_settings.setHeight(m_canvas->height());
-
-    settingsDidChange();
 }
 
 void CanvasCaptureMediaStreamTrack::Source::canvasChanged(HTMLCanvasElement& canvas, const FloatRect&)
index b2f12af..69a5cf6 100644 (file)
@@ -35,11 +35,9 @@ namespace WebCore {
 class H264VideoToolboxEncoder final : public webrtc::H264VideoToolboxEncoder {
 public:
     explicit H264VideoToolboxEncoder(const cricket::VideoCodec& codec) : webrtc::H264VideoToolboxEncoder(codec) { }
-    WEBCORE_EXPORT static void setHardwareEncoderForWebRTCAllowed(bool);
-    static bool hardwareEncoderForWebRTCAllowed();
 
 private:
-    int CreateCompressionSession(VTCompressionSessionRef&, VTCompressionOutputCallback, int32_t width, int32_t height, bool useHardwareAcceleratedVideoEncoder) final;
+    int CreateCompressionSession(VTCompressionSessionRef&, VTCompressionOutputCallback, int32_t width, int32_t height) final;
 };
 
 }
index 8ef982b..bfd4b09 100644 (file)
 #include "config.h"
 #include "H264VideoToolBoxEncoder.h"
 
-#include "Logging.h"
-
 #if USE(LIBWEBRTC) && PLATFORM(COCOA)
 
-namespace WebCore {
-
-static bool isHardwareEncoderForWebRTCAllowed = true;
-
-void H264VideoToolboxEncoder::setHardwareEncoderForWebRTCAllowed(bool allowed)
-{
-    isHardwareEncoderForWebRTCAllowed = allowed;
-}
-
-bool H264VideoToolboxEncoder::hardwareEncoderForWebRTCAllowed()
-{
-    return isHardwareEncoderForWebRTCAllowed;
-}
-
-#if PLATFORM(MAC) && ENABLE(MAC_VIDEO_TOOLBOX)
-static inline bool isStandardFrameSize(int32_t width, int32_t height)
-{
-    // FIXME: Envision relaxing this rule, something like width and height dividable by 4 or 8 should be good enough.
-    if (width == 1280)
-        return height == 720;
-    if (width == 720)
-        return height == 1280;
-    if (width == 960)
-        return height == 540;
-    if (width == 540)
-        return height == 960;
-    if (width == 640)
-        return height == 480;
-    if (width == 480)
-        return height == 640;
-    if (width == 288)
-        return height == 352;
-    if (width == 352)
-        return height == 288;
-    if (width == 320)
-        return height == 240;
-    if (width == 240)
-        return height == 320;
-    return false;
-}
-#endif
-
-}
-
 #if ENABLE(MAC_VIDEO_TOOLBOX) && USE(APPLE_INTERNAL_SDK) && __has_include(<WebKitAdditions/VideoToolBoxEncoderMac.mm>)
 #import <WebKitAdditions/VideoToolBoxEncoderMac.mm>
 #else
 
 namespace WebCore {
 
-#if PLATFORM(MAC) && ENABLE(MAC_VIDEO_TOOLBOX)
-static inline bool isUsingSoftwareEncoder(VTCompressionSessionRef& compressionSession)
-{
-    CFNumberRef useHardwareEncoderValue = nullptr;
-    OSStatus statusGetter = VTSessionCopyProperty(compressionSession, kVTCompressionPropertyKey_UsingHardwareAcceleratedVideoEncoder, nullptr, &useHardwareEncoderValue);
-    if (statusGetter || !useHardwareEncoderValue)
-        return true;
-
-    int useHardwareEncoder = 0;
-    CFNumberGetValue(useHardwareEncoderValue, kCFNumberIntType, &useHardwareEncoder);
-    CFRelease(useHardwareEncoderValue);
-
-    return useHardwareEncoder;
-}
-#endif
-
-int H264VideoToolboxEncoder::CreateCompressionSession(VTCompressionSessionRef& compressionSession, VTCompressionOutputCallback outputCallback, int32_t width, int32_t height, bool useHardwareAcceleratedVideoEncoder)
+int H264VideoToolboxEncoder::CreateCompressionSession(VTCompressionSessionRef& compressionSession, VTCompressionOutputCallback outputCallback, int32_t width, int32_t height)
 {
-    int result = webrtc::H264VideoToolboxEncoder::CreateCompressionSession(compressionSession, outputCallback, width, height, hardwareEncoderForWebRTCAllowed() ? useHardwareAcceleratedVideoEncoder : false);
-    if (result)
-        return result;
-
-#if PLATFORM(MAC) && ENABLE(MAC_VIDEO_TOOLBOX)
-    if (!isUsingSoftwareEncoder(compressionSession))
-        return 0;
-
-    if (!isStandardFrameSize(width, height)) {
-        RELEASE_LOG(WebRTC, "Using H264 software encoder with non standard size is not supported");
-        DestroyCompressionSession();
-        return -1;
-    }
-    RELEASE_LOG(WebRTC, "Using H264 software encoder");
-#endif
-    return 0;
+    return webrtc::H264VideoToolboxEncoder::CreateCompressionSession(compressionSession, outputCallback, width, height);
 }
     
 }
index 7589fd0..9853234 100644 (file)
 #include "MockMediaPlayerMediaSource.h"
 #endif
 
-#if USE(LIBWEBRTC) && PLATFORM(COCOA)
-#include "H264VideoToolboxEncoder.h"
-#endif
-
 #if PLATFORM(MAC)
 #include "DictionaryLookup.h"
 #endif
@@ -4042,17 +4038,6 @@ void Internals::setPageVisibility(bool isVisible)
     page.setActivityState(state);
 }
 
-#if ENABLE(WEB_RTC)
-void Internals::setH264HardwareEncoderAllowed(bool allowed)
-{
-#if PLATFORM(MAC)
-    H264VideoToolboxEncoder::setHardwareEncoderForWebRTCAllowed(allowed);
-#else
-    UNUSED_PARAM(allowed);
-#endif
-}
-#endif
-
 #if ENABLE(MEDIA_STREAM)
 
 void Internals::setCameraMediaStreamTrackOrientation(MediaStreamTrack& track, int orientation)
index 9821ff2..73d9bf7 100644 (file)
@@ -579,10 +579,6 @@ public:
 
     void setPageVisibility(bool isVisible);
 
-#if ENABLE(WEB_RTC)
-    void setH264HardwareEncoderAllowed(bool allowed);
-#endif
-
 #if ENABLE(MEDIA_STREAM)
     void setCameraMediaStreamTrackOrientation(MediaStreamTrack&, int orientation);
     ExceptionOr<void> setMediaDeviceState(const String& id, const String& property, bool value);
index a0ff944..2bb2772 100644 (file)
@@ -537,7 +537,6 @@ enum EventThrottlingBehavior {
 
     void setPageVisibility(boolean isVisible);
 
-    [Conditional=WEB_RTC] void setH264HardwareEncoderAllowed(boolean allowed);
     [Conditional=WEB_RTC] void applyRotationForOutgoingVideoSources(RTCPeerConnection connection);
 
     [Conditional=MEDIA_STREAM] void setCameraMediaStreamTrackOrientation(MediaStreamTrack track, short orientation);