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