<!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>[246263] trunk</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/246263">246263</a></dd>
<dt>Author</dt> <dd>youenn@apple.com</dd>
<dt>Date</dt> <dd>2019-06-10 08:59:14 -0700 (Mon, 10 Jun 2019)</dd>
</dl>

<h3>Log Message</h3>
<pre>Call was negotiated with H264 Base Profile 42e01f but encoded in High Profile
https://bugs.webkit.org/show_bug.cgi?id=195124
<rdar://problem/48453085>

Reviewed by Eric Carlson.

Source/ThirdParty/libwebrtc:

Use VTB directly instead of VCP when baseline is requested.
For platforms supporting the VCP-in-VTB API, use VCP for high profile, VTB for baseline.
For platforms not supporting the VCP-in-VTB API, use regular VTB for both baseline and high profile.
On MacOS, if VTB session creation fails, use VCP as a fallback.
Keep VTB-only code path for non internal builds.

* Source/webrtc/sdk/WebKit/EncoderUtilities.h: Removed.
* Source/webrtc/sdk/WebKit/VideoProcessingSoftLink.h:
* Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm:
(-[RTCSingleVideoEncoderH264 initWithCodecInfo:simulcastIndex:]):
(-[RTCSingleVideoEncoderH264 hasCompressionSession]):
(-[RTCSingleVideoEncoderH264 encode:codecSpecificInfo:frameTypes:]):
(-[RTCSingleVideoEncoderH264 resetCompressionSessionIfNeededWithFrame:]):
(-[RTCSingleVideoEncoderH264 resetCompressionSessionWithPixelFormat:]):
(-[RTCSingleVideoEncoderH264 configureCompressionSession]):
(-[RTCSingleVideoEncoderH264 destroyCompressionSession]):
(-[RTCSingleVideoEncoderH264 setEncoderBitrateBps:]):
* Source/webrtc/sdk/objc/components/video_codec/helpers.cc:
* Source/webrtc/sdk/objc/components/video_codec/helpers.h:

LayoutTests:

* webrtc/video-h264-expected.txt: Added.
* webrtc/video-h264.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceThirdPartylibwebrtcChangeLog">trunk/Source/ThirdParty/libwebrtc/ChangeLog</a></li>
<li><a href="#trunkSourceThirdPartylibwebrtcSourcewebrtcsdkWebKitVideoProcessingSoftLinkh">trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/VideoProcessingSoftLink.h</a></li>
<li><a href="#trunkSourceThirdPartylibwebrtcSourcewebrtcsdkobjccomponentsvideo_codecRTCVideoEncoderH264mm">trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm</a></li>
<li><a href="#trunkSourceThirdPartylibwebrtcSourcewebrtcsdkobjccomponentsvideo_codechelperscc">trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/helpers.cc</a></li>
<li><a href="#trunkSourceThirdPartylibwebrtcSourcewebrtcsdkobjccomponentsvideo_codechelpersh">trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/helpers.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestswebrtcvideoh264expectedtxt">trunk/LayoutTests/webrtc/video-h264-expected.txt</a></li>
<li><a href="#trunkLayoutTestswebrtcvideoh264html">trunk/LayoutTests/webrtc/video-h264.html</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceThirdPartylibwebrtcSourcewebrtcsdkWebKitEncoderUtilitiesh">trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/EncoderUtilities.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (246262 => 246263)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog      2019-06-10 14:42:26 UTC (rev 246262)
+++ trunk/LayoutTests/ChangeLog 2019-06-10 15:59:14 UTC (rev 246263)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2019-06-10  Youenn Fablet  <youenn@apple.com>
+
+        Call was negotiated with H264 Base Profile 42e01f but encoded in High Profile
+        https://bugs.webkit.org/show_bug.cgi?id=195124
+        <rdar://problem/48453085>
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/video-h264-expected.txt: Added.
+        * webrtc/video-h264.html: Added.
+
</ins><span class="cx"> 2019-06-08  Cathie Chen  <cathiechen@igalia.com>
</span><span class="cx"> 
</span><span class="cx">         resize-observer/element-leak.html fails on Windows platform
</span></span></pre></div>
<a id="trunkLayoutTestswebrtcvideoh264expectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/video-h264-expected.txt (0 => 246263)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/video-h264-expected.txt                         (rev 0)
+++ trunk/LayoutTests/webrtc/video-h264-expected.txt    2019-06-10 15:59:14 UTC (rev 246263)
</span><span class="lines">@@ -0,0 +1,5 @@
</span><ins>+
+
+PASS Baseline H264 
+PASS High H264 
+
</ins></span></pre></div>
<a id="trunkLayoutTestswebrtcvideoh264html"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/webrtc/video-h264.html (0 => 246263)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/webrtc/video-h264.html                         (rev 0)
+++ trunk/LayoutTests/webrtc/video-h264.html    2019-06-10 15:59:14 UTC (rev 246263)
</span><span class="lines">@@ -0,0 +1,96 @@
</span><ins>+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>Testing H264 baseline and high profile</title>
+        <script src="../resources/testharness.js"></script>
+        <script src="../resources/testharnessreport.js"></script>
+    </head>
+    <body>
+        <video id="video" autoplay=""></video>
+        <canvas id="canvas" width="640" height="480"></canvas>
+        <script src ="routines.js"></script>
+        <script>
+function grabFrameData(x, y, w, h)
+{
+    canvas.width = video.videoWidth;
+    canvas.height = video.videoHeight;
+
+    canvas.getContext('2d').drawImage(video, x, y, w, h, x, y, w, h);
+    return canvas.getContext('2d').getImageData(x, y, w, h).data;
+}
+
+function testImage()
+{
+    const data = grabFrameData(10, 325, 250, 1);
+
+    var index = 20;
+    assert_true(data[index] < 100);
+    assert_true(data[index + 1] < 100);
+    assert_true(data[index + 2] < 100);
+
+    index = 80;
+    assert_true(data[index] > 200);
+    assert_true(data[index + 1] > 200);
+    assert_true(data[index + 2] > 200);
+
+    index += 80;
+    assert_true(data[index] > 200);
+    assert_true(data[index + 1] > 200);
+    assert_true(data[index + 2] < 100);
+}
+
+promise_test(async (test) => {
+    if (window.testRunner)
+        testRunner.setUserMediaPermission(true);
+
+    const localStream = await navigator.mediaDevices.getUserMedia({video: true});
+    const stream = await new Promise((resolve, reject) => {
+        createConnections((firstConnection) => {
+            firstConnection.addTrack(localStream.getVideoTracks()[0], localStream);
+        }, (secondConnection) => {
+            secondConnection.ontrack = (trackEvent) => {
+                resolve(trackEvent.streams[0]);
+            };
+        }, { observeOffer : (offer) => {
+            offer.sdp = offer.sdp.replace("640c1f", "42e01f");
+            return offer;
+        }
+        });
+        setTimeout(() => reject("Test timed out"), 5000);
+    });
+
+    video.srcObject = stream;
+    await video.play();
+
+    testImage();
+}, "Baseline H264");
+
+promise_test(async (test) => {
+    if (window.testRunner)
+        testRunner.setUserMediaPermission(true);
+
+    const localStream = await navigator.mediaDevices.getUserMedia({video: true});
+    const stream = await new Promise((resolve, reject) => {
+        createConnections((firstConnection) => {
+            firstConnection.addTrack(localStream.getVideoTracks()[0], localStream);
+        }, (secondConnection) => {
+            secondConnection.ontrack = (trackEvent) => {
+                resolve(trackEvent.streams[0]);
+            };
+        }, { observeOffer : (offer) => {
+            offer.sdp = offer.sdp.replace("42e01f", "640c1f");
+            return offer;
+        }
+        });
+        setTimeout(() => reject("Test timed out"), 5000);
+    });
+
+    video.srcObject = stream;
+    await video.play();
+
+    testImage();
+}, "High H264");
+        </script>
+    </body>
+</html>
</ins></span></pre></div>
<a id="trunkSourceThirdPartylibwebrtcChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/libwebrtc/ChangeLog (246262 => 246263)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/libwebrtc/ChangeLog      2019-06-10 14:42:26 UTC (rev 246262)
+++ trunk/Source/ThirdParty/libwebrtc/ChangeLog 2019-06-10 15:59:14 UTC (rev 246263)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2019-06-10  Youenn Fablet  <youenn@apple.com>
+
+        Call was negotiated with H264 Base Profile 42e01f but encoded in High Profile
+        https://bugs.webkit.org/show_bug.cgi?id=195124
+        <rdar://problem/48453085>
+
+        Reviewed by Eric Carlson.
+
+        Use VTB directly instead of VCP when baseline is requested.
+        For platforms supporting the VCP-in-VTB API, use VCP for high profile, VTB for baseline.
+        For platforms not supporting the VCP-in-VTB API, use regular VTB for both baseline and high profile.
+        On MacOS, if VTB session creation fails, use VCP as a fallback.
+        Keep VTB-only code path for non internal builds.
+
+        * Source/webrtc/sdk/WebKit/EncoderUtilities.h: Removed.
+        * Source/webrtc/sdk/WebKit/VideoProcessingSoftLink.h:
+        * Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm:
+        (-[RTCSingleVideoEncoderH264 initWithCodecInfo:simulcastIndex:]):
+        (-[RTCSingleVideoEncoderH264 hasCompressionSession]):
+        (-[RTCSingleVideoEncoderH264 encode:codecSpecificInfo:frameTypes:]):
+        (-[RTCSingleVideoEncoderH264 resetCompressionSessionIfNeededWithFrame:]):
+        (-[RTCSingleVideoEncoderH264 resetCompressionSessionWithPixelFormat:]):
+        (-[RTCSingleVideoEncoderH264 configureCompressionSession]):
+        (-[RTCSingleVideoEncoderH264 destroyCompressionSession]):
+        (-[RTCSingleVideoEncoderH264 setEncoderBitrateBps:]):
+        * Source/webrtc/sdk/objc/components/video_codec/helpers.cc:
+        * Source/webrtc/sdk/objc/components/video_codec/helpers.h:
+
</ins><span class="cx"> 2019-05-28  Youenn Fablet  <youenn@apple.com>
</span><span class="cx"> 
</span><span class="cx">         createAnswer() SDP Rejected by setLocalDescription()
</span></span></pre></div>
<a id="trunkSourceThirdPartylibwebrtcSourcewebrtcsdkWebKitEncoderUtilitiesh"></a>
<div class="delfile"><h4>Deleted: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/EncoderUtilities.h (246262 => 246263)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/EncoderUtilities.h    2019-06-10 14:42:26 UTC (rev 246262)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/EncoderUtilities.h       2019-06-10 15:59:14 UTC (rev 246263)
</span><span class="lines">@@ -1,50 +0,0 @@
</span><del>-/*
- * Copyright (C) 2018 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
-
-#include "VideoProcessingSoftLink.h"
-
-#if ENABLE_VCP_ENCODER
-
-#define CompressionSessionRef VCPCompressionSessionRef
-#define CompressionSessionSetProperty webrtc::VCPCompressionSessionSetProperty
-#define CompressionSessionGetPixelBufferPool webrtc::VCPCompressionSessionGetPixelBufferPool
-#define CompressionSessionEncodeFrame webrtc::VCPCompressionSessionEncodeFrame
-#define CompressionSessionCreate webrtc::VCPCompressionSessionCreate
-#define kCodecTypeH264 kVCPCodecType4CC_H264
-#define CompressionSessionInvalidate webrtc::VCPCompressionSessionInvalidate
-
-#else
-
-#define CompressionSessionRef VTCompressionSessionRef
-#define CompressionSessionSetProperty VTSessionSetProperty
-#define CompressionSessionGetPixelBufferPool VTCompressionSessionGetPixelBufferPool
-#define CompressionSessionEncodeFrame VTCompressionSessionEncodeFrame
-#define CompressionSessionCreate VTCompressionSessionCreate
-#define kCodecTypeH264 kCMVideoCodecType_H264
-#define CompressionSessionInvalidate VTCompressionSessionInvalidate
-
-#endif
</del></span></pre></div>
<a id="trunkSourceThirdPartylibwebrtcSourcewebrtcsdkWebKitVideoProcessingSoftLinkh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/VideoProcessingSoftLink.h (246262 => 246263)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/VideoProcessingSoftLink.h     2019-06-10 14:42:26 UTC (rev 246262)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/VideoProcessingSoftLink.h        2019-06-10 15:59:14 UTC (rev 246263)
</span><span class="lines">@@ -33,14 +33,14 @@
</span><span class="cx"> // Macro taken from WTF/wtf/Platform.h
</span><span class="cx"> #if defined __has_include && __has_include(<CoreFoundation/CFPriv.h>)
</span><span class="cx"> 
</span><del>-#if (defined(TARGET_IPHONE_SIMULATOR)  && TARGET_IPHONE_SIMULATOR)
</del><ins>+#if (defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR)
</ins><span class="cx"> #define ENABLE_VCP_ENCODER 0
</span><span class="cx"> #define ENABLE_VCP_VTB_ENCODER 0
</span><del>-#elif (defined(TARGET_OS_IPHONE)  && TARGET_OS_IPHONE)
-#define ENABLE_VCP_ENCODER __MAC_OS_X_VERSION_MAX_ALLOWED < 101500
</del><ins>+#elif (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE)
+#define ENABLE_VCP_ENCODER 1
</ins><span class="cx"> #define ENABLE_VCP_VTB_ENCODER __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
</span><span class="cx"> #elif (defined(TARGET_OS_MAC) && TARGET_OS_MAC)
</span><del>-#define ENABLE_VCP_ENCODER (__MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 && __MAC_OS_X_VERSION_MAX_ALLOWED < 101500)
</del><ins>+#define ENABLE_VCP_ENCODER __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
</ins><span class="cx"> #define ENABLE_VCP_VTB_ENCODER __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -145,6 +145,8 @@
</span><span class="cx"> SOFT_LINK_FUNCTION_FOR_HEADER(webrtc, VideoProcessing, VCPCompressionSessionInvalidate, void, (VCPCompressionSessionRef session), (session))
</span><span class="cx"> #define VCPCompressionSessionInvalidate softLink_VideoProcessing_VCPCompressionSessionInvalidate
</span><span class="cx"> 
</span><ins>+#else
+using VCPCompressionSessionRef = void*;
</ins><span class="cx"> #endif // ENABLE_VCP_ENCODER
</span><span class="cx"> 
</span><span class="cx"> #endif // __APPLE__
</span></span></pre></div>
<a id="trunkSourceThirdPartylibwebrtcSourcewebrtcsdkobjccomponentsvideo_codecRTCVideoEncoderH264mm"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm (246262 => 246263)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm   2019-06-10 14:42:26 UTC (rev 246262)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm      2019-06-10 15:59:14 UTC (rev 246263)
</span><span class="lines">@@ -31,7 +31,6 @@
</span><span class="cx"> #include "system_wrappers/include/clock.h"
</span><span class="cx"> #include "third_party/libyuv/include/libyuv/convert_from.h"
</span><span class="cx"> 
</span><del>-#include "sdk/WebKit/EncoderUtilities.h"
</del><span class="cx"> #include "sdk/WebKit/WebKitUtilities.h"
</span><span class="cx"> 
</span><span class="cx"> #import <dlfcn.h>
</span><span class="lines">@@ -40,7 +39,7 @@
</span><span class="cx"> VT_EXPORT const CFStringRef kVTVideoEncoderSpecification_Usage;
</span><span class="cx"> VT_EXPORT const CFStringRef kVTCompressionPropertyKey_Usage;
</span><span class="cx"> 
</span><del>-#if !ENABLE_VCP_ENCODER && !defined(WEBRTC_IOS) && !ENABLE_VCP_VTB_ENCODER
</del><ins>+#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) && !ENABLE_VCP_ENCODER
</ins><span class="cx"> static inline bool isStandardFrameSize(int32_t width, int32_t height)
</span><span class="cx"> {
</span><span class="cx">     // FIXME: Envision relaxing this rule, something like width and height dividable by 4 or 8 should be good enough.
</span><span class="lines">@@ -318,7 +317,9 @@
</span><span class="cx">   RTCVideoEncoderCallback _callback;
</span><span class="cx">   int32_t _width;
</span><span class="cx">   int32_t _height;
</span><del>-  CompressionSessionRef _compressionSession;
</del><ins>+  bool _useVCP;
+  VTCompressionSessionRef _vtCompressionSession;
+  VCPCompressionSessionRef _vcpCompressionSession;
</ins><span class="cx">   CVPixelBufferPoolRef _pixelBufferPool;
</span><span class="cx">   RTCVideoCodecMode _mode;
</span><span class="cx"> 
</span><span class="lines">@@ -343,6 +344,11 @@
</span><span class="cx">     _bitrateAdjuster.reset(new webrtc::BitrateAdjuster(.5, .95));
</span><span class="cx">     _packetizationMode = RTCH264PacketizationModeNonInterleaved;
</span><span class="cx">     _profile = ExtractProfile([codecInfo nativeSdpVideoFormat]);
</span><ins>+#if ENABLE_VCP_VTB_ENCODER
+    _useVCP = [(__bridge NSString *)_profile containsString: @"High"];
+#else
+    _useVCP = false;
+#endif
</ins><span class="cx">     _simulcastIndex = index;
</span><span class="cx">     RTC_LOG(LS_INFO) << "Using profile " << CFStringToString(_profile);
</span><span class="cx">     RTC_CHECK([codecInfo.name isEqualToString:kRTCVideoCodecH264Name]);
</span><span class="lines">@@ -376,12 +382,17 @@
</span><span class="cx">   return [self resetCompressionSessionWithPixelFormat:kNV12PixelFormat];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (bool)hasCompressionSession
+{
+    return _vtCompressionSession || _vcpCompressionSession;
+}
+
</ins><span class="cx"> - (NSInteger)encode:(RTCVideoFrame *)frame
</span><span class="cx">     codecSpecificInfo:(nullable id<RTCCodecSpecificInfo>)codecSpecificInfo
</span><span class="cx">            frameTypes:(NSArray<NSNumber *> *)frameTypes {
</span><span class="cx">   RTC_DCHECK_EQ(frame.width, _width);
</span><span class="cx">   RTC_DCHECK_EQ(frame.height, _height);
</span><del>-  if (!_callback || !_compressionSession) {
</del><ins>+  if (!_callback || ![self hasCompressionSession]) {
</ins><span class="cx">     return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
</span><span class="cx">   }
</span><span class="cx">   BOOL isKeyframeRequired = NO;
</span><span class="lines">@@ -474,7 +485,9 @@
</span><span class="cx">   // Update the bitrate if needed.
</span><span class="cx">   [self setBitrateBps:_bitrateAdjuster->GetAdjustedBitrateBps()];
</span><span class="cx"> 
</span><del>-  OSStatus status = CompressionSessionEncodeFrame(_compressionSession,
</del><ins>+  OSStatus status;
+  if (_vtCompressionSession) {
+    status = VTCompressionSessionEncodeFrame(_vtCompressionSession,
</ins><span class="cx">                                                     pixelBuffer,
</span><span class="cx">                                                     presentationTimeStamp,
</span><span class="cx">                                                     kCMTimeInvalid,
</span><span class="lines">@@ -481,6 +494,19 @@
</span><span class="cx">                                                     frameProperties,
</span><span class="cx">                                                     encodeParams.release(),
</span><span class="cx">                                                     nullptr);
</span><ins>+  } else {
+#if ENABLE_VCP_ENCODER
+    status = webrtc::VCPCompressionSessionEncodeFrame(_vcpCompressionSession,
+                                                    pixelBuffer,
+                                                    presentationTimeStamp,
+                                                    kCMTimeInvalid,
+                                                    frameProperties,
+                                                    encodeParams.release(),
+                                                    nullptr);
+#else
+    status = 1;
+#endif
+  }
</ins><span class="cx">   if (frameProperties) {
</span><span class="cx">     CFRelease(frameProperties);
</span><span class="cx">   }
</span><span class="lines">@@ -540,7 +566,7 @@
</span><span class="cx">   // configured with, make sure the compression session is reset using the correct pixel format.
</span><span class="cx">   OSType framePixelFormat = [self pixelFormatOfFrame:frame];
</span><span class="cx"> 
</span><del>-  if (_compressionSession) {
</del><ins>+  if ([self hasCompressionSession]) {
</ins><span class="cx"> #if defined(WEBRTC_WEBKIT_BUILD)
</span><span class="cx">     if (!_pixelBufferPool) {
</span><span class="cx">       return NO;
</span><span class="lines">@@ -618,60 +644,83 @@
</span><span class="cx"> #endif
</span><span class="cx">   CFDictionarySetValue(encoderSpecs, kVTCompressionPropertyKey_RealTime, kCFBooleanTrue);
</span><span class="cx"> 
</span><del>-#if ENABLE_VCP_ENCODER || ENABLE_VCP_VTB_ENCODER
-  int usageValue = 1;
-  auto usage = CFNumberCreate(nullptr, kCFNumberIntType, &usageValue);
-  CFDictionarySetValue(encoderSpecs, kVTCompressionPropertyKey_Usage, usage);
-  CFRelease(usage);
</del><ins>+#if ENABLE_VCP_ENCODER
+  if (_useVCP) {
+    int usageValue = 1;
+    auto usage = CFNumberCreate(nullptr, kCFNumberIntType, &usageValue);
+    CFDictionarySetValue(encoderSpecs, kVTCompressionPropertyKey_Usage, usage);
+    CFRelease(usage);
+  }
</ins><span class="cx"> #endif
</span><span class="cx"> #if ENABLE_VCP_VTB_ENCODER
</span><ins>+  if (_useVCP) {
</ins><span class="cx">     CFDictionarySetValue(encoderSpecs, kVTVideoEncoderList_EncoderID, CFSTR("com.apple.videotoolbox.videoencoder.h264.rtvc"));
</span><ins>+  }
</ins><span class="cx"> #endif
</span><span class="cx">   OSStatus status =
</span><del>-      CompressionSessionCreate(nullptr,  // use default allocator
</del><ins>+      VTCompressionSessionCreate(nullptr,  // use default allocator
</ins><span class="cx">                                  _width,
</span><span class="cx">                                  _height,
</span><del>-                                 kCodecTypeH264,
</del><ins>+                                 kCMVideoCodecType_H264,
</ins><span class="cx">                                  encoderSpecs,  // use hardware accelerated encoder if available
</span><span class="cx">                                  sourceAttributes,
</span><span class="cx">                                  nullptr,  // use default compressed data allocator
</span><span class="cx">                                  compressionOutputCallback,
</span><span class="cx">                                  nullptr,
</span><del>-                                 &_compressionSession);
-  if (sourceAttributes) {
-    CFRelease(sourceAttributes);
-    sourceAttributes = nullptr;
-  }
-  if (encoderSpecs) {
-    CFRelease(encoderSpecs);
-    encoderSpecs = nullptr;
-  }
</del><ins>+                                 &_vtCompressionSession);
</ins><span class="cx"> 
</span><del>-#if ENABLE_VCP_ENCODER || defined(WEBRTC_IOS)
-  if (status != noErr) {
-    RTC_LOG(LS_ERROR) << "Failed to create compression session: " << status;
-    return WEBRTC_VIDEO_CODEC_ERROR;
-  }
-#endif
</del><span class="cx"> #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
</span><del>-  CFBooleanRef hwaccl_enabled = nullptr;
-  if (status == noErr) {
-    status = VTSessionCopyProperty(_compressionSession,
</del><ins>+#if ENABLE_VCP_ENCODER
+  if (!_useVCP) {
+    CFBooleanRef hwaccl_enabled = nullptr;
+    if (status == noErr) {
+      status = VTSessionCopyProperty(_vtCompressionSession,
</ins><span class="cx">                                  kVTCompressionPropertyKey_UsingHardwareAcceleratedVideoEncoder,
</span><span class="cx">                                  nullptr,
</span><span class="cx">                                  &hwaccl_enabled);
</span><ins>+    }
+    if (status == noErr && (CFBooleanGetValue(hwaccl_enabled))) {
+      RTC_LOG(LS_INFO) << "Compression session created with hw accl enabled";
+    } else {
+      [self destroyCompressionSession];
+
+      // Use VCP instead.
+      int usageValue = 1;
+      auto usage = CFNumberCreate(nullptr, kCFNumberIntType, &usageValue);
+      CFDictionarySetValue(encoderSpecs, kVTCompressionPropertyKey_Usage, usage);
+      CFRelease(usage);
+
+      RTC_LOG(LS_INFO) << "Compression session created with VCP";
+      status =
+          webrtc::VCPCompressionSessionCreate(nullptr,  // use default allocator
+                                 _width,
+                                 _height,
+                                 kVCPCodecType4CC_H264,
+                                 encoderSpecs,
+                                 sourceAttributes,
+                                 nullptr,  // use default compressed data allocator
+                                 compressionOutputCallback,
+                                 nullptr,
+                                 &_vcpCompressionSession);
+    }
</ins><span class="cx">   }
</span><del>-  if (status == noErr && (CFBooleanGetValue(hwaccl_enabled))) {
-    RTC_LOG(LS_INFO) << "Compression session created with hw accl enabled";
-  } else {
-    RTC_LOG(LS_INFO) << "Compression session created with hw accl disabled";
</del><ins>+#else
+  if (status != noErr) {
+    if (encoderSpecs) {
+        CFRelease(encoderSpecs);
+        encoderSpecs = nullptr;
+    }
+    if (sourceAttributes) {
+      CFRelease(sourceAttributes);
+      sourceAttributes = nullptr;
+    }
</ins><span class="cx"> 
</span><del>-#if !ENABLE_VCP_ENCODER && !ENABLE_VCP_VTB_ENCODER && !defined(WEBRTC_IOS)
</del><span class="cx">     if (!isStandardFrameSize(_width, _height)) {
</span><span class="cx">       _disableEncoding = true;
</span><span class="cx">       RTC_LOG(LS_ERROR) << "Using H264 software encoder with non standard size is not supported";
</span><span class="cx">       return WEBRTC_VIDEO_CODEC_ERROR;
</span><span class="cx">     }
</span><ins>+    [self destroyCompressionSession];
</ins><span class="cx"> 
</span><span class="cx">     CFDictionaryRef ioSurfaceValue = CreateCFTypeDictionary(nullptr, nullptr, 0);
</span><span class="cx">     int64_t pixelFormatType = framePixelFormat;
</span><span class="lines">@@ -687,7 +736,7 @@
</span><span class="cx">       kCFBooleanTrue,
</span><span class="cx">       ioSurfaceValue,
</span><span class="cx">       pixelFormat};
</span><del>-    CFDictionaryRef sourceAttributes = CreateCFTypeDictionary(keys, values, attributesSize);
</del><ins>+    sourceAttributes = CreateCFTypeDictionary(keys, values, attributesSize);
</ins><span class="cx"> 
</span><span class="cx">     if (ioSurfaceValue) {
</span><span class="cx">       CFRelease(ioSurfaceValue);
</span><span class="lines">@@ -698,61 +747,67 @@
</span><span class="cx">       pixelFormat = nullptr;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    CFMutableDictionaryRef encoderSpecs = CFDictionaryCreateMutable(nullptr, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
</del><ins>+    encoderSpecs = CFDictionaryCreateMutable(nullptr, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
</ins><span class="cx">     CFDictionarySetValue(encoderSpecs, kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder, kCFBooleanFalse);
</span><span class="cx">     int usageValue = 1;
</span><span class="cx">     CFNumberRef usage = CFNumberCreate(nullptr, kCFNumberIntType, &usageValue);
</span><span class="cx">     CFDictionarySetValue(encoderSpecs, kVTVideoEncoderSpecification_Usage, usage);
</span><del>-
</del><span class="cx">     if (usage) {
</span><span class="cx">       CFRelease(usage);
</span><span class="cx">       usage = nullptr;
</span><span class="cx">     }
</span><del>-
-    [self destroyCompressionSession];
-
-    OSStatus status =
-      CompressionSessionCreate(nullptr,  // use default allocator
</del><ins>+    status = VTCompressionSessionCreate(nullptr,  // use default allocator
</ins><span class="cx">                                  _width,
</span><span class="cx">                                  _height,
</span><del>-                                 kCodecTypeH264,
-                                 encoderSpecs,
</del><ins>+                                 kCMVideoCodecType_H264,
+                                 encoderSpecs,  // use hardware accelerated encoder if available
</ins><span class="cx">                                  sourceAttributes,
</span><span class="cx">                                  nullptr,  // use default compressed data allocator
</span><span class="cx">                                  compressionOutputCallback,
</span><span class="cx">                                  nullptr,
</span><del>-                                 &_compressionSession);
-    if (sourceAttributes) {
-      CFRelease(sourceAttributes);
-      sourceAttributes = nullptr;
-    }
-    if (encoderSpecs) {
-      CFRelease(encoderSpecs);
-      encoderSpecs = nullptr;
-    }
-    if (status != noErr) {
-      return WEBRTC_VIDEO_CODEC_ERROR;
-    }
-#endif
</del><ins>+                                 &_vtCompressionSession);
+
</ins><span class="cx">   }
</span><del>-#endif
</del><ins>+#endif // ENABLE_VCP_ENCODER
+#endif // defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
+  if (sourceAttributes) {
+    CFRelease(sourceAttributes);
+    sourceAttributes = nullptr;
+  }
+  if (encoderSpecs) {
+    CFRelease(encoderSpecs);
+    encoderSpecs = nullptr;
+  }
+
+  if (status != noErr) {
+    RTC_LOG(LS_ERROR) << "Failed to create compression session: " << status;
+    return WEBRTC_VIDEO_CODEC_ERROR;
+  }
+
</ins><span class="cx">   [self configureCompressionSession];
</span><span class="cx"> 
</span><span class="cx"> #if !defined(WEBRTC_WEBKIT_BUILD)
</span><span class="cx">   // The pixel buffer pool is dependent on the compression session so if the session is reset, the
</span><span class="cx">   // pool should be reset as well.
</span><del>-  _pixelBufferPool = CompressionSessionGetPixelBufferPool(_compressionSession);
</del><ins>+  if (_vtCompressionSession)
+    _pixelBufferPool = VTCompressionSessionGetPixelBufferPool(_vtCompressionSession);
+#if ENABLE_VCP_ENCODER
+  else
+    _pixelBufferPool = webrtc::VCPCompressionSessionGetPixelBufferPool(_vtCompressionSession);
</ins><span class="cx"> #endif
</span><ins>+#endif
</ins><span class="cx">   return WEBRTC_VIDEO_CODEC_OK;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)configureCompressionSession {
</span><del>-  RTC_DCHECK(_compressionSession);
-  SetVTSessionProperty(_compressionSession, kVTCompressionPropertyKey_RealTime, true);
-  SetVTSessionProperty(_compressionSession, kVTCompressionPropertyKey_ProfileLevel, _profile);
-  SetVTSessionProperty(_compressionSession, kVTCompressionPropertyKey_AllowFrameReordering, false);
</del><ins>+  RTC_DCHECK([self hasCompressionSession]);
+  SetVTSessionProperty(_vtCompressionSession, _vcpCompressionSession, kVTCompressionPropertyKey_RealTime, true);
+  SetVTSessionProperty(_vtCompressionSession, _vcpCompressionSession, kVTCompressionPropertyKey_ProfileLevel, _profile);
+  SetVTSessionProperty(_vtCompressionSession, _vcpCompressionSession, kVTCompressionPropertyKey_AllowFrameReordering, false);
</ins><span class="cx"> #if ENABLE_VCP_ENCODER
</span><del>-  SetVTSessionProperty(_compressionSession, kVTCompressionPropertyKey_Usage, 1);
</del><ins>+  if (_useVCP) {
+    SetVTSessionProperty(_vtCompressionSession, _vcpCompressionSession, kVTCompressionPropertyKey_Usage, 1);
+  }
</ins><span class="cx"> #endif
</span><span class="cx">   [self setEncoderBitrateBps:_targetBitrateBps];
</span><span class="cx">   // TODO(tkchin): Look at entropy mode and colorspace matrices.
</span><span class="lines">@@ -764,18 +819,24 @@
</span><span class="cx">   //     1);
</span><span class="cx"> 
</span><span class="cx">   // Set a relatively large value for keyframe emission (7200 frames or 4 minutes).
</span><del>-  SetVTSessionProperty(_compressionSession, kVTCompressionPropertyKey_MaxKeyFrameInterval, 7200);
-  SetVTSessionProperty(
-      _compressionSession, kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration, 240);
</del><ins>+  SetVTSessionProperty(_vtCompressionSession, _vcpCompressionSession, kVTCompressionPropertyKey_MaxKeyFrameInterval, 7200);
+  SetVTSessionProperty(_vtCompressionSession, _vcpCompressionSession, kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration, 240);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)destroyCompressionSession {
</span><del>-  if (_compressionSession) {
-    CompressionSessionInvalidate(_compressionSession);
-    CFRelease(_compressionSession);
-    _compressionSession = nullptr;
-    _pixelBufferPool = nullptr;
</del><ins>+  if (_vtCompressionSession) {
+    VTCompressionSessionInvalidate(_vtCompressionSession);
+    CFRelease(_vtCompressionSession);
+    _vtCompressionSession = nullptr;
</ins><span class="cx">   }
</span><ins>+#if ENABLE_VCP_ENCODER
+  if (_vcpCompressionSession) {
+    webrtc::VCPCompressionSessionInvalidate(_vcpCompressionSession);
+    CFRelease(_vcpCompressionSession);
+    _vcpCompressionSession = nullptr;
+  }
+#endif
+  _pixelBufferPool = nullptr;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (NSString *)implementationName {
</span><span class="lines">@@ -789,8 +850,8 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> - (void)setEncoderBitrateBps:(uint32_t)bitrateBps {
</span><del>-  if (_compressionSession) {
-    SetVTSessionProperty(_compressionSession, kVTCompressionPropertyKey_AverageBitRate, bitrateBps);
</del><ins>+  if ([self hasCompressionSession]) {
+    SetVTSessionProperty(_vtCompressionSession, _vcpCompressionSession, kVTCompressionPropertyKey_AverageBitRate, bitrateBps);
</ins><span class="cx"> 
</span><span class="cx">     // TODO(tkchin): Add a helper method to set array value.
</span><span class="cx">     int64_t dataLimitBytesPerSecondValue =
</span><span class="lines">@@ -802,8 +863,19 @@
</span><span class="cx">         CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &oneSecondValue);
</span><span class="cx">     const void *nums[2] = {bytesPerSecond, oneSecond};
</span><span class="cx">     CFArrayRef dataRateLimits = CFArrayCreate(nullptr, nums, 2, &kCFTypeArrayCallBacks);
</span><del>-    OSStatus status = CompressionSessionSetProperty(
-        _compressionSession, kVTCompressionPropertyKey_DataRateLimits, dataRateLimits);
</del><ins>+
+    OSStatus status = noErr;
+    if (_vtCompressionSession)
+      VTSessionSetProperty(_vtCompressionSession, kVTCompressionPropertyKey_DataRateLimits, dataRateLimits);
+#if ENABLE_VCP_ENCODER
+    else
+      webrtc::VCPCompressionSessionSetProperty(_vcpCompressionSession, kVTCompressionPropertyKey_DataRateLimits, dataRateLimits);
+#endif
+    if (status != noErr) {
+      RTC_LOG(LS_ERROR) << "VTSessionSetProperty failed to set: " << kVTCompressionPropertyKey_DataRateLimits
+        << ": " << status;
+    }
+
</ins><span class="cx">     if (bytesPerSecond) {
</span><span class="cx">       CFRelease(bytesPerSecond);
</span><span class="cx">     }
</span><span class="lines">@@ -813,10 +885,6 @@
</span><span class="cx">     if (dataRateLimits) {
</span><span class="cx">       CFRelease(dataRateLimits);
</span><span class="cx">     }
</span><del>-    if (status != noErr) {
-      RTC_LOG(LS_ERROR) << "Failed to set data rate limit";
-    }
-
</del><span class="cx">     _encoderBitrateBps = bitrateBps;
</span><span class="cx">   }
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkSourceThirdPartylibwebrtcSourcewebrtcsdkobjccomponentsvideo_codechelperscc"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/helpers.cc (246262 => 246263)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/helpers.cc       2019-06-10 14:42:26 UTC (rev 246262)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/helpers.cc  2019-06-10 15:59:14 UTC (rev 246263)
</span><span class="lines">@@ -35,12 +35,19 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Convenience function for setting a VT property.
</span><del>-void SetVTSessionProperty(CompressionSessionRef session,
</del><ins>+void SetVTSessionProperty(VTCompressionSessionRef vtSession, VCPCompressionSessionRef vcpSession,
</ins><span class="cx">                           CFStringRef key,
</span><span class="cx">                           int32_t value) {
</span><ins>+  RTC_DCHECK(vtSession || vcpSession);
</ins><span class="cx">   CFNumberRef cfNum =
</span><span class="cx">       CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &value);
</span><del>-  OSStatus status = CompressionSessionSetProperty(session, key, cfNum);
</del><ins>+  OSStatus status = noErr;
+  if (vtSession)
+    status = VTSessionSetProperty(vtSession, key, cfNum);
+#if ENABLE_VCP_ENCODER
+  else
+    status = webrtc::VCPCompressionSessionSetProperty(vcpSession, key, cfNum);
+#endif
</ins><span class="cx">   CFRelease(cfNum);
</span><span class="cx">   if (status != noErr) {
</span><span class="cx">     std::string key_string = CFStringToString(key);
</span><span class="lines">@@ -50,13 +57,20 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Convenience function for setting a VT property.
</span><del>-void SetVTSessionProperty(CompressionSessionRef session,
</del><ins>+void SetVTSessionProperty(VTCompressionSessionRef vtSession, VCPCompressionSessionRef vcpSession,
</ins><span class="cx">                           CFStringRef key,
</span><span class="cx">                           uint32_t value) {
</span><ins>+  RTC_DCHECK(vtSession || vcpSession);
</ins><span class="cx">   int64_t value_64 = value;
</span><span class="cx">   CFNumberRef cfNum =
</span><span class="cx">       CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt64Type, &value_64);
</span><del>-  OSStatus status = CompressionSessionSetProperty(session, key, cfNum);
</del><ins>+  OSStatus status = noErr;
+  if (vtSession)
+    status = VTSessionSetProperty(vtSession, key, cfNum);
+#if ENABLE_VCP_ENCODER
+  else
+    status = webrtc::VCPCompressionSessionSetProperty(vcpSession, key, cfNum);
+#endif
</ins><span class="cx">   CFRelease(cfNum);
</span><span class="cx">   if (status != noErr) {
</span><span class="cx">     std::string key_string = CFStringToString(key);
</span><span class="lines">@@ -66,9 +80,16 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Convenience function for setting a VT property.
</span><del>-void SetVTSessionProperty(CompressionSessionRef session, CFStringRef key, bool value) {
</del><ins>+void SetVTSessionProperty(VTCompressionSessionRef vtSession, VCPCompressionSessionRef vcpSession, CFStringRef key, bool value) {
+  RTC_DCHECK(vtSession || vcpSession);
</ins><span class="cx">   CFBooleanRef cf_bool = (value) ? kCFBooleanTrue : kCFBooleanFalse;
</span><del>-  OSStatus status = CompressionSessionSetProperty(session, key, cf_bool);
</del><ins>+  OSStatus status = noErr;
+  if (vtSession)
+    status = VTSessionSetProperty(vtSession, key, cf_bool);
+#if ENABLE_VCP_ENCODER
+  else
+    status = webrtc::VCPCompressionSessionSetProperty(vcpSession, key, cf_bool);
+#endif
</ins><span class="cx">   if (status != noErr) {
</span><span class="cx">     std::string key_string = CFStringToString(key);
</span><span class="cx">     RTC_LOG(LS_ERROR) << "VTSessionSetProperty failed to set: " << key_string
</span><span class="lines">@@ -77,10 +98,17 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> // Convenience function for setting a VT property.
</span><del>-void SetVTSessionProperty(CompressionSessionRef session,
</del><ins>+void SetVTSessionProperty(VTCompressionSessionRef vtSession, VCPCompressionSessionRef vcpSession,
</ins><span class="cx">                           CFStringRef key,
</span><span class="cx">                           CFStringRef value) {
</span><del>-  OSStatus status = CompressionSessionSetProperty(session, key, value);
</del><ins>+  RTC_DCHECK(vtSession || vcpSession);
+  OSStatus status = noErr;
+  if (vtSession)
+    status = VTSessionSetProperty(vtSession, key, value);
+#if ENABLE_VCP_ENCODER
+  else
+    status = webrtc::VCPCompressionSessionSetProperty(vcpSession, key, value);
+#endif
</ins><span class="cx">   if (status != noErr) {
</span><span class="cx">     std::string key_string = CFStringToString(key);
</span><span class="cx">     std::string val_string = CFStringToString(value);
</span></span></pre></div>
<a id="trunkSourceThirdPartylibwebrtcSourcewebrtcsdkobjccomponentsvideo_codechelpersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/helpers.h (246262 => 246263)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/helpers.h        2019-06-10 14:42:26 UTC (rev 246262)
+++ trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/helpers.h   2019-06-10 15:59:14 UTC (rev 246263)
</span><span class="lines">@@ -16,7 +16,7 @@
</span><span class="cx"> #include <VideoToolbox/VideoToolbox.h>
</span><span class="cx"> #include <string>
</span><span class="cx"> 
</span><del>-#include "sdk/WebKit/EncoderUtilities.h"
</del><ins>+#include "sdk/WebKit/VideoProcessingSoftLink.h"
</ins><span class="cx"> 
</span><span class="cx"> // Convenience function for creating a dictionary.
</span><span class="cx"> inline CFDictionaryRef CreateCFTypeDictionary(CFTypeRef* keys,
</span><span class="lines">@@ -31,18 +31,18 @@
</span><span class="cx"> std::string CFStringToString(const CFStringRef cf_string);
</span><span class="cx"> 
</span><span class="cx"> // Convenience function for setting a VT property.
</span><del>-void SetVTSessionProperty(CompressionSessionRef session, CFStringRef key, int32_t value);
</del><ins>+void SetVTSessionProperty(VTCompressionSessionRef session, VCPCompressionSessionRef vcpSession,CFStringRef key, int32_t value);
</ins><span class="cx"> 
</span><span class="cx"> // Convenience function for setting a VT property.
</span><del>-void SetVTSessionProperty(CompressionSessionRef session,
</del><ins>+void SetVTSessionProperty(VTCompressionSessionRef session, VCPCompressionSessionRef vcpSession,
</ins><span class="cx">                           CFStringRef key,
</span><span class="cx">                           uint32_t value);
</span><span class="cx"> 
</span><span class="cx"> // Convenience function for setting a VT property.
</span><del>-void SetVTSessionProperty(CompressionSessionRef session, CFStringRef key, bool value);
</del><ins>+void SetVTSessionProperty(VTCompressionSessionRef session, VCPCompressionSessionRef vcpSession, CFStringRef key, bool value);
</ins><span class="cx"> 
</span><span class="cx"> // Convenience function for setting a VT property.
</span><del>-void SetVTSessionProperty(CompressionSessionRef session,
</del><ins>+void SetVTSessionProperty(VTCompressionSessionRef session, VCPCompressionSessionRef vcpSession,
</ins><span class="cx">                           CFStringRef key,
</span><span class="cx">                           CFStringRef value);
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>