ObjC style fix for injectable video codecs
This CL fixes some ObjC style issues from CL https://codereview.webrtc.org/2977213002/. BUG=webrtc:7924 Review-Url: https://codereview.webrtc.org/2989803002 Cr-Commit-Position: refs/heads/master@{#19186}
This commit is contained in:
@ -51,7 +51,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (webrtc::EncodedImage)toCpp {
|
||||
- (webrtc::EncodedImage)nativeEncodedImage {
|
||||
// Return the pointer without copying.
|
||||
webrtc::EncodedImage encodedImage(
|
||||
(uint8_t *)_buffer.bytes, (size_t)_buffer.length, (size_t)_buffer.length);
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
@synthesize fragmentationTimeDiff = _fragmentationTimeDiff;
|
||||
@synthesize fragmentationPlType = _fragmentationPlType;
|
||||
|
||||
- (instancetype)initWithFragmentationHeader:
|
||||
- (instancetype)initWithNativeFragmentationHeader:
|
||||
(const webrtc::RTPFragmentationHeader *)fragmentationHeader {
|
||||
if (self = [super init]) {
|
||||
if (fragmentationHeader) {
|
||||
@ -44,7 +44,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (std::unique_ptr<webrtc::RTPFragmentationHeader>)toCpp {
|
||||
- (std::unique_ptr<webrtc::RTPFragmentationHeader>)createNativeFragmentationHeader {
|
||||
auto fragmentationHeader =
|
||||
std::unique_ptr<webrtc::RTPFragmentationHeader>(new webrtc::RTPFragmentationHeader);
|
||||
fragmentationHeader->VerifyAndAllocateFragmentationHeader(_fragmentationOffset.count);
|
||||
|
||||
@ -22,35 +22,35 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@interface RTCEncodedImage ()
|
||||
|
||||
- (instancetype)initWithNativeEncodedImage:(webrtc::EncodedImage)encodedImage;
|
||||
- (webrtc::EncodedImage)toCpp;
|
||||
- (webrtc::EncodedImage)nativeEncodedImage;
|
||||
|
||||
@end
|
||||
|
||||
@interface RTCVideoEncoderSettings ()
|
||||
|
||||
- (instancetype)initWithVideoCodec:(const webrtc::VideoCodec *__nullable)videoCodec;
|
||||
- (std::unique_ptr<webrtc::VideoCodec>)toCpp;
|
||||
- (instancetype)initWithNativeVideoCodec:(const webrtc::VideoCodec *__nullable)videoCodec;
|
||||
- (std::unique_ptr<webrtc::VideoCodec>)createNativeVideoEncoderSettings;
|
||||
|
||||
@end
|
||||
|
||||
@interface RTCCodecSpecificInfoH264 ()
|
||||
|
||||
- (webrtc::CodecSpecificInfo)toCpp;
|
||||
- (webrtc::CodecSpecificInfo)nativeCodecSpecificInfo;
|
||||
|
||||
@end
|
||||
|
||||
@interface RTCRtpFragmentationHeader ()
|
||||
|
||||
- (instancetype)initWithFragmentationHeader:
|
||||
- (instancetype)initWithNativeFragmentationHeader:
|
||||
(const webrtc::RTPFragmentationHeader *__nullable)fragmentationHeader;
|
||||
- (std::unique_ptr<webrtc::RTPFragmentationHeader>)toCpp;
|
||||
- (std::unique_ptr<webrtc::RTPFragmentationHeader>)createNativeFragmentationHeader;
|
||||
|
||||
@end
|
||||
|
||||
@interface RTCVideoCodecInfo ()
|
||||
|
||||
- (instancetype)initWithVideoCodec:(cricket::VideoCodec)videoCodec;
|
||||
- (cricket::VideoCodec)toCpp;
|
||||
- (instancetype)initWithNativeVideoCodec:(cricket::VideoCodec)videoCodec;
|
||||
- (cricket::VideoCodec)nativeVideoCodec;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (instancetype)initWithVideoCodec:(cricket::VideoCodec)videoCodec {
|
||||
- (instancetype)initWithNativeVideoCodec:(cricket::VideoCodec)videoCodec {
|
||||
NSMutableDictionary *params = [NSMutableDictionary dictionary];
|
||||
for (auto it = videoCodec.params.begin(); it != videoCodec.params.end(); ++it) {
|
||||
[params setObject:[NSString stringForStdString:it->second]
|
||||
@ -43,7 +43,7 @@
|
||||
parameters:params];
|
||||
}
|
||||
|
||||
- (cricket::VideoCodec)toCpp {
|
||||
- (cricket::VideoCodec)nativeVideoCodec {
|
||||
cricket::VideoCodec codec([NSString stdStringForString:_name]);
|
||||
for (NSString *paramKey in _parameters.allKeys) {
|
||||
codec.SetParam([NSString stdStringForString:paramKey],
|
||||
|
||||
@ -36,7 +36,7 @@ bool IsHighProfileEnabled() {
|
||||
|
||||
@synthesize packetizationMode = _packetizationMode;
|
||||
|
||||
- (webrtc::CodecSpecificInfo)toCpp {
|
||||
- (webrtc::CodecSpecificInfo)nativeCodecSpecificInfo {
|
||||
webrtc::CodecSpecificInfo codecSpecificInfo;
|
||||
codecSpecificInfo.codecType = webrtc::kVideoCodecH264;
|
||||
codecSpecificInfo.codec_name = "H264";
|
||||
@ -62,7 +62,7 @@ class H264VideoToolboxEncodeCompleteCallback : public webrtc::EncodedImageCallba
|
||||
(RTCH264PacketizationMode)codec_specific_info->codecSpecific.H264.packetization_mode;
|
||||
|
||||
RTCRtpFragmentationHeader *header =
|
||||
[[RTCRtpFragmentationHeader alloc] initWithFragmentationHeader:fragmentation];
|
||||
[[RTCRtpFragmentationHeader alloc] initWithNativeFragmentationHeader:fragmentation];
|
||||
|
||||
callback(image, info, header);
|
||||
return Result(Result::OK, 0);
|
||||
@ -105,7 +105,7 @@ class H264VideoToolboxDecodeCompleteCallback : public webrtc::DecodedImageCallba
|
||||
|
||||
- (instancetype)initWithCodecInfo:(RTCVideoCodecInfo *)codecInfo {
|
||||
if (self = [super init]) {
|
||||
cricket::VideoCodec codec = [codecInfo toCpp];
|
||||
cricket::VideoCodec codec = [codecInfo nativeVideoCodec];
|
||||
_videoToolboxEncoder = new webrtc::H264VideoToolboxEncoder(codec);
|
||||
}
|
||||
return self;
|
||||
@ -133,7 +133,7 @@ class H264VideoToolboxDecodeCompleteCallback : public webrtc::DecodedImageCallba
|
||||
|
||||
- (NSInteger)startEncodeWithSettings:(RTCVideoEncoderSettings *)settings
|
||||
numberOfCores:(int)numberOfCores {
|
||||
std::unique_ptr<webrtc::VideoCodec> codecSettings = [settings toCpp];
|
||||
std::unique_ptr<webrtc::VideoCodec> codecSettings = [settings createNativeVideoEncoderSettings];
|
||||
return _videoToolboxEncoder->InitEncode(
|
||||
codecSettings.release(), numberOfCores, kDefaultPayloadSize);
|
||||
}
|
||||
@ -155,7 +155,7 @@ class H264VideoToolboxDecodeCompleteCallback : public webrtc::DecodedImageCallba
|
||||
// Handle types than can be converted into one of webrtc::CodecSpecificInfo's hard coded cases.
|
||||
webrtc::CodecSpecificInfo codecSpecificInfo;
|
||||
if ([info isKindOfClass:[RTCCodecSpecificInfoH264 class]]) {
|
||||
codecSpecificInfo = [(RTCCodecSpecificInfoH264 *)info toCpp];
|
||||
codecSpecificInfo = [(RTCCodecSpecificInfoH264 *)info nativeCodecSpecificInfo];
|
||||
}
|
||||
|
||||
std::vector<webrtc::FrameType> nativeFrameTypes;
|
||||
@ -189,7 +189,7 @@ class H264VideoToolboxDecodeCompleteCallback : public webrtc::DecodedImageCallba
|
||||
|
||||
- (NSInteger)startDecodeWithSettings:(RTCVideoEncoderSettings *)settings
|
||||
numberOfCores:(int)numberOfCores {
|
||||
std::unique_ptr<webrtc::VideoCodec> codecSettings = [settings toCpp];
|
||||
std::unique_ptr<webrtc::VideoCodec> codecSettings = [settings createNativeVideoEncoderSettings];
|
||||
return _videoToolboxDecoder->InitDecode(codecSettings.release(), numberOfCores);
|
||||
}
|
||||
|
||||
@ -222,15 +222,16 @@ class H264VideoToolboxDecodeCompleteCallback : public webrtc::DecodedImageCallba
|
||||
fragmentationHeader:(RTCRtpFragmentationHeader *)fragmentationHeader
|
||||
codecSpecificInfo:(__nullable id<RTCCodecSpecificInfo>)info
|
||||
renderTimeMs:(int64_t)renderTimeMs {
|
||||
webrtc::EncodedImage image = [encodedImage toCpp];
|
||||
webrtc::EncodedImage image = [encodedImage nativeEncodedImage];
|
||||
|
||||
// Handle types than can be converted into one of webrtc::CodecSpecificInfo's hard coded cases.
|
||||
webrtc::CodecSpecificInfo codecSpecificInfo;
|
||||
if ([info isKindOfClass:[RTCCodecSpecificInfoH264 class]]) {
|
||||
codecSpecificInfo = [(RTCCodecSpecificInfoH264 *)info toCpp];
|
||||
codecSpecificInfo = [(RTCCodecSpecificInfoH264 *)info nativeCodecSpecificInfo];
|
||||
}
|
||||
|
||||
std::unique_ptr<webrtc::RTPFragmentationHeader> header = [fragmentationHeader toCpp];
|
||||
std::unique_ptr<webrtc::RTPFragmentationHeader> header =
|
||||
[fragmentationHeader createNativeFragmentationHeader];
|
||||
|
||||
return _videoToolboxDecoder->Decode(
|
||||
image, missingFrames, header.release(), &codecSpecificInfo, renderTimeMs);
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
@synthesize maxFramerate = _maxFramerate;
|
||||
@synthesize qpMax = _qpMax;
|
||||
|
||||
- (instancetype)initWithVideoCodec:(const webrtc::VideoCodec *__nullable)videoCodec {
|
||||
- (instancetype)initWithNativeVideoCodec:(const webrtc::VideoCodec *)videoCodec {
|
||||
if (self = [super init]) {
|
||||
if (videoCodec) {
|
||||
rtc::Optional<const char *> codecName = CodecTypeToPayloadName(videoCodec->codecType);
|
||||
@ -48,7 +48,7 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
- (std::unique_ptr<webrtc::VideoCodec>)toCpp {
|
||||
- (std::unique_ptr<webrtc::VideoCodec>)createNativeVideoEncoderSettings {
|
||||
auto codecSettings = std::unique_ptr<webrtc::VideoCodec>(new webrtc::VideoCodec);
|
||||
|
||||
rtc::Optional<webrtc::VideoCodecType> codecType =
|
||||
|
||||
Reference in New Issue
Block a user