pbos@webrtc.org | 1e92b0a | 2014-05-15 09:35:06 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | #include "webrtc/config.h" |
| 11 | |
| 12 | #include <sstream> |
| 13 | #include <string> |
| 14 | |
kthelgason | 29a44e3 | 2016-09-27 03:52:02 -0700 | [diff] [blame] | 15 | #include "webrtc/base/checks.h" |
| 16 | |
pbos@webrtc.org | 1e92b0a | 2014-05-15 09:35:06 +0000 | [diff] [blame] | 17 | namespace webrtc { |
solenberg | 971cab0 | 2016-06-14 10:02:41 -0700 | [diff] [blame] | 18 | std::string NackConfig::ToString() const { |
| 19 | std::stringstream ss; |
| 20 | ss << "{rtp_history_ms: " << rtp_history_ms; |
| 21 | ss << '}'; |
| 22 | return ss.str(); |
| 23 | } |
| 24 | |
brandtr | b5f2c3f | 2016-10-04 23:28:39 -0700 | [diff] [blame] | 25 | std::string UlpfecConfig::ToString() const { |
pbos@webrtc.org | 1e92b0a | 2014-05-15 09:35:06 +0000 | [diff] [blame] | 26 | std::stringstream ss; |
| 27 | ss << "{ulpfec_payload_type: " << ulpfec_payload_type; |
| 28 | ss << ", red_payload_type: " << red_payload_type; |
Stefan Holmer | 1088001 | 2016-02-03 13:29:59 +0100 | [diff] [blame] | 29 | ss << ", red_rtx_payload_type: " << red_rtx_payload_type; |
pbos@webrtc.org | 1e92b0a | 2014-05-15 09:35:06 +0000 | [diff] [blame] | 30 | ss << '}'; |
| 31 | return ss.str(); |
| 32 | } |
| 33 | |
solenberg | 940b6d6 | 2016-10-25 11:19:07 -0700 | [diff] [blame] | 34 | FlexfecConfig::FlexfecConfig() |
| 35 | : flexfec_payload_type(-1), flexfec_ssrc(0), protected_media_ssrcs() {} |
| 36 | |
| 37 | FlexfecConfig::~FlexfecConfig() = default; |
| 38 | |
brandtr | 76648da | 2016-10-20 04:54:48 -0700 | [diff] [blame] | 39 | std::string FlexfecConfig::ToString() const { |
| 40 | std::stringstream ss; |
| 41 | ss << "{flexfec_payload_type: " << flexfec_payload_type; |
| 42 | ss << ", flexfec_ssrc: " << flexfec_ssrc; |
| 43 | ss << ", protected_media_ssrcs: ["; |
| 44 | size_t i = 0; |
| 45 | for (; i + 1 < protected_media_ssrcs.size(); ++i) |
| 46 | ss << protected_media_ssrcs[i] << ", "; |
| 47 | if (!protected_media_ssrcs.empty()) |
| 48 | ss << protected_media_ssrcs[i]; |
| 49 | ss << "]}"; |
| 50 | return ss.str(); |
| 51 | } |
| 52 | |
pbos@webrtc.org | 1e92b0a | 2014-05-15 09:35:06 +0000 | [diff] [blame] | 53 | std::string RtpExtension::ToString() const { |
| 54 | std::stringstream ss; |
isheriff | 6f8d686 | 2016-05-26 11:24:55 -0700 | [diff] [blame] | 55 | ss << "{uri: " << uri; |
pbos@webrtc.org | 1e92b0a | 2014-05-15 09:35:06 +0000 | [diff] [blame] | 56 | ss << ", id: " << id; |
| 57 | ss << '}'; |
| 58 | return ss.str(); |
| 59 | } |
| 60 | |
isheriff | 6f8d686 | 2016-05-26 11:24:55 -0700 | [diff] [blame] | 61 | const char* RtpExtension::kAudioLevelUri = |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 62 | "urn:ietf:params:rtp-hdrext:ssrc-audio-level"; |
isheriff | 6f8d686 | 2016-05-26 11:24:55 -0700 | [diff] [blame] | 63 | const int RtpExtension::kAudioLevelDefaultId = 1; |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 64 | |
isheriff | 6f8d686 | 2016-05-26 11:24:55 -0700 | [diff] [blame] | 65 | const char* RtpExtension::kTimestampOffsetUri = |
| 66 | "urn:ietf:params:rtp-hdrext:toffset"; |
| 67 | const int RtpExtension::kTimestampOffsetDefaultId = 2; |
| 68 | |
| 69 | const char* RtpExtension::kAbsSendTimeUri = |
| 70 | "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time"; |
| 71 | const int RtpExtension::kAbsSendTimeDefaultId = 3; |
| 72 | |
| 73 | const char* RtpExtension::kVideoRotationUri = "urn:3gpp:video-orientation"; |
| 74 | const int RtpExtension::kVideoRotationDefaultId = 4; |
| 75 | |
| 76 | const char* RtpExtension::kTransportSequenceNumberUri = |
| 77 | "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01"; |
| 78 | const int RtpExtension::kTransportSequenceNumberDefaultId = 5; |
| 79 | |
isheriff | 6b4b5f3 | 2016-06-08 00:24:21 -0700 | [diff] [blame] | 80 | // This extension allows applications to adaptively limit the playout delay |
| 81 | // on frames as per the current needs. For example, a gaming application |
| 82 | // has very different needs on end-to-end delay compared to a video-conference |
| 83 | // application. |
| 84 | const char* RtpExtension::kPlayoutDelayUri = |
| 85 | "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay"; |
| 86 | const int RtpExtension::kPlayoutDelayDefaultId = 6; |
| 87 | |
isheriff | 6f8d686 | 2016-05-26 11:24:55 -0700 | [diff] [blame] | 88 | bool RtpExtension::IsSupportedForAudio(const std::string& uri) { |
| 89 | return uri == webrtc::RtpExtension::kAbsSendTimeUri || |
| 90 | uri == webrtc::RtpExtension::kAudioLevelUri || |
| 91 | uri == webrtc::RtpExtension::kTransportSequenceNumberUri; |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 92 | } |
| 93 | |
isheriff | 6f8d686 | 2016-05-26 11:24:55 -0700 | [diff] [blame] | 94 | bool RtpExtension::IsSupportedForVideo(const std::string& uri) { |
| 95 | return uri == webrtc::RtpExtension::kTimestampOffsetUri || |
| 96 | uri == webrtc::RtpExtension::kAbsSendTimeUri || |
| 97 | uri == webrtc::RtpExtension::kVideoRotationUri || |
isheriff | 6b4b5f3 | 2016-06-08 00:24:21 -0700 | [diff] [blame] | 98 | uri == webrtc::RtpExtension::kTransportSequenceNumberUri || |
| 99 | uri == webrtc::RtpExtension::kPlayoutDelayUri; |
Fredrik Solenberg | 23fba1f | 2015-04-29 15:24:01 +0200 | [diff] [blame] | 100 | } |
| 101 | |
kwiberg@webrtc.org | ac2d27d | 2015-02-26 13:59:22 +0000 | [diff] [blame] | 102 | VideoStream::VideoStream() |
| 103 | : width(0), |
| 104 | height(0), |
| 105 | max_framerate(-1), |
| 106 | min_bitrate_bps(-1), |
| 107 | target_bitrate_bps(-1), |
| 108 | max_bitrate_bps(-1), |
| 109 | max_qp(-1) {} |
| 110 | |
| 111 | VideoStream::~VideoStream() = default; |
| 112 | |
pbos@webrtc.org | 1e92b0a | 2014-05-15 09:35:06 +0000 | [diff] [blame] | 113 | std::string VideoStream::ToString() const { |
| 114 | std::stringstream ss; |
| 115 | ss << "{width: " << width; |
| 116 | ss << ", height: " << height; |
| 117 | ss << ", max_framerate: " << max_framerate; |
| 118 | ss << ", min_bitrate_bps:" << min_bitrate_bps; |
| 119 | ss << ", target_bitrate_bps:" << target_bitrate_bps; |
| 120 | ss << ", max_bitrate_bps:" << max_bitrate_bps; |
| 121 | ss << ", max_qp: " << max_qp; |
| 122 | |
pbos@webrtc.org | 931e3da | 2014-11-06 09:35:08 +0000 | [diff] [blame] | 123 | ss << ", temporal_layer_thresholds_bps: ["; |
pbos@webrtc.org | b7ed779 | 2014-10-31 13:08:10 +0000 | [diff] [blame] | 124 | for (size_t i = 0; i < temporal_layer_thresholds_bps.size(); ++i) { |
| 125 | ss << temporal_layer_thresholds_bps[i]; |
| 126 | if (i != temporal_layer_thresholds_bps.size() - 1) |
pbos@webrtc.org | 931e3da | 2014-11-06 09:35:08 +0000 | [diff] [blame] | 127 | ss << ", "; |
pbos@webrtc.org | 1e92b0a | 2014-05-15 09:35:06 +0000 | [diff] [blame] | 128 | } |
pbos@webrtc.org | 931e3da | 2014-11-06 09:35:08 +0000 | [diff] [blame] | 129 | ss << ']'; |
pbos@webrtc.org | 1e92b0a | 2014-05-15 09:35:06 +0000 | [diff] [blame] | 130 | |
| 131 | ss << '}'; |
| 132 | return ss.str(); |
| 133 | } |
pbos@webrtc.org | ad3b5a5 | 2014-10-24 09:23:21 +0000 | [diff] [blame] | 134 | |
kwiberg@webrtc.org | ac2d27d | 2015-02-26 13:59:22 +0000 | [diff] [blame] | 135 | VideoEncoderConfig::VideoEncoderConfig() |
Erik Språng | 143cec1 | 2015-04-28 10:01:41 +0200 | [diff] [blame] | 136 | : content_type(ContentType::kRealtimeVideo), |
kthelgason | 29a44e3 | 2016-09-27 03:52:02 -0700 | [diff] [blame] | 137 | encoder_specific_settings(nullptr), |
skvlad | 3abb764 | 2016-06-16 12:08:03 -0700 | [diff] [blame] | 138 | min_transmit_bitrate_bps(0), |
perkj | fa10b55 | 2016-10-02 23:45:26 -0700 | [diff] [blame] | 139 | max_bitrate_bps(0), |
| 140 | number_of_streams(0) {} |
kwiberg@webrtc.org | ac2d27d | 2015-02-26 13:59:22 +0000 | [diff] [blame] | 141 | |
solenberg | 940b6d6 | 2016-10-25 11:19:07 -0700 | [diff] [blame] | 142 | VideoEncoderConfig::VideoEncoderConfig(VideoEncoderConfig&&) = default; |
| 143 | |
kwiberg@webrtc.org | ac2d27d | 2015-02-26 13:59:22 +0000 | [diff] [blame] | 144 | VideoEncoderConfig::~VideoEncoderConfig() = default; |
| 145 | |
pbos@webrtc.org | ad3b5a5 | 2014-10-24 09:23:21 +0000 | [diff] [blame] | 146 | std::string VideoEncoderConfig::ToString() const { |
| 147 | std::stringstream ss; |
perkj | fa10b55 | 2016-10-02 23:45:26 -0700 | [diff] [blame] | 148 | ss << "{content_type: "; |
pbos@webrtc.org | ad3b5a5 | 2014-10-24 09:23:21 +0000 | [diff] [blame] | 149 | switch (content_type) { |
Erik Språng | 143cec1 | 2015-04-28 10:01:41 +0200 | [diff] [blame] | 150 | case ContentType::kRealtimeVideo: |
pbos@webrtc.org | ad3b5a5 | 2014-10-24 09:23:21 +0000 | [diff] [blame] | 151 | ss << "kRealtimeVideo"; |
| 152 | break; |
Erik Språng | 143cec1 | 2015-04-28 10:01:41 +0200 | [diff] [blame] | 153 | case ContentType::kScreen: |
pbos@webrtc.org | ad3b5a5 | 2014-10-24 09:23:21 +0000 | [diff] [blame] | 154 | ss << "kScreenshare"; |
| 155 | break; |
| 156 | } |
| 157 | ss << ", encoder_specific_settings: "; |
| 158 | ss << (encoder_specific_settings != NULL ? "(ptr)" : "NULL"); |
| 159 | |
| 160 | ss << ", min_transmit_bitrate_bps: " << min_transmit_bitrate_bps; |
| 161 | ss << '}'; |
| 162 | return ss.str(); |
| 163 | } |
| 164 | |
solenberg | 940b6d6 | 2016-10-25 11:19:07 -0700 | [diff] [blame] | 165 | VideoEncoderConfig::VideoEncoderConfig(const VideoEncoderConfig&) = default; |
| 166 | |
kthelgason | 29a44e3 | 2016-09-27 03:52:02 -0700 | [diff] [blame] | 167 | void VideoEncoderConfig::EncoderSpecificSettings::FillEncoderSpecificSettings( |
| 168 | VideoCodec* codec) const { |
| 169 | if (codec->codecType == kVideoCodecH264) { |
hta | 527d347 | 2016-11-16 23:23:04 -0800 | [diff] [blame^] | 170 | FillVideoCodecH264(codec->H264()); |
kthelgason | 29a44e3 | 2016-09-27 03:52:02 -0700 | [diff] [blame] | 171 | } else if (codec->codecType == kVideoCodecVP8) { |
hta | 527d347 | 2016-11-16 23:23:04 -0800 | [diff] [blame^] | 172 | FillVideoCodecVp8(codec->VP8()); |
kthelgason | 29a44e3 | 2016-09-27 03:52:02 -0700 | [diff] [blame] | 173 | } else if (codec->codecType == kVideoCodecVP9) { |
hta | 527d347 | 2016-11-16 23:23:04 -0800 | [diff] [blame^] | 174 | FillVideoCodecVp9(codec->VP9()); |
kthelgason | 29a44e3 | 2016-09-27 03:52:02 -0700 | [diff] [blame] | 175 | } else { |
| 176 | RTC_NOTREACHED() << "Encoder specifics set/used for unknown codec type."; |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecH264( |
| 181 | VideoCodecH264* h264_settings) const { |
| 182 | RTC_NOTREACHED(); |
| 183 | } |
| 184 | |
| 185 | void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp8( |
| 186 | VideoCodecVP8* vp8_settings) const { |
| 187 | RTC_NOTREACHED(); |
| 188 | } |
| 189 | |
| 190 | void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp9( |
| 191 | VideoCodecVP9* vp9_settings) const { |
| 192 | RTC_NOTREACHED(); |
| 193 | } |
| 194 | |
| 195 | VideoEncoderConfig::H264EncoderSpecificSettings::H264EncoderSpecificSettings( |
| 196 | const VideoCodecH264& specifics) |
| 197 | : specifics_(specifics) {} |
| 198 | |
| 199 | void VideoEncoderConfig::H264EncoderSpecificSettings::FillVideoCodecH264( |
| 200 | VideoCodecH264* h264_settings) const { |
| 201 | *h264_settings = specifics_; |
| 202 | } |
| 203 | |
| 204 | VideoEncoderConfig::Vp8EncoderSpecificSettings::Vp8EncoderSpecificSettings( |
| 205 | const VideoCodecVP8& specifics) |
| 206 | : specifics_(specifics) {} |
| 207 | |
| 208 | void VideoEncoderConfig::Vp8EncoderSpecificSettings::FillVideoCodecVp8( |
| 209 | VideoCodecVP8* vp8_settings) const { |
| 210 | *vp8_settings = specifics_; |
| 211 | } |
| 212 | |
| 213 | VideoEncoderConfig::Vp9EncoderSpecificSettings::Vp9EncoderSpecificSettings( |
| 214 | const VideoCodecVP9& specifics) |
| 215 | : specifics_(specifics) {} |
| 216 | |
| 217 | void VideoEncoderConfig::Vp9EncoderSpecificSettings::FillVideoCodecVp9( |
| 218 | VideoCodecVP9* vp9_settings) const { |
| 219 | *vp9_settings = specifics_; |
| 220 | } |
| 221 | |
solenberg | 940b6d6 | 2016-10-25 11:19:07 -0700 | [diff] [blame] | 222 | DecoderSpecificSettings::DecoderSpecificSettings() = default; |
| 223 | |
| 224 | DecoderSpecificSettings::~DecoderSpecificSettings() = default; |
| 225 | |
pbos@webrtc.org | 1e92b0a | 2014-05-15 09:35:06 +0000 | [diff] [blame] | 226 | } // namespace webrtc |