From 244ad80444255714b85de742095aceeaee26b5d2 Mon Sep 17 00:00:00 2001 From: Magnus Jedvert Date: Thu, 28 Sep 2017 21:19:18 +0200 Subject: [PATCH] Clean up some bad constructs in media/ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We currently suppress warnings for bad constructs in media/. Still, the warnings are causing problems when trying to include header files from this directory. This CL cleans up some of the bad constructs. Bug: None Change-Id: I808ad39eb23870d20fa5bb05429b50c9078543ae Reviewed-on: https://webrtc-review.googlesource.com/4541 Reviewed-by: Sami Kalliomäki Commit-Queue: Magnus Jedvert Cr-Commit-Position: refs/heads/master@{#20039} --- media/BUILD.gn | 2 ++ media/base/codec.cc | 2 ++ media/base/codec.h | 7 +++-- media/engine/webrtcvideodecoderfactory.cc | 36 +++++++++++++++++++++++ media/engine/webrtcvideodecoderfactory.h | 19 ++++-------- media/engine/webrtcvideoencoderfactory.cc | 20 +++++++++++++ media/engine/webrtcvideoencoderfactory.h | 4 +-- 7 files changed, 70 insertions(+), 20 deletions(-) create mode 100644 media/engine/webrtcvideodecoderfactory.cc create mode 100644 media/engine/webrtcvideoencoderfactory.cc diff --git a/media/BUILD.gn b/media/BUILD.gn index 4b956c8edc..2678a31a7c 100644 --- a/media/BUILD.gn +++ b/media/BUILD.gn @@ -168,7 +168,9 @@ rtc_static_library("rtc_audio_video") { "engine/webrtcvideocapturer.h", "engine/webrtcvideocapturerfactory.cc", "engine/webrtcvideocapturerfactory.h", + "engine/webrtcvideodecoderfactory.cc", "engine/webrtcvideodecoderfactory.h", + "engine/webrtcvideoencoderfactory.cc", "engine/webrtcvideoencoderfactory.h", "engine/webrtcvideoengine.cc", "engine/webrtcvideoengine.h", diff --git a/media/base/codec.cc b/media/base/codec.cc index b5a68efb6b..629aba4350 100644 --- a/media/base/codec.cc +++ b/media/base/codec.cc @@ -32,6 +32,8 @@ static bool IsSameH264Profile(const CodecParameterMap& params1, profile_level_id->profile == other_profile_level_id->profile; } +FeedbackParams::FeedbackParams() = default; + bool FeedbackParam::operator==(const FeedbackParam& other) const { return _stricmp(other.id().c_str(), id().c_str()) == 0 && _stricmp(other.param().c_str(), param().c_str()) == 0; diff --git a/media/base/codec.h b/media/base/codec.h index ed5c1215b6..bbd7760cc0 100644 --- a/media/base/codec.h +++ b/media/base/codec.h @@ -47,6 +47,7 @@ class FeedbackParam { class FeedbackParams { public: + FeedbackParams(); bool operator==(const FeedbackParams& other) const; bool Has(const FeedbackParam& param) const; @@ -126,7 +127,7 @@ struct AudioCodec : public Codec { AudioCodec(); AudioCodec(const AudioCodec& c); AudioCodec(AudioCodec&& c); - virtual ~AudioCodec() = default; + ~AudioCodec() override = default; // Indicates if this codec is compatible with the specified codec. bool Matches(const AudioCodec& codec) const; @@ -176,7 +177,7 @@ struct VideoCodec : public Codec { VideoCodec(); VideoCodec(const VideoCodec& c); VideoCodec(VideoCodec&& c); - virtual ~VideoCodec() = default; + ~VideoCodec() override = default; // Indicates if this video codec is the same as the other video codec, e.g. if // they are both VP8 or VP9, or if they are both H264 with the same H264 @@ -222,7 +223,7 @@ struct DataCodec : public Codec { DataCodec(); DataCodec(const DataCodec& c); DataCodec(DataCodec&& c); - virtual ~DataCodec() = default; + ~DataCodec() override = default; DataCodec& operator=(const DataCodec& c); DataCodec& operator=(DataCodec&& c); diff --git a/media/engine/webrtcvideodecoderfactory.cc b/media/engine/webrtcvideodecoderfactory.cc new file mode 100644 index 0000000000..5eee788d8f --- /dev/null +++ b/media/engine/webrtcvideodecoderfactory.cc @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "media/engine/webrtcvideodecoderfactory.h" + +namespace cricket { + +webrtc::VideoDecoder* WebRtcVideoDecoderFactory::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); +} + +webrtc::VideoDecoder* WebRtcVideoDecoderFactory::CreateVideoDecoder( + webrtc::VideoCodecType type) { + RTC_NOTREACHED(); + return nullptr; +} + +webrtc::VideoDecoder* WebRtcVideoDecoderFactory::CreateVideoDecoderWithParams( + webrtc::VideoCodecType type, + VideoDecoderParams params) { + return CreateVideoDecoder(type); +} + +} // namespace cricket diff --git a/media/engine/webrtcvideodecoderfactory.h b/media/engine/webrtcvideodecoderfactory.h index 2c921c5c25..4032aa2a5d 100644 --- a/media/engine/webrtcvideodecoderfactory.h +++ b/media/engine/webrtcvideodecoderfactory.h @@ -33,26 +33,17 @@ class WebRtcVideoDecoderFactory { // 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); - } + VideoDecoderParams 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) { - RTC_NOTREACHED(); - return nullptr; - }; + virtual webrtc::VideoDecoder* CreateVideoDecoder(webrtc::VideoCodecType type); virtual webrtc::VideoDecoder* CreateVideoDecoderWithParams( webrtc::VideoCodecType type, - VideoDecoderParams params) { - return CreateVideoDecoder(type); - } + VideoDecoderParams params); + virtual ~WebRtcVideoDecoderFactory() {} virtual void DestroyVideoDecoder(webrtc::VideoDecoder* decoder) = 0; diff --git a/media/engine/webrtcvideoencoderfactory.cc b/media/engine/webrtcvideoencoderfactory.cc new file mode 100644 index 0000000000..815613ec13 --- /dev/null +++ b/media/engine/webrtcvideoencoderfactory.cc @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. + * + * Use of this source code is governed by a BSD-style license + * that can be found in the LICENSE file in the root of the source + * tree. An additional intellectual property rights grant can be found + * in the file PATENTS. All contributing project authors may + * be found in the AUTHORS file in the root of the source tree. + */ + +#include "media/engine/webrtcvideoencoderfactory.h" + +namespace cricket { + +bool WebRtcVideoEncoderFactory::EncoderTypeHasInternalSource( + webrtc::VideoCodecType type) const { + return false; +} + +} // namespace cricket diff --git a/media/engine/webrtcvideoencoderfactory.h b/media/engine/webrtcvideoencoderfactory.h index 8c629e0ac6..53a529aadf 100644 --- a/media/engine/webrtcvideoencoderfactory.h +++ b/media/engine/webrtcvideoencoderfactory.h @@ -39,9 +39,7 @@ class WebRtcVideoEncoderFactory { // Returns true if encoders created by this factory of the given codec type // will use internal camera sources, meaning that they don't require/expect // frames to be delivered via webrtc::VideoEncoder::Encode. - virtual bool EncoderTypeHasInternalSource(webrtc::VideoCodecType type) const { - return false; - } + virtual bool EncoderTypeHasInternalSource(webrtc::VideoCodecType type) const; virtual void DestroyVideoEncoder(webrtc::VideoEncoder* encoder) = 0; };