-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from GetStream/patch/ios/simulcast
Support for simulcast in iOS SDK
- Loading branch information
Showing
10 changed files
with
216 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#import "RTCMacros.h" | ||
#import "RTCVideoEncoder.h" | ||
#import "RTCVideoEncoderFactory.h" | ||
#import "RTCVideoCodecInfo.h" | ||
|
||
RTC_OBJC_EXPORT | ||
@interface RTC_OBJC_TYPE (RTCVideoEncoderSimulcast) : NSObject | ||
|
||
+ (id<RTC_OBJC_TYPE(RTCVideoEncoder)>)simulcastEncoderWithPrimary:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)primary | ||
fallback:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)fallback | ||
videoCodecInfo:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)videoCodecInfo; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
#import "RTCMacros.h" | ||
#import "RTCVideoEncoderSimulcast.h" | ||
#import "RTCWrappedNativeVideoEncoder.h" | ||
#import "api/peerconnection/RTCVideoCodecInfo+Private.h" | ||
|
||
#include "native/api/video_encoder_factory.h" | ||
#include "media/engine/simulcast_encoder_adapter.h" | ||
|
||
@implementation RTC_OBJC_TYPE (RTCVideoEncoderSimulcast) | ||
|
||
+ (id<RTC_OBJC_TYPE(RTCVideoEncoder)>)simulcastEncoderWithPrimary:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)primary | ||
fallback:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)fallback | ||
videoCodecInfo:(RTC_OBJC_TYPE(RTCVideoCodecInfo) *)videoCodecInfo { | ||
auto nativePrimary = webrtc::ObjCToNativeVideoEncoderFactory(primary); | ||
auto nativeFallback = webrtc::ObjCToNativeVideoEncoderFactory(fallback); | ||
auto nativeFormat = [videoCodecInfo nativeSdpVideoFormat]; | ||
return [[RTC_OBJC_TYPE(RTCWrappedNativeVideoEncoder) alloc] | ||
initWithNativeEncoder: std::make_unique<webrtc::SimulcastEncoderAdapter>( | ||
nativePrimary.release(), | ||
nativeFallback.release(), | ||
std::move(nativeFormat))]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
sdk/objc/components/video_codec/RTCVideoEncoderFactorySimulcast.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
#import "RTCMacros.h" | ||
#import "RTCVideoEncoderFactory.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
RTC_OBJC_EXPORT | ||
@interface RTC_OBJC_TYPE (RTCVideoEncoderFactorySimulcast) : NSObject <RTC_OBJC_TYPE(RTCVideoEncoderFactory)> | ||
|
||
- (instancetype)initWithPrimary:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)primary | ||
fallback:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)fallback; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
63 changes: 63 additions & 0 deletions
63
sdk/objc/components/video_codec/RTCVideoEncoderFactorySimulcast.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
#import "RTCMacros.h" | ||
#import "RTCVideoCodecInfo.h" | ||
#import "RTCVideoEncoderFactorySimulcast.h" | ||
#import "api/video_codec/RTCVideoEncoderSimulcast.h" | ||
#import "api/peerconnection/RTCVideoCodecInfo+Private.h" | ||
|
||
#include "absl/container/inlined_vector.h" | ||
#include "api/video_codecs/video_codec.h" | ||
#include "api/video_codecs/sdp_video_format.h" | ||
#include "api/video_codecs/video_codec.h" | ||
#include "modules/video_coding/codecs/av1/av1_svc_config.h" | ||
#include "modules/video_coding/codecs/vp9/include/vp9.h" | ||
#include "media/base/media_constants.h" | ||
|
||
@interface RTC_OBJC_TYPE (RTCVideoEncoderFactorySimulcast) () | ||
|
||
@property id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)> primary; | ||
@property id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)> fallback; | ||
|
||
@end | ||
|
||
|
||
@implementation RTC_OBJC_TYPE (RTCVideoEncoderFactorySimulcast) | ||
|
||
@synthesize primary = _primary; | ||
@synthesize fallback = _fallback; | ||
|
||
- (instancetype)initWithPrimary:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)primary | ||
fallback:(id<RTC_OBJC_TYPE(RTCVideoEncoderFactory)>)fallback { | ||
if (self = [super init]) { | ||
_primary = primary; | ||
_fallback = fallback; | ||
} | ||
return self; | ||
} | ||
|
||
- (nullable id<RTC_OBJC_TYPE(RTCVideoEncoder)>)createEncoder: (RTC_OBJC_TYPE(RTCVideoCodecInfo) *)info { | ||
return [RTCVideoEncoderSimulcast simulcastEncoderWithPrimary: _primary fallback: _fallback videoCodecInfo: info]; | ||
} | ||
|
||
- (NSArray<RTC_OBJC_TYPE(RTCVideoCodecInfo) *> *)supportedCodecs { | ||
NSArray *supportedCodecs = [[_primary supportedCodecs] arrayByAddingObjectsFromArray: [_fallback supportedCodecs]]; | ||
|
||
NSMutableArray<RTCVideoCodecInfo *> *addingCodecs = [[NSMutableArray alloc] init]; | ||
|
||
for (const webrtc::SdpVideoFormat& format : webrtc::SupportedVP9Codecs(true)) { | ||
RTCVideoCodecInfo *codec = [[RTCVideoCodecInfo alloc] initWithNativeSdpVideoFormat: format]; | ||
[addingCodecs addObject: codec]; | ||
} | ||
|
||
auto av1Format = webrtc::SdpVideoFormat( | ||
cricket::kAv1CodecName, webrtc::SdpVideoFormat::Parameters(), | ||
webrtc::LibaomAv1EncoderSupportedScalabilityModes()); | ||
RTCVideoCodecInfo *av1Codec = [[RTCVideoCodecInfo alloc] initWithNativeSdpVideoFormat: av1Format]; | ||
[addingCodecs addObject: av1Codec]; | ||
|
||
return [supportedCodecs arrayByAddingObjectsFromArray: addingCodecs]; | ||
} | ||
|
||
|
||
@end |