Add support for injecting VideoBitrateAllocatorFactory also on IOS
This patch exposes webrtc::PeerConnectionDependencies c++-object and makes it possible to supply one when creating a PeerConnection. This makes it possible to e.g inject a VideoBitrateAllocatorFactory. Bug: webrtc:10547 Change-Id: Ib7431bdcec1380e7903dc5f66f3583501aeab0a5 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168307 Commit-Queue: Jonas Oreland <jonaso@webrtc.org> Reviewed-by: Anders Carlsson <andersc@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30480}
This commit is contained in:
committed by
Commit Bot
parent
56e611bbda
commit
285f83d47b
@ -78,7 +78,17 @@ class PeerConnectionDelegateAdapter : public PeerConnectionObserver {
|
||||
- (instancetype)initWithFactory:(RTCPeerConnectionFactory *)factory
|
||||
configuration:(RTCConfiguration *)configuration
|
||||
constraints:(RTCMediaConstraints *)constraints
|
||||
delegate:(nullable id<RTCPeerConnectionDelegate>)delegate
|
||||
delegate:(nullable id<RTCPeerConnectionDelegate>)delegate;
|
||||
|
||||
/** Initialize an RTCPeerConnection with a configuration, constraints,
|
||||
* delegate and PeerConnectionDependencies.
|
||||
*/
|
||||
- (instancetype)initWithDependencies:(RTCPeerConnectionFactory *)factory
|
||||
configuration:(RTCConfiguration *)configuration
|
||||
constraints:(RTCMediaConstraints *)constraints
|
||||
dependencies:
|
||||
(std::unique_ptr<webrtc::PeerConnectionDependencies>)dependencies
|
||||
delegate:(nullable id<RTCPeerConnectionDelegate>)delegate
|
||||
NS_DESIGNATED_INITIALIZER;
|
||||
|
||||
+ (webrtc::PeerConnectionInterface::SignalingState)nativeSignalingStateForState:
|
||||
|
||||
@ -307,6 +307,23 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack(
|
||||
constraints:(RTCMediaConstraints *)constraints
|
||||
delegate:(id<RTCPeerConnectionDelegate>)delegate {
|
||||
NSParameterAssert(factory);
|
||||
std::unique_ptr<webrtc::PeerConnectionDependencies> dependencies =
|
||||
std::make_unique<webrtc::PeerConnectionDependencies>(nullptr);
|
||||
return [self initWithDependencies:factory
|
||||
configuration:configuration
|
||||
constraints:constraints
|
||||
dependencies:std::move(dependencies)
|
||||
delegate:delegate];
|
||||
}
|
||||
|
||||
- (instancetype)initWithDependencies:(RTCPeerConnectionFactory *)factory
|
||||
configuration:(RTCConfiguration *)configuration
|
||||
constraints:(RTCMediaConstraints *)constraints
|
||||
dependencies:
|
||||
(std::unique_ptr<webrtc::PeerConnectionDependencies>)dependencies
|
||||
delegate:(id<RTCPeerConnectionDelegate>)delegate {
|
||||
NSParameterAssert(factory);
|
||||
NSParameterAssert(dependencies.get());
|
||||
std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> config(
|
||||
[configuration createNativeConfiguration]);
|
||||
if (!config) {
|
||||
@ -315,13 +332,12 @@ void PeerConnectionDelegateAdapter::OnRemoveTrack(
|
||||
if (self = [super init]) {
|
||||
_observer.reset(new webrtc::PeerConnectionDelegateAdapter(self));
|
||||
_nativeConstraints = constraints.nativeConstraints;
|
||||
CopyConstraintsIntoRtcConfiguration(_nativeConstraints.get(),
|
||||
config.get());
|
||||
_peerConnection =
|
||||
factory.nativeFactory->CreatePeerConnection(*config,
|
||||
nullptr,
|
||||
nullptr,
|
||||
_observer.get());
|
||||
CopyConstraintsIntoRtcConfiguration(_nativeConstraints.get(), config.get());
|
||||
|
||||
webrtc::PeerConnectionDependencies deps = std::move(*dependencies.release());
|
||||
deps.observer = _observer.get();
|
||||
_peerConnection = factory.nativeFactory->CreatePeerConnection(*config, std::move(deps));
|
||||
|
||||
if (!_peerConnection) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
@ -22,6 +22,7 @@ class NetworkControllerFactoryInterface;
|
||||
class VideoEncoderFactory;
|
||||
class VideoDecoderFactory;
|
||||
class AudioProcessing;
|
||||
struct PeerConnectionDependencies;
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -87,6 +88,16 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
decoderFactory:(nullable id<RTCVideoDecoderFactory>)decoderFactory
|
||||
mediaTransportFactory:
|
||||
(std::unique_ptr<webrtc::MediaTransportFactory>)mediaTransportFactory;
|
||||
|
||||
/** Initialize an RTCPeerConnection with a configuration, constraints, and
|
||||
* dependencies.
|
||||
*/
|
||||
- (RTCPeerConnection *)
|
||||
peerConnectionWithDependencies:(RTCConfiguration *)configuration
|
||||
constraints:(RTCMediaConstraints *)constraints
|
||||
dependencies:(std::unique_ptr<webrtc::PeerConnectionDependencies>)dependencies
|
||||
delegate:(nullable id<RTCPeerConnectionDelegate>)delegate;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
@ -296,6 +296,18 @@
|
||||
delegate:delegate];
|
||||
}
|
||||
|
||||
- (RTCPeerConnection *)
|
||||
peerConnectionWithDependencies:(RTCConfiguration *)configuration
|
||||
constraints:(RTCMediaConstraints *)constraints
|
||||
dependencies:(std::unique_ptr<webrtc::PeerConnectionDependencies>)dependencies
|
||||
delegate:(id<RTCPeerConnectionDelegate>)delegate {
|
||||
return [[RTCPeerConnection alloc] initWithDependencies:self
|
||||
configuration:configuration
|
||||
constraints:constraints
|
||||
dependencies:std::move(dependencies)
|
||||
delegate:delegate];
|
||||
}
|
||||
|
||||
- (void)setOptions:(nonnull RTCPeerConnectionFactoryOptions *)options {
|
||||
RTC_DCHECK(options != nil);
|
||||
_nativeFactory->SetOptions(options.nativeOptions);
|
||||
|
||||
Reference in New Issue
Block a user