From be682d47ace03c1eb5845bebc4a66d1219b85216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Tue, 27 Mar 2018 08:31:45 +0200 Subject: [PATCH] Fix chromium warnings for SdpVideoFormat. Bug: webrtc:163 Change-Id: I29ad3c00116692f047456df7721ba636bbb2ca89 Reviewed-on: https://webrtc-review.googlesource.com/64723 Commit-Queue: Niels Moller Reviewed-by: Philip Eliasson Reviewed-by: Karl Wiberg Cr-Commit-Position: refs/heads/master@{#22618} --- api/BUILD.gn | 6 +-- api/video/encoded_frame.cc | 19 ++++++++ api/video/encoded_frame.h | 2 +- api/video_codecs/BUILD.gn | 2 + api/video_codecs/sdp_video_format.cc | 30 +++++++++++++ api/video_codecs/sdp_video_format.h | 12 ++--- api/video_codecs/video_decoder.cc | 44 +++++++++++++++++++ api/video_codecs/video_decoder.h | 21 +++------ modules/video_coding/BUILD.gn | 1 + modules/video_coding/codec_timer.cc | 1 + modules/video_coding/codec_timer.h | 1 + modules/video_coding/frame_buffer2.cc | 4 ++ modules/video_coding/frame_buffer2.h | 4 ++ .../include/video_coding_defines.h | 8 ++-- modules/video_coding/video_coding_defines.cc | 23 ++++++++++ video/BUILD.gn | 5 --- video/video_stream_decoder_impl.cc | 2 +- 17 files changed, 148 insertions(+), 37 deletions(-) create mode 100644 api/video/encoded_frame.cc create mode 100644 api/video_codecs/sdp_video_format.cc create mode 100644 api/video_codecs/video_decoder.cc create mode 100644 modules/video_coding/video_coding_defines.cc diff --git a/api/BUILD.gn b/api/BUILD.gn index 7b0dc09b9c..1a2ae4b96c 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn @@ -242,6 +242,7 @@ rtc_source_set("video_frame_api") { rtc_source_set("encoded_frame_api") { visibility = [ "*" ] sources = [ + "video/encoded_frame.cc", "video/encoded_frame.h", ] @@ -276,11 +277,6 @@ rtc_source_set("video_stream_decoder_create") { "../rtc_base:rtc_base_approved", "../video:video_stream_decoder_impl", ] - - if (!build_with_chromium && is_clang) { - # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163). - suppressed_configs += [ "//build/config/clang:find_bad_constructs" ] - } } rtc_source_set("video_frame_api_i420") { diff --git a/api/video/encoded_frame.cc b/api/video/encoded_frame.cc new file mode 100644 index 0000000000..37da35f047 --- /dev/null +++ b/api/video/encoded_frame.cc @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2018 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 "api/video/encoded_frame.h" + +namespace webrtc { +namespace video_coding { + +bool EncodedFrame::delayed_by_retransmission() const { return 0; } + +} // namespace video_coding +} // namespace webrtc diff --git a/api/video/encoded_frame.h b/api/video/encoded_frame.h index 345cc2137f..1e919d0077 100644 --- a/api/video/encoded_frame.h +++ b/api/video/encoded_frame.h @@ -70,7 +70,7 @@ class EncodedFrame : public webrtc::VCMEncodedFrame { // This information is currently needed by the timing calculation class. // TODO(philipel): Remove this function when a new timing class has // been implemented. - virtual bool delayed_by_retransmission() const { return 0; } + virtual bool delayed_by_retransmission() const; size_t size() const { return _length; } diff --git a/api/video_codecs/BUILD.gn b/api/video_codecs/BUILD.gn index 5da8980756..e2ac074bfd 100644 --- a/api/video_codecs/BUILD.gn +++ b/api/video_codecs/BUILD.gn @@ -15,7 +15,9 @@ if (is_android) { rtc_source_set("video_codecs_api") { visibility = [ "*" ] sources = [ + "sdp_video_format.cc", "sdp_video_format.h", + "video_decoder.cc", "video_decoder.h", "video_decoder_factory.h", "video_encoder.cc", diff --git a/api/video_codecs/sdp_video_format.cc b/api/video_codecs/sdp_video_format.cc new file mode 100644 index 0000000000..9f19602f21 --- /dev/null +++ b/api/video_codecs/sdp_video_format.cc @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2018 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 "api/video_codecs/sdp_video_format.h" + +namespace webrtc { + +SdpVideoFormat::SdpVideoFormat(const std::string& name) : name(name) {} + +SdpVideoFormat::SdpVideoFormat(const std::string& name, + const Parameters& parameters) + : name(name), parameters(parameters) {} + +SdpVideoFormat::SdpVideoFormat(const SdpVideoFormat&) = default; +SdpVideoFormat::SdpVideoFormat(SdpVideoFormat&&) = default; + +SdpVideoFormat::~SdpVideoFormat() = default; + +bool operator==(const SdpVideoFormat& a, const SdpVideoFormat& b) { + return a.name == b.name && a.parameters == b.parameters; +} + +} // namespace webrtc diff --git a/api/video_codecs/sdp_video_format.h b/api/video_codecs/sdp_video_format.h index 542353aea7..eae06cded1 100644 --- a/api/video_codecs/sdp_video_format.h +++ b/api/video_codecs/sdp_video_format.h @@ -21,14 +21,14 @@ namespace webrtc { struct SdpVideoFormat { using Parameters = std::map; - explicit SdpVideoFormat(const std::string& name) : name(name) {} - SdpVideoFormat(const std::string& name, const Parameters& parameters) - : name(name), parameters(parameters) {} + explicit SdpVideoFormat(const std::string& name); + SdpVideoFormat(const std::string& name, const Parameters& parameters); + SdpVideoFormat(const SdpVideoFormat&); + SdpVideoFormat(SdpVideoFormat&&); - friend bool operator==(const SdpVideoFormat& a, const SdpVideoFormat& b) { - return a.name == b.name && a.parameters == b.parameters; - } + ~SdpVideoFormat(); + friend bool operator==(const SdpVideoFormat& a, const SdpVideoFormat& b); friend bool operator!=(const SdpVideoFormat& a, const SdpVideoFormat& b) { return !(a == b); } diff --git a/api/video_codecs/video_decoder.cc b/api/video_codecs/video_decoder.cc new file mode 100644 index 0000000000..4e8db88370 --- /dev/null +++ b/api/video_codecs/video_decoder.cc @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2018 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 "api/video_codecs/video_decoder.h" + +namespace webrtc { + +int32_t DecodedImageCallback::Decoded(VideoFrame& decodedImage, + int64_t decode_time_ms) { + // The default implementation ignores custom decode time value. + return Decoded(decodedImage); +} + +void DecodedImageCallback::Decoded(VideoFrame& decodedImage, + rtc::Optional decode_time_ms, + rtc::Optional qp) { + Decoded(decodedImage, decode_time_ms.value_or(-1)); +} + +int32_t DecodedImageCallback::ReceivedDecodedReferenceFrame( + const uint64_t pictureId) { + return -1; +} + +int32_t DecodedImageCallback::ReceivedDecodedFrame(const uint64_t pictureId) { + return -1; +} + +bool VideoDecoder::PrefersLateDecoding() const { + return true; +} + +const char* VideoDecoder::ImplementationName() const { + return "unknown"; +} + +} // namespace webrtc diff --git a/api/video_codecs/video_decoder.h b/api/video_codecs/video_decoder.h index 5897901346..660f444a86 100644 --- a/api/video_codecs/video_decoder.h +++ b/api/video_codecs/video_decoder.h @@ -36,24 +36,17 @@ class DecodedImageCallback { // decode time excluding waiting time for any previous pending frame to // return. This is necessary for breaking positive feedback in the delay // estimation when the decoder has a single output buffer. - virtual int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms) { - // The default implementation ignores custom decode time value. - return Decoded(decodedImage); - } + virtual int32_t Decoded(VideoFrame& decodedImage, int64_t decode_time_ms); + // TODO(sakal): Remove other implementations when upstream projects have been // updated. virtual void Decoded(VideoFrame& decodedImage, rtc::Optional decode_time_ms, - rtc::Optional qp) { - Decoded(decodedImage, - decode_time_ms ? static_cast(*decode_time_ms) : -1); - } + rtc::Optional qp); - virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) { - return -1; - } + virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId); - virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId) { return -1; } + virtual int32_t ReceivedDecodedFrame(const uint64_t pictureId); }; class VideoDecoder { @@ -77,9 +70,9 @@ class VideoDecoder { // Returns true if the decoder prefer to decode frames late. // That is, it can not decode infinite number of frames before the decoded // frame is consumed. - virtual bool PrefersLateDecoding() const { return true; } + virtual bool PrefersLateDecoding() const; - virtual const char* ImplementationName() const { return "unknown"; } + virtual const char* ImplementationName() const; }; } // namespace webrtc diff --git a/modules/video_coding/BUILD.gn b/modules/video_coding/BUILD.gn index ad2d35987b..d261dce889 100644 --- a/modules/video_coding/BUILD.gn +++ b/modules/video_coding/BUILD.gn @@ -168,6 +168,7 @@ rtc_source_set("video_codec_interface") { "include/video_codec_interface.h", "include/video_coding_defines.h", "include/video_error_codes.h", + "video_coding_defines.cc", ] deps = [ "..:module_api", diff --git a/modules/video_coding/codec_timer.cc b/modules/video_coding/codec_timer.cc index 5a9b6e4e78..725f02501d 100644 --- a/modules/video_coding/codec_timer.cc +++ b/modules/video_coding/codec_timer.cc @@ -25,6 +25,7 @@ const int64_t kTimeLimitMs = 10000; VCMCodecTimer::VCMCodecTimer() : ignored_sample_count_(0), filter_(kPercentile) {} +VCMCodecTimer::~VCMCodecTimer() = default; void VCMCodecTimer::AddTiming(int64_t decode_time_ms, int64_t now_ms) { // Ignore the first |kIgnoredSampleCount| samples. diff --git a/modules/video_coding/codec_timer.h b/modules/video_coding/codec_timer.h index d112959660..1a46834f73 100644 --- a/modules/video_coding/codec_timer.h +++ b/modules/video_coding/codec_timer.h @@ -22,6 +22,7 @@ namespace webrtc { class VCMCodecTimer { public: VCMCodecTimer(); + ~VCMCodecTimer(); // Add a new decode time to the filter. void AddTiming(int64_t new_decode_time_ms, int64_t now_ms); diff --git a/modules/video_coding/frame_buffer2.cc b/modules/video_coding/frame_buffer2.cc index 86f6e42c46..9cf3652e7e 100644 --- a/modules/video_coding/frame_buffer2.cc +++ b/modules/video_coding/frame_buffer2.cc @@ -602,5 +602,9 @@ void FrameBuffer::ClearFramesAndHistory() { num_frames_buffered_ = 0; } +FrameBuffer::FrameInfo::FrameInfo() = default; +FrameBuffer::FrameInfo::FrameInfo(FrameInfo&&) = default; +FrameBuffer::FrameInfo::~FrameInfo() = default; + } // namespace video_coding } // namespace webrtc diff --git a/modules/video_coding/frame_buffer2.h b/modules/video_coding/frame_buffer2.h index 1197e82dec..bb57b83feb 100644 --- a/modules/video_coding/frame_buffer2.h +++ b/modules/video_coding/frame_buffer2.h @@ -80,6 +80,10 @@ class FrameBuffer { private: struct FrameInfo { + FrameInfo(); + FrameInfo(FrameInfo&&); + ~FrameInfo(); + // The maximum number of frames that can depend on this frame. static constexpr size_t kMaxNumDependentFrames = 8; diff --git a/modules/video_coding/include/video_coding_defines.h b/modules/video_coding/include/video_coding_defines.h index e000bc6dde..ea3e3ecefc 100644 --- a/modules/video_coding/include/video_coding_defines.h +++ b/modules/video_coding/include/video_coding_defines.h @@ -73,12 +73,10 @@ class VCMReceiveCallback { rtc::Optional qp, VideoContentType content_type) = 0; - virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId) { - return -1; - } + virtual int32_t ReceivedDecodedReferenceFrame(const uint64_t pictureId); // Called when the current receive codec changes. - virtual void OnIncomingPayloadType(int payload_type) {} - virtual void OnDecoderImplementationName(const char* implementation_name) {} + virtual void OnIncomingPayloadType(int payload_type); + virtual void OnDecoderImplementationName(const char* implementation_name); protected: virtual ~VCMReceiveCallback() {} diff --git a/modules/video_coding/video_coding_defines.cc b/modules/video_coding/video_coding_defines.cc new file mode 100644 index 0000000000..0a9cb3a331 --- /dev/null +++ b/modules/video_coding/video_coding_defines.cc @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2018 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 "modules/video_coding/include/video_coding_defines.h" + +namespace webrtc { + +int32_t VCMReceiveCallback::ReceivedDecodedReferenceFrame( + const uint64_t pictureId) { + return -1; +} +void VCMReceiveCallback::OnIncomingPayloadType(int payload_type) {} +void VCMReceiveCallback::OnDecoderImplementationName( + const char* implementation_name) {} + +} // namespace webrtc diff --git a/video/BUILD.gn b/video/BUILD.gn index 8a996a3c56..f3d2c6d80f 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -121,11 +121,6 @@ rtc_source_set("video_stream_decoder_impl") { "../rtc_base:rtc_task_queue_api", "../system_wrappers:system_wrappers", ] - - if (!build_with_chromium && is_clang) { - # Suppress warnings from the Chromium Clang plugin (bugs.webrtc.org/163). - suppressed_configs += [ "//build/config/clang:find_bad_constructs" ] - } } if (rtc_include_tests) { diff --git a/video/video_stream_decoder_impl.cc b/video/video_stream_decoder_impl.cc index 6d262b63c3..fc164901a9 100644 --- a/video/video_stream_decoder_impl.cc +++ b/video/video_stream_decoder_impl.cc @@ -43,7 +43,7 @@ void VideoStreamDecoderImpl::OnFrame( : frame_(std::move(frame)), video_stream_decoder_(video_stream_decoder) {} - bool Run() { + bool Run() override { video_stream_decoder_->OnFrame(std::move(frame_)); return true; }