2016-01-20 13:40:30 -08:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-08-29 03:57:22 -07:00
|
|
|
#import "RTCPeerConnectionFactory+Native.h"
|
2016-04-27 01:54:20 -07:00
|
|
|
#import "RTCPeerConnectionFactory+Private.h"
|
2018-01-02 13:33:16 +03:00
|
|
|
#import "RTCPeerConnectionFactoryOptions+Private.h"
|
2016-01-20 13:40:30 -08:00
|
|
|
|
2016-08-30 11:56:05 -07:00
|
|
|
#import "RTCAudioSource+Private.h"
|
2016-04-27 01:54:20 -07:00
|
|
|
#import "RTCAudioTrack+Private.h"
|
2016-08-30 11:56:05 -07:00
|
|
|
#import "RTCMediaConstraints+Private.h"
|
2016-04-27 01:54:20 -07:00
|
|
|
#import "RTCMediaStream+Private.h"
|
|
|
|
|
#import "RTCPeerConnection+Private.h"
|
|
|
|
|
#import "RTCVideoSource+Private.h"
|
|
|
|
|
#import "RTCVideoTrack+Private.h"
|
2018-08-30 09:30:29 +02:00
|
|
|
#import "base/RTCLogging.h"
|
|
|
|
|
#import "base/RTCVideoDecoderFactory.h"
|
|
|
|
|
#import "base/RTCVideoEncoderFactory.h"
|
|
|
|
|
#import "helpers/NSString+StdString.h"
|
Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2980173002/ )
Reason for revert:
Relanding after fixing issues with no video.
Original issue's description:
> Revert of Injectable Obj-C video codecs (patchset #2 id:370001 of https://codereview.webrtc.org/2979983002/ )
>
> Reason for revert:
> Still having problems with no video. Reverting.
> Once no video is visible, no video is available from then on even if the callee app is in the foreground.
>
>
> Original issue's description:
> > Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2979973002/ )
> >
> > Reason for revert:
> > Fix the broken build file
> >
> > Original issue's description:
> > > Revert of Injectable Obj-C video codecs (patchset #3 id:400001 of https://codereview.webrtc.org/2981583002/ )
> > >
> > > Reason for revert:
> > > Breaks bots. Build file incorrect.
> > >
> > > Original issue's description:
> > > > Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2975963002/ )
> > > >
> > > > Reason for revert:
> > > > New CL for fixing the issues
> > > >
> > > > Original issue's description:
> > > > > Revert of Injectable Obj-C video codecs (patchset #8 id:140001 of https://codereview.webrtc.org/2966023002/ )
> > > > >
> > > > > Reason for revert:
> > > > > Causes no video in certain scenarios. Please come up with a test plan or unit test to prevent such problems in the future.
> > > > >
> > > > > Original issue's description:
> > > > > > Injectable Obj-C video codecs
> > > > > >
> > > > > > Initial CL for this effort, with a working RTCVideoEncoder/Decoder for H264
> > > > > > (wrapping the VideoToolbox codec).
> > > > > >
> > > > > > Some notes / things left to do:
> > > > > > - There are some hard-coded references to codec types that are supported by
> > > > > > webrtc::VideoCodec, cricket::VideoCodec, webrtc::CodecSpecificInfo etc
> > > > > > since we need to convert to/from these types in ObjCVideoEncoder/Decoder.
> > > > > > These types would need to be more codec agnostic to avoid this.
> > > > > > - Most interfaces are borrowed from the design document for injectable
> > > > > > codecs in Android. Some data in the corresponding C++ classes is discarded
> > > > > > when converting to the Obj-C version, since it has fewer fields. I have not
> > > > > > verified whether all data that we do keep is needed, or whether we might be
> > > > > > losing anything useful in these conversions.
> > > > > > - Implement the VideoToolbox codec code directly in the RTCVideoEncoderH264
> > > > > > classes, instead of wrapping webrtc::H264VideoToolboxEncoder / decoder.
> > > > > > Eliminates converting between ObjC/C++ types outside the ObjCVideoEncoder/
> > > > > > Decoder wrapper classes.
> > > > > > - List the injected codec factory's supported codecs in the list of codecs in
> > > > > > AppRTCMobile.
> > > > > >
> > > > > > BUG=webrtc:7924
> > > > > > R=magjed@webrtc.org
> > > > > >
> > > > > > Review-Url: https://codereview.webrtc.org/2966023002 .
> > > > > > Cr-Commit-Position: refs/heads/master@{#18928}
> > > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/a0349c138db62c52435be84b6c837f5f4758e264
> > > > >
> > > > > TBR=magjed@webrtc.org,andersc@webrtc.org
> > > > > # Not skipping CQ checks because original CL landed more than 1 days ago.
> > > > > BUG=webrtc:7924
> > > > > NOTRY=true
> > > > >
> > > > > Review-Url: https://codereview.webrtc.org/2975963002
> > > > > Cr-Commit-Position: refs/heads/master@{#18979}
> > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/1095ada7ad56fe29b7b2bbc560a8f6475a7978ce
> > > >
> > > > R=magjed@webrtc.org
> > > > TBR=tkchin@webrtc.org
> > > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > > NOPRESUBMIT=true
> > > > NOTREECHECKS=true
> > > > NOTRY=true
> > > > BUG=webrtc:7924
> > > >
> > > > Review-Url: https://codereview.webrtc.org/2981583002 .
> > > > Cr-Commit-Position: refs/heads/master@{#19002}
> > > > Committed: https://chromium.googlesource.com/external/webrtc/+/a5f1de1e6541de03f944bcbf49be87c01f57a18b
> > >
> > > TBR=magjed@webrtc.org,tkchin@webrtc.org,jtteh@webrtc.org,andersc@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:7924
> > >
> > > Review-Url: https://codereview.webrtc.org/2979973002
> > > Cr-Commit-Position: refs/heads/master@{#19004}
> > > Committed: https://chromium.googlesource.com/external/webrtc/+/81d40ee1491d5229c2677cc04b1f40d67c2babef
> >
> > TBR=magjed@webrtc.org,tkchin@webrtc.org,jtteh@webrtc.org,sprang@webrtc.org
> > BUG=webrtc:7924
> >
> > Review-Url: https://codereview.webrtc.org/2979983002
> > Cr-Commit-Position: refs/heads/master@{#19005}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/732a3437da4db7b452758b8e1cf26fce0ce3bf65
>
> TBR=magjed@webrtc.org,tkchin@webrtc.org,sprang@webrtc.org,haysc@webrtc.org,andersc@webrtc.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=webrtc:7924
>
> Review-Url: https://codereview.webrtc.org/2980173002
> Cr-Commit-Position: refs/heads/master@{#19036}
> Committed: https://chromium.googlesource.com/external/webrtc/+/860f7298166084d966749e22b69aa2fdcf4d4ed6
TBR=magjed@webrtc.org,tkchin@webrtc.org,sprang@webrtc.org,haysc@webrtc.org,andersc@webrtc.org,jtteh@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7924
Review-Url: https://codereview.webrtc.org/2977213002
Cr-Commit-Position: refs/heads/master@{#19135}
2017-07-25 07:55:58 -07:00
|
|
|
#ifndef HAVE_NO_MEDIA
|
2018-08-30 09:30:29 +02:00
|
|
|
#import "components/video_codec/RTCVideoDecoderFactoryH264.h"
|
|
|
|
|
#import "components/video_codec/RTCVideoEncoderFactoryH264.h"
|
2017-08-29 03:57:22 -07:00
|
|
|
// The no-media version PeerConnectionFactory doesn't depend on these files, but the gn check tool
|
|
|
|
|
// is not smart enough to take the #ifdef into account.
|
2017-10-05 16:55:38 +02:00
|
|
|
#include "api/audio_codecs/builtin_audio_decoder_factory.h" // nogncheck
|
|
|
|
|
#include "api/audio_codecs/builtin_audio_encoder_factory.h" // nogncheck
|
2019-01-09 11:15:34 +01:00
|
|
|
#include "logging/rtc_event_log/rtc_event_log_factory.h"
|
2018-01-19 11:36:48 +01:00
|
|
|
#include "media/engine/convert_legacy_video_factory.h" // nogncheck
|
2017-10-05 16:55:38 +02:00
|
|
|
#include "modules/audio_device/include/audio_device.h" // nogncheck
|
|
|
|
|
#include "modules/audio_processing/include/audio_processing.h" // nogncheck
|
2018-02-01 15:47:05 +01:00
|
|
|
|
2018-08-30 09:30:29 +02:00
|
|
|
#include "sdk/objc/native/api/video_decoder_factory.h"
|
|
|
|
|
#include "sdk/objc/native/api/video_encoder_factory.h"
|
|
|
|
|
#include "sdk/objc/native/src/objc_video_decoder_factory.h"
|
|
|
|
|
#include "sdk/objc/native/src/objc_video_encoder_factory.h"
|
Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2980173002/ )
Reason for revert:
Relanding after fixing issues with no video.
Original issue's description:
> Revert of Injectable Obj-C video codecs (patchset #2 id:370001 of https://codereview.webrtc.org/2979983002/ )
>
> Reason for revert:
> Still having problems with no video. Reverting.
> Once no video is visible, no video is available from then on even if the callee app is in the foreground.
>
>
> Original issue's description:
> > Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2979973002/ )
> >
> > Reason for revert:
> > Fix the broken build file
> >
> > Original issue's description:
> > > Revert of Injectable Obj-C video codecs (patchset #3 id:400001 of https://codereview.webrtc.org/2981583002/ )
> > >
> > > Reason for revert:
> > > Breaks bots. Build file incorrect.
> > >
> > > Original issue's description:
> > > > Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2975963002/ )
> > > >
> > > > Reason for revert:
> > > > New CL for fixing the issues
> > > >
> > > > Original issue's description:
> > > > > Revert of Injectable Obj-C video codecs (patchset #8 id:140001 of https://codereview.webrtc.org/2966023002/ )
> > > > >
> > > > > Reason for revert:
> > > > > Causes no video in certain scenarios. Please come up with a test plan or unit test to prevent such problems in the future.
> > > > >
> > > > > Original issue's description:
> > > > > > Injectable Obj-C video codecs
> > > > > >
> > > > > > Initial CL for this effort, with a working RTCVideoEncoder/Decoder for H264
> > > > > > (wrapping the VideoToolbox codec).
> > > > > >
> > > > > > Some notes / things left to do:
> > > > > > - There are some hard-coded references to codec types that are supported by
> > > > > > webrtc::VideoCodec, cricket::VideoCodec, webrtc::CodecSpecificInfo etc
> > > > > > since we need to convert to/from these types in ObjCVideoEncoder/Decoder.
> > > > > > These types would need to be more codec agnostic to avoid this.
> > > > > > - Most interfaces are borrowed from the design document for injectable
> > > > > > codecs in Android. Some data in the corresponding C++ classes is discarded
> > > > > > when converting to the Obj-C version, since it has fewer fields. I have not
> > > > > > verified whether all data that we do keep is needed, or whether we might be
> > > > > > losing anything useful in these conversions.
> > > > > > - Implement the VideoToolbox codec code directly in the RTCVideoEncoderH264
> > > > > > classes, instead of wrapping webrtc::H264VideoToolboxEncoder / decoder.
> > > > > > Eliminates converting between ObjC/C++ types outside the ObjCVideoEncoder/
> > > > > > Decoder wrapper classes.
> > > > > > - List the injected codec factory's supported codecs in the list of codecs in
> > > > > > AppRTCMobile.
> > > > > >
> > > > > > BUG=webrtc:7924
> > > > > > R=magjed@webrtc.org
> > > > > >
> > > > > > Review-Url: https://codereview.webrtc.org/2966023002 .
> > > > > > Cr-Commit-Position: refs/heads/master@{#18928}
> > > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/a0349c138db62c52435be84b6c837f5f4758e264
> > > > >
> > > > > TBR=magjed@webrtc.org,andersc@webrtc.org
> > > > > # Not skipping CQ checks because original CL landed more than 1 days ago.
> > > > > BUG=webrtc:7924
> > > > > NOTRY=true
> > > > >
> > > > > Review-Url: https://codereview.webrtc.org/2975963002
> > > > > Cr-Commit-Position: refs/heads/master@{#18979}
> > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/1095ada7ad56fe29b7b2bbc560a8f6475a7978ce
> > > >
> > > > R=magjed@webrtc.org
> > > > TBR=tkchin@webrtc.org
> > > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > > NOPRESUBMIT=true
> > > > NOTREECHECKS=true
> > > > NOTRY=true
> > > > BUG=webrtc:7924
> > > >
> > > > Review-Url: https://codereview.webrtc.org/2981583002 .
> > > > Cr-Commit-Position: refs/heads/master@{#19002}
> > > > Committed: https://chromium.googlesource.com/external/webrtc/+/a5f1de1e6541de03f944bcbf49be87c01f57a18b
> > >
> > > TBR=magjed@webrtc.org,tkchin@webrtc.org,jtteh@webrtc.org,andersc@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:7924
> > >
> > > Review-Url: https://codereview.webrtc.org/2979973002
> > > Cr-Commit-Position: refs/heads/master@{#19004}
> > > Committed: https://chromium.googlesource.com/external/webrtc/+/81d40ee1491d5229c2677cc04b1f40d67c2babef
> >
> > TBR=magjed@webrtc.org,tkchin@webrtc.org,jtteh@webrtc.org,sprang@webrtc.org
> > BUG=webrtc:7924
> >
> > Review-Url: https://codereview.webrtc.org/2979983002
> > Cr-Commit-Position: refs/heads/master@{#19005}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/732a3437da4db7b452758b8e1cf26fce0ce3bf65
>
> TBR=magjed@webrtc.org,tkchin@webrtc.org,sprang@webrtc.org,haysc@webrtc.org,andersc@webrtc.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=webrtc:7924
>
> Review-Url: https://codereview.webrtc.org/2980173002
> Cr-Commit-Position: refs/heads/master@{#19036}
> Committed: https://chromium.googlesource.com/external/webrtc/+/860f7298166084d966749e22b69aa2fdcf4d4ed6
TBR=magjed@webrtc.org,tkchin@webrtc.org,sprang@webrtc.org,haysc@webrtc.org,andersc@webrtc.org,jtteh@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7924
Review-Url: https://codereview.webrtc.org/2977213002
Cr-Commit-Position: refs/heads/master@{#19135}
2017-07-25 07:55:58 -07:00
|
|
|
#endif
|
2016-05-01 14:53:46 -07:00
|
|
|
|
2018-05-15 10:22:36 +02:00
|
|
|
#if defined(WEBRTC_IOS)
|
2018-08-30 09:30:29 +02:00
|
|
|
#import "sdk/objc/native/api/audio_device_module.h"
|
2018-05-15 10:22:36 +02:00
|
|
|
#endif
|
|
|
|
|
|
2017-06-28 14:05:44 -07:00
|
|
|
// Adding the nogncheck to disable the including header check.
|
|
|
|
|
// The no-media version PeerConnectionFactory doesn't depend on media related
|
|
|
|
|
// C++ target.
|
|
|
|
|
// TODO(zhihuang): Remove nogncheck once MediaEngineInterface is moved to C++
|
|
|
|
|
// API layer.
|
Use absl::make_unique and absl::WrapUnique directly
Instead of going through our wrappers in ptr_util.h.
This CL was generated by the following script:
git grep -l ptr_util | xargs perl -pi -e 's,#include "rtc_base/ptr_util.h",#include "absl/memory/memory.h",'
git grep -l MakeUnique | xargs perl -pi -e 's,\b(rtc::)?MakeUnique\b,absl::make_unique,g'
git grep -l WrapUnique | xargs perl -pi -e 's,\b(rtc::)?WrapUnique\b,absl::WrapUnique,g'
git checkout -- rtc_base/ptr_util{.h,_unittest.cc}
git cl format
Followed by manually adding dependencies on
//third_party/abseil-cpp/absl/memory until `gn check` stopped
complaining.
Bug: webrtc:9473
Change-Id: I89ccd363f070479b8c431eb2c3d404a46eaacc1c
Reviewed-on: https://webrtc-review.googlesource.com/86600
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23850}
2018-07-05 11:40:33 +02:00
|
|
|
#include "absl/memory/memory.h"
|
2018-10-08 09:43:21 -07:00
|
|
|
#include "api/media_transport_interface.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "media/engine/webrtcmediaengine.h" // nogncheck
|
2016-11-09 10:43:26 +01:00
|
|
|
|
2016-01-20 13:40:30 -08:00
|
|
|
@implementation RTCPeerConnectionFactory {
|
2016-05-17 01:52:02 -07:00
|
|
|
std::unique_ptr<rtc::Thread> _networkThread;
|
2016-05-01 14:53:46 -07:00
|
|
|
std::unique_ptr<rtc::Thread> _workerThread;
|
2016-05-17 01:52:02 -07:00
|
|
|
std::unique_ptr<rtc::Thread> _signalingThread;
|
2016-08-30 12:58:11 -07:00
|
|
|
BOOL _hasStartedAecDump;
|
2016-01-20 13:40:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@synthesize nativeFactory = _nativeFactory;
|
|
|
|
|
|
2018-05-15 10:22:36 +02:00
|
|
|
- (rtc::scoped_refptr<webrtc::AudioDeviceModule>)audioDeviceModule {
|
|
|
|
|
#if defined(WEBRTC_IOS)
|
|
|
|
|
return webrtc::CreateAudioDeviceModule();
|
|
|
|
|
#else
|
|
|
|
|
return nullptr;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-20 13:40:30 -08:00
|
|
|
- (instancetype)init {
|
Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2980173002/ )
Reason for revert:
Relanding after fixing issues with no video.
Original issue's description:
> Revert of Injectable Obj-C video codecs (patchset #2 id:370001 of https://codereview.webrtc.org/2979983002/ )
>
> Reason for revert:
> Still having problems with no video. Reverting.
> Once no video is visible, no video is available from then on even if the callee app is in the foreground.
>
>
> Original issue's description:
> > Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2979973002/ )
> >
> > Reason for revert:
> > Fix the broken build file
> >
> > Original issue's description:
> > > Revert of Injectable Obj-C video codecs (patchset #3 id:400001 of https://codereview.webrtc.org/2981583002/ )
> > >
> > > Reason for revert:
> > > Breaks bots. Build file incorrect.
> > >
> > > Original issue's description:
> > > > Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2975963002/ )
> > > >
> > > > Reason for revert:
> > > > New CL for fixing the issues
> > > >
> > > > Original issue's description:
> > > > > Revert of Injectable Obj-C video codecs (patchset #8 id:140001 of https://codereview.webrtc.org/2966023002/ )
> > > > >
> > > > > Reason for revert:
> > > > > Causes no video in certain scenarios. Please come up with a test plan or unit test to prevent such problems in the future.
> > > > >
> > > > > Original issue's description:
> > > > > > Injectable Obj-C video codecs
> > > > > >
> > > > > > Initial CL for this effort, with a working RTCVideoEncoder/Decoder for H264
> > > > > > (wrapping the VideoToolbox codec).
> > > > > >
> > > > > > Some notes / things left to do:
> > > > > > - There are some hard-coded references to codec types that are supported by
> > > > > > webrtc::VideoCodec, cricket::VideoCodec, webrtc::CodecSpecificInfo etc
> > > > > > since we need to convert to/from these types in ObjCVideoEncoder/Decoder.
> > > > > > These types would need to be more codec agnostic to avoid this.
> > > > > > - Most interfaces are borrowed from the design document for injectable
> > > > > > codecs in Android. Some data in the corresponding C++ classes is discarded
> > > > > > when converting to the Obj-C version, since it has fewer fields. I have not
> > > > > > verified whether all data that we do keep is needed, or whether we might be
> > > > > > losing anything useful in these conversions.
> > > > > > - Implement the VideoToolbox codec code directly in the RTCVideoEncoderH264
> > > > > > classes, instead of wrapping webrtc::H264VideoToolboxEncoder / decoder.
> > > > > > Eliminates converting between ObjC/C++ types outside the ObjCVideoEncoder/
> > > > > > Decoder wrapper classes.
> > > > > > - List the injected codec factory's supported codecs in the list of codecs in
> > > > > > AppRTCMobile.
> > > > > >
> > > > > > BUG=webrtc:7924
> > > > > > R=magjed@webrtc.org
> > > > > >
> > > > > > Review-Url: https://codereview.webrtc.org/2966023002 .
> > > > > > Cr-Commit-Position: refs/heads/master@{#18928}
> > > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/a0349c138db62c52435be84b6c837f5f4758e264
> > > > >
> > > > > TBR=magjed@webrtc.org,andersc@webrtc.org
> > > > > # Not skipping CQ checks because original CL landed more than 1 days ago.
> > > > > BUG=webrtc:7924
> > > > > NOTRY=true
> > > > >
> > > > > Review-Url: https://codereview.webrtc.org/2975963002
> > > > > Cr-Commit-Position: refs/heads/master@{#18979}
> > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/1095ada7ad56fe29b7b2bbc560a8f6475a7978ce
> > > >
> > > > R=magjed@webrtc.org
> > > > TBR=tkchin@webrtc.org
> > > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > > NOPRESUBMIT=true
> > > > NOTREECHECKS=true
> > > > NOTRY=true
> > > > BUG=webrtc:7924
> > > >
> > > > Review-Url: https://codereview.webrtc.org/2981583002 .
> > > > Cr-Commit-Position: refs/heads/master@{#19002}
> > > > Committed: https://chromium.googlesource.com/external/webrtc/+/a5f1de1e6541de03f944bcbf49be87c01f57a18b
> > >
> > > TBR=magjed@webrtc.org,tkchin@webrtc.org,jtteh@webrtc.org,andersc@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:7924
> > >
> > > Review-Url: https://codereview.webrtc.org/2979973002
> > > Cr-Commit-Position: refs/heads/master@{#19004}
> > > Committed: https://chromium.googlesource.com/external/webrtc/+/81d40ee1491d5229c2677cc04b1f40d67c2babef
> >
> > TBR=magjed@webrtc.org,tkchin@webrtc.org,jtteh@webrtc.org,sprang@webrtc.org
> > BUG=webrtc:7924
> >
> > Review-Url: https://codereview.webrtc.org/2979983002
> > Cr-Commit-Position: refs/heads/master@{#19005}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/732a3437da4db7b452758b8e1cf26fce0ce3bf65
>
> TBR=magjed@webrtc.org,tkchin@webrtc.org,sprang@webrtc.org,haysc@webrtc.org,andersc@webrtc.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=webrtc:7924
>
> Review-Url: https://codereview.webrtc.org/2980173002
> Cr-Commit-Position: refs/heads/master@{#19036}
> Committed: https://chromium.googlesource.com/external/webrtc/+/860f7298166084d966749e22b69aa2fdcf4d4ed6
TBR=magjed@webrtc.org,tkchin@webrtc.org,sprang@webrtc.org,haysc@webrtc.org,andersc@webrtc.org,jtteh@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7924
Review-Url: https://codereview.webrtc.org/2977213002
Cr-Commit-Position: refs/heads/master@{#19135}
2017-07-25 07:55:58 -07:00
|
|
|
#ifdef HAVE_NO_MEDIA
|
2017-10-05 16:55:38 +02:00
|
|
|
return [self initWithNoMedia];
|
2018-04-13 15:36:43 +02:00
|
|
|
#else
|
2018-01-30 10:32:13 +01:00
|
|
|
return [self initWithNativeAudioEncoderFactory:webrtc::CreateBuiltinAudioEncoderFactory()
|
|
|
|
|
nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
|
2018-02-01 15:47:05 +01:00
|
|
|
nativeVideoEncoderFactory:webrtc::ObjCToNativeVideoEncoderFactory(
|
|
|
|
|
[[RTCVideoEncoderFactoryH264 alloc] init])
|
|
|
|
|
nativeVideoDecoderFactory:webrtc::ObjCToNativeVideoDecoderFactory(
|
|
|
|
|
[[RTCVideoDecoderFactoryH264 alloc] init])
|
2018-05-15 10:22:36 +02:00
|
|
|
audioDeviceModule:[self audioDeviceModule]
|
2018-10-08 09:43:21 -07:00
|
|
|
audioProcessingModule:nullptr
|
|
|
|
|
mediaTransportFactory:nullptr];
|
Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2980173002/ )
Reason for revert:
Relanding after fixing issues with no video.
Original issue's description:
> Revert of Injectable Obj-C video codecs (patchset #2 id:370001 of https://codereview.webrtc.org/2979983002/ )
>
> Reason for revert:
> Still having problems with no video. Reverting.
> Once no video is visible, no video is available from then on even if the callee app is in the foreground.
>
>
> Original issue's description:
> > Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2979973002/ )
> >
> > Reason for revert:
> > Fix the broken build file
> >
> > Original issue's description:
> > > Revert of Injectable Obj-C video codecs (patchset #3 id:400001 of https://codereview.webrtc.org/2981583002/ )
> > >
> > > Reason for revert:
> > > Breaks bots. Build file incorrect.
> > >
> > > Original issue's description:
> > > > Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2975963002/ )
> > > >
> > > > Reason for revert:
> > > > New CL for fixing the issues
> > > >
> > > > Original issue's description:
> > > > > Revert of Injectable Obj-C video codecs (patchset #8 id:140001 of https://codereview.webrtc.org/2966023002/ )
> > > > >
> > > > > Reason for revert:
> > > > > Causes no video in certain scenarios. Please come up with a test plan or unit test to prevent such problems in the future.
> > > > >
> > > > > Original issue's description:
> > > > > > Injectable Obj-C video codecs
> > > > > >
> > > > > > Initial CL for this effort, with a working RTCVideoEncoder/Decoder for H264
> > > > > > (wrapping the VideoToolbox codec).
> > > > > >
> > > > > > Some notes / things left to do:
> > > > > > - There are some hard-coded references to codec types that are supported by
> > > > > > webrtc::VideoCodec, cricket::VideoCodec, webrtc::CodecSpecificInfo etc
> > > > > > since we need to convert to/from these types in ObjCVideoEncoder/Decoder.
> > > > > > These types would need to be more codec agnostic to avoid this.
> > > > > > - Most interfaces are borrowed from the design document for injectable
> > > > > > codecs in Android. Some data in the corresponding C++ classes is discarded
> > > > > > when converting to the Obj-C version, since it has fewer fields. I have not
> > > > > > verified whether all data that we do keep is needed, or whether we might be
> > > > > > losing anything useful in these conversions.
> > > > > > - Implement the VideoToolbox codec code directly in the RTCVideoEncoderH264
> > > > > > classes, instead of wrapping webrtc::H264VideoToolboxEncoder / decoder.
> > > > > > Eliminates converting between ObjC/C++ types outside the ObjCVideoEncoder/
> > > > > > Decoder wrapper classes.
> > > > > > - List the injected codec factory's supported codecs in the list of codecs in
> > > > > > AppRTCMobile.
> > > > > >
> > > > > > BUG=webrtc:7924
> > > > > > R=magjed@webrtc.org
> > > > > >
> > > > > > Review-Url: https://codereview.webrtc.org/2966023002 .
> > > > > > Cr-Commit-Position: refs/heads/master@{#18928}
> > > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/a0349c138db62c52435be84b6c837f5f4758e264
> > > > >
> > > > > TBR=magjed@webrtc.org,andersc@webrtc.org
> > > > > # Not skipping CQ checks because original CL landed more than 1 days ago.
> > > > > BUG=webrtc:7924
> > > > > NOTRY=true
> > > > >
> > > > > Review-Url: https://codereview.webrtc.org/2975963002
> > > > > Cr-Commit-Position: refs/heads/master@{#18979}
> > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/1095ada7ad56fe29b7b2bbc560a8f6475a7978ce
> > > >
> > > > R=magjed@webrtc.org
> > > > TBR=tkchin@webrtc.org
> > > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > > NOPRESUBMIT=true
> > > > NOTREECHECKS=true
> > > > NOTRY=true
> > > > BUG=webrtc:7924
> > > >
> > > > Review-Url: https://codereview.webrtc.org/2981583002 .
> > > > Cr-Commit-Position: refs/heads/master@{#19002}
> > > > Committed: https://chromium.googlesource.com/external/webrtc/+/a5f1de1e6541de03f944bcbf49be87c01f57a18b
> > >
> > > TBR=magjed@webrtc.org,tkchin@webrtc.org,jtteh@webrtc.org,andersc@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:7924
> > >
> > > Review-Url: https://codereview.webrtc.org/2979973002
> > > Cr-Commit-Position: refs/heads/master@{#19004}
> > > Committed: https://chromium.googlesource.com/external/webrtc/+/81d40ee1491d5229c2677cc04b1f40d67c2babef
> >
> > TBR=magjed@webrtc.org,tkchin@webrtc.org,jtteh@webrtc.org,sprang@webrtc.org
> > BUG=webrtc:7924
> >
> > Review-Url: https://codereview.webrtc.org/2979983002
> > Cr-Commit-Position: refs/heads/master@{#19005}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/732a3437da4db7b452758b8e1cf26fce0ce3bf65
>
> TBR=magjed@webrtc.org,tkchin@webrtc.org,sprang@webrtc.org,haysc@webrtc.org,andersc@webrtc.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=webrtc:7924
>
> Review-Url: https://codereview.webrtc.org/2980173002
> Cr-Commit-Position: refs/heads/master@{#19036}
> Committed: https://chromium.googlesource.com/external/webrtc/+/860f7298166084d966749e22b69aa2fdcf4d4ed6
TBR=magjed@webrtc.org,tkchin@webrtc.org,sprang@webrtc.org,haysc@webrtc.org,andersc@webrtc.org,jtteh@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7924
Review-Url: https://codereview.webrtc.org/2977213002
Cr-Commit-Position: refs/heads/master@{#19135}
2017-07-25 07:55:58 -07:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-29 09:49:43 +00:00
|
|
|
- (instancetype)initWithEncoderFactory:(nullable id<RTCVideoEncoderFactory>)encoderFactory
|
2018-10-08 09:43:21 -07:00
|
|
|
decoderFactory:(nullable id<RTCVideoDecoderFactory>)decoderFactory
|
|
|
|
|
mediaTransportFactory:
|
|
|
|
|
(std::unique_ptr<webrtc::MediaTransportFactory>)mediaTransportFactory {
|
2017-08-29 03:57:22 -07:00
|
|
|
#ifdef HAVE_NO_MEDIA
|
2017-10-05 16:55:38 +02:00
|
|
|
return [self initWithNoMedia];
|
2017-08-29 03:57:22 -07:00
|
|
|
#else
|
2017-10-05 16:55:38 +02:00
|
|
|
std::unique_ptr<webrtc::VideoEncoderFactory> native_encoder_factory;
|
|
|
|
|
std::unique_ptr<webrtc::VideoDecoderFactory> native_decoder_factory;
|
|
|
|
|
if (encoderFactory) {
|
2018-02-01 15:47:05 +01:00
|
|
|
native_encoder_factory = webrtc::ObjCToNativeVideoEncoderFactory(encoderFactory);
|
2017-10-05 16:55:38 +02:00
|
|
|
}
|
|
|
|
|
if (decoderFactory) {
|
2018-02-01 15:47:05 +01:00
|
|
|
native_decoder_factory = webrtc::ObjCToNativeVideoDecoderFactory(decoderFactory);
|
2017-10-05 16:55:38 +02:00
|
|
|
}
|
2017-08-29 03:57:22 -07:00
|
|
|
return [self initWithNativeAudioEncoderFactory:webrtc::CreateBuiltinAudioEncoderFactory()
|
|
|
|
|
nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
|
2017-10-05 16:55:38 +02:00
|
|
|
nativeVideoEncoderFactory:std::move(native_encoder_factory)
|
2017-10-30 07:50:17 -07:00
|
|
|
nativeVideoDecoderFactory:std::move(native_decoder_factory)
|
2018-05-15 10:22:36 +02:00
|
|
|
audioDeviceModule:[self audioDeviceModule]
|
2018-10-08 09:43:21 -07:00
|
|
|
audioProcessingModule:nullptr
|
|
|
|
|
mediaTransportFactory:std::move(mediaTransportFactory)];
|
2017-08-29 03:57:22 -07:00
|
|
|
#endif
|
|
|
|
|
}
|
2018-10-08 09:43:21 -07:00
|
|
|
- (instancetype)initWithEncoderFactory:(nullable id<RTCVideoEncoderFactory>)encoderFactory
|
|
|
|
|
decoderFactory:(nullable id<RTCVideoDecoderFactory>)decoderFactory {
|
|
|
|
|
return [self initWithEncoderFactory:encoderFactory
|
|
|
|
|
decoderFactory:decoderFactory
|
|
|
|
|
mediaTransportFactory:nullptr];
|
|
|
|
|
}
|
2017-08-29 03:57:22 -07:00
|
|
|
|
2017-10-05 16:55:38 +02:00
|
|
|
- (instancetype)initNative {
|
Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2980173002/ )
Reason for revert:
Relanding after fixing issues with no video.
Original issue's description:
> Revert of Injectable Obj-C video codecs (patchset #2 id:370001 of https://codereview.webrtc.org/2979983002/ )
>
> Reason for revert:
> Still having problems with no video. Reverting.
> Once no video is visible, no video is available from then on even if the callee app is in the foreground.
>
>
> Original issue's description:
> > Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2979973002/ )
> >
> > Reason for revert:
> > Fix the broken build file
> >
> > Original issue's description:
> > > Revert of Injectable Obj-C video codecs (patchset #3 id:400001 of https://codereview.webrtc.org/2981583002/ )
> > >
> > > Reason for revert:
> > > Breaks bots. Build file incorrect.
> > >
> > > Original issue's description:
> > > > Reland of Injectable Obj-C video codecs (patchset #1 id:1 of https://codereview.webrtc.org/2975963002/ )
> > > >
> > > > Reason for revert:
> > > > New CL for fixing the issues
> > > >
> > > > Original issue's description:
> > > > > Revert of Injectable Obj-C video codecs (patchset #8 id:140001 of https://codereview.webrtc.org/2966023002/ )
> > > > >
> > > > > Reason for revert:
> > > > > Causes no video in certain scenarios. Please come up with a test plan or unit test to prevent such problems in the future.
> > > > >
> > > > > Original issue's description:
> > > > > > Injectable Obj-C video codecs
> > > > > >
> > > > > > Initial CL for this effort, with a working RTCVideoEncoder/Decoder for H264
> > > > > > (wrapping the VideoToolbox codec).
> > > > > >
> > > > > > Some notes / things left to do:
> > > > > > - There are some hard-coded references to codec types that are supported by
> > > > > > webrtc::VideoCodec, cricket::VideoCodec, webrtc::CodecSpecificInfo etc
> > > > > > since we need to convert to/from these types in ObjCVideoEncoder/Decoder.
> > > > > > These types would need to be more codec agnostic to avoid this.
> > > > > > - Most interfaces are borrowed from the design document for injectable
> > > > > > codecs in Android. Some data in the corresponding C++ classes is discarded
> > > > > > when converting to the Obj-C version, since it has fewer fields. I have not
> > > > > > verified whether all data that we do keep is needed, or whether we might be
> > > > > > losing anything useful in these conversions.
> > > > > > - Implement the VideoToolbox codec code directly in the RTCVideoEncoderH264
> > > > > > classes, instead of wrapping webrtc::H264VideoToolboxEncoder / decoder.
> > > > > > Eliminates converting between ObjC/C++ types outside the ObjCVideoEncoder/
> > > > > > Decoder wrapper classes.
> > > > > > - List the injected codec factory's supported codecs in the list of codecs in
> > > > > > AppRTCMobile.
> > > > > >
> > > > > > BUG=webrtc:7924
> > > > > > R=magjed@webrtc.org
> > > > > >
> > > > > > Review-Url: https://codereview.webrtc.org/2966023002 .
> > > > > > Cr-Commit-Position: refs/heads/master@{#18928}
> > > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/a0349c138db62c52435be84b6c837f5f4758e264
> > > > >
> > > > > TBR=magjed@webrtc.org,andersc@webrtc.org
> > > > > # Not skipping CQ checks because original CL landed more than 1 days ago.
> > > > > BUG=webrtc:7924
> > > > > NOTRY=true
> > > > >
> > > > > Review-Url: https://codereview.webrtc.org/2975963002
> > > > > Cr-Commit-Position: refs/heads/master@{#18979}
> > > > > Committed: https://chromium.googlesource.com/external/webrtc/+/1095ada7ad56fe29b7b2bbc560a8f6475a7978ce
> > > >
> > > > R=magjed@webrtc.org
> > > > TBR=tkchin@webrtc.org
> > > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > > NOPRESUBMIT=true
> > > > NOTREECHECKS=true
> > > > NOTRY=true
> > > > BUG=webrtc:7924
> > > >
> > > > Review-Url: https://codereview.webrtc.org/2981583002 .
> > > > Cr-Commit-Position: refs/heads/master@{#19002}
> > > > Committed: https://chromium.googlesource.com/external/webrtc/+/a5f1de1e6541de03f944bcbf49be87c01f57a18b
> > >
> > > TBR=magjed@webrtc.org,tkchin@webrtc.org,jtteh@webrtc.org,andersc@webrtc.org
> > > # Skipping CQ checks because original CL landed less than 1 days ago.
> > > NOPRESUBMIT=true
> > > NOTREECHECKS=true
> > > NOTRY=true
> > > BUG=webrtc:7924
> > >
> > > Review-Url: https://codereview.webrtc.org/2979973002
> > > Cr-Commit-Position: refs/heads/master@{#19004}
> > > Committed: https://chromium.googlesource.com/external/webrtc/+/81d40ee1491d5229c2677cc04b1f40d67c2babef
> >
> > TBR=magjed@webrtc.org,tkchin@webrtc.org,jtteh@webrtc.org,sprang@webrtc.org
> > BUG=webrtc:7924
> >
> > Review-Url: https://codereview.webrtc.org/2979983002
> > Cr-Commit-Position: refs/heads/master@{#19005}
> > Committed: https://chromium.googlesource.com/external/webrtc/+/732a3437da4db7b452758b8e1cf26fce0ce3bf65
>
> TBR=magjed@webrtc.org,tkchin@webrtc.org,sprang@webrtc.org,haysc@webrtc.org,andersc@webrtc.org
> # Not skipping CQ checks because original CL landed more than 1 days ago.
> BUG=webrtc:7924
>
> Review-Url: https://codereview.webrtc.org/2980173002
> Cr-Commit-Position: refs/heads/master@{#19036}
> Committed: https://chromium.googlesource.com/external/webrtc/+/860f7298166084d966749e22b69aa2fdcf4d4ed6
TBR=magjed@webrtc.org,tkchin@webrtc.org,sprang@webrtc.org,haysc@webrtc.org,andersc@webrtc.org,jtteh@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:7924
Review-Url: https://codereview.webrtc.org/2977213002
Cr-Commit-Position: refs/heads/master@{#19135}
2017-07-25 07:55:58 -07:00
|
|
|
if (self = [super init]) {
|
2016-05-17 01:52:02 -07:00
|
|
|
_networkThread = rtc::Thread::CreateWithSocketServer();
|
2018-05-01 00:58:43 +03:00
|
|
|
_networkThread->SetName("network_thread", _networkThread.get());
|
2016-05-17 01:52:02 -07:00
|
|
|
BOOL result = _networkThread->Start();
|
|
|
|
|
NSAssert(result, @"Failed to start network thread.");
|
|
|
|
|
|
|
|
|
|
_workerThread = rtc::Thread::Create();
|
2018-05-01 00:58:43 +03:00
|
|
|
_workerThread->SetName("worker_thread", _workerThread.get());
|
2016-01-20 13:40:30 -08:00
|
|
|
result = _workerThread->Start();
|
|
|
|
|
NSAssert(result, @"Failed to start worker thread.");
|
|
|
|
|
|
2016-05-17 01:52:02 -07:00
|
|
|
_signalingThread = rtc::Thread::Create();
|
2018-05-01 00:58:43 +03:00
|
|
|
_signalingThread->SetName("signaling_thread", _signalingThread.get());
|
2016-05-17 01:52:02 -07:00
|
|
|
result = _signalingThread->Start();
|
|
|
|
|
NSAssert(result, @"Failed to start signaling thread.");
|
2017-10-05 16:55:38 +02:00
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithNoMedia {
|
|
|
|
|
if (self = [self initNative]) {
|
2017-06-28 14:05:44 -07:00
|
|
|
_nativeFactory = webrtc::CreateModularPeerConnectionFactory(
|
|
|
|
|
_networkThread.get(),
|
|
|
|
|
_workerThread.get(),
|
|
|
|
|
_signalingThread.get(),
|
|
|
|
|
std::unique_ptr<cricket::MediaEngineInterface>(),
|
|
|
|
|
std::unique_ptr<webrtc::CallFactoryInterface>(),
|
|
|
|
|
std::unique_ptr<webrtc::RtcEventLogFactoryInterface>());
|
2017-10-05 16:55:38 +02:00
|
|
|
NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!");
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (instancetype)initWithNativeAudioEncoderFactory:
|
|
|
|
|
(rtc::scoped_refptr<webrtc::AudioEncoderFactory>)audioEncoderFactory
|
|
|
|
|
nativeAudioDecoderFactory:
|
|
|
|
|
(rtc::scoped_refptr<webrtc::AudioDecoderFactory>)audioDecoderFactory
|
|
|
|
|
nativeVideoEncoderFactory:
|
|
|
|
|
(std::unique_ptr<webrtc::VideoEncoderFactory>)videoEncoderFactory
|
|
|
|
|
nativeVideoDecoderFactory:
|
2017-10-30 07:50:17 -07:00
|
|
|
(std::unique_ptr<webrtc::VideoDecoderFactory>)videoDecoderFactory
|
|
|
|
|
audioDeviceModule:
|
2017-11-13 14:56:02 +01:00
|
|
|
(nullable webrtc::AudioDeviceModule *)audioDeviceModule
|
|
|
|
|
audioProcessingModule:
|
|
|
|
|
(rtc::scoped_refptr<webrtc::AudioProcessing>)audioProcessingModule {
|
2018-10-08 09:43:21 -07:00
|
|
|
return [self initWithNativeAudioEncoderFactory:audioEncoderFactory
|
|
|
|
|
nativeAudioDecoderFactory:audioDecoderFactory
|
|
|
|
|
nativeVideoEncoderFactory:std::move(videoEncoderFactory)
|
|
|
|
|
nativeVideoDecoderFactory:std::move(videoDecoderFactory)
|
|
|
|
|
audioDeviceModule:audioDeviceModule
|
|
|
|
|
audioProcessingModule:audioProcessingModule
|
|
|
|
|
mediaTransportFactory:nullptr];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (instancetype)
|
|
|
|
|
initWithNativeAudioEncoderFactory:
|
|
|
|
|
(rtc::scoped_refptr<webrtc::AudioEncoderFactory>)audioEncoderFactory
|
|
|
|
|
nativeAudioDecoderFactory:
|
|
|
|
|
(rtc::scoped_refptr<webrtc::AudioDecoderFactory>)audioDecoderFactory
|
|
|
|
|
nativeVideoEncoderFactory:
|
|
|
|
|
(std::unique_ptr<webrtc::VideoEncoderFactory>)videoEncoderFactory
|
|
|
|
|
nativeVideoDecoderFactory:
|
|
|
|
|
(std::unique_ptr<webrtc::VideoDecoderFactory>)videoDecoderFactory
|
|
|
|
|
audioDeviceModule:(nullable webrtc::AudioDeviceModule *)audioDeviceModule
|
|
|
|
|
audioProcessingModule:
|
|
|
|
|
(rtc::scoped_refptr<webrtc::AudioProcessing>)audioProcessingModule
|
|
|
|
|
mediaTransportFactory:
|
|
|
|
|
(std::unique_ptr<webrtc::MediaTransportFactory>)mediaTransportFactory {
|
2017-10-05 16:55:38 +02:00
|
|
|
#ifdef HAVE_NO_MEDIA
|
|
|
|
|
return [self initWithNoMedia];
|
|
|
|
|
#else
|
|
|
|
|
if (self = [self initNative]) {
|
2018-10-08 09:43:21 -07:00
|
|
|
if (!audioProcessingModule) audioProcessingModule = webrtc::AudioProcessingBuilder().Create();
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<cricket::MediaEngineInterface> media_engine =
|
Revert "Use the factory instead of using the builtin code path in `VideoCodecInitializer`."
This reverts commit be142178aaf6ab4089b4d81c88c3d59c12cca567.
Reason for revert: breaking internal projects
Original change's description:
> Use the factory instead of using the builtin code path in `VideoCodecInitializer`.
>
> Bug: webrtc:9513
> Change-Id: Ia299ae1044a3ff4c91e208200938cba540bdcea6
> Reviewed-on: https://webrtc-review.googlesource.com/c/94782
> Commit-Queue: Jiawei Ou <ouj@fb.com>
> Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
> Reviewed-by: Sebastian Jansson <srte@webrtc.org>
> Reviewed-by: Anders Carlsson <andersc@webrtc.org>
> Reviewed-by: Seth Hampson <shampson@webrtc.org>
> Reviewed-by: Erik Språng <sprang@webrtc.org>
> Reviewed-by: Niels Moller <nisse@webrtc.org>
> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#25456}
TBR=brandtr@webrtc.org,magjed@webrtc.org,sakal@webrtc.org,nisse@webrtc.org,andersc@webrtc.org,tommi@webrtc.org,kthelgason@webrtc.org,sprang@webrtc.org,srte@webrtc.org,perkj@webrtc.org,tkchin@webrtc.org,shampson@webrtc.org,glaznev@webrtc.org,ouj@fb.com,qingsi@webrtc.org
Change-Id: I8040ccabe3ae6464d72c7696adb663c1dd275b63
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9513
Reviewed-on: https://webrtc-review.googlesource.com/c/108980
Reviewed-by: Qingsi Wang <qingsi@webrtc.org>
Commit-Queue: Qingsi Wang <qingsi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25459}
2018-11-01 04:45:53 +00:00
|
|
|
cricket::WebRtcMediaEngineFactory::Create(audioDeviceModule,
|
|
|
|
|
audioEncoderFactory,
|
|
|
|
|
audioDecoderFactory,
|
|
|
|
|
std::move(videoEncoderFactory),
|
|
|
|
|
std::move(videoDecoderFactory),
|
|
|
|
|
nullptr, // audio mixer
|
|
|
|
|
audioProcessingModule);
|
2018-10-08 09:43:21 -07:00
|
|
|
|
|
|
|
|
std::unique_ptr<webrtc::CallFactoryInterface> call_factory = webrtc::CreateCallFactory();
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<webrtc::RtcEventLogFactoryInterface> event_log_factory =
|
|
|
|
|
webrtc::CreateRtcEventLogFactory();
|
|
|
|
|
webrtc::PeerConnectionFactoryDependencies dependencies;
|
|
|
|
|
dependencies.network_thread = _networkThread.get();
|
|
|
|
|
dependencies.worker_thread = _workerThread.get();
|
|
|
|
|
dependencies.signaling_thread = _signalingThread.get();
|
|
|
|
|
dependencies.media_engine = std::move(media_engine);
|
|
|
|
|
dependencies.call_factory = std::move(call_factory);
|
|
|
|
|
dependencies.event_log_factory = std::move(event_log_factory);
|
|
|
|
|
dependencies.media_transport_factory = std::move(mediaTransportFactory);
|
|
|
|
|
_nativeFactory = webrtc::CreateModularPeerConnectionFactory(std::move(dependencies));
|
2017-10-05 16:55:38 +02:00
|
|
|
NSAssert(_nativeFactory, @"Failed to initialize PeerConnectionFactory!");
|
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-30 11:56:05 -07:00
|
|
|
- (RTCAudioSource *)audioSourceWithConstraints:(nullable RTCMediaConstraints *)constraints {
|
|
|
|
|
std::unique_ptr<webrtc::MediaConstraints> nativeConstraints;
|
|
|
|
|
if (constraints) {
|
|
|
|
|
nativeConstraints = constraints.nativeConstraints;
|
|
|
|
|
}
|
2018-05-21 11:23:35 +02:00
|
|
|
cricket::AudioOptions options;
|
|
|
|
|
CopyConstraintsIntoAudioOptions(nativeConstraints.get(), &options);
|
|
|
|
|
|
2016-08-30 11:56:05 -07:00
|
|
|
rtc::scoped_refptr<webrtc::AudioSourceInterface> source =
|
2018-05-21 11:23:35 +02:00
|
|
|
_nativeFactory->CreateAudioSource(options);
|
2018-07-11 15:35:40 +03:00
|
|
|
return [[RTCAudioSource alloc] initWithFactory:self nativeAudioSource:source];
|
2016-03-23 11:29:27 -07:00
|
|
|
}
|
2016-03-22 10:57:40 -07:00
|
|
|
|
|
|
|
|
- (RTCAudioTrack *)audioTrackWithTrackId:(NSString *)trackId {
|
2016-08-30 11:56:05 -07:00
|
|
|
RTCAudioSource *audioSource = [self audioSourceWithConstraints:nil];
|
|
|
|
|
return [self audioTrackWithSource:audioSource trackId:trackId];
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-29 09:49:43 +00:00
|
|
|
- (RTCAudioTrack *)audioTrackWithSource:(RTCAudioSource *)source
|
|
|
|
|
trackId:(NSString *)trackId {
|
|
|
|
|
return [[RTCAudioTrack alloc] initWithFactory:self
|
|
|
|
|
source:source
|
|
|
|
|
trackId:trackId];
|
2016-03-22 10:57:40 -07:00
|
|
|
}
|
|
|
|
|
|
2017-03-28 01:56:41 -07:00
|
|
|
- (RTCVideoSource *)videoSource {
|
2018-07-11 15:35:40 +03:00
|
|
|
return [[RTCVideoSource alloc] initWithFactory:self
|
|
|
|
|
signalingThread:_signalingThread.get()
|
|
|
|
|
workerThread:_workerThread.get()];
|
2017-03-28 01:56:41 -07:00
|
|
|
}
|
|
|
|
|
|
2017-08-29 09:49:43 +00:00
|
|
|
- (RTCVideoTrack *)videoTrackWithSource:(RTCVideoSource *)source
|
|
|
|
|
trackId:(NSString *)trackId {
|
|
|
|
|
return [[RTCVideoTrack alloc] initWithFactory:self
|
|
|
|
|
source:source
|
|
|
|
|
trackId:trackId];
|
2016-03-22 10:57:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (RTCMediaStream *)mediaStreamWithStreamId:(NSString *)streamId {
|
2017-08-29 09:49:43 +00:00
|
|
|
return [[RTCMediaStream alloc] initWithFactory:self
|
|
|
|
|
streamId:streamId];
|
2016-03-22 10:57:40 -07:00
|
|
|
}
|
|
|
|
|
|
2017-08-29 09:49:43 +00:00
|
|
|
- (RTCPeerConnection *)peerConnectionWithConfiguration:
|
|
|
|
|
(RTCConfiguration *)configuration
|
|
|
|
|
constraints:
|
|
|
|
|
(RTCMediaConstraints *)constraints
|
2016-03-22 10:57:40 -07:00
|
|
|
delegate:
|
2017-08-29 09:49:43 +00:00
|
|
|
(nullable id<RTCPeerConnectionDelegate>)delegate {
|
2016-03-22 10:57:40 -07:00
|
|
|
return [[RTCPeerConnection alloc] initWithFactory:self
|
|
|
|
|
configuration:configuration
|
|
|
|
|
constraints:constraints
|
|
|
|
|
delegate:delegate];
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-02 13:33:16 +03:00
|
|
|
- (void)setOptions:(nonnull RTCPeerConnectionFactoryOptions *)options {
|
|
|
|
|
RTC_DCHECK(options != nil);
|
|
|
|
|
_nativeFactory->SetOptions(options.nativeOptions);
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-29 09:49:43 +00:00
|
|
|
- (BOOL)startAecDumpWithFilePath:(NSString *)filePath
|
|
|
|
|
maxSizeInBytes:(int64_t)maxSizeInBytes {
|
2016-08-30 12:58:11 -07:00
|
|
|
RTC_DCHECK(filePath.length);
|
|
|
|
|
RTC_DCHECK_GT(maxSizeInBytes, 0);
|
|
|
|
|
|
|
|
|
|
if (_hasStartedAecDump) {
|
|
|
|
|
RTCLogError(@"Aec dump already started.");
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
int fd = open(filePath.UTF8String, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
|
|
|
|
|
if (fd < 0) {
|
|
|
|
|
RTCLogError(@"Error opening file: %@. Error: %d", filePath, errno);
|
|
|
|
|
return NO;
|
|
|
|
|
}
|
|
|
|
|
_hasStartedAecDump = _nativeFactory->StartAecDump(fd, maxSizeInBytes);
|
|
|
|
|
return _hasStartedAecDump;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)stopAecDump {
|
|
|
|
|
_nativeFactory->StopAecDump();
|
|
|
|
|
_hasStartedAecDump = NO;
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-20 13:40:30 -08:00
|
|
|
@end
|