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_ #define WEBRTC_MEDIA_ENGINE_WEBRTCVIDEODECODERFACTORY_H_
#include "webrtc/common_types.h" #include "webrtc/common_types.h"
#include "webrtc/media/base/codec.h"
#include "webrtc/rtc_base/refcount.h" #include "webrtc/rtc_base/refcount.h"
namespace webrtc { namespace webrtc {
@ -28,8 +29,23 @@ class WebRtcVideoDecoderFactory {
public: public:
// Caller takes the ownership of the returned object and it should be released // Caller takes the ownership of the returned object and it should be released
// by calling DestroyVideoDecoder(). // 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( virtual webrtc::VideoDecoder* CreateVideoDecoder(
webrtc::VideoCodecType type) = 0; webrtc::VideoCodecType type) {
RTC_NOTREACHED();
return nullptr;
};
virtual webrtc::VideoDecoder* CreateVideoDecoderWithParams( virtual webrtc::VideoDecoder* CreateVideoDecoderWithParams(
webrtc::VideoCodecType type, webrtc::VideoCodecType type,
VideoDecoderParams params) { VideoDecoderParams params) {

View File

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

View File

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

View File

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

View File

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

View File

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