| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 #include "webrtc/config.h" | 10 #include "webrtc/api/rtpparameters.h" |
| 11 | 11 |
| 12 #include <algorithm> | 12 #include <algorithm> |
| 13 #include <sstream> | 13 #include <sstream> |
| 14 #include <string> | 14 #include <string> |
| 15 | 15 |
| 16 #include "webrtc/rtc_base/checks.h" | 16 #include "webrtc/rtc_base/checks.h" |
| 17 | 17 |
| 18 namespace webrtc { | 18 namespace webrtc { |
| 19 std::string NackConfig::ToString() const { | |
| 20 std::stringstream ss; | |
| 21 ss << "{rtp_history_ms: " << rtp_history_ms; | |
| 22 ss << '}'; | |
| 23 return ss.str(); | |
| 24 } | |
| 25 | 19 |
| 26 std::string UlpfecConfig::ToString() const { | 20 RtcpFeedback::RtcpFeedback() {} |
| 27 std::stringstream ss; | 21 RtcpFeedback::RtcpFeedback(RtcpFeedbackType type) : type(type) {} |
| 28 ss << "{ulpfec_payload_type: " << ulpfec_payload_type; | 22 RtcpFeedback::RtcpFeedback(RtcpFeedbackType type, |
| 29 ss << ", red_payload_type: " << red_payload_type; | 23 RtcpFeedbackMessageType message_type) |
| 30 ss << ", red_rtx_payload_type: " << red_rtx_payload_type; | 24 : type(type), message_type(message_type) {} |
| 31 ss << '}'; | 25 RtcpFeedback::~RtcpFeedback() {} |
| 32 return ss.str(); | |
| 33 } | |
| 34 | 26 |
| 35 bool UlpfecConfig::operator==(const UlpfecConfig& other) const { | 27 RtpCodecCapability::RtpCodecCapability() {} |
| 36 return ulpfec_payload_type == other.ulpfec_payload_type && | 28 RtpCodecCapability::~RtpCodecCapability() {} |
| 37 red_payload_type == other.red_payload_type && | 29 |
| 38 red_rtx_payload_type == other.red_rtx_payload_type; | 30 RtpHeaderExtensionCapability::RtpHeaderExtensionCapability() {} |
| 39 } | 31 RtpHeaderExtensionCapability::RtpHeaderExtensionCapability( |
| 32 const std::string& uri) |
| 33 : uri(uri) {} |
| 34 RtpHeaderExtensionCapability::RtpHeaderExtensionCapability( |
| 35 const std::string& uri, |
| 36 int preferred_id) |
| 37 : uri(uri), preferred_id(preferred_id) {} |
| 38 RtpHeaderExtensionCapability::~RtpHeaderExtensionCapability() {} |
| 39 |
| 40 RtpExtension::RtpExtension() {} |
| 41 RtpExtension::RtpExtension(const std::string& uri, int id) : uri(uri), id(id) {} |
| 42 RtpExtension::RtpExtension(const std::string& uri, int id, bool encrypt) |
| 43 : uri(uri), id(id), encrypt(encrypt) {} |
| 44 RtpExtension::~RtpExtension() {} |
| 45 |
| 46 RtpFecParameters::RtpFecParameters() {} |
| 47 RtpFecParameters::RtpFecParameters(FecMechanism mechanism) |
| 48 : mechanism(mechanism) {} |
| 49 RtpFecParameters::RtpFecParameters(FecMechanism mechanism, uint32_t ssrc) |
| 50 : ssrc(ssrc), mechanism(mechanism) {} |
| 51 RtpFecParameters::~RtpFecParameters() {} |
| 52 |
| 53 RtpRtxParameters::RtpRtxParameters() {} |
| 54 RtpRtxParameters::RtpRtxParameters(uint32_t ssrc) : ssrc(ssrc) {} |
| 55 RtpRtxParameters::~RtpRtxParameters() {} |
| 56 |
| 57 RtpEncodingParameters::RtpEncodingParameters() {} |
| 58 RtpEncodingParameters::~RtpEncodingParameters() {} |
| 59 |
| 60 RtpCodecParameters::RtpCodecParameters() {} |
| 61 RtpCodecParameters::~RtpCodecParameters() {} |
| 62 |
| 63 RtpCapabilities::RtpCapabilities() {} |
| 64 RtpCapabilities::~RtpCapabilities() {} |
| 65 |
| 66 RtpParameters::RtpParameters() {} |
| 67 RtpParameters::~RtpParameters() {} |
| 40 | 68 |
| 41 std::string RtpExtension::ToString() const { | 69 std::string RtpExtension::ToString() const { |
| 42 std::stringstream ss; | 70 std::stringstream ss; |
| 43 ss << "{uri: " << uri; | 71 ss << "{uri: " << uri; |
| 44 ss << ", id: " << id; | 72 ss << ", id: " << id; |
| 45 if (encrypt) { | 73 if (encrypt) { |
| 46 ss << ", encrypt"; | 74 ss << ", encrypt"; |
| 47 } | 75 } |
| 48 ss << '}'; | 76 ss << '}'; |
| 49 return ss.str(); | 77 return ss.str(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 return &extension; | 158 return &extension; |
| 131 } | 159 } |
| 132 } | 160 } |
| 133 return nullptr; | 161 return nullptr; |
| 134 } | 162 } |
| 135 | 163 |
| 136 std::vector<RtpExtension> RtpExtension::FilterDuplicateNonEncrypted( | 164 std::vector<RtpExtension> RtpExtension::FilterDuplicateNonEncrypted( |
| 137 const std::vector<RtpExtension>& extensions) { | 165 const std::vector<RtpExtension>& extensions) { |
| 138 std::vector<RtpExtension> filtered; | 166 std::vector<RtpExtension> filtered; |
| 139 for (auto extension = extensions.begin(); extension != extensions.end(); | 167 for (auto extension = extensions.begin(); extension != extensions.end(); |
| 140 ++extension) { | 168 ++extension) { |
| 141 if (extension->encrypt) { | 169 if (extension->encrypt) { |
| 142 filtered.push_back(*extension); | 170 filtered.push_back(*extension); |
| 143 continue; | 171 continue; |
| 144 } | 172 } |
| 145 | 173 |
| 146 // Only add non-encrypted extension if no encrypted with the same URI | 174 // Only add non-encrypted extension if no encrypted with the same URI |
| 147 // is also present... | 175 // is also present... |
| 148 if (std::find_if(extension + 1, extensions.end(), | 176 if (std::find_if(extension + 1, extensions.end(), |
| 149 [extension](const RtpExtension& check) { | 177 [extension](const RtpExtension& check) { |
| 150 return extension->uri == check.uri; | 178 return extension->uri == check.uri; |
| 151 }) != extensions.end()) { | 179 }) != extensions.end()) { |
| 152 continue; | 180 continue; |
| 153 } | 181 } |
| 154 | 182 |
| 155 // ...and has not been added before. | 183 // ...and has not been added before. |
| 156 if (!FindHeaderExtensionByUri(filtered, extension->uri)) { | 184 if (!FindHeaderExtensionByUri(filtered, extension->uri)) { |
| 157 filtered.push_back(*extension); | 185 filtered.push_back(*extension); |
| 158 } | 186 } |
| 159 } | 187 } |
| 160 return filtered; | 188 return filtered; |
| 161 } | 189 } |
| 162 | |
| 163 VideoStream::VideoStream() | |
| 164 : width(0), | |
| 165 height(0), | |
| 166 max_framerate(-1), | |
| 167 min_bitrate_bps(-1), | |
| 168 target_bitrate_bps(-1), | |
| 169 max_bitrate_bps(-1), | |
| 170 max_qp(-1) {} | |
| 171 | |
| 172 VideoStream::~VideoStream() = default; | |
| 173 | |
| 174 std::string VideoStream::ToString() const { | |
| 175 std::stringstream ss; | |
| 176 ss << "{width: " << width; | |
| 177 ss << ", height: " << height; | |
| 178 ss << ", max_framerate: " << max_framerate; | |
| 179 ss << ", min_bitrate_bps:" << min_bitrate_bps; | |
| 180 ss << ", target_bitrate_bps:" << target_bitrate_bps; | |
| 181 ss << ", max_bitrate_bps:" << max_bitrate_bps; | |
| 182 ss << ", max_qp: " << max_qp; | |
| 183 | |
| 184 ss << ", temporal_layer_thresholds_bps: ["; | |
| 185 for (size_t i = 0; i < temporal_layer_thresholds_bps.size(); ++i) { | |
| 186 ss << temporal_layer_thresholds_bps[i]; | |
| 187 if (i != temporal_layer_thresholds_bps.size() - 1) | |
| 188 ss << ", "; | |
| 189 } | |
| 190 ss << ']'; | |
| 191 | |
| 192 ss << '}'; | |
| 193 return ss.str(); | |
| 194 } | |
| 195 | |
| 196 VideoEncoderConfig::VideoEncoderConfig() | |
| 197 : content_type(ContentType::kRealtimeVideo), | |
| 198 encoder_specific_settings(nullptr), | |
| 199 min_transmit_bitrate_bps(0), | |
| 200 max_bitrate_bps(0), | |
| 201 number_of_streams(0) {} | |
| 202 | |
| 203 VideoEncoderConfig::VideoEncoderConfig(VideoEncoderConfig&&) = default; | |
| 204 | |
| 205 VideoEncoderConfig::~VideoEncoderConfig() = default; | |
| 206 | |
| 207 std::string VideoEncoderConfig::ToString() const { | |
| 208 std::stringstream ss; | |
| 209 ss << "{content_type: "; | |
| 210 switch (content_type) { | |
| 211 case ContentType::kRealtimeVideo: | |
| 212 ss << "kRealtimeVideo"; | |
| 213 break; | |
| 214 case ContentType::kScreen: | |
| 215 ss << "kScreenshare"; | |
| 216 break; | |
| 217 } | |
| 218 ss << ", encoder_specific_settings: "; | |
| 219 ss << (encoder_specific_settings != NULL ? "(ptr)" : "NULL"); | |
| 220 | |
| 221 ss << ", min_transmit_bitrate_bps: " << min_transmit_bitrate_bps; | |
| 222 ss << '}'; | |
| 223 return ss.str(); | |
| 224 } | |
| 225 | |
| 226 VideoEncoderConfig::VideoEncoderConfig(const VideoEncoderConfig&) = default; | |
| 227 | |
| 228 void VideoEncoderConfig::EncoderSpecificSettings::FillEncoderSpecificSettings( | |
| 229 VideoCodec* codec) const { | |
| 230 if (codec->codecType == kVideoCodecH264) { | |
| 231 FillVideoCodecH264(codec->H264()); | |
| 232 } else if (codec->codecType == kVideoCodecVP8) { | |
| 233 FillVideoCodecVp8(codec->VP8()); | |
| 234 } else if (codec->codecType == kVideoCodecVP9) { | |
| 235 FillVideoCodecVp9(codec->VP9()); | |
| 236 } else { | |
| 237 RTC_NOTREACHED() << "Encoder specifics set/used for unknown codec type."; | |
| 238 } | |
| 239 } | |
| 240 | |
| 241 void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecH264( | |
| 242 VideoCodecH264* h264_settings) const { | |
| 243 RTC_NOTREACHED(); | |
| 244 } | |
| 245 | |
| 246 void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp8( | |
| 247 VideoCodecVP8* vp8_settings) const { | |
| 248 RTC_NOTREACHED(); | |
| 249 } | |
| 250 | |
| 251 void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp9( | |
| 252 VideoCodecVP9* vp9_settings) const { | |
| 253 RTC_NOTREACHED(); | |
| 254 } | |
| 255 | |
| 256 VideoEncoderConfig::H264EncoderSpecificSettings::H264EncoderSpecificSettings( | |
| 257 const VideoCodecH264& specifics) | |
| 258 : specifics_(specifics) {} | |
| 259 | |
| 260 void VideoEncoderConfig::H264EncoderSpecificSettings::FillVideoCodecH264( | |
| 261 VideoCodecH264* h264_settings) const { | |
| 262 *h264_settings = specifics_; | |
| 263 } | |
| 264 | |
| 265 VideoEncoderConfig::Vp8EncoderSpecificSettings::Vp8EncoderSpecificSettings( | |
| 266 const VideoCodecVP8& specifics) | |
| 267 : specifics_(specifics) {} | |
| 268 | |
| 269 void VideoEncoderConfig::Vp8EncoderSpecificSettings::FillVideoCodecVp8( | |
| 270 VideoCodecVP8* vp8_settings) const { | |
| 271 *vp8_settings = specifics_; | |
| 272 } | |
| 273 | |
| 274 VideoEncoderConfig::Vp9EncoderSpecificSettings::Vp9EncoderSpecificSettings( | |
| 275 const VideoCodecVP9& specifics) | |
| 276 : specifics_(specifics) {} | |
| 277 | |
| 278 void VideoEncoderConfig::Vp9EncoderSpecificSettings::FillVideoCodecVp9( | |
| 279 VideoCodecVP9* vp9_settings) const { | |
| 280 *vp9_settings = specifics_; | |
| 281 } | |
| 282 | |
| 283 } // namespace webrtc | 190 } // namespace webrtc |
| OLD | NEW |