|
| 1 | +#import <Foundation/Foundation.h> |
| 2 | + |
| 3 | +#import "RTCMacros.h" |
| 4 | +#import "RTCVideoEncoderSimulcast.h" |
| 5 | +#import "RTCNativeVideoEncoder.h" |
| 6 | +#import "RTCNativeVideoEncoderBuilder+Native.h" |
| 7 | +#import "api/peerconnection/RTCVideoCodecInfo+Private.h" |
| 8 | +#include "api/transport/field_trial_based_config.h" |
| 9 | + |
| 10 | +#include "native/api/video_encoder_factory.h" |
| 11 | +#include "media/engine/simulcast_encoder_adapter.h" |
| 12 | + |
| 13 | +@interface RTC_OBJC_TYPE (RTCVideoEncoderSimulcastBuilder) |
| 14 | + : RTC_OBJC_TYPE(RTCNativeVideoEncoder) <RTC_OBJC_TYPE (RTCNativeVideoEncoderBuilder)> { |
| 15 | + |
| 16 | + id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)> _primary; |
| 17 | + id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)> _fallback; |
| 18 | + RTC_OBJC_TYPE(RTCVideoCodecInfo) *_videoCodecInfo; |
| 19 | +} |
| 20 | + |
| 21 | +- (id)initWithPrimary:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)primary |
| 22 | + fallback:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)fallback |
| 23 | + videoCodecInfo:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)videoCodecInfo; |
| 24 | + |
| 25 | +@end |
| 26 | + |
| 27 | +@implementation RTC_OBJC_TYPE (RTCVideoEncoderSimulcastBuilder) |
| 28 | + |
| 29 | +- (std::unique_ptr<webrtc::VideoEncoder>)build:(const webrtc::Environment&)env { |
| 30 | + auto nativePrimary = webrtc::ObjCToNativeVideoEncoderFactory(_primary); |
| 31 | + auto nativeFallback = webrtc::ObjCToNativeVideoEncoderFactory(_fallback); |
| 32 | + auto nativeFormat = [_videoCodecInfo nativeSdpVideoFormat]; |
| 33 | + return std::make_unique<webrtc::SimulcastEncoderAdapter>( |
| 34 | + env, |
| 35 | + nativePrimary.release(), |
| 36 | + nativeFallback.release(), |
| 37 | + std::move(nativeFormat)); |
| 38 | +} |
| 39 | + |
| 40 | +- (id)initWithPrimary:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)primary |
| 41 | + fallback:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)fallback |
| 42 | + videoCodecInfo:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)videoCodecInfo { |
| 43 | + if (self = [super init]) { |
| 44 | + self->_primary = primary; |
| 45 | + self->_fallback = fallback; |
| 46 | + self->_videoCodecInfo = videoCodecInfo; |
| 47 | + } |
| 48 | + return self; |
| 49 | +} |
| 50 | + |
| 51 | +@end |
| 52 | + |
| 53 | +@implementation RTC_OBJC_TYPE (RTCVideoEncoderSimulcast) |
| 54 | + |
| 55 | ++ (id<RTC_OBJC_TYPE(RTCVideoEncoder)>)simulcastEncoderWithPrimary:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)primary |
| 56 | + fallback:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)fallback |
| 57 | + videoCodecInfo:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)videoCodecInfo { |
| 58 | + return [[RTC_OBJC_TYPE(RTCVideoEncoderSimulcastBuilder) alloc] |
| 59 | + initWithPrimary:primary |
| 60 | + fallback:fallback |
| 61 | + videoCodecInfo:videoCodecInfo]; |
| 62 | +} |
| 63 | + |
| 64 | +@end |
0 commit comments