From 755092983734b3e2140c4048039b3ff30423eb0e Mon Sep 17 00:00:00 2001 From: Jianjun Zhu Date: Fri, 19 Jul 2019 14:36:57 +0800 Subject: [PATCH] Some changes for building with OWT. --- BUILD.gn | 23 +++++++++++++++++-- examples/BUILD.gn | 4 ++-- rtc_base/BUILD.gn | 1 + sdk/BUILD.gn | 14 +++++------ .../RTCPeerConnectionFactory+Native.h | 4 ++++ .../RTCPeerConnectionFactory.mm | 7 ++++++ .../native/src/objc_video_decoder_factory.mm | 5 +++- .../native/src/objc_video_encoder_factory.mm | 5 +++- webrtc.gni | 6 ++--- 9 files changed, 53 insertions(+), 16 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 4acda15c982..2011fc31871 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -140,6 +140,25 @@ config("common_inherited_config") { target_gen_dir, ] } + if (build_with_owt) { + include_dirs = [ + # The overrides must be included first as that is the mechanism for + # selecting the override headers in Chromium. + #"../webrtc_overrides", + + # Allow includes to be prefixed with webrtc/ in case it is not an + # immediate subdirectory of the top-level. + ".", + + # Just like the root WebRTC directory is added to include path, the + # corresponding directory tree with generated files needs to be added too. + # Note: this path does not change depending on the current target, e.g. + # it is always "//gen/third_party/webrtc" when building with Chromium. + # See also: http://cs.chromium.org/?q=%5C"default_include_dirs + # https://gn.googlesource.com/gn/+/master/docs/reference.md#target_gen_dir + target_gen_dir, + ] + } if (is_posix || is_fuchsia) { defines += [ "WEBRTC_POSIX" ] } @@ -245,7 +264,7 @@ config("common_config") { defines += [ "WEBRTC_USE_H264" ] } - if (build_with_chromium) { + if (build_with_chromium || build_with_owt) { defines += [ # NOTICE: Since common_inherited_config is used in public_configs for our # targets, there's no point including the defines in that config here. @@ -382,7 +401,7 @@ if (!build_with_chromium) { # Target to build all the WebRTC production code. rtc_static_library("webrtc") { # Only the root target should depend on this. - visibility = [ "//:default" ] + visibility = [ ".:default" ] sources = [] complete_static_lib = true diff --git a/examples/BUILD.gn b/examples/BUILD.gn index a14c2064753..dae2cf2bcd3 100644 --- a/examples/BUILD.gn +++ b/examples/BUILD.gn @@ -81,7 +81,7 @@ if (rtc_include_tests) { deps = [ ":read_auth_file", "../test:test_main", - "//test:test_support", + "../test:test_support", "//testing/gtest", ] } @@ -618,7 +618,7 @@ if (is_ios || (is_mac && target_cpu != "x86")) { ":AppRTCMobile_lib", ":apprtcmobile_test_sources", "../sdk:framework_objc", - "//test:test_support", + "../test:test_support", ] ldflags = [ "-all_load" ] } diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn index a3dd22eee11..d2f0ba2c676 100644 --- a/rtc_base/BUILD.gn +++ b/rtc_base/BUILD.gn @@ -612,6 +612,7 @@ rtc_static_library("rtc_numerics") { } rtc_source_set("rtc_json") { + visibility = [ "*", "//talk/owt:owt_deps" ] defines = [] sources = [ "strings/json.cc", diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn index 784101eb914..1db64702f56 100644 --- a/sdk/BUILD.gn +++ b/sdk/BUILD.gn @@ -358,11 +358,11 @@ if (is_ios || is_mac) { ] deps = [ ":base_objc", - "//api/video:video_frame", - "//api/video:video_frame_i420", - "//common_video", - "//rtc_base:checks", - "//rtc_base:rtc_base_approved", + "../api/video:video_frame", + "../api/video:video_frame_i420", + "../common_video", + "../rtc_base:checks", + "../rtc_base:rtc_base_approved", "//third_party/libyuv", ] configs += [ @@ -1119,7 +1119,7 @@ if (is_ios || is_mac) { ":peerconnectionfactory_base_objc", ":sdk_unittests_bundle_data", ":sdk_unittests_sources", - "//test:test_support", + "../test:test_support", ] ldflags = [ "-all_load" ] } @@ -1137,7 +1137,7 @@ if (is_ios || is_mac) { deps = [ ":framework_objc+link", ":ios_framework_bundle", - "//test:test_support", + "../test:test_support", ] } } diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h index 7a57645c0e1..519ff7ee8c7 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory+Native.h @@ -22,6 +22,7 @@ class NetworkControllerFactoryInterface; class VideoEncoderFactory; class VideoDecoderFactory; class AudioProcessing; +class PeerConnectionFactoryInterface; } // namespace webrtc @@ -87,6 +88,9 @@ NS_ASSUME_NONNULL_BEGIN decoderFactory:(nullable id)decoderFactory mediaTransportFactory: (std::unique_ptr)mediaTransportFactory; + +- (instancetype)initWithNativePeerConnectionFactory:( + rtc::scoped_refptr)factory; @end NS_ASSUME_NONNULL_END diff --git a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm index 7fcd3c507b5..3b9d3112c0e 100644 --- a/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm +++ b/sdk/objc/api/peerconnection/RTCPeerConnectionFactory.mm @@ -240,6 +240,13 @@ - (instancetype)initWithNativeAudioEncoderFactory: } return self; } +- (instancetype)initWithNativePeerConnectionFactory: + (rtc::scoped_refptr)factory { + if (self = [self initNative]) { + _nativeFactory = factory; + } + return self; +} - (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)constraints { std::unique_ptr nativeConstraints; diff --git a/sdk/objc/native/src/objc_video_decoder_factory.mm b/sdk/objc/native/src/objc_video_decoder_factory.mm index d1d8ca23d5c..c31a25abe61 100644 --- a/sdk/objc/native/src/objc_video_decoder_factory.mm +++ b/sdk/objc/native/src/objc_video_decoder_factory.mm @@ -98,7 +98,10 @@ int32_t RegisterDecodeCompleteCallback(DecodedImageCallback *callback) override if ([codecName isEqualToString:codecInfo.name]) { id decoder = [decoder_factory_ createDecoder:codecInfo]; - if ([decoder isKindOfClass:[RTCWrappedNativeVideoDecoder class]]) { + // Because of symbol conflict, isKindOfClass doesn't work as expected. + // See https://bugs.webkit.org/show_bug.cgi?id=198782. + // if ([decoder isKindOfClass:[RTCWrappedNativeVideoDecoder class]]) { + if ([codecName isEqual:@"VP8"] || [codecName isEqual:@"VP9"]) { return [(RTCWrappedNativeVideoDecoder *)decoder releaseWrappedDecoder]; } else { return std::unique_ptr(new ObjCVideoDecoder(decoder)); diff --git a/sdk/objc/native/src/objc_video_encoder_factory.mm b/sdk/objc/native/src/objc_video_encoder_factory.mm index 7de9875eac6..baf560f1800 100644 --- a/sdk/objc/native/src/objc_video_encoder_factory.mm +++ b/sdk/objc/native/src/objc_video_encoder_factory.mm @@ -147,7 +147,10 @@ void SetRates(const RateControlParameters ¶meters) override { const SdpVideoFormat &format) { RTCVideoCodecInfo *info = [[RTCVideoCodecInfo alloc] initWithNativeSdpVideoFormat:format]; id encoder = [encoder_factory_ createEncoder:info]; - if ([encoder isKindOfClass:[RTCWrappedNativeVideoEncoder class]]) { + // Because of symbol conflict, isKindOfClass doesn't work as expected. + // See https://bugs.webkit.org/show_bug.cgi?id=198782. + // if ([encoder isKindOfClass:[RTCWrappedNativeVideoEncoder class]]) { + if ([info.name isEqual:@"VP8"] || [info.name isEqual:@"VP9"]) { return [(RTCWrappedNativeVideoEncoder *)encoder releaseWrappedEncoder]; } else { return std::unique_ptr(new ObjCVideoEncoder(encoder)); diff --git a/webrtc.gni b/webrtc.gni index 6ba8d0aeb35..640e6d9eef1 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -694,7 +694,7 @@ if (is_ios) { action("umbrella_header_$target_name") { forward_variables_from(invoker, [ "public_headers" ]) - script = "//tools_webrtc/ios/generate_umbrella_header.py" + script = "../tools_webrtc/ios/generate_umbrella_header.py" outputs = [ umbrella_header_path, @@ -769,7 +769,7 @@ if (is_mac) { } action("modulemap_$this_target_name") { - script = "//tools_webrtc/ios/generate_modulemap.py" + script = "../tools_webrtc/ios/generate_modulemap.py" args = [ "--out", rebase_path(modulemap_path, root_build_dir), @@ -796,7 +796,7 @@ if (is_mac) { action("umbrella_header_$this_target_name") { forward_variables_from(invoker, [ "sources" ]) - script = "//tools_webrtc/ios/generate_umbrella_header.py" + script = "../tools_webrtc/ios/generate_umbrella_header.py" outputs = [ umbrella_header_path,