From 024d8970a7c4b147958ec7858e69f827724ef50c Mon Sep 17 00:00:00 2001 From: Magnus Jedvert Date: Fri, 29 Sep 2017 15:00:29 +0200 Subject: [PATCH] Add conversion from webrtc::SdpVideoFormat to cricket::VideoCodec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We will have to convert from webrtc::SdpVideoFormat to cricket::VideoCodec in a couple of places until cricket::WebRtcVideoEncoderFactory is gone. It will be convenient to have the conversion logic in a common place. Bug: webrtc:7925 Change-Id: Ie5e88599f28aeea647e936300c04f9071daffd53 Reviewed-on: https://webrtc-review.googlesource.com/4840 Reviewed-by: Sami Kalliomäki Commit-Queue: Magnus Jedvert Cr-Commit-Position: refs/heads/master@{#20048} --- media/base/codec.cc | 5 +++++ media/base/codec.h | 2 ++ media/engine/webrtcvideoengine.cc | 5 +---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/media/base/codec.cc b/media/base/codec.cc index 629aba4350..625875b285 100644 --- a/media/base/codec.cc +++ b/media/base/codec.cc @@ -231,6 +231,11 @@ VideoCodec::VideoCodec() : Codec() { clockrate = kVideoCodecClockrate; } +VideoCodec::VideoCodec(const webrtc::SdpVideoFormat& c) + : Codec(0 /* id */, c.name, kVideoCodecClockrate) { + params = c.parameters; +} + VideoCodec::VideoCodec(const VideoCodec& c) = default; VideoCodec::VideoCodec(VideoCodec&& c) = default; VideoCodec& VideoCodec::operator=(const VideoCodec& c) = default; diff --git a/media/base/codec.h b/media/base/codec.h index bbd7760cc0..6c88998077 100644 --- a/media/base/codec.h +++ b/media/base/codec.h @@ -17,6 +17,7 @@ #include #include "api/rtpparameters.h" +#include "api/video_codecs/sdp_video_format.h" #include "common_types.h" // NOLINT(build/include) #include "media/base/mediaconstants.h" @@ -176,6 +177,7 @@ struct VideoCodec : public Codec { // Creates an empty codec. VideoCodec(); VideoCodec(const VideoCodec& c); + explicit VideoCodec(const webrtc::SdpVideoFormat& c); VideoCodec(VideoCodec&& c); ~VideoCodec() override = default; diff --git a/media/engine/webrtcvideoengine.cc b/media/engine/webrtcvideoengine.cc index 8dda10be01..5db4d207a2 100644 --- a/media/engine/webrtcvideoengine.cc +++ b/media/engine/webrtcvideoengine.cc @@ -153,10 +153,7 @@ class WebRtcEncoderFactoryAdapter : public EncoderFactoryAdapter { std::vector codecs; for (const webrtc::SdpVideoFormat& format : encoder_factory_->GetSupportedFormats()) { - VideoCodec codec; - codec.name = format.name; - codec.params = format.parameters; - codecs.push_back(codec); + codecs.push_back(VideoCodec(format)); } return AssignPayloadTypesAndAddAssociatedRtxCodecs(codecs); }