Deprecate RTCRtpFragmentationHeader argument for objc decoders.

Bug: webrtc:6471
Change-Id: Id542360c470ed0ea13b7e963f11bcd50d52c1d43
Reviewed-on: https://webrtc-review.googlesource.com/72442
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Reviewed-by: Anders Carlsson <andersc@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23036}
This commit is contained in:
Niels Möller
2018-04-26 09:54:25 +02:00
committed by Commit Bot
parent 530a55fc86
commit c199fae89f
5 changed files with 56 additions and 13 deletions

View File

@ -51,6 +51,14 @@
return 0;
}
- (NSInteger)decode:(RTCEncodedImage *)encodedImage
missingFrames:(BOOL)missingFrames
codecSpecificInfo:(nullable id<RTCCodecSpecificInfo>)info
renderTimeMs:(int64_t)renderTimeMs {
RTC_NOTREACHED();
return 0;
}
- (NSInteger)decode:(RTCEncodedImage *)encodedImage
missingFrames:(BOOL)missingFrames
fragmentationHeader:(RTCRtpFragmentationHeader *)fragmentationHeader

View File

@ -101,11 +101,21 @@ void decompressionOutputCallback(void *decoderRef,
return WEBRTC_VIDEO_CODEC_OK;
}
- (NSInteger)decode:(RTCEncodedImage *)inputImage
- (NSInteger)decode:(RTCEncodedImage *)encodedImage
missingFrames:(BOOL)missingFrames
fragmentationHeader:(RTCRtpFragmentationHeader *)fragmentationHeader
codecSpecificInfo:(nullable id<RTCCodecSpecificInfo>)info
renderTimeMs:(int64_t)renderTimeMs {
return [self decode:encodedImage
missingFrames:missingFrames
codecSpecificInfo:info
renderTimeMs:renderTimeMs];
}
- (NSInteger)decode:(RTCEncodedImage *)inputImage
missingFrames:(BOOL)missingFrames
codecSpecificInfo:(nullable id<RTCCodecSpecificInfo>)info
renderTimeMs:(int64_t)renderTimeMs {
RTC_DCHECK(inputImage.buffer);
if (_error != noErr) {

View File

@ -175,13 +175,21 @@ RTC_EXPORT
missingFrames:(BOOL)missingFrames
fragmentationHeader:(RTCRtpFragmentationHeader *)fragmentationHeader
codecSpecificInfo:(nullable id<RTCCodecSpecificInfo>)info
renderTimeMs:(int64_t)renderTimeMs;
renderTimeMs:(int64_t)renderTimeMs
DEPRECATED_MSG_ATTRIBUTE("use decode:missingFrames:codecSpecificInfo:renderTimeMs: instead");
- (NSString *)implementationName;
// TODO(andersc): Make non-optional when `startDecodeWithSettings:numberOfCores:` is removed.
@optional
- (NSInteger)startDecodeWithNumberOfCores:(int)numberOfCores;
// TODO(andersc): Make non-optional when `decode:...fragmentationHeader:...` is removed.
@optional
- (NSInteger)decode:(RTCEncodedImage *)encodedImage
missingFrames:(BOOL)missingFrames
codecSpecificInfo:(nullable id<RTCCodecSpecificInfo>)info
renderTimeMs:(int64_t)renderTimeMs;
@end
NS_ASSUME_NONNULL_END

View File

@ -55,8 +55,6 @@ class ObjCVideoDecoder : public VideoDecoder {
int64_t render_time_ms = -1) {
RTCEncodedImage *encodedImage =
[[RTCEncodedImage alloc] initWithNativeEncodedImage:input_image];
RTCRtpFragmentationHeader *header =
[[RTCRtpFragmentationHeader alloc] initWithNativeFragmentationHeader:fragmentation];
// webrtc::CodecSpecificInfo only handles a hard coded list of codecs
id<RTCCodecSpecificInfo> rtcCodecSpecificInfo = nil;
@ -69,11 +67,24 @@ class ObjCVideoDecoder : public VideoDecoder {
}
}
return [decoder_ decode:encodedImage
missingFrames:missing_frames
fragmentationHeader:header
codecSpecificInfo:rtcCodecSpecificInfo
renderTimeMs:render_time_ms];
if ([decoder_ respondsToSelector:@selector
(decode:missingFrames:codecSpecificInfo:renderTimeMs:)]) {
return [decoder_ decode:encodedImage
missingFrames:missing_frames
codecSpecificInfo:rtcCodecSpecificInfo
renderTimeMs:render_time_ms];
} else {
RTCRtpFragmentationHeader *header =
[[RTCRtpFragmentationHeader alloc] initWithNativeFragmentationHeader:fragmentation];
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
return [decoder_ decode:encodedImage
missingFrames:missing_frames
fragmentationHeader:header
codecSpecificInfo:rtcCodecSpecificInfo
renderTimeMs:render_time_ms];
#pragma clang diagnostic pop
}
}
int32_t RegisterDecodeCompleteCallback(DecodedImageCallback *callback) {

View File

@ -24,12 +24,20 @@
id<RTCVideoDecoderFactory> CreateDecoderFactoryReturning(int return_code) {
id decoderMock = OCMProtocolMock(@protocol(RTCVideoDecoder));
OCMStub([decoderMock startDecodeWithNumberOfCores:1]).andReturn(return_code);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
OCMStub([decoderMock decode:[OCMArg any]
missingFrames:NO
fragmentationHeader:[OCMArg any]
codecSpecificInfo:[OCMArg any]
renderTimeMs:0])
.andReturn(return_code);
#pragma clang diagnostic pop
OCMStub([decoderMock decode:[OCMArg any]
missingFrames:NO
codecSpecificInfo:[OCMArg any]
renderTimeMs:0])
.andReturn(return_code);
OCMStub([decoderMock releaseDecoder]).andReturn(return_code);
id decoderFactoryMock = OCMProtocolMock(@protocol(RTCVideoDecoderFactory));
@ -73,22 +81,20 @@ TEST(ObjCVideoDecoderFactoryTest, DecodeReturnsOKOnSuccess) {
webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateOKDecoderFactory());
webrtc::EncodedImage encoded_image;
webrtc::RTPFragmentationHeader header;
webrtc::CodecSpecificInfo info;
info.codecType = webrtc::kVideoCodecH264;
EXPECT_EQ(decoder->Decode(encoded_image, false, &header, &info, 0), WEBRTC_VIDEO_CODEC_OK);
EXPECT_EQ(decoder->Decode(encoded_image, false, nullptr, &info, 0), WEBRTC_VIDEO_CODEC_OK);
}
TEST(ObjCVideoDecoderFactoryTest, DecodeReturnsErrorOnFail) {
webrtc::VideoDecoder *decoder = GetObjCDecoder(CreateErrorDecoderFactory());
webrtc::EncodedImage encoded_image;
webrtc::RTPFragmentationHeader header;
webrtc::CodecSpecificInfo info;
info.codecType = webrtc::kVideoCodecH264;
EXPECT_EQ(decoder->Decode(encoded_image, false, &header, &info, 0), WEBRTC_VIDEO_CODEC_ERROR);
EXPECT_EQ(decoder->Decode(encoded_image, false, nullptr, &info, 0), WEBRTC_VIDEO_CODEC_ERROR);
}
TEST(ObjCVideoDecoderFactoryTest, ReleaseDecodeReturnsOKOnSuccess) {