Add a webrtc{en,de}coderfactory implementation for VideoToolbox
This CL removes the coupling of the VideoToolbox h264 implementation to the generic h264 code. The files have been moved into sdb/obj/Framework and all dependency on them has been removed from the rest of WebRTC. We now add it as an external encoder via a factory supplied to the CreatePeerConnectionFactory call. This also brings the iOS implementation closer to what we do on Android for MediaCodec. BUG=webrtc:6619 Review-Url: https://codereview.webrtc.org/2463313002 Cr-Commit-Position: refs/heads/master@{#14953}
This commit is contained in:
@ -705,10 +705,7 @@ if (rtc_include_tests) {
|
|||||||
"//build/config/compiler:enable_arc",
|
"//build/config/compiler:enable_arc",
|
||||||
]
|
]
|
||||||
|
|
||||||
sources += [
|
sources += [ "audio_device/ios/objc/RTCAudioSessionTest.mm" ]
|
||||||
"audio_device/ios/objc/RTCAudioSessionTest.mm",
|
|
||||||
"video_coding/codecs/h264/h264_video_toolbox_nalu_unittest.cc",
|
|
||||||
]
|
|
||||||
|
|
||||||
if (target_cpu != "x64") {
|
if (target_cpu != "x64") {
|
||||||
sources += [ "audio_device/ios/audio_device_unittest_ios.cc" ]
|
sources += [ "audio_device/ios/audio_device_unittest_ios.cc" ]
|
||||||
|
|||||||
@ -141,11 +141,6 @@ rtc_static_library("webrtc_h264") {
|
|||||||
"../../system_wrappers",
|
"../../system_wrappers",
|
||||||
]
|
]
|
||||||
|
|
||||||
if (is_ios) {
|
|
||||||
sources += [ "codecs/h264/h264_objc.mm" ]
|
|
||||||
deps += [ ":webrtc_h264_video_toolbox" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rtc_use_h264) {
|
if (rtc_use_h264) {
|
||||||
defines += [ "WEBRTC_USE_H264" ]
|
defines += [ "WEBRTC_USE_H264" ]
|
||||||
if (rtc_initialize_ffmpeg) {
|
if (rtc_initialize_ffmpeg) {
|
||||||
@ -165,60 +160,6 @@ rtc_static_library("webrtc_h264") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_ios) {
|
|
||||||
config("webrtc_h264_video_toolbox_warnings_config") {
|
|
||||||
if (is_clang) {
|
|
||||||
# TODO(tkchin): Make webrtc_h264_video_toolbox compile with the standard set
|
|
||||||
# of warnings.
|
|
||||||
# See https://bugs.chromium.org/p/webrtc/issues/detail?id=6307
|
|
||||||
cflags = [ "-Wno-thread-safety-analysis" ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rtc_static_library("webrtc_h264_video_toolbox") {
|
|
||||||
sources = [
|
|
||||||
"codecs/h264/h264_video_toolbox_decoder.cc",
|
|
||||||
"codecs/h264/h264_video_toolbox_decoder.h",
|
|
||||||
"codecs/h264/h264_video_toolbox_encoder.h",
|
|
||||||
"codecs/h264/h264_video_toolbox_encoder.mm",
|
|
||||||
"codecs/h264/h264_video_toolbox_nalu.cc",
|
|
||||||
"codecs/h264/h264_video_toolbox_nalu.h",
|
|
||||||
]
|
|
||||||
|
|
||||||
configs += [
|
|
||||||
":webrtc_h264_video_toolbox_warnings_config",
|
|
||||||
"../..:common_objc",
|
|
||||||
"//build/config/compiler:enable_arc",
|
|
||||||
]
|
|
||||||
|
|
||||||
deps = [
|
|
||||||
"../../sdk:rtc_sdk_common_objc",
|
|
||||||
]
|
|
||||||
|
|
||||||
libs = [
|
|
||||||
"CoreFoundation.framework",
|
|
||||||
"CoreMedia.framework",
|
|
||||||
"CoreVideo.framework",
|
|
||||||
"VideoToolbox.framework",
|
|
||||||
]
|
|
||||||
|
|
||||||
if (!build_with_chromium && is_clang) {
|
|
||||||
# Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
|
|
||||||
suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rtc_build_libyuv) {
|
|
||||||
deps += [ "$rtc_libyuv_dir" ]
|
|
||||||
public_deps = [
|
|
||||||
"$rtc_libyuv_dir",
|
|
||||||
]
|
|
||||||
} else {
|
|
||||||
# Need to add a directory normally exported by libyuv.
|
|
||||||
include_dirs = [ "$rtc_libyuv_dir/include" ]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rtc_static_library("webrtc_i420") {
|
rtc_static_library("webrtc_i420") {
|
||||||
sources = [
|
sources = [
|
||||||
"codecs/i420/i420.cc",
|
"codecs/i420/i420.cc",
|
||||||
|
|||||||
@ -15,10 +15,6 @@
|
|||||||
#include "webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.h"
|
#include "webrtc/modules/video_coding/codecs/h264/h264_decoder_impl.h"
|
||||||
#include "webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h"
|
#include "webrtc/modules/video_coding/codecs/h264/h264_encoder_impl.h"
|
||||||
#endif
|
#endif
|
||||||
#if defined(WEBRTC_IOS)
|
|
||||||
#include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_decoder.h"
|
|
||||||
#include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "webrtc/base/checks.h"
|
#include "webrtc/base/checks.h"
|
||||||
#include "webrtc/base/logging.h"
|
#include "webrtc/base/logging.h"
|
||||||
@ -39,20 +35,8 @@ void DisableRtcUseH264() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need this file to be C++ only so it will compile properly for all
|
|
||||||
// platforms. In order to write ObjC specific implementations we use private
|
|
||||||
// externs. This function is defined in h264.mm.
|
|
||||||
#if defined(WEBRTC_IOS)
|
|
||||||
extern bool IsH264CodecSupportedObjC();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// If any H.264 codec is supported (iOS HW or OpenH264/FFmpeg).
|
// If any H.264 codec is supported (iOS HW or OpenH264/FFmpeg).
|
||||||
bool IsH264CodecSupported() {
|
bool IsH264CodecSupported() {
|
||||||
#if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
|
|
||||||
if (IsH264CodecSupportedObjC()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if defined(WEBRTC_USE_H264)
|
#if defined(WEBRTC_USE_H264)
|
||||||
return g_rtc_use_h264;
|
return g_rtc_use_h264;
|
||||||
#else
|
#else
|
||||||
@ -62,12 +46,6 @@ bool IsH264CodecSupported() {
|
|||||||
|
|
||||||
H264Encoder* H264Encoder::Create() {
|
H264Encoder* H264Encoder::Create() {
|
||||||
RTC_DCHECK(H264Encoder::IsSupported());
|
RTC_DCHECK(H264Encoder::IsSupported());
|
||||||
#if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
|
|
||||||
if (IsH264CodecSupportedObjC()) {
|
|
||||||
LOG(LS_INFO) << "Creating H264VideoToolboxEncoder.";
|
|
||||||
return new H264VideoToolboxEncoder();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if defined(WEBRTC_USE_H264)
|
#if defined(WEBRTC_USE_H264)
|
||||||
RTC_CHECK(g_rtc_use_h264);
|
RTC_CHECK(g_rtc_use_h264);
|
||||||
LOG(LS_INFO) << "Creating H264EncoderImpl.";
|
LOG(LS_INFO) << "Creating H264EncoderImpl.";
|
||||||
@ -84,12 +62,6 @@ bool H264Encoder::IsSupported() {
|
|||||||
|
|
||||||
H264Decoder* H264Decoder::Create() {
|
H264Decoder* H264Decoder::Create() {
|
||||||
RTC_DCHECK(H264Decoder::IsSupported());
|
RTC_DCHECK(H264Decoder::IsSupported());
|
||||||
#if defined(WEBRTC_IOS) && defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
|
|
||||||
if (IsH264CodecSupportedObjC()) {
|
|
||||||
LOG(LS_INFO) << "Creating H264VideoToolboxDecoder.";
|
|
||||||
return new H264VideoToolboxDecoder();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if defined(WEBRTC_USE_H264)
|
#if defined(WEBRTC_USE_H264)
|
||||||
RTC_CHECK(g_rtc_use_h264);
|
RTC_CHECK(g_rtc_use_h264);
|
||||||
LOG(LS_INFO) << "Creating H264DecoderImpl.";
|
LOG(LS_INFO) << "Creating H264DecoderImpl.";
|
||||||
|
|||||||
@ -15,14 +15,6 @@
|
|||||||
'target_name': 'webrtc_h264',
|
'target_name': 'webrtc_h264',
|
||||||
'type': 'static_library',
|
'type': 'static_library',
|
||||||
'conditions': [
|
'conditions': [
|
||||||
['OS=="ios"', {
|
|
||||||
'dependencies': [
|
|
||||||
'webrtc_h264_video_toolbox',
|
|
||||||
],
|
|
||||||
'sources': [
|
|
||||||
'h264_objc.mm',
|
|
||||||
],
|
|
||||||
}],
|
|
||||||
# TODO(hbos): Consider renaming this flag and the below macro to
|
# TODO(hbos): Consider renaming this flag and the below macro to
|
||||||
# something which helps distinguish OpenH264/FFmpeg from other H264
|
# something which helps distinguish OpenH264/FFmpeg from other H264
|
||||||
# implementations.
|
# implementations.
|
||||||
@ -56,41 +48,4 @@
|
|||||||
],
|
],
|
||||||
}, # webrtc_h264
|
}, # webrtc_h264
|
||||||
],
|
],
|
||||||
'conditions': [
|
|
||||||
['OS=="ios"', {
|
|
||||||
'targets': [
|
|
||||||
{
|
|
||||||
'target_name': 'webrtc_h264_video_toolbox',
|
|
||||||
'type': 'static_library',
|
|
||||||
'includes': [ '../../../../build/objc_common.gypi' ],
|
|
||||||
'dependencies': [
|
|
||||||
'<(webrtc_root)/sdk/sdk.gyp:rtc_sdk_common_objc',
|
|
||||||
],
|
|
||||||
'link_settings': {
|
|
||||||
'xcode_settings': {
|
|
||||||
'OTHER_LDFLAGS': [
|
|
||||||
'-framework CoreFoundation',
|
|
||||||
'-framework CoreMedia',
|
|
||||||
'-framework CoreVideo',
|
|
||||||
'-framework VideoToolbox',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
'sources': [
|
|
||||||
'h264_video_toolbox_decoder.cc',
|
|
||||||
'h264_video_toolbox_decoder.h',
|
|
||||||
'h264_video_toolbox_encoder.h',
|
|
||||||
'h264_video_toolbox_encoder.mm',
|
|
||||||
'h264_video_toolbox_nalu.cc',
|
|
||||||
'h264_video_toolbox_nalu.h',
|
|
||||||
],
|
|
||||||
'conditions': [
|
|
||||||
['build_libyuv==1', {
|
|
||||||
'dependencies': ['<(DEPTH)/third_party/libyuv/libyuv.gyp:libyuv'],
|
|
||||||
}],
|
|
||||||
],
|
|
||||||
}, # webrtc_h264_video_toolbox
|
|
||||||
], # targets
|
|
||||||
}], # OS=="ios"
|
|
||||||
], # conditions
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Use of this source code is governed by a BSD-style license
|
|
||||||
* that can be found in the LICENSE file in the root of the source
|
|
||||||
* tree. An additional intellectual property rights grant can be found
|
|
||||||
* in the file PATENTS. All contributing project authors may
|
|
||||||
* be found in the AUTHORS file in the root of the source tree.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
|
|
||||||
|
|
||||||
#if defined(WEBRTC_IOS)
|
|
||||||
#import <UIKit/UIKit.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace webrtc {
|
|
||||||
|
|
||||||
bool IsH264CodecSupportedObjC() {
|
|
||||||
#if defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED) && \
|
|
||||||
defined(WEBRTC_IOS)
|
|
||||||
// Supported on iOS8+.
|
|
||||||
return [[[UIDevice currentDevice] systemVersion] doubleValue] >= 8.0;
|
|
||||||
#else
|
|
||||||
// TODO(tkchin): Support OS/X once we stop mixing libstdc++ and libc++ on
|
|
||||||
// OSX 10.9.
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace webrtc
|
|
||||||
@ -30,6 +30,14 @@ if (is_ios || (is_mac && mac_deployment_target == "10.7")) {
|
|||||||
"objc/Framework/Headers",
|
"objc/Framework/Headers",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
config("webrtc_h264_video_toolbox_warnings_config") {
|
||||||
|
if (is_clang) {
|
||||||
|
# TODO(tkchin): Make webrtc_h264_video_toolbox compile with the standard set
|
||||||
|
# of warnings.
|
||||||
|
# See https://bugs.chromium.org/p/webrtc/issues/detail?id=6307
|
||||||
|
cflags = [ "-Wno-thread-safety-analysis" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rtc_static_library("rtc_sdk_common_objc") {
|
rtc_static_library("rtc_sdk_common_objc") {
|
||||||
deps = [
|
deps = [
|
||||||
@ -143,6 +151,8 @@ if (is_ios || (is_mac && mac_deployment_target == "10.7")) {
|
|||||||
"objc/Framework/Classes/RTCVideoTrack.mm",
|
"objc/Framework/Classes/RTCVideoTrack.mm",
|
||||||
"objc/Framework/Classes/avfoundationvideocapturer.h",
|
"objc/Framework/Classes/avfoundationvideocapturer.h",
|
||||||
"objc/Framework/Classes/avfoundationvideocapturer.mm",
|
"objc/Framework/Classes/avfoundationvideocapturer.mm",
|
||||||
|
"objc/Framework/Classes/videotoolboxvideocodecfactory.cc",
|
||||||
|
"objc/Framework/Classes/videotoolboxvideocodecfactory.h",
|
||||||
"objc/Framework/Headers/WebRTC/RTCAVFoundationVideoSource.h",
|
"objc/Framework/Headers/WebRTC/RTCAVFoundationVideoSource.h",
|
||||||
"objc/Framework/Headers/WebRTC/RTCAudioSource.h",
|
"objc/Framework/Headers/WebRTC/RTCAudioSource.h",
|
||||||
"objc/Framework/Headers/WebRTC/RTCAudioTrack.h",
|
"objc/Framework/Headers/WebRTC/RTCAudioTrack.h",
|
||||||
@ -182,6 +192,9 @@ if (is_ios || (is_mac && mac_deployment_target == "10.7")) {
|
|||||||
"OpenGLES.framework",
|
"OpenGLES.framework",
|
||||||
"QuartzCore.framework",
|
"QuartzCore.framework",
|
||||||
]
|
]
|
||||||
|
deps = [
|
||||||
|
":webrtc_h264_video_toolbox",
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_mac) {
|
if (is_mac) {
|
||||||
@ -193,6 +206,7 @@ if (is_ios || (is_mac && mac_deployment_target == "10.7")) {
|
|||||||
"CoreMedia.framework",
|
"CoreMedia.framework",
|
||||||
"OpenGL.framework",
|
"OpenGL.framework",
|
||||||
]
|
]
|
||||||
|
deps = []
|
||||||
}
|
}
|
||||||
|
|
||||||
configs += [
|
configs += [
|
||||||
@ -209,7 +223,7 @@ if (is_ios || (is_mac && mac_deployment_target == "10.7")) {
|
|||||||
|
|
||||||
libs += [ "AVFoundation.framework" ]
|
libs += [ "AVFoundation.framework" ]
|
||||||
|
|
||||||
deps = [
|
deps += [
|
||||||
":rtc_sdk_common_objc",
|
":rtc_sdk_common_objc",
|
||||||
"../api:libjingle_peerconnection",
|
"../api:libjingle_peerconnection",
|
||||||
]
|
]
|
||||||
@ -351,8 +365,51 @@ if (is_ios || (is_mac && mac_deployment_target == "10.7")) {
|
|||||||
complete_static_lib = true
|
complete_static_lib = true
|
||||||
deps = [
|
deps = [
|
||||||
":rtc_sdk_peerconnection_objc",
|
":rtc_sdk_peerconnection_objc",
|
||||||
"../system_wrappers:field_trial_default",
|
"//webrtc/system_wrappers:field_trial_default",
|
||||||
"../system_wrappers:metrics_default",
|
"//webrtc/system_wrappers:metrics_default",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rtc_static_library("webrtc_h264_video_toolbox") {
|
||||||
|
sources = [
|
||||||
|
"objc/Framework/Classes/h264_video_toolbox_decoder.cc",
|
||||||
|
"objc/Framework/Classes/h264_video_toolbox_decoder.h",
|
||||||
|
"objc/Framework/Classes/h264_video_toolbox_encoder.h",
|
||||||
|
"objc/Framework/Classes/h264_video_toolbox_encoder.mm",
|
||||||
|
"objc/Framework/Classes/h264_video_toolbox_nalu.cc",
|
||||||
|
"objc/Framework/Classes/h264_video_toolbox_nalu.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
configs += [
|
||||||
|
":webrtc_h264_video_toolbox_warnings_config",
|
||||||
|
"//webrtc:common_objc",
|
||||||
|
"//build/config/compiler:enable_arc",
|
||||||
|
]
|
||||||
|
|
||||||
|
deps = [
|
||||||
|
":rtc_sdk_common_objc",
|
||||||
|
]
|
||||||
|
|
||||||
|
libs = [
|
||||||
|
"CoreFoundation.framework",
|
||||||
|
"CoreMedia.framework",
|
||||||
|
"CoreVideo.framework",
|
||||||
|
"VideoToolbox.framework",
|
||||||
|
]
|
||||||
|
|
||||||
|
if (!build_with_chromium && is_clang) {
|
||||||
|
# Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163).
|
||||||
|
suppressed_configs += [ "//build/config/clang:find_bad_constructs" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rtc_build_libyuv) {
|
||||||
|
deps += [ "$rtc_libyuv_dir" ]
|
||||||
|
public_deps = [
|
||||||
|
"$rtc_libyuv_dir",
|
||||||
|
]
|
||||||
|
} else {
|
||||||
|
# Need to add a directory normally exported by libyuv.
|
||||||
|
include_dirs = [ "$rtc_libyuv_dir/include" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,8 @@ include_rules = [
|
|||||||
"+WebRTC",
|
"+WebRTC",
|
||||||
"+webrtc/api",
|
"+webrtc/api",
|
||||||
"+webrtc/common_video/include",
|
"+webrtc/common_video/include",
|
||||||
|
"+webrtc/common_video/h264",
|
||||||
"+webrtc/media",
|
"+webrtc/media",
|
||||||
|
"+webrtc/modules/video_coding",
|
||||||
"+webrtc/system_wrappers",
|
"+webrtc/system_wrappers",
|
||||||
]
|
]
|
||||||
|
|||||||
@ -21,6 +21,8 @@
|
|||||||
#import "RTCVideoTrack+Private.h"
|
#import "RTCVideoTrack+Private.h"
|
||||||
#import "WebRTC/RTCLogging.h"
|
#import "WebRTC/RTCLogging.h"
|
||||||
|
|
||||||
|
#include "videotoolboxvideocodecfactory.h"
|
||||||
|
|
||||||
@implementation RTCPeerConnectionFactory {
|
@implementation RTCPeerConnectionFactory {
|
||||||
std::unique_ptr<rtc::Thread> _networkThread;
|
std::unique_ptr<rtc::Thread> _networkThread;
|
||||||
std::unique_ptr<rtc::Thread> _workerThread;
|
std::unique_ptr<rtc::Thread> _workerThread;
|
||||||
@ -44,9 +46,14 @@
|
|||||||
result = _signalingThread->Start();
|
result = _signalingThread->Start();
|
||||||
NSAssert(result, @"Failed to start signaling thread.");
|
NSAssert(result, @"Failed to start signaling thread.");
|
||||||
|
|
||||||
|
const auto encoder_factory = new webrtc::VideoToolboxVideoEncoderFactory();
|
||||||
|
const auto decoder_factory = new webrtc::VideoToolboxVideoDecoderFactory();
|
||||||
|
|
||||||
|
// Ownership of encoder/decoder factories is passed on to the
|
||||||
|
// peerconnectionfactory, that handles deleting them.
|
||||||
_nativeFactory = webrtc::CreatePeerConnectionFactory(
|
_nativeFactory = webrtc::CreatePeerConnectionFactory(
|
||||||
_networkThread.get(), _workerThread.get(), _signalingThread.get(),
|
_networkThread.get(), _workerThread.get(), _signalingThread.get(),
|
||||||
nullptr, nullptr, nullptr);
|
nullptr, encoder_factory, decoder_factory);
|
||||||
NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!");
|
NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!");
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
|
|||||||
@ -9,9 +9,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_decoder.h"
|
#include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_decoder.h"
|
||||||
|
|
||||||
#if defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -22,7 +20,7 @@
|
|||||||
#include "webrtc/base/checks.h"
|
#include "webrtc/base/checks.h"
|
||||||
#include "webrtc/base/logging.h"
|
#include "webrtc/base/logging.h"
|
||||||
#include "webrtc/common_video/include/corevideo_frame_buffer.h"
|
#include "webrtc/common_video/include/corevideo_frame_buffer.h"
|
||||||
#include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu.h"
|
#include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_nalu.h"
|
||||||
#include "webrtc/video_frame.h"
|
#include "webrtc/video_frame.h"
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
@ -277,5 +275,3 @@ const char* H264VideoToolboxDecoder::ImplementationName() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
|
|
||||||
@ -9,13 +9,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_H264_VIDEO_TOOLBOX_DECODER_H_
|
#ifndef WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_H264_VIDEO_TOOLBOX_DECODER_H_
|
||||||
#define WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_H264_VIDEO_TOOLBOX_DECODER_H_
|
#define WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_H264_VIDEO_TOOLBOX_DECODER_H_
|
||||||
|
|
||||||
#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
|
#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
|
||||||
|
|
||||||
#if defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
|
|
||||||
|
|
||||||
#include <VideoToolbox/VideoToolbox.h>
|
#include <VideoToolbox/VideoToolbox.h>
|
||||||
|
|
||||||
// This file provides a H264 encoder implementation using the VideoToolbox
|
// This file provides a H264 encoder implementation using the VideoToolbox
|
||||||
@ -58,5 +56,4 @@ class H264VideoToolboxDecoder : public H264Decoder {
|
|||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
|
#endif // WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_H264_VIDEO_TOOLBOX_DECODER_H_
|
||||||
#endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_H264_VIDEO_TOOLBOX_DECODER_H_
|
|
||||||
@ -9,8 +9,8 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_H264_VIDEO_TOOLBOX_ENCODER_H_
|
#ifndef WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_H264_VIDEO_TOOLBOX_ENCODER_H_
|
||||||
#define WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_H264_VIDEO_TOOLBOX_ENCODER_H_
|
#define WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_H264_VIDEO_TOOLBOX_ENCODER_H_
|
||||||
|
|
||||||
#include "webrtc/base/criticalsection.h"
|
#include "webrtc/base/criticalsection.h"
|
||||||
#include "webrtc/common_video/h264/h264_bitstream_parser.h"
|
#include "webrtc/common_video/h264/h264_bitstream_parser.h"
|
||||||
@ -19,8 +19,6 @@
|
|||||||
#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
|
#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
|
||||||
#include "webrtc/modules/video_coding/utility/quality_scaler.h"
|
#include "webrtc/modules/video_coding/utility/quality_scaler.h"
|
||||||
|
|
||||||
#if defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
|
|
||||||
|
|
||||||
#include <VideoToolbox/VideoToolbox.h>
|
#include <VideoToolbox/VideoToolbox.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -94,5 +92,4 @@ class H264VideoToolboxEncoder : public H264Encoder {
|
|||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
|
#endif // WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_H264_VIDEO_TOOLBOX_ENCODER_H_
|
||||||
#endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_H264_VIDEO_TOOLBOX_ENCODER_H_
|
|
||||||
@ -9,9 +9,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_encoder.h"
|
#include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h"
|
||||||
|
|
||||||
#if defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -25,7 +23,7 @@
|
|||||||
#include "webrtc/base/checks.h"
|
#include "webrtc/base/checks.h"
|
||||||
#include "webrtc/base/logging.h"
|
#include "webrtc/base/logging.h"
|
||||||
#include "webrtc/common_video/include/corevideo_frame_buffer.h"
|
#include "webrtc/common_video/include/corevideo_frame_buffer.h"
|
||||||
#include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu.h"
|
#include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_nalu.h"
|
||||||
#include "webrtc/system_wrappers/include/clock.h"
|
#include "webrtc/system_wrappers/include/clock.h"
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
@ -660,5 +658,3 @@ void H264VideoToolboxEncoder::OnEncodedFrame(
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
|
|
||||||
@ -9,9 +9,7 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu.h"
|
#include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_nalu.h"
|
||||||
|
|
||||||
#if defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
|
|
||||||
|
|
||||||
#include <CoreFoundation/CoreFoundation.h>
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@ -365,5 +363,3 @@ size_t AvccBufferWriter::BytesRemaining() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
|
|
||||||
@ -9,13 +9,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_H264_VIDEO_TOOLBOX_NALU_H_
|
#ifndef WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_H264_VIDEO_TOOLBOX_NALU_H_
|
||||||
#define WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_H264_VIDEO_TOOLBOX_NALU_H_
|
#define WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_H264_VIDEO_TOOLBOX_NALU_H_
|
||||||
|
|
||||||
#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
|
#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
|
||||||
|
|
||||||
#if defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
|
|
||||||
|
|
||||||
#include <CoreMedia/CoreMedia.h>
|
#include <CoreMedia/CoreMedia.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -111,5 +109,4 @@ class AvccBufferWriter final {
|
|||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
|
#endif // WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_H264_VIDEO_TOOLBOX_NALU_H_
|
||||||
#endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_H264_H264_VIDEO_TOOLBOX_NALU_H_
|
|
||||||
@ -12,11 +12,9 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "webrtc/base/arraysize.h"
|
#include "webrtc/base/arraysize.h"
|
||||||
#include "webrtc/modules/video_coding/codecs/h264/h264_video_toolbox_nalu.h"
|
#include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_nalu.h"
|
||||||
#include "webrtc/test/gtest.h"
|
#include "webrtc/test/gtest.h"
|
||||||
|
|
||||||
#if defined(WEBRTC_VIDEO_TOOLBOX_SUPPORTED)
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
static const uint8_t NALU_TEST_DATA_0[] = {0xAA, 0xBB, 0xCC};
|
static const uint8_t NALU_TEST_DATA_0[] = {0xAA, 0xBB, 0xCC};
|
||||||
@ -204,5 +202,3 @@ TEST(AvccBufferWriterTest, TestOverflow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace webrtc
|
} // namespace webrtc
|
||||||
|
|
||||||
#endif // WEBRTC_VIDEO_TOOLBOX_SUPPORTED
|
|
||||||
@ -0,0 +1,103 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2015 The WebRTC project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license
|
||||||
|
* that can be found in the LICENSE file in the root of the source
|
||||||
|
* tree. An additional intellectual property rights grant can be found
|
||||||
|
* in the file PATENTS. All contributing project authors may
|
||||||
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
#include "webrtc/sdk/objc/Framework/Classes/videotoolboxvideocodecfactory.h"
|
||||||
|
|
||||||
|
#include "webrtc/base/logging.h"
|
||||||
|
#include "webrtc/media/base/codec.h"
|
||||||
|
#if defined(WEBRTC_IOS)
|
||||||
|
#include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_encoder.h"
|
||||||
|
#include "webrtc/sdk/objc/Framework/Classes/h264_video_toolbox_decoder.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// TODO(kthelgason): delete this when CreateVideoDecoder takes
|
||||||
|
// a cricket::VideoCodec instead of webrtc::VideoCodecType.
|
||||||
|
static const char* NameFromCodecType(webrtc::VideoCodecType type) {
|
||||||
|
switch (type) {
|
||||||
|
case webrtc::kVideoCodecVP8:
|
||||||
|
return cricket::kVp8CodecName;
|
||||||
|
case webrtc::kVideoCodecVP9:
|
||||||
|
return cricket::kVp9CodecName;
|
||||||
|
case webrtc::kVideoCodecH264:
|
||||||
|
return cricket::kH264CodecName;
|
||||||
|
default:
|
||||||
|
return "Unknown codec";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
// VideoToolboxVideoEncoderFactory
|
||||||
|
|
||||||
|
VideoToolboxVideoEncoderFactory::VideoToolboxVideoEncoderFactory() {
|
||||||
|
// Hardware H264 encoding only supported on iOS for now.
|
||||||
|
#if defined(WEBRTC_IOS)
|
||||||
|
supported_codecs_.push_back(cricket::VideoCodec(cricket::kH264CodecName));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
VideoToolboxVideoEncoderFactory::~VideoToolboxVideoEncoderFactory() {}
|
||||||
|
|
||||||
|
VideoEncoder* VideoToolboxVideoEncoderFactory::CreateVideoEncoder(
|
||||||
|
const cricket::VideoCodec& codec) {
|
||||||
|
#if defined(WEBRTC_IOS)
|
||||||
|
if (IsCodecSupported(supported_codecs_, codec)) {
|
||||||
|
LOG(LS_INFO) << "Creating HW encoder for " << codec.name;
|
||||||
|
return new H264VideoToolboxEncoder();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
LOG(LS_INFO) << "No HW encoder found for codec " << codec.name;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoToolboxVideoEncoderFactory::DestroyVideoEncoder(
|
||||||
|
VideoEncoder* encoder) {
|
||||||
|
#if defined(WEBRTC_IOS)
|
||||||
|
delete encoder;
|
||||||
|
encoder = nullptr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::vector<cricket::VideoCodec>&
|
||||||
|
VideoToolboxVideoEncoderFactory::supported_codecs() const {
|
||||||
|
return supported_codecs_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// VideoToolboxVideoDecoderFactory
|
||||||
|
|
||||||
|
VideoToolboxVideoDecoderFactory::VideoToolboxVideoDecoderFactory() {
|
||||||
|
#if defined(WEBRTC_IOS)
|
||||||
|
supported_codecs_.push_back(cricket::VideoCodec("H264"));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
VideoToolboxVideoDecoderFactory::~VideoToolboxVideoDecoderFactory() {}
|
||||||
|
|
||||||
|
VideoDecoder* VideoToolboxVideoDecoderFactory::CreateVideoDecoder(
|
||||||
|
VideoCodecType type) {
|
||||||
|
const auto codec = cricket::VideoCodec(NameFromCodecType(type));
|
||||||
|
#if defined(WEBRTC_IOS)
|
||||||
|
if (IsCodecSupported(supported_codecs_, codec)) {
|
||||||
|
LOG(LS_INFO) << "Creating HW decoder for " << codec.name;
|
||||||
|
return new H264VideoToolboxDecoder();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
LOG(LS_INFO) << "No HW decoder found for codec " << codec.name;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VideoToolboxVideoDecoderFactory::DestroyVideoDecoder(
|
||||||
|
VideoDecoder* decoder) {
|
||||||
|
#if defined(WEBRTC_IOS)
|
||||||
|
delete decoder;
|
||||||
|
decoder = nullptr;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license
|
||||||
|
* that can be found in the LICENSE file in the root of the source
|
||||||
|
* tree. An additional intellectual property rights grant can be found
|
||||||
|
* in the file PATENTS. All contributing project authors may
|
||||||
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#ifndef WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_VIDEOTOOLBOXVIDEOCODECFACTORY_H_
|
||||||
|
#define WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_VIDEOTOOLBOXVIDEOCODECFACTORY_H_
|
||||||
|
|
||||||
|
#include "webrtc/media/engine/webrtcvideoencoderfactory.h"
|
||||||
|
#include "webrtc/media/engine/webrtcvideodecoderfactory.h"
|
||||||
|
|
||||||
|
namespace webrtc {
|
||||||
|
|
||||||
|
class VideoToolboxVideoEncoderFactory
|
||||||
|
: public cricket::WebRtcVideoEncoderFactory {
|
||||||
|
public:
|
||||||
|
VideoToolboxVideoEncoderFactory();
|
||||||
|
~VideoToolboxVideoEncoderFactory();
|
||||||
|
|
||||||
|
// WebRtcVideoEncoderFactory implementation.
|
||||||
|
VideoEncoder* CreateVideoEncoder(const cricket::VideoCodec& codec) override;
|
||||||
|
void DestroyVideoEncoder(VideoEncoder* encoder) override;
|
||||||
|
const std::vector<cricket::VideoCodec>& supported_codecs() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<cricket::VideoCodec> supported_codecs_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class VideoToolboxVideoDecoderFactory
|
||||||
|
: public cricket::WebRtcVideoDecoderFactory {
|
||||||
|
public:
|
||||||
|
VideoToolboxVideoDecoderFactory();
|
||||||
|
~VideoToolboxVideoDecoderFactory();
|
||||||
|
|
||||||
|
// WebRtcVideoDecoderFactory implementation.
|
||||||
|
VideoDecoder* CreateVideoDecoder(VideoCodecType type) override;
|
||||||
|
void DestroyVideoDecoder(VideoDecoder* decoder) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<cricket::VideoCodec> supported_codecs_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace webrtc
|
||||||
|
|
||||||
|
#endif // WEBRTC_SDK_OBJC_FRAMEWORK_CLASSES_VIDEOTOOLBOXVIDEOCODECFACTORY_H_
|
||||||
Reference in New Issue
Block a user