Add conversion from webrtc::SdpVideoFormat to cricket::VideoCodec

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 <sakal@webrtc.org>
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20048}
This commit is contained in:
Magnus Jedvert 2017-09-29 15:00:29 +02:00 committed by Commit Bot
parent d4a790fbea
commit 024d8970a7
3 changed files with 8 additions and 4 deletions

View File

@ -231,6 +231,11 @@ VideoCodec::VideoCodec() : Codec() {
clockrate = kVideoCodecClockrate; 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(const VideoCodec& c) = default;
VideoCodec::VideoCodec(VideoCodec&& c) = default; VideoCodec::VideoCodec(VideoCodec&& c) = default;
VideoCodec& VideoCodec::operator=(const VideoCodec& c) = default; VideoCodec& VideoCodec::operator=(const VideoCodec& c) = default;

View File

@ -17,6 +17,7 @@
#include <vector> #include <vector>
#include "api/rtpparameters.h" #include "api/rtpparameters.h"
#include "api/video_codecs/sdp_video_format.h"
#include "common_types.h" // NOLINT(build/include) #include "common_types.h" // NOLINT(build/include)
#include "media/base/mediaconstants.h" #include "media/base/mediaconstants.h"
@ -176,6 +177,7 @@ struct VideoCodec : public Codec {
// Creates an empty codec. // Creates an empty codec.
VideoCodec(); VideoCodec();
VideoCodec(const VideoCodec& c); VideoCodec(const VideoCodec& c);
explicit VideoCodec(const webrtc::SdpVideoFormat& c);
VideoCodec(VideoCodec&& c); VideoCodec(VideoCodec&& c);
~VideoCodec() override = default; ~VideoCodec() override = default;

View File

@ -153,10 +153,7 @@ class WebRtcEncoderFactoryAdapter : public EncoderFactoryAdapter {
std::vector<VideoCodec> codecs; std::vector<VideoCodec> codecs;
for (const webrtc::SdpVideoFormat& format : for (const webrtc::SdpVideoFormat& format :
encoder_factory_->GetSupportedFormats()) { encoder_factory_->GetSupportedFormats()) {
VideoCodec codec; codecs.push_back(VideoCodec(format));
codec.name = format.name;
codec.params = format.parameters;
codecs.push_back(codec);
} }
return AssignPayloadTypesAndAddAssociatedRtxCodecs(codecs); return AssignPayloadTypesAndAddAssociatedRtxCodecs(codecs);
} }