iOS: Move the fallback logic to the initWithNative… initializer.

This makes it possible to only inject 1 or 0 video codec factories when
consuming the API using the PeerConnectionFactory+Native header.

Bug: webrtc:7925
Change-Id: I671d8dcdbdf2198a31f3890ff6b416441bd32d48
Reviewed-on: https://webrtc-review.googlesource.com/42661
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Commit-Queue: Anders Carlsson <andersc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21715}
This commit is contained in:
Anders Carlsson 2018-01-22 14:30:32 +01:00 committed by Commit Bot
parent f475e3aa0e
commit 4418376d16

View File

@ -79,17 +79,9 @@
std::unique_ptr<webrtc::VideoDecoderFactory> native_decoder_factory;
if (encoderFactory) {
native_encoder_factory.reset(new webrtc::ObjCVideoEncoderFactory(encoderFactory));
} else {
auto legacy_video_encoder_factory =
rtc::MakeUnique<webrtc::ObjCVideoEncoderFactory>([[RTCVideoEncoderFactoryH264 alloc] init]);
native_encoder_factory = ConvertVideoEncoderFactory(std::move(legacy_video_encoder_factory));
}
if (decoderFactory) {
native_decoder_factory.reset(new webrtc::ObjCVideoDecoderFactory(decoderFactory));
} else {
auto legacy_video_decoder_factory =
rtc::MakeUnique<webrtc::ObjCVideoDecoderFactory>([[RTCVideoDecoderFactoryH264 alloc] init]);
native_decoder_factory = ConvertVideoDecoderFactory(std::move(legacy_video_decoder_factory));
}
return [self initWithNativeAudioEncoderFactory:webrtc::CreateBuiltinAudioEncoderFactory()
nativeAudioDecoderFactory:webrtc::CreateBuiltinAudioDecoderFactory()
@ -147,6 +139,16 @@
return [self initWithNoMedia];
#else
if (self = [self initNative]) {
if (!videoEncoderFactory) {
auto legacy_video_encoder_factory = rtc::MakeUnique<webrtc::ObjCVideoEncoderFactory>(
[[RTCVideoEncoderFactoryH264 alloc] init]);
videoEncoderFactory = ConvertVideoEncoderFactory(std::move(legacy_video_encoder_factory));
}
if (!videoDecoderFactory) {
auto legacy_video_decoder_factory = rtc::MakeUnique<webrtc::ObjCVideoDecoderFactory>(
[[RTCVideoDecoderFactoryH264 alloc] init]);
videoDecoderFactory = ConvertVideoDecoderFactory(std::move(legacy_video_decoder_factory));
}
_nativeFactory = webrtc::CreatePeerConnectionFactory(_networkThread.get(),
_workerThread.get(),
_signalingThread.get(),