Move RtpExtension to api/ directory and config.h/.cc to call/. BUG=webrtc:5876 R=deadbeef@webrtc.org, solenberg@webrtc.org Review-Url: https://codereview.webrtc.org/3004723002 . Cr-Original-Commit-Position: refs/heads/master@{#19639} Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc Cr-Mirrored-Commit: 1acbd68718476b2754a7872fb72e3a8a74166eb9
diff --git a/BUILD.gn b/BUILD.gn index b5c832d..4216bd3 100644 --- a/BUILD.gn +++ b/BUILD.gn
@@ -347,7 +347,6 @@ sources = [ "common_types.cc", "common_types.h", - "config.cc", "config.h", "typedefs.h", ] @@ -384,9 +383,6 @@ rtc_test("rtc_unittests") { testonly = true - sources = [ - "config_unittest.cc", - ] deps = [ ":webrtc_common",
diff --git a/DEPS b/DEPS index 276991d..0459f4c 100644 --- a/DEPS +++ b/DEPS
@@ -9,8 +9,8 @@ "+libyuv", "-webrtc", # Has to be disabled; otherwise all dirs below will be allowed. # Individual headers that will be moved out of here, see webrtc:4243. + "+webrtc/call/rtp_config.h", "+webrtc/common_types.h", - "+webrtc/config.h", "+webrtc/transport.h", "+webrtc/typedefs.h", "+webrtc/voice_engine_configurations.h",
diff --git a/api/BUILD.gn b/api/BUILD.gn index 3d19f03..e58f393 100644 --- a/api/BUILD.gn +++ b/api/BUILD.gn
@@ -62,6 +62,7 @@ "proxy.h", "rtcerror.cc", "rtcerror.h", + "rtpparameters.cc", "rtpparameters.h", "rtpreceiverinterface.h", "rtpsender.h", @@ -258,6 +259,7 @@ "ortc/mediadescription_unittest.cc", "ortc/sessiondescription_unittest.cc", "rtcerror_unittest.cc", + "rtpparameters_unittest.cc", ] if (!build_with_chromium && is_clang) {
diff --git a/api/rtpparameters.cc b/api/rtpparameters.cc new file mode 100644 index 0000000..29b14fb --- /dev/null +++ b/api/rtpparameters.cc
@@ -0,0 +1,190 @@ +/* + * 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 "webrtc/api/rtpparameters.h" + +#include <algorithm> +#include <sstream> +#include <string> + +#include "webrtc/rtc_base/checks.h" + +namespace webrtc { + +RtcpFeedback::RtcpFeedback() {} +RtcpFeedback::RtcpFeedback(RtcpFeedbackType type) : type(type) {} +RtcpFeedback::RtcpFeedback(RtcpFeedbackType type, + RtcpFeedbackMessageType message_type) + : type(type), message_type(message_type) {} +RtcpFeedback::~RtcpFeedback() {} + +RtpCodecCapability::RtpCodecCapability() {} +RtpCodecCapability::~RtpCodecCapability() {} + +RtpHeaderExtensionCapability::RtpHeaderExtensionCapability() {} +RtpHeaderExtensionCapability::RtpHeaderExtensionCapability( + const std::string& uri) + : uri(uri) {} +RtpHeaderExtensionCapability::RtpHeaderExtensionCapability( + const std::string& uri, + int preferred_id) + : uri(uri), preferred_id(preferred_id) {} +RtpHeaderExtensionCapability::~RtpHeaderExtensionCapability() {} + +RtpExtension::RtpExtension() {} +RtpExtension::RtpExtension(const std::string& uri, int id) : uri(uri), id(id) {} +RtpExtension::RtpExtension(const std::string& uri, int id, bool encrypt) + : uri(uri), id(id), encrypt(encrypt) {} +RtpExtension::~RtpExtension() {} + +RtpFecParameters::RtpFecParameters() {} +RtpFecParameters::RtpFecParameters(FecMechanism mechanism) + : mechanism(mechanism) {} +RtpFecParameters::RtpFecParameters(FecMechanism mechanism, uint32_t ssrc) + : ssrc(ssrc), mechanism(mechanism) {} +RtpFecParameters::~RtpFecParameters() {} + +RtpRtxParameters::RtpRtxParameters() {} +RtpRtxParameters::RtpRtxParameters(uint32_t ssrc) : ssrc(ssrc) {} +RtpRtxParameters::~RtpRtxParameters() {} + +RtpEncodingParameters::RtpEncodingParameters() {} +RtpEncodingParameters::~RtpEncodingParameters() {} + +RtpCodecParameters::RtpCodecParameters() {} +RtpCodecParameters::~RtpCodecParameters() {} + +RtpCapabilities::RtpCapabilities() {} +RtpCapabilities::~RtpCapabilities() {} + +RtpParameters::RtpParameters() {} +RtpParameters::~RtpParameters() {} + +std::string RtpExtension::ToString() const { + std::stringstream ss; + ss << "{uri: " << uri; + ss << ", id: " << id; + if (encrypt) { + ss << ", encrypt"; + } + ss << '}'; + return ss.str(); +} + +const char RtpExtension::kAudioLevelUri[] = + "urn:ietf:params:rtp-hdrext:ssrc-audio-level"; +const int RtpExtension::kAudioLevelDefaultId = 1; + +const char RtpExtension::kTimestampOffsetUri[] = + "urn:ietf:params:rtp-hdrext:toffset"; +const int RtpExtension::kTimestampOffsetDefaultId = 2; + +const char RtpExtension::kAbsSendTimeUri[] = + "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; +const int RtpExtension::kAbsSendTimeDefaultId = 3; + +const char RtpExtension::kVideoRotationUri[] = "urn:3gpp:video-orientation"; +const int RtpExtension::kVideoRotationDefaultId = 4; + +const char RtpExtension::kTransportSequenceNumberUri[] = + "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"; +const int RtpExtension::kTransportSequenceNumberDefaultId = 5; + +// This extension allows applications to adaptively limit the playout delay +// on frames as per the current needs. For example, a gaming application +// has very different needs on end-to-end delay compared to a video-conference +// application. +const char RtpExtension::kPlayoutDelayUri[] = + "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"; +const int RtpExtension::kPlayoutDelayDefaultId = 6; + +const char RtpExtension::kVideoContentTypeUri[] = + "http://www.webrtc.org/experiments/rtp-hdrext/video-content-type"; +const int RtpExtension::kVideoContentTypeDefaultId = 7; + +const char RtpExtension::kVideoTimingUri[] = + "http://www.webrtc.org/experiments/rtp-hdrext/video-timing"; +const int RtpExtension::kVideoTimingDefaultId = 8; + +const char RtpExtension::kEncryptHeaderExtensionsUri[] = + "urn:ietf:params:rtp-hdrext:encrypt"; + +const int RtpExtension::kMinId = 1; +const int RtpExtension::kMaxId = 14; + +bool RtpExtension::IsSupportedForAudio(const std::string& uri) { + return uri == webrtc::RtpExtension::kAudioLevelUri || + uri == webrtc::RtpExtension::kTransportSequenceNumberUri; +} + +bool RtpExtension::IsSupportedForVideo(const std::string& uri) { + return uri == webrtc::RtpExtension::kTimestampOffsetUri || + uri == webrtc::RtpExtension::kAbsSendTimeUri || + uri == webrtc::RtpExtension::kVideoRotationUri || + uri == webrtc::RtpExtension::kTransportSequenceNumberUri || + uri == webrtc::RtpExtension::kPlayoutDelayUri || + uri == webrtc::RtpExtension::kVideoContentTypeUri || + uri == webrtc::RtpExtension::kVideoTimingUri; +} + +bool RtpExtension::IsEncryptionSupported(const std::string& uri) { + return uri == webrtc::RtpExtension::kAudioLevelUri || + uri == webrtc::RtpExtension::kTimestampOffsetUri || +#if !defined(ENABLE_EXTERNAL_AUTH) + // TODO(jbauch): Figure out a way to always allow "kAbsSendTimeUri" + // here and filter out later if external auth is really used in + // srtpfilter. External auth is used by Chromium and replaces the + // extension header value of "kAbsSendTimeUri", so it must not be + // encrypted (which can't be done by Chromium). + uri == webrtc::RtpExtension::kAbsSendTimeUri || +#endif + uri == webrtc::RtpExtension::kVideoRotationUri || + uri == webrtc::RtpExtension::kTransportSequenceNumberUri || + uri == webrtc::RtpExtension::kPlayoutDelayUri || + uri == webrtc::RtpExtension::kVideoContentTypeUri; +} + +const RtpExtension* RtpExtension::FindHeaderExtensionByUri( + const std::vector<RtpExtension>& extensions, + const std::string& uri) { + for (const auto& extension : extensions) { + if (extension.uri == uri) { + return &extension; + } + } + return nullptr; +} + +std::vector<RtpExtension> RtpExtension::FilterDuplicateNonEncrypted( + const std::vector<RtpExtension>& extensions) { + std::vector<RtpExtension> filtered; + for (auto extension = extensions.begin(); extension != extensions.end(); + ++extension) { + if (extension->encrypt) { + filtered.push_back(*extension); + continue; + } + + // Only add non-encrypted extension if no encrypted with the same URI + // is also present... + if (std::find_if(extension + 1, extensions.end(), + [extension](const RtpExtension& check) { + return extension->uri == check.uri; + }) != extensions.end()) { + continue; + } + + // ...and has not been added before. + if (!FindHeaderExtensionByUri(filtered, extension->uri)) { + filtered.push_back(*extension); + } + } + return filtered; +} +} // namespace webrtc
diff --git a/api/rtpparameters.h b/api/rtpparameters.h index 94d9d73..46f7139 100644 --- a/api/rtpparameters.h +++ b/api/rtpparameters.h
@@ -16,7 +16,6 @@ #include <vector> #include "webrtc/api/mediatypes.h" -#include "webrtc/config.h" #include "webrtc/rtc_base/optional.h" namespace webrtc { @@ -85,10 +84,10 @@ rtc::Optional<RtcpFeedbackMessageType> message_type; // Constructors for convenience. - RtcpFeedback() {} - explicit RtcpFeedback(RtcpFeedbackType type) : type(type) {} - RtcpFeedback(RtcpFeedbackType type, RtcpFeedbackMessageType message_type) - : type(type), message_type(message_type) {} + RtcpFeedback(); + explicit RtcpFeedback(RtcpFeedbackType type); + RtcpFeedback(RtcpFeedbackType type, RtcpFeedbackMessageType message_type); + ~RtcpFeedback(); bool operator==(const RtcpFeedback& o) const { return type == o.type && message_type == o.message_type; @@ -100,6 +99,9 @@ // RtpParameters. This represents the static capabilities of an endpoint's // implementation of a codec. struct RtpCodecCapability { + RtpCodecCapability(); + ~RtpCodecCapability(); + // Build MIME "type/subtype" string from |name| and |kind|. std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; } @@ -196,10 +198,10 @@ bool preferred_encrypt = false; // Constructors for convenience. - RtpHeaderExtensionCapability() = default; - explicit RtpHeaderExtensionCapability(const std::string& uri) : uri(uri) {} - RtpHeaderExtensionCapability(const std::string& uri, int preferred_id) - : uri(uri), preferred_id(preferred_id) {} + RtpHeaderExtensionCapability(); + explicit RtpHeaderExtensionCapability(const std::string& uri); + RtpHeaderExtensionCapability(const std::string& uri, int preferred_id); + ~RtpHeaderExtensionCapability(); bool operator==(const RtpHeaderExtensionCapability& o) const { return uri == o.uri && preferred_id == o.preferred_id && @@ -210,6 +212,83 @@ } }; +// RTP header extension, see RFC 5285. +struct RtpExtension { + RtpExtension(); + RtpExtension(const std::string& uri, int id); + RtpExtension(const std::string& uri, int id, bool encrypt); + ~RtpExtension(); + std::string ToString() const; + bool operator==(const RtpExtension& rhs) const { + return uri == rhs.uri && id == rhs.id && encrypt == rhs.encrypt; + } + static bool IsSupportedForAudio(const std::string& uri); + static bool IsSupportedForVideo(const std::string& uri); + // Return "true" if the given RTP header extension URI may be encrypted. + static bool IsEncryptionSupported(const std::string& uri); + + // Returns the named header extension if found among all extensions, + // nullptr otherwise. + static const RtpExtension* FindHeaderExtensionByUri( + const std::vector<RtpExtension>& extensions, + const std::string& uri); + + // Return a list of RTP header extensions with the non-encrypted extensions + // removed if both the encrypted and non-encrypted extension is present for + // the same URI. + static std::vector<RtpExtension> FilterDuplicateNonEncrypted( + const std::vector<RtpExtension>& extensions); + + // Header extension for audio levels, as defined in: + // http://tools.ietf.org/html/draft-ietf-avtext-client-to-mixer-audio-level-03 + static const char kAudioLevelUri[]; + static const int kAudioLevelDefaultId; + + // Header extension for RTP timestamp offset, see RFC 5450 for details: + // http://tools.ietf.org/html/rfc5450 + static const char kTimestampOffsetUri[]; + static const int kTimestampOffsetDefaultId; + + // Header extension for absolute send time, see url for details: + // http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time + static const char kAbsSendTimeUri[]; + static const int kAbsSendTimeDefaultId; + + // Header extension for coordination of video orientation, see url for + // details: + // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126114v120700p.pdf + static const char kVideoRotationUri[]; + static const int kVideoRotationDefaultId; + + // Header extension for video content type. E.g. default or screenshare. + static const char kVideoContentTypeUri[]; + static const int kVideoContentTypeDefaultId; + + // Header extension for video timing. + static const char kVideoTimingUri[]; + static const int kVideoTimingDefaultId; + + // Header extension for transport sequence number, see url for details: + // http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions + static const char kTransportSequenceNumberUri[]; + static const int kTransportSequenceNumberDefaultId; + + static const char kPlayoutDelayUri[]; + static const int kPlayoutDelayDefaultId; + + // Encryption of Header Extensions, see RFC 6904 for details: + // https://tools.ietf.org/html/rfc6904 + static const char kEncryptHeaderExtensionsUri[]; + + // Inclusive min and max IDs for one-byte header extensions, per RFC5285. + static const int kMinId; + static const int kMaxId; + + std::string uri; + int id = 0; + bool encrypt = false; +}; + // See webrtc/config.h. Has "uri" and "id" fields. // TODO(deadbeef): This is missing the "encrypt" flag, which is unimplemented. typedef RtpExtension RtpHeaderExtensionParameters; @@ -222,10 +301,10 @@ FecMechanism mechanism = FecMechanism::RED; // Constructors for convenience. - RtpFecParameters() = default; - explicit RtpFecParameters(FecMechanism mechanism) : mechanism(mechanism) {} - RtpFecParameters(FecMechanism mechanism, uint32_t ssrc) - : ssrc(ssrc), mechanism(mechanism) {} + RtpFecParameters(); + explicit RtpFecParameters(FecMechanism mechanism); + RtpFecParameters(FecMechanism mechanism, uint32_t ssrc); + ~RtpFecParameters(); bool operator==(const RtpFecParameters& o) const { return ssrc == o.ssrc && mechanism == o.mechanism; @@ -239,14 +318,18 @@ rtc::Optional<uint32_t> ssrc; // Constructors for convenience. - RtpRtxParameters() = default; - explicit RtpRtxParameters(uint32_t ssrc) : ssrc(ssrc) {} + RtpRtxParameters(); + explicit RtpRtxParameters(uint32_t ssrc); + ~RtpRtxParameters(); bool operator==(const RtpRtxParameters& o) const { return ssrc == o.ssrc; } bool operator!=(const RtpRtxParameters& o) const { return !(*this == o); } }; struct RtpEncodingParameters { + RtpEncodingParameters(); + ~RtpEncodingParameters(); + // If unset, a value is chosen by the implementation. // // Note that the chosen value is NOT returned by GetParameters, because it @@ -338,6 +421,9 @@ }; struct RtpCodecParameters { + RtpCodecParameters(); + ~RtpCodecParameters(); + // Build MIME "type/subtype" string from |name| and |kind|. std::string mime_type() const { return MediaTypeToString(kind) + "/" + name; } @@ -400,6 +486,9 @@ // endpoint. An application can use these capabilities to construct an // RtpParameters. struct RtpCapabilities { + RtpCapabilities(); + ~RtpCapabilities(); + // Supported codecs. std::vector<RtpCodecCapability> codecs; @@ -422,6 +511,9 @@ // RtpParameters, because our API includes an additional "RtpTransport" // abstraction on which RTCP parameters are set. struct RtpParameters { + RtpParameters(); + ~RtpParameters(); + // Used when calling getParameters/setParameters with a PeerConnection // RtpSender, to ensure that outdated parameters are not unintentionally // applied successfully.
diff --git a/config_unittest.cc b/api/rtpparameters_unittest.cc similarity index 92% rename from config_unittest.cc rename to api/rtpparameters_unittest.cc index 03784d4..6cb90c2 100644 --- a/config_unittest.cc +++ b/api/rtpparameters_unittest.cc
@@ -8,11 +8,12 @@ * be found in the AUTHORS file in the root of the source tree. */ -#include "webrtc/config.h" +#include <utility> -#include <vector> +#include "webrtc/api/rtpparameters.h" +#include "webrtc/test/gtest.h" -#include "webrtc/rtc_base/gunit.h" +namespace webrtc { using webrtc::RtpExtension; @@ -47,3 +48,4 @@ EXPECT_EQ(2u, filtered.size()); EXPECT_EQ(extensions, filtered); } +} // namespace webrtc
diff --git a/call/BUILD.gn b/call/BUILD.gn index d86df1e..263f16d 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn
@@ -38,6 +38,8 @@ rtc_source_set("rtp_interfaces") { sources = [ "rtcp_packet_sink_interface.h", + "rtp_config.cc", + "rtp_config.h", "rtp_packet_sink_interface.h", "rtp_stream_receiver_controller_interface.h", "rtp_transport_controller_send_interface.h", @@ -100,6 +102,7 @@ public_deps = [ ":call_interfaces", "../api:call_api", + "../api:libjingle_peerconnection_api", ] deps = [ @@ -107,6 +110,7 @@ ":rtp_interfaces", ":rtp_receiver", ":rtp_sender", + ":video_stream_api", "..:webrtc_common", "../api:transport_api", "../audio", @@ -127,13 +131,17 @@ rtc_source_set("video_stream_api") { sources = [ + "video_config.cc", + "video_config.h", "video_receive_stream.cc", "video_receive_stream.h", "video_send_stream.cc", "video_send_stream.h", ] deps = [ + ":rtp_interfaces", "../:webrtc_common", + "../api:libjingle_peerconnection_api", "../api:transport_api", "../common_video:common_video", "../rtc_base:rtc_base_approved", @@ -209,6 +217,7 @@ ] deps = [ ":call_interfaces", + ":video_stream_api", "..:webrtc_common", "../api/audio_codecs:builtin_audio_encoder_factory", "../logging:rtc_event_log_api",
diff --git a/call/audio_receive_stream.h b/call/audio_receive_stream.h index fdf1698..018ad35 100644 --- a/call/audio_receive_stream.h +++ b/call/audio_receive_stream.h
@@ -18,9 +18,10 @@ #include "webrtc/api/audio_codecs/audio_decoder_factory.h" #include "webrtc/api/call/transport.h" +#include "webrtc/api/rtpparameters.h" #include "webrtc/api/rtpreceiverinterface.h" +#include "webrtc/call/rtp_config.h" #include "webrtc/common_types.h" -#include "webrtc/config.h" #include "webrtc/rtc_base/optional.h" #include "webrtc/rtc_base/scoped_ref_ptr.h" #include "webrtc/typedefs.h"
diff --git a/call/audio_send_stream.h b/call/audio_send_stream.h index fa5b5ee..8720249 100644 --- a/call/audio_send_stream.h +++ b/call/audio_send_stream.h
@@ -18,8 +18,10 @@ #include "webrtc/api/audio_codecs/audio_encoder_factory.h" #include "webrtc/api/audio_codecs/audio_format.h" #include "webrtc/api/call/transport.h" -#include "webrtc/config.h" +#include "webrtc/api/rtpparameters.h" +#include "webrtc/call/rtp_config.h" #include "webrtc/rtc_base/optional.h" +#include "webrtc/rtc_base/scoped_ref_ptr.h" #include "webrtc/typedefs.h" namespace webrtc {
diff --git a/call/call.cc b/call/call.cc index b1f56d3..edb9bf3 100644 --- a/call/call.cc +++ b/call/call.cc
@@ -26,7 +26,6 @@ #include "webrtc/call/flexfec_receive_stream_impl.h" #include "webrtc/call/rtp_stream_receiver_controller.h" #include "webrtc/call/rtp_transport_controller_send.h" -#include "webrtc/config.h" #include "webrtc/logging/rtc_event_log/rtc_event_log.h" #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" #include "webrtc/modules/congestion_controller/include/receive_side_congestion_controller.h"
diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc index 530ad29..29dd0e4 100644 --- a/call/call_perf_tests.cc +++ b/call/call_perf_tests.cc
@@ -15,7 +15,7 @@ #include "webrtc/api/audio_codecs/builtin_audio_encoder_factory.h" #include "webrtc/call/call.h" -#include "webrtc/config.h" +#include "webrtc/call/video_config.h" #include "webrtc/logging/rtc_event_log/rtc_event_log.h" #include "webrtc/modules/audio_coding/include/audio_coding_module.h" #include "webrtc/modules/audio_mixer/audio_mixer_impl.h"
diff --git a/call/flexfec_receive_stream.h b/call/flexfec_receive_stream.h index 84447ff..400bca4 100644 --- a/call/flexfec_receive_stream.h +++ b/call/flexfec_receive_stream.h
@@ -17,8 +17,9 @@ #include <vector> #include "webrtc/api/call/transport.h" +#include "webrtc/api/rtpparameters.h" #include "webrtc/call/rtp_packet_sink_interface.h" -#include "webrtc/config.h" +#include "webrtc/common_types.h" namespace webrtc {
diff --git a/call/rtp_config.cc b/call/rtp_config.cc new file mode 100644 index 0000000..dc3ea21 --- /dev/null +++ b/call/rtp_config.cc
@@ -0,0 +1,38 @@ +/* + * 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 "webrtc/call/rtp_config.h" + +#include <sstream> + +namespace webrtc { + +std::string NackConfig::ToString() const { + std::stringstream ss; + ss << "{rtp_history_ms: " << rtp_history_ms; + ss << '}'; + return ss.str(); +} + +std::string UlpfecConfig::ToString() const { + std::stringstream ss; + ss << "{ulpfec_payload_type: " << ulpfec_payload_type; + ss << ", red_payload_type: " << red_payload_type; + ss << ", red_rtx_payload_type: " << red_rtx_payload_type; + ss << '}'; + return ss.str(); +} + +bool UlpfecConfig::operator==(const UlpfecConfig& other) const { + return ulpfec_payload_type == other.ulpfec_payload_type && + red_payload_type == other.red_payload_type && + red_rtx_payload_type == other.red_rtx_payload_type; +} +} // namespace webrtc
diff --git a/call/rtp_config.h b/call/rtp_config.h new file mode 100644 index 0000000..f33103d --- /dev/null +++ b/call/rtp_config.h
@@ -0,0 +1,48 @@ +/* + * 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. + */ + +#ifndef WEBRTC_CALL_RTP_CONFIG_H_ +#define WEBRTC_CALL_RTP_CONFIG_H_ + +#include <string> + +namespace webrtc { +// Settings for NACK, see RFC 4585 for details. +struct NackConfig { + NackConfig() : rtp_history_ms(0) {} + std::string ToString() const; + // Send side: the time RTP packets are stored for retransmissions. + // Receive side: the time the receiver is prepared to wait for + // retransmissions. + // Set to '0' to disable. + int rtp_history_ms; +}; + +// Settings for ULPFEC forward error correction. +// Set the payload types to '-1' to disable. +struct UlpfecConfig { + UlpfecConfig() + : ulpfec_payload_type(-1), + red_payload_type(-1), + red_rtx_payload_type(-1) {} + std::string ToString() const; + bool operator==(const UlpfecConfig& other) const; + + // Payload type used for ULPFEC packets. + int ulpfec_payload_type; + + // Payload type used for RED packets. + int red_payload_type; + + // RTX payload type for RED payload. + int red_rtx_payload_type; +}; +} // namespace webrtc +#endif // WEBRTC_CALL_RTP_CONFIG_H_
diff --git a/call/video_config.cc b/call/video_config.cc new file mode 100644 index 0000000..e06d5e8 --- /dev/null +++ b/call/video_config.cc
@@ -0,0 +1,139 @@ +/* + * Copyright (c) 2014 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 "webrtc/call/video_config.h" + +#include <algorithm> +#include <sstream> +#include <string> + +#include "webrtc/rtc_base/checks.h" + +namespace webrtc { +VideoStream::VideoStream() + : width(0), + height(0), + max_framerate(-1), + min_bitrate_bps(-1), + target_bitrate_bps(-1), + max_bitrate_bps(-1), + max_qp(-1) {} + +VideoStream::~VideoStream() = default; + +std::string VideoStream::ToString() const { + std::stringstream ss; + ss << "{width: " << width; + ss << ", height: " << height; + ss << ", max_framerate: " << max_framerate; + ss << ", min_bitrate_bps:" << min_bitrate_bps; + ss << ", target_bitrate_bps:" << target_bitrate_bps; + ss << ", max_bitrate_bps:" << max_bitrate_bps; + ss << ", max_qp: " << max_qp; + + ss << ", temporal_layer_thresholds_bps: ["; + for (size_t i = 0; i < temporal_layer_thresholds_bps.size(); ++i) { + ss << temporal_layer_thresholds_bps[i]; + if (i != temporal_layer_thresholds_bps.size() - 1) + ss << ", "; + } + ss << ']'; + + ss << '}'; + return ss.str(); +} + +VideoEncoderConfig::VideoEncoderConfig() + : content_type(ContentType::kRealtimeVideo), + encoder_specific_settings(nullptr), + min_transmit_bitrate_bps(0), + max_bitrate_bps(0), + number_of_streams(0) {} + +VideoEncoderConfig::VideoEncoderConfig(VideoEncoderConfig&&) = default; + +VideoEncoderConfig::~VideoEncoderConfig() = default; + +std::string VideoEncoderConfig::ToString() const { + std::stringstream ss; + ss << "{content_type: "; + switch (content_type) { + case ContentType::kRealtimeVideo: + ss << "kRealtimeVideo"; + break; + case ContentType::kScreen: + ss << "kScreenshare"; + break; + } + ss << ", encoder_specific_settings: "; + ss << (encoder_specific_settings != NULL ? "(ptr)" : "NULL"); + + ss << ", min_transmit_bitrate_bps: " << min_transmit_bitrate_bps; + ss << '}'; + return ss.str(); +} + +VideoEncoderConfig::VideoEncoderConfig(const VideoEncoderConfig&) = default; + +void VideoEncoderConfig::EncoderSpecificSettings::FillEncoderSpecificSettings( + VideoCodec* codec) const { + if (codec->codecType == kVideoCodecH264) { + FillVideoCodecH264(codec->H264()); + } else if (codec->codecType == kVideoCodecVP8) { + FillVideoCodecVp8(codec->VP8()); + } else if (codec->codecType == kVideoCodecVP9) { + FillVideoCodecVp9(codec->VP9()); + } else { + RTC_NOTREACHED() << "Encoder specifics set/used for unknown codec type."; + } +} + +void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecH264( + VideoCodecH264* h264_settings) const { + RTC_NOTREACHED(); +} + +void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp8( + VideoCodecVP8* vp8_settings) const { + RTC_NOTREACHED(); +} + +void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp9( + VideoCodecVP9* vp9_settings) const { + RTC_NOTREACHED(); +} + +VideoEncoderConfig::H264EncoderSpecificSettings::H264EncoderSpecificSettings( + const VideoCodecH264& specifics) + : specifics_(specifics) {} + +void VideoEncoderConfig::H264EncoderSpecificSettings::FillVideoCodecH264( + VideoCodecH264* h264_settings) const { + *h264_settings = specifics_; +} + +VideoEncoderConfig::Vp8EncoderSpecificSettings::Vp8EncoderSpecificSettings( + const VideoCodecVP8& specifics) + : specifics_(specifics) {} + +void VideoEncoderConfig::Vp8EncoderSpecificSettings::FillVideoCodecVp8( + VideoCodecVP8* vp8_settings) const { + *vp8_settings = specifics_; +} + +VideoEncoderConfig::Vp9EncoderSpecificSettings::Vp9EncoderSpecificSettings( + const VideoCodecVP9& specifics) + : specifics_(specifics) {} + +void VideoEncoderConfig::Vp9EncoderSpecificSettings::FillVideoCodecVp9( + VideoCodecVP9* vp9_settings) const { + *vp9_settings = specifics_; +} + +} // namespace webrtc
diff --git a/call/video_config.h b/call/video_config.h new file mode 100644 index 0000000..cdff513 --- /dev/null +++ b/call/video_config.h
@@ -0,0 +1,157 @@ +/* + * Copyright (c) 2013 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. + */ + +#ifndef WEBRTC_CALL_VIDEO_CONFIG_H_ +#define WEBRTC_CALL_VIDEO_CONFIG_H_ + +#include <string> +#include <vector> + +#include "webrtc/common_types.h" +#include "webrtc/rtc_base/basictypes.h" +#include "webrtc/rtc_base/optional.h" +#include "webrtc/rtc_base/refcount.h" +#include "webrtc/rtc_base/scoped_ref_ptr.h" +#include "webrtc/typedefs.h" + +namespace webrtc { + +struct VideoStream { + VideoStream(); + ~VideoStream(); + std::string ToString() const; + + size_t width; + size_t height; + int max_framerate; + + int min_bitrate_bps; + int target_bitrate_bps; + int max_bitrate_bps; + + int max_qp; + + // Bitrate thresholds for enabling additional temporal layers. Since these are + // thresholds in between layers, we have one additional layer. One threshold + // gives two temporal layers, one below the threshold and one above, two give + // three, and so on. + // The VideoEncoder may redistribute bitrates over the temporal layers so a + // bitrate threshold of 100k and an estimate of 105k does not imply that we + // get 100k in one temporal layer and 5k in the other, just that the bitrate + // in the first temporal layer should not exceed 100k. + // TODO(kthelgason): Apart from a special case for two-layer screencast these + // thresholds are not propagated to the VideoEncoder. To be implemented. + std::vector<int> temporal_layer_thresholds_bps; +}; + +class VideoEncoderConfig { + public: + // These are reference counted to permit copying VideoEncoderConfig and be + // kept alive until all encoder_specific_settings go out of scope. + // TODO(kthelgason): Consider removing the need for copying VideoEncoderConfig + // and use rtc::Optional for encoder_specific_settings instead. + class EncoderSpecificSettings : public rtc::RefCountInterface { + public: + // TODO(pbos): Remove FillEncoderSpecificSettings as soon as VideoCodec is + // not in use and encoder implementations ask for codec-specific structs + // directly. + void FillEncoderSpecificSettings(VideoCodec* codec_struct) const; + + virtual void FillVideoCodecVp8(VideoCodecVP8* vp8_settings) const; + virtual void FillVideoCodecVp9(VideoCodecVP9* vp9_settings) const; + virtual void FillVideoCodecH264(VideoCodecH264* h264_settings) const; + + private: + ~EncoderSpecificSettings() override {} + friend class VideoEncoderConfig; + }; + + class H264EncoderSpecificSettings : public EncoderSpecificSettings { + public: + explicit H264EncoderSpecificSettings(const VideoCodecH264& specifics); + void FillVideoCodecH264(VideoCodecH264* h264_settings) const override; + + private: + VideoCodecH264 specifics_; + }; + + class Vp8EncoderSpecificSettings : public EncoderSpecificSettings { + public: + explicit Vp8EncoderSpecificSettings(const VideoCodecVP8& specifics); + void FillVideoCodecVp8(VideoCodecVP8* vp8_settings) const override; + + private: + VideoCodecVP8 specifics_; + }; + + class Vp9EncoderSpecificSettings : public EncoderSpecificSettings { + public: + explicit Vp9EncoderSpecificSettings(const VideoCodecVP9& specifics); + void FillVideoCodecVp9(VideoCodecVP9* vp9_settings) const override; + + private: + VideoCodecVP9 specifics_; + }; + + enum class ContentType { + kRealtimeVideo, + kScreen, + }; + + class VideoStreamFactoryInterface : public rtc::RefCountInterface { + public: + // An implementation should return a std::vector<VideoStream> with the + // wanted VideoStream settings for the given video resolution. + // The size of the vector may not be larger than + // |encoder_config.number_of_streams|. + virtual std::vector<VideoStream> CreateEncoderStreams( + int width, + int height, + const VideoEncoderConfig& encoder_config) = 0; + + protected: + ~VideoStreamFactoryInterface() override {} + }; + + VideoEncoderConfig& operator=(VideoEncoderConfig&&) = default; + VideoEncoderConfig& operator=(const VideoEncoderConfig&) = delete; + + // Mostly used by tests. Avoid creating copies if you can. + VideoEncoderConfig Copy() const { return VideoEncoderConfig(*this); } + + VideoEncoderConfig(); + VideoEncoderConfig(VideoEncoderConfig&&); + ~VideoEncoderConfig(); + std::string ToString() const; + + rtc::scoped_refptr<VideoStreamFactoryInterface> video_stream_factory; + std::vector<SpatialLayer> spatial_layers; + ContentType content_type; + rtc::scoped_refptr<const EncoderSpecificSettings> encoder_specific_settings; + + // Padding will be used up to this bitrate regardless of the bitrate produced + // by the encoder. Padding above what's actually produced by the encoder helps + // maintaining a higher bitrate estimate. Padding will however not be sent + // unless the estimated bandwidth indicates that the link can handle it. + int min_transmit_bitrate_bps; + int max_bitrate_bps; + + // Max number of encoded VideoStreams to produce. + size_t number_of_streams; + + private: + // Access to the copy constructor is private to force use of the Copy() + // method for those exceptional cases where we do use it. + VideoEncoderConfig(const VideoEncoderConfig&); +}; + +} // namespace webrtc + +#endif // WEBRTC_CALL_VIDEO_CONFIG_H_
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h index 18e904d..8ed93a1 100644 --- a/call/video_receive_stream.h +++ b/call/video_receive_stream.h
@@ -17,9 +17,10 @@ #include <vector> #include "webrtc/api/call/transport.h" +#include "webrtc/api/rtpparameters.h" +#include "webrtc/call/rtp_config.h" #include "webrtc/common_types.h" #include "webrtc/common_video/include/frame_callback.h" -#include "webrtc/config.h" #include "webrtc/media/base/videosinkinterface.h" #include "webrtc/rtc_base/platform_file.h"
diff --git a/call/video_send_stream.h b/call/video_send_stream.h index a176709..a458203 100644 --- a/call/video_send_stream.h +++ b/call/video_send_stream.h
@@ -17,9 +17,11 @@ #include <vector> #include "webrtc/api/call/transport.h" +#include "webrtc/api/rtpparameters.h" +#include "webrtc/call/rtp_config.h" +#include "webrtc/call/video_config.h" #include "webrtc/common_types.h" #include "webrtc/common_video/include/frame_callback.h" -#include "webrtc/config.h" #include "webrtc/media/base/videosinkinterface.h" #include "webrtc/media/base/videosourceinterface.h" #include "webrtc/rtc_base/platform_file.h"
diff --git a/config.cc b/config.cc deleted file mode 100644 index 19a9a96..0000000 --- a/config.cc +++ /dev/null
@@ -1,283 +0,0 @@ -/* - * Copyright (c) 2014 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 "webrtc/config.h" - -#include <algorithm> -#include <sstream> -#include <string> - -#include "webrtc/rtc_base/checks.h" - -namespace webrtc { -std::string NackConfig::ToString() const { - std::stringstream ss; - ss << "{rtp_history_ms: " << rtp_history_ms; - ss << '}'; - return ss.str(); -} - -std::string UlpfecConfig::ToString() const { - std::stringstream ss; - ss << "{ulpfec_payload_type: " << ulpfec_payload_type; - ss << ", red_payload_type: " << red_payload_type; - ss << ", red_rtx_payload_type: " << red_rtx_payload_type; - ss << '}'; - return ss.str(); -} - -bool UlpfecConfig::operator==(const UlpfecConfig& other) const { - return ulpfec_payload_type == other.ulpfec_payload_type && - red_payload_type == other.red_payload_type && - red_rtx_payload_type == other.red_rtx_payload_type; -} - -std::string RtpExtension::ToString() const { - std::stringstream ss; - ss << "{uri: " << uri; - ss << ", id: " << id; - if (encrypt) { - ss << ", encrypt"; - } - ss << '}'; - return ss.str(); -} - -const char RtpExtension::kAudioLevelUri[] = - "urn:ietf:params:rtp-hdrext:ssrc-audio-level"; -const int RtpExtension::kAudioLevelDefaultId = 1; - -const char RtpExtension::kTimestampOffsetUri[] = - "urn:ietf:params:rtp-hdrext:toffset"; -const int RtpExtension::kTimestampOffsetDefaultId = 2; - -const char RtpExtension::kAbsSendTimeUri[] = - "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; -const int RtpExtension::kAbsSendTimeDefaultId = 3; - -const char RtpExtension::kVideoRotationUri[] = "urn:3gpp:video-orientation"; -const int RtpExtension::kVideoRotationDefaultId = 4; - -const char RtpExtension::kTransportSequenceNumberUri[] = - "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"; -const int RtpExtension::kTransportSequenceNumberDefaultId = 5; - -// This extension allows applications to adaptively limit the playout delay -// on frames as per the current needs. For example, a gaming application -// has very different needs on end-to-end delay compared to a video-conference -// application. -const char RtpExtension::kPlayoutDelayUri[] = - "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"; -const int RtpExtension::kPlayoutDelayDefaultId = 6; - -const char RtpExtension::kVideoContentTypeUri[] = - "http://www.webrtc.org/experiments/rtp-hdrext/video-content-type"; -const int RtpExtension::kVideoContentTypeDefaultId = 7; - -const char RtpExtension::kVideoTimingUri[] = - "http://www.webrtc.org/experiments/rtp-hdrext/video-timing"; -const int RtpExtension::kVideoTimingDefaultId = 8; - -const char RtpExtension::kEncryptHeaderExtensionsUri[] = - "urn:ietf:params:rtp-hdrext:encrypt"; - -const int RtpExtension::kMinId = 1; -const int RtpExtension::kMaxId = 14; - -bool RtpExtension::IsSupportedForAudio(const std::string& uri) { - return uri == webrtc::RtpExtension::kAudioLevelUri || - uri == webrtc::RtpExtension::kTransportSequenceNumberUri; -} - -bool RtpExtension::IsSupportedForVideo(const std::string& uri) { - return uri == webrtc::RtpExtension::kTimestampOffsetUri || - uri == webrtc::RtpExtension::kAbsSendTimeUri || - uri == webrtc::RtpExtension::kVideoRotationUri || - uri == webrtc::RtpExtension::kTransportSequenceNumberUri || - uri == webrtc::RtpExtension::kPlayoutDelayUri || - uri == webrtc::RtpExtension::kVideoContentTypeUri || - uri == webrtc::RtpExtension::kVideoTimingUri; -} - -bool RtpExtension::IsEncryptionSupported(const std::string& uri) { - return uri == webrtc::RtpExtension::kAudioLevelUri || - uri == webrtc::RtpExtension::kTimestampOffsetUri || -#if !defined(ENABLE_EXTERNAL_AUTH) - // TODO(jbauch): Figure out a way to always allow "kAbsSendTimeUri" - // here and filter out later if external auth is really used in - // srtpfilter. External auth is used by Chromium and replaces the - // extension header value of "kAbsSendTimeUri", so it must not be - // encrypted (which can't be done by Chromium). - uri == webrtc::RtpExtension::kAbsSendTimeUri || -#endif - uri == webrtc::RtpExtension::kVideoRotationUri || - uri == webrtc::RtpExtension::kTransportSequenceNumberUri || - uri == webrtc::RtpExtension::kPlayoutDelayUri || - uri == webrtc::RtpExtension::kVideoContentTypeUri; -} - -const RtpExtension* RtpExtension::FindHeaderExtensionByUri( - const std::vector<RtpExtension>& extensions, - const std::string& uri) { - for (const auto& extension : extensions) { - if (extension.uri == uri) { - return &extension; - } - } - return nullptr; -} - -std::vector<RtpExtension> RtpExtension::FilterDuplicateNonEncrypted( - const std::vector<RtpExtension>& extensions) { - std::vector<RtpExtension> filtered; - for (auto extension = extensions.begin(); extension != extensions.end(); - ++extension) { - if (extension->encrypt) { - filtered.push_back(*extension); - continue; - } - - // Only add non-encrypted extension if no encrypted with the same URI - // is also present... - if (std::find_if(extension + 1, extensions.end(), - [extension](const RtpExtension& check) { - return extension->uri == check.uri; - }) != extensions.end()) { - continue; - } - - // ...and has not been added before. - if (!FindHeaderExtensionByUri(filtered, extension->uri)) { - filtered.push_back(*extension); - } - } - return filtered; -} - -VideoStream::VideoStream() - : width(0), - height(0), - max_framerate(-1), - min_bitrate_bps(-1), - target_bitrate_bps(-1), - max_bitrate_bps(-1), - max_qp(-1) {} - -VideoStream::~VideoStream() = default; - -std::string VideoStream::ToString() const { - std::stringstream ss; - ss << "{width: " << width; - ss << ", height: " << height; - ss << ", max_framerate: " << max_framerate; - ss << ", min_bitrate_bps:" << min_bitrate_bps; - ss << ", target_bitrate_bps:" << target_bitrate_bps; - ss << ", max_bitrate_bps:" << max_bitrate_bps; - ss << ", max_qp: " << max_qp; - - ss << ", temporal_layer_thresholds_bps: ["; - for (size_t i = 0; i < temporal_layer_thresholds_bps.size(); ++i) { - ss << temporal_layer_thresholds_bps[i]; - if (i != temporal_layer_thresholds_bps.size() - 1) - ss << ", "; - } - ss << ']'; - - ss << '}'; - return ss.str(); -} - -VideoEncoderConfig::VideoEncoderConfig() - : content_type(ContentType::kRealtimeVideo), - encoder_specific_settings(nullptr), - min_transmit_bitrate_bps(0), - max_bitrate_bps(0), - number_of_streams(0) {} - -VideoEncoderConfig::VideoEncoderConfig(VideoEncoderConfig&&) = default; - -VideoEncoderConfig::~VideoEncoderConfig() = default; - -std::string VideoEncoderConfig::ToString() const { - std::stringstream ss; - ss << "{content_type: "; - switch (content_type) { - case ContentType::kRealtimeVideo: - ss << "kRealtimeVideo"; - break; - case ContentType::kScreen: - ss << "kScreenshare"; - break; - } - ss << ", encoder_specific_settings: "; - ss << (encoder_specific_settings != NULL ? "(ptr)" : "NULL"); - - ss << ", min_transmit_bitrate_bps: " << min_transmit_bitrate_bps; - ss << '}'; - return ss.str(); -} - -VideoEncoderConfig::VideoEncoderConfig(const VideoEncoderConfig&) = default; - -void VideoEncoderConfig::EncoderSpecificSettings::FillEncoderSpecificSettings( - VideoCodec* codec) const { - if (codec->codecType == kVideoCodecH264) { - FillVideoCodecH264(codec->H264()); - } else if (codec->codecType == kVideoCodecVP8) { - FillVideoCodecVp8(codec->VP8()); - } else if (codec->codecType == kVideoCodecVP9) { - FillVideoCodecVp9(codec->VP9()); - } else { - RTC_NOTREACHED() << "Encoder specifics set/used for unknown codec type."; - } -} - -void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecH264( - VideoCodecH264* h264_settings) const { - RTC_NOTREACHED(); -} - -void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp8( - VideoCodecVP8* vp8_settings) const { - RTC_NOTREACHED(); -} - -void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp9( - VideoCodecVP9* vp9_settings) const { - RTC_NOTREACHED(); -} - -VideoEncoderConfig::H264EncoderSpecificSettings::H264EncoderSpecificSettings( - const VideoCodecH264& specifics) - : specifics_(specifics) {} - -void VideoEncoderConfig::H264EncoderSpecificSettings::FillVideoCodecH264( - VideoCodecH264* h264_settings) const { - *h264_settings = specifics_; -} - -VideoEncoderConfig::Vp8EncoderSpecificSettings::Vp8EncoderSpecificSettings( - const VideoCodecVP8& specifics) - : specifics_(specifics) {} - -void VideoEncoderConfig::Vp8EncoderSpecificSettings::FillVideoCodecVp8( - VideoCodecVP8* vp8_settings) const { - *vp8_settings = specifics_; -} - -VideoEncoderConfig::Vp9EncoderSpecificSettings::Vp9EncoderSpecificSettings( - const VideoCodecVP9& specifics) - : specifics_(specifics) {} - -void VideoEncoderConfig::Vp9EncoderSpecificSettings::FillVideoCodecVp9( - VideoCodecVP9* vp9_settings) const { - *vp9_settings = specifics_; -} - -} // namespace webrtc
diff --git a/config.h b/config.h index 962e0f2..46c1f42 100644 --- a/config.h +++ b/config.h
@@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. + * 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 @@ -8,259 +8,12 @@ * be found in the AUTHORS file in the root of the source tree. */ -// TODO(pbos): Move Config from common.h to here. - #ifndef WEBRTC_CONFIG_H_ #define WEBRTC_CONFIG_H_ -#include <string> -#include <vector> +// TODO(holmer): Delete this file once downstream projects have been updated. -#include "webrtc/common_types.h" -#include "webrtc/rtc_base/basictypes.h" -#include "webrtc/rtc_base/optional.h" -#include "webrtc/rtc_base/refcount.h" -#include "webrtc/rtc_base/scoped_ref_ptr.h" -#include "webrtc/typedefs.h" - -namespace webrtc { - -// Settings for NACK, see RFC 4585 for details. -struct NackConfig { - NackConfig() : rtp_history_ms(0) {} - std::string ToString() const; - // Send side: the time RTP packets are stored for retransmissions. - // Receive side: the time the receiver is prepared to wait for - // retransmissions. - // Set to '0' to disable. - int rtp_history_ms; -}; - -// Settings for ULPFEC forward error correction. -// Set the payload types to '-1' to disable. -struct UlpfecConfig { - UlpfecConfig() - : ulpfec_payload_type(-1), - red_payload_type(-1), - red_rtx_payload_type(-1) {} - std::string ToString() const; - bool operator==(const UlpfecConfig& other) const; - - // Payload type used for ULPFEC packets. - int ulpfec_payload_type; - - // Payload type used for RED packets. - int red_payload_type; - - // RTX payload type for RED payload. - int red_rtx_payload_type; -}; - -// RTP header extension, see RFC 5285. -struct RtpExtension { - RtpExtension() {} - RtpExtension(const std::string& uri, int id) : uri(uri), id(id) {} - RtpExtension(const std::string& uri, int id, bool encrypt) : uri(uri), - id(id), encrypt(encrypt) {} - std::string ToString() const; - bool operator==(const RtpExtension& rhs) const { - return uri == rhs.uri && id == rhs.id && encrypt == rhs.encrypt; - } - static bool IsSupportedForAudio(const std::string& uri); - static bool IsSupportedForVideo(const std::string& uri); - // Return "true" if the given RTP header extension URI may be encrypted. - static bool IsEncryptionSupported(const std::string& uri); - - // Returns the named header extension if found among all extensions, - // nullptr otherwise. - static const RtpExtension* FindHeaderExtensionByUri( - const std::vector<RtpExtension>& extensions, - const std::string& uri); - - // Return a list of RTP header extensions with the non-encrypted extensions - // removed if both the encrypted and non-encrypted extension is present for - // the same URI. - static std::vector<RtpExtension> FilterDuplicateNonEncrypted( - const std::vector<RtpExtension>& extensions); - - // Header extension for audio levels, as defined in: - // http://tools.ietf.org/html/draft-ietf-avtext-client-to-mixer-audio-level-03 - static const char kAudioLevelUri[]; - static const int kAudioLevelDefaultId; - - // Header extension for RTP timestamp offset, see RFC 5450 for details: - // http://tools.ietf.org/html/rfc5450 - static const char kTimestampOffsetUri[]; - static const int kTimestampOffsetDefaultId; - - // Header extension for absolute send time, see url for details: - // http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time - static const char kAbsSendTimeUri[]; - static const int kAbsSendTimeDefaultId; - - // Header extension for coordination of video orientation, see url for - // details: - // http://www.etsi.org/deliver/etsi_ts/126100_126199/126114/12.07.00_60/ts_126114v120700p.pdf - static const char kVideoRotationUri[]; - static const int kVideoRotationDefaultId; - - // Header extension for video content type. E.g. default or screenshare. - static const char kVideoContentTypeUri[]; - static const int kVideoContentTypeDefaultId; - - // Header extension for video timing. - static const char kVideoTimingUri[]; - static const int kVideoTimingDefaultId; - - // Header extension for transport sequence number, see url for details: - // http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions - static const char kTransportSequenceNumberUri[]; - static const int kTransportSequenceNumberDefaultId; - - static const char kPlayoutDelayUri[]; - static const int kPlayoutDelayDefaultId; - - // Encryption of Header Extensions, see RFC 6904 for details: - // https://tools.ietf.org/html/rfc6904 - static const char kEncryptHeaderExtensionsUri[]; - - // Inclusive min and max IDs for one-byte header extensions, per RFC5285. - static const int kMinId; - static const int kMaxId; - - std::string uri; - int id = 0; - bool encrypt = false; -}; - -struct VideoStream { - VideoStream(); - ~VideoStream(); - std::string ToString() const; - - size_t width; - size_t height; - int max_framerate; - - int min_bitrate_bps; - int target_bitrate_bps; - int max_bitrate_bps; - - int max_qp; - - // Bitrate thresholds for enabling additional temporal layers. Since these are - // thresholds in between layers, we have one additional layer. One threshold - // gives two temporal layers, one below the threshold and one above, two give - // three, and so on. - // The VideoEncoder may redistribute bitrates over the temporal layers so a - // bitrate threshold of 100k and an estimate of 105k does not imply that we - // get 100k in one temporal layer and 5k in the other, just that the bitrate - // in the first temporal layer should not exceed 100k. - // TODO(kthelgason): Apart from a special case for two-layer screencast these - // thresholds are not propagated to the VideoEncoder. To be implemented. - std::vector<int> temporal_layer_thresholds_bps; -}; - -class VideoEncoderConfig { - public: - // These are reference counted to permit copying VideoEncoderConfig and be - // kept alive until all encoder_specific_settings go out of scope. - // TODO(kthelgason): Consider removing the need for copying VideoEncoderConfig - // and use rtc::Optional for encoder_specific_settings instead. - class EncoderSpecificSettings : public rtc::RefCountInterface { - public: - // TODO(pbos): Remove FillEncoderSpecificSettings as soon as VideoCodec is - // not in use and encoder implementations ask for codec-specific structs - // directly. - void FillEncoderSpecificSettings(VideoCodec* codec_struct) const; - - virtual void FillVideoCodecVp8(VideoCodecVP8* vp8_settings) const; - virtual void FillVideoCodecVp9(VideoCodecVP9* vp9_settings) const; - virtual void FillVideoCodecH264(VideoCodecH264* h264_settings) const; - private: - ~EncoderSpecificSettings() override {} - friend class VideoEncoderConfig; - }; - - class H264EncoderSpecificSettings : public EncoderSpecificSettings { - public: - explicit H264EncoderSpecificSettings(const VideoCodecH264& specifics); - void FillVideoCodecH264(VideoCodecH264* h264_settings) const override; - - private: - VideoCodecH264 specifics_; - }; - - class Vp8EncoderSpecificSettings : public EncoderSpecificSettings { - public: - explicit Vp8EncoderSpecificSettings(const VideoCodecVP8& specifics); - void FillVideoCodecVp8(VideoCodecVP8* vp8_settings) const override; - - private: - VideoCodecVP8 specifics_; - }; - - class Vp9EncoderSpecificSettings : public EncoderSpecificSettings { - public: - explicit Vp9EncoderSpecificSettings(const VideoCodecVP9& specifics); - void FillVideoCodecVp9(VideoCodecVP9* vp9_settings) const override; - - private: - VideoCodecVP9 specifics_; - }; - - enum class ContentType { - kRealtimeVideo, - kScreen, - }; - - class VideoStreamFactoryInterface : public rtc::RefCountInterface { - public: - // An implementation should return a std::vector<VideoStream> with the - // wanted VideoStream settings for the given video resolution. - // The size of the vector may not be larger than - // |encoder_config.number_of_streams|. - virtual std::vector<VideoStream> CreateEncoderStreams( - int width, - int height, - const VideoEncoderConfig& encoder_config) = 0; - - protected: - ~VideoStreamFactoryInterface() override {} - }; - - VideoEncoderConfig& operator=(VideoEncoderConfig&&) = default; - VideoEncoderConfig& operator=(const VideoEncoderConfig&) = delete; - - // Mostly used by tests. Avoid creating copies if you can. - VideoEncoderConfig Copy() const { return VideoEncoderConfig(*this); } - - VideoEncoderConfig(); - VideoEncoderConfig(VideoEncoderConfig&&); - ~VideoEncoderConfig(); - std::string ToString() const; - - rtc::scoped_refptr<VideoStreamFactoryInterface> video_stream_factory; - std::vector<SpatialLayer> spatial_layers; - ContentType content_type; - rtc::scoped_refptr<const EncoderSpecificSettings> encoder_specific_settings; - - // Padding will be used up to this bitrate regardless of the bitrate produced - // by the encoder. Padding above what's actually produced by the encoder helps - // maintaining a higher bitrate estimate. Padding will however not be sent - // unless the estimated bandwidth indicates that the link can handle it. - int min_transmit_bitrate_bps; - int max_bitrate_bps; - - // Max number of encoded VideoStreams to produce. - size_t number_of_streams; - - private: - // Access to the copy constructor is private to force use of the Copy() - // method for those exceptional cases where we do use it. - VideoEncoderConfig(const VideoEncoderConfig&); -}; - -} // namespace webrtc +#include "webrtc/api/rtpparameters.h" +#include "webrtc/call/rtp_config.h" #endif // WEBRTC_CONFIG_H_
diff --git a/logging/BUILD.gn b/logging/BUILD.gn index 8f1e493..6b1e549 100644 --- a/logging/BUILD.gn +++ b/logging/BUILD.gn
@@ -29,6 +29,7 @@ ] deps = [ "..:webrtc_common", + "../api:libjingle_peerconnection_api", "../call:video_stream_api", "../rtc_base:rtc_base_approved", ] @@ -159,6 +160,7 @@ ":rtc_event_log_api", ":rtc_event_log_impl", ":rtc_event_log_parser", + "../call:video_stream_api", "../rtc_base:rtc_base_approved", # TODO(kwiberg): Remove this dependency.
diff --git a/logging/rtc_event_log/rtc_event_log.h b/logging/rtc_event_log/rtc_event_log.h index dc33511..d26dccb 100644 --- a/logging/rtc_event_log/rtc_event_log.h +++ b/logging/rtc_event_log/rtc_event_log.h
@@ -15,7 +15,8 @@ #include <string> #include <vector> -#include "webrtc/config.h" +#include "webrtc/api/rtpparameters.h" +#include "webrtc/common_types.h" #include "webrtc/rtc_base/platform_file.h" namespace webrtc {
diff --git a/logging/rtc_event_log/rtc_event_log2text.cc b/logging/rtc_event_log/rtc_event_log2text.cc index 3f03108..bba6ace 100644 --- a/logging/rtc_event_log/rtc_event_log2text.cc +++ b/logging/rtc_event_log/rtc_event_log2text.cc
@@ -16,8 +16,8 @@ #include <string> #include <utility> // pair +#include "webrtc/call/video_config.h" #include "webrtc/common_types.h" -#include "webrtc/config.h" #include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h" #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h"
diff --git a/media/base/mediachannel.h b/media/base/mediachannel.h index 99ed291..1ab4123 100644 --- a/media/base/mediachannel.h +++ b/media/base/mediachannel.h
@@ -18,7 +18,7 @@ #include "webrtc/api/rtpparameters.h" #include "webrtc/api/rtpreceiverinterface.h" #include "webrtc/api/video/video_timing.h" -#include "webrtc/config.h" +#include "webrtc/call/video_config.h" #include "webrtc/media/base/codec.h" #include "webrtc/media/base/mediaconstants.h" #include "webrtc/media/base/streamparams.h"
diff --git a/media/engine/simulcast.h b/media/engine/simulcast.h index 4531bcc..81668e4 100644 --- a/media/engine/simulcast.h +++ b/media/engine/simulcast.h
@@ -13,7 +13,7 @@ #include <vector> -#include "webrtc/config.h" +#include "webrtc/call/video_config.h" #include "webrtc/rtc_base/basictypes.h" namespace cricket {
diff --git a/media/engine/webrtcmediaengine.h b/media/engine/webrtcmediaengine.h index edbda66..8740917 100644 --- a/media/engine/webrtcmediaengine.h +++ b/media/engine/webrtcmediaengine.h
@@ -15,7 +15,6 @@ #include <vector> #include "webrtc/call/call.h" -#include "webrtc/config.h" #include "webrtc/media/base/mediaengine.h" namespace webrtc {
diff --git a/media/engine/webrtcvoiceengine.h b/media/engine/webrtcvoiceengine.h index f938446..a42459a 100644 --- a/media/engine/webrtcvoiceengine.h +++ b/media/engine/webrtcvoiceengine.h
@@ -20,7 +20,6 @@ #include "webrtc/api/rtpreceiverinterface.h" #include "webrtc/call/audio_state.h" #include "webrtc/call/call.h" -#include "webrtc/config.h" #include "webrtc/media/base/rtputils.h" #include "webrtc/media/engine/apm_helpers.h" #include "webrtc/media/engine/webrtccommon.h"
diff --git a/modules/audio_coding/BUILD.gn b/modules/audio_coding/BUILD.gn index 50819f1..569d214 100644 --- a/modules/audio_coding/BUILD.gn +++ b/modules/audio_coding/BUILD.gn
@@ -1569,8 +1569,11 @@ ":isac_fix", ":webrtc_opus", "../..:webrtc_common", + "../../api:libjingle_peerconnection_api", "../../rtc_base:rtc_base_approved", + "../../system_wrappers:metrics_default", "../../system_wrappers:system_wrappers_default", + "../../test:field_trial", "../../test:test_main", "../audio_processing", "//testing/gtest", @@ -1702,6 +1705,8 @@ "../..:webrtc_common", "../../common_audio", "../../rtc_base:rtc_base_approved", + "../../system_wrappers:metrics_default", + "../../test:field_trial", ] configs += [ ":RTPencode_config" ]
diff --git a/modules/audio_processing/audio_processing_impl_locking_unittest.cc b/modules/audio_processing/audio_processing_impl_locking_unittest.cc index db2aacb..f8707c3 100644 --- a/modules/audio_processing/audio_processing_impl_locking_unittest.cc +++ b/modules/audio_processing/audio_processing_impl_locking_unittest.cc
@@ -14,7 +14,6 @@ #include <memory> #include <vector> -#include "webrtc/config.h" #include "webrtc/modules/audio_processing/test/test_utils.h" #include "webrtc/modules/include/module_common_types.h" #include "webrtc/rtc_base/array_view.h"
diff --git a/modules/audio_processing/audio_processing_impl_unittest.cc b/modules/audio_processing/audio_processing_impl_unittest.cc index 75e5aab..e49b632 100644 --- a/modules/audio_processing/audio_processing_impl_unittest.cc +++ b/modules/audio_processing/audio_processing_impl_unittest.cc
@@ -10,7 +10,6 @@ #include "webrtc/modules/audio_processing/audio_processing_impl.h" -#include "webrtc/config.h" #include "webrtc/modules/audio_processing/test/test_utils.h" #include "webrtc/modules/include/module_common_types.h" #include "webrtc/test/gmock.h"
diff --git a/modules/audio_processing/audio_processing_performance_unittest.cc b/modules/audio_processing/audio_processing_performance_unittest.cc index 6d0a61b..e478c72 100644 --- a/modules/audio_processing/audio_processing_performance_unittest.cc +++ b/modules/audio_processing/audio_processing_performance_unittest.cc
@@ -15,7 +15,6 @@ #include <memory> #include <vector> -#include "webrtc/config.h" #include "webrtc/modules/audio_processing/test/test_utils.h" #include "webrtc/modules/include/module_common_types.h" #include "webrtc/rtc_base/array_view.h"
diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn index 775ebcb..07ac7ae 100644 --- a/modules/rtp_rtcp/BUILD.gn +++ b/modules/rtp_rtcp/BUILD.gn
@@ -341,6 +341,7 @@ ":rtp_rtcp", "..:module_api", "../..:webrtc_common", + "../../api:libjingle_peerconnection_api", "../../api:transport_api", "../../common_video:common_video", "../../rtc_base:rtc_base_approved",
diff --git a/modules/rtp_rtcp/include/flexfec_sender.h b/modules/rtp_rtcp/include/flexfec_sender.h index 3bcd2eb..82a01cc 100644 --- a/modules/rtp_rtcp/include/flexfec_sender.h +++ b/modules/rtp_rtcp/include/flexfec_sender.h
@@ -14,7 +14,7 @@ #include <memory> #include <vector> -#include "webrtc/config.h" +#include "webrtc/api/rtpparameters.h" #include "webrtc/modules/include/module_common_types.h" #include "webrtc/modules/rtp_rtcp/include/flexfec_sender.h" #include "webrtc/modules/rtp_rtcp/include/rtp_header_extension_map.h"
diff --git a/modules/rtp_rtcp/include/rtp_header_extension_map.h b/modules/rtp_rtcp/include/rtp_header_extension_map.h index 98bc9ec..93cbd10 100644 --- a/modules/rtp_rtcp/include/rtp_header_extension_map.h +++ b/modules/rtp_rtcp/include/rtp_header_extension_map.h
@@ -13,7 +13,7 @@ #include <string> -#include "webrtc/config.h" +#include "webrtc/api/rtpparameters.h" #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "webrtc/rtc_base/array_view.h" #include "webrtc/rtc_base/basictypes.h"
diff --git a/modules/rtp_rtcp/source/flexfec_sender_unittest.cc b/modules/rtp_rtcp/source/flexfec_sender_unittest.cc index 7c26b80..da33837 100644 --- a/modules/rtp_rtcp/source/flexfec_sender_unittest.cc +++ b/modules/rtp_rtcp/source/flexfec_sender_unittest.cc
@@ -10,7 +10,7 @@ #include <vector> -#include "webrtc/config.h" +#include "webrtc/api/rtpparameters.h" #include "webrtc/modules/rtp_rtcp/include/flexfec_sender.h" #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "webrtc/modules/rtp_rtcp/source/fec_test_helper.h"
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc index 790319a..31d1b0e 100644 --- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc +++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -16,8 +16,8 @@ #include <set> #include <string> +#include "webrtc/api/rtpparameters.h" #include "webrtc/common_types.h" -#include "webrtc/config.h" #include "webrtc/rtc_base/checks.h" #include "webrtc/rtc_base/logging.h"
diff --git a/pc/webrtcsdp.cc b/pc/webrtcsdp.cc index e514fe7..7dc2605 100644 --- a/pc/webrtcsdp.cc +++ b/pc/webrtcsdp.cc
@@ -22,13 +22,8 @@ #include "webrtc/api/jsepicecandidate.h" #include "webrtc/api/jsepsessiondescription.h" -#include "webrtc/rtc_base/arraysize.h" -#include "webrtc/rtc_base/checks.h" -#include "webrtc/rtc_base/logging.h" -#include "webrtc/rtc_base/messagedigest.h" -#include "webrtc/rtc_base/stringutils.h" // for RtpExtension -#include "webrtc/config.h" +#include "webrtc/api/rtpparameters.h" #include "webrtc/media/base/codec.h" #include "webrtc/media/base/cryptoparams.h" #include "webrtc/media/base/mediaconstants.h" @@ -38,6 +33,11 @@ #include "webrtc/p2p/base/p2pconstants.h" #include "webrtc/p2p/base/port.h" #include "webrtc/pc/mediasession.h" +#include "webrtc/rtc_base/arraysize.h" +#include "webrtc/rtc_base/checks.h" +#include "webrtc/rtc_base/logging.h" +#include "webrtc/rtc_base/messagedigest.h" +#include "webrtc/rtc_base/stringutils.h" using cricket::AudioContentDescription; using cricket::Candidate;
diff --git a/test/call_test.cc b/test/call_test.cc index 3efc022..b5d7236 100644 --- a/test/call_test.cc +++ b/test/call_test.cc
@@ -15,7 +15,7 @@ #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" #include "webrtc/api/audio_codecs/builtin_audio_encoder_factory.h" #include "webrtc/call/rtp_transport_controller_send.h" -#include "webrtc/config.h" +#include "webrtc/call/video_config.h" #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" #include "webrtc/rtc_base/checks.h" #include "webrtc/rtc_base/event.h"
diff --git a/video/payload_router.h b/video/payload_router.h index 8b51861..bfd4b8e 100644 --- a/video/payload_router.h +++ b/video/payload_router.h
@@ -15,7 +15,6 @@ #include "webrtc/api/video_codecs/video_encoder.h" #include "webrtc/common_types.h" -#include "webrtc/config.h" #include "webrtc/rtc_base/constructormagic.h" #include "webrtc/rtc_base/criticalsection.h" #include "webrtc/rtc_base/thread_annotations.h"
diff --git a/video/payload_router_unittest.cc b/video/payload_router_unittest.cc index 9f58ceb..2293a24 100644 --- a/video/payload_router_unittest.cc +++ b/video/payload_router_unittest.cc
@@ -10,6 +10,7 @@ #include <memory> +#include "webrtc/call/video_config.h" #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" #include "webrtc/modules/rtp_rtcp/mocks/mock_rtp_rtcp.h" #include "webrtc/modules/video_coding/include/video_codec_interface.h"
diff --git a/video/rtp_video_stream_receiver.cc b/video/rtp_video_stream_receiver.cc index 4678b8f..0dbb2f7 100644 --- a/video/rtp_video_stream_receiver.cc +++ b/video/rtp_video_stream_receiver.cc
@@ -14,8 +14,8 @@ #include <utility> #include <vector> +#include "webrtc/call/video_config.h" #include "webrtc/common_types.h" -#include "webrtc/config.h" #include "webrtc/media/base/mediaconstants.h" #include "webrtc/modules/pacing/packet_router.h" #include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
diff --git a/voice_engine/channel.cc b/voice_engine/channel.cc index 901d80c..039d935 100644 --- a/voice_engine/channel.cc +++ b/voice_engine/channel.cc
@@ -15,7 +15,6 @@ #include "webrtc/audio/utility/audio_frame_operations.h" #include "webrtc/call/rtp_transport_controller_send_interface.h" -#include "webrtc/config.h" #include "webrtc/logging/rtc_event_log/rtc_event_log.h" #include "webrtc/modules/audio_coding/codecs/audio_format_conversion.h" #include "webrtc/modules/audio_device/include/audio_device.h"