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