Don't register invalid encode complete callbacks.
Bug: webrtc:12866 Change-Id: Ia225b2f211155b4623ba07b61cee85366d822b29 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/221741 Reviewed-by: Sergey Silkin <ssilkin@webrtc.org> Reviewed-by: Åsa Persson <asapersson@webrtc.org> Commit-Queue: Peter Hanspers <peterhanspers@webrtc.org> Cr-Commit-Position: refs/heads/master@{#34277}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
10814873c5
commit
74cc9eaca3
@ -48,21 +48,24 @@ class ObjCVideoEncoder : public VideoEncoder {
|
||||
}
|
||||
|
||||
int32_t RegisterEncodeCompleteCallback(EncodedImageCallback *callback) override {
|
||||
[encoder_ setCallback:^BOOL(RTC_OBJC_TYPE(RTCEncodedImage) * _Nonnull frame,
|
||||
id<RTC_OBJC_TYPE(RTCCodecSpecificInfo)> _Nonnull info) {
|
||||
EncodedImage encodedImage = [frame nativeEncodedImage];
|
||||
if (callback) {
|
||||
[encoder_ setCallback:^BOOL(RTC_OBJC_TYPE(RTCEncodedImage) * _Nonnull frame,
|
||||
id<RTC_OBJC_TYPE(RTCCodecSpecificInfo)> _Nonnull info) {
|
||||
EncodedImage encodedImage = [frame nativeEncodedImage];
|
||||
|
||||
// Handle types that can be converted into one of CodecSpecificInfo's hard coded cases.
|
||||
CodecSpecificInfo codecSpecificInfo;
|
||||
if ([info isKindOfClass:[RTC_OBJC_TYPE(RTCCodecSpecificInfoH264) class]]) {
|
||||
codecSpecificInfo =
|
||||
[(RTC_OBJC_TYPE(RTCCodecSpecificInfoH264) *)info nativeCodecSpecificInfo];
|
||||
}
|
||||
|
||||
EncodedImageCallback::Result res = callback->OnEncodedImage(encodedImage, &codecSpecificInfo);
|
||||
return res.error == EncodedImageCallback::Result::OK;
|
||||
}];
|
||||
// Handle types that can be converted into one of CodecSpecificInfo's hard coded cases.
|
||||
CodecSpecificInfo codecSpecificInfo;
|
||||
if ([info isKindOfClass:[RTC_OBJC_TYPE(RTCCodecSpecificInfoH264) class]]) {
|
||||
codecSpecificInfo =
|
||||
[(RTC_OBJC_TYPE(RTCCodecSpecificInfoH264) *)info nativeCodecSpecificInfo];
|
||||
}
|
||||
|
||||
EncodedImageCallback::Result res = callback->OnEncodedImage(encodedImage, &codecSpecificInfo);
|
||||
return res.error == EncodedImageCallback::Result::OK;
|
||||
}];
|
||||
} else {
|
||||
[encoder_ setCallback:nil];
|
||||
}
|
||||
return WEBRTC_VIDEO_CODEC_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user