Let CreateVideoDecoder take a cricket::VideoCodec.

This makes it possible for decoder factories to actually provide any
video codec, not just the ones WebRTC knows about. It also brings
the decoder factory interface more in line with that of the encoder
factory.

BUG=webrtc:8140

Review-Url: https://codereview.webrtc.org/3007433002
Cr-Commit-Position: refs/heads/master@{#19654}
This commit is contained in:
kthelgason
2017-09-04 04:36:21 -07:00
committed by Commit Bot
parent 3c39c0137a
commit ebd4f7988e
6 changed files with 30 additions and 10 deletions

View File

@ -12,6 +12,7 @@
#define WEBRTC_MEDIA_ENGINE_WEBRTCVIDEODECODERFACTORY_H_
#include "webrtc/common_types.h"
#include "webrtc/media/base/codec.h"
#include "webrtc/rtc_base/refcount.h"
namespace webrtc {
@ -28,8 +29,23 @@ class WebRtcVideoDecoderFactory {
public:
// Caller takes the ownership of the returned object and it should be released
// by calling DestroyVideoDecoder().
virtual webrtc::VideoDecoder* CreateVideoDecoderWithParams(
const VideoCodec& codec,
VideoDecoderParams params) {
// Default implementation that delegates to old version in order to preserve
// backwards-compatability.
webrtc::VideoCodecType type = webrtc::PayloadStringToCodecType(codec.name);
return CreateVideoDecoderWithParams(type, params);
}
// DEPRECATED.
// These methods should not be used by new code and will eventually be
// removed. See http://crbug.com/webrtc/8140.
virtual webrtc::VideoDecoder* CreateVideoDecoder(
webrtc::VideoCodecType type) = 0;
webrtc::VideoCodecType type) {
RTC_NOTREACHED();
return nullptr;
};
virtual webrtc::VideoDecoder* CreateVideoDecoderWithParams(
webrtc::VideoCodecType type,
VideoDecoderParams params) {

View File

@ -2147,7 +2147,7 @@ WebRtcVideoChannel::WebRtcVideoReceiveStream::CreateOrReuseVideoDecoder(
if (external_decoder_factory_ != NULL) {
webrtc::VideoDecoder* decoder =
external_decoder_factory_->CreateVideoDecoderWithParams(
type, {stream_params_.id});
codec, {stream_params_.id});
if (decoder != NULL) {
return AllocatedDecoder(decoder, type, true /* is_external */);
}
@ -2155,7 +2155,7 @@ WebRtcVideoChannel::WebRtcVideoReceiveStream::CreateOrReuseVideoDecoder(
InternalDecoderFactory internal_decoder_factory;
return AllocatedDecoder(internal_decoder_factory.CreateVideoDecoderWithParams(
type, {stream_params_.id}),
codec, {stream_params_.id}),
type, false /* is_external */);
}

View File

@ -541,6 +541,7 @@ if (is_ios || is_mac) {
":videotoolbox_objc",
":videotracksource_objc",
"..//system_wrappers:system_wrappers_default",
"../media:rtc_media_base",
"../modules:module_api",
"../rtc_base:rtc_base_tests_utils",
"../system_wrappers:system_wrappers_default",

View File

@ -25,8 +25,10 @@ class ObjCVideoDecoderFactory : public cricket::WebRtcVideoDecoderFactory {
id<RTCVideoDecoderFactory> wrapped_decoder_factory() const;
webrtc::VideoDecoder* CreateVideoDecoder(
webrtc::VideoCodecType type) override;
VideoDecoder* CreateVideoDecoderWithParams(
const cricket::VideoCodec& codec,
cricket::VideoDecoderParams params) override;
void DestroyVideoDecoder(webrtc::VideoDecoder* decoder) override;
private:

View File

@ -103,10 +103,9 @@ id<RTCVideoDecoderFactory> ObjCVideoDecoderFactory::wrapped_decoder_factory() co
return decoder_factory_;
}
VideoDecoder *ObjCVideoDecoderFactory::CreateVideoDecoder(VideoCodecType type) {
const char *codec_name = CodecTypeToPayloadString(type);
NSString *codecName = [NSString stringWithUTF8String:codec_name];
VideoDecoder *ObjCVideoDecoderFactory::CreateVideoDecoderWithParams(
const cricket::VideoCodec &codec, cricket::VideoDecoderParams params) {
NSString *codecName = [NSString stringWithUTF8String:codec.name.c_str()];
for (RTCVideoCodecInfo *codecInfo in decoder_factory_.supportedCodecs) {
if ([codecName isEqualToString:codecInfo.name]) {
id<RTCVideoDecoder> decoder = [decoder_factory_ createDecoder:codecInfo];

View File

@ -15,6 +15,7 @@
#import "WebRTC/RTCVideoCodec.h"
#import "WebRTC/RTCVideoCodecFactory.h"
#include "webrtc/media/base/codec.h"
#include "webrtc/modules/include/module_common_types.h"
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
#include "webrtc/modules/video_coding/include/video_error_codes.h"
@ -49,7 +50,8 @@ id<RTCVideoDecoderFactory> CreateErrorDecoderFactory() {
webrtc::VideoDecoder *GetObjCDecoder(id<RTCVideoDecoderFactory> factory) {
webrtc::ObjCVideoDecoderFactory decoder_factory(factory);
return decoder_factory.CreateVideoDecoder(webrtc::kVideoCodecH264);
return decoder_factory.CreateVideoDecoderWithParams(cricket::VideoCodec(cricket::kH264CodecName),
{});
}
#pragma mark -