blob: 6ffd1c3fd1563f2d50dd0462c0117b61ea591f3e [file] [log] [blame]
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +00001/*
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
kthelgason29a44e32016-09-27 03:52:02 -070015#include "webrtc/base/checks.h"
16
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +000017namespace webrtc {
solenberg971cab02016-06-14 10:02:41 -070018std::string NackConfig::ToString() const {
19 std::stringstream ss;
20 ss << "{rtp_history_ms: " << rtp_history_ms;
21 ss << '}';
22 return ss.str();
23}
24
brandtrb5f2c3f2016-10-04 23:28:39 -070025std::string UlpfecConfig::ToString() const {
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +000026 std::stringstream ss;
27 ss << "{ulpfec_payload_type: " << ulpfec_payload_type;
28 ss << ", red_payload_type: " << red_payload_type;
Stefan Holmer10880012016-02-03 13:29:59 +010029 ss << ", red_rtx_payload_type: " << red_rtx_payload_type;
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +000030 ss << '}';
31 return ss.str();
32}
33
brandtr468da7c2016-11-22 02:16:47 -080034bool 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.org1e92b0a2014-05-15 09:35:06 +000040std::string RtpExtension::ToString() const {
41 std::stringstream ss;
isheriff6f8d6862016-05-26 11:24:55 -070042 ss << "{uri: " << uri;
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +000043 ss << ", id: " << id;
44 ss << '}';
45 return ss.str();
46}
47
isheriff6f8d6862016-05-26 11:24:55 -070048const char* RtpExtension::kAudioLevelUri =
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020049 "urn:ietf:params:rtp-hdrext:ssrc-audio-level";
isheriff6f8d6862016-05-26 11:24:55 -070050const int RtpExtension::kAudioLevelDefaultId = 1;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020051
isheriff6f8d6862016-05-26 11:24:55 -070052const char* RtpExtension::kTimestampOffsetUri =
53 "urn:ietf:params:rtp-hdrext:toffset";
54const int RtpExtension::kTimestampOffsetDefaultId = 2;
55
56const char* RtpExtension::kAbsSendTimeUri =
57 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time";
58const int RtpExtension::kAbsSendTimeDefaultId = 3;
59
60const char* RtpExtension::kVideoRotationUri = "urn:3gpp:video-orientation";
61const int RtpExtension::kVideoRotationDefaultId = 4;
62
63const char* RtpExtension::kTransportSequenceNumberUri =
64 "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01";
65const int RtpExtension::kTransportSequenceNumberDefaultId = 5;
66
isheriff6b4b5f32016-06-08 00:24:21 -070067// 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.
71const char* RtpExtension::kPlayoutDelayUri =
72 "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay";
73const int RtpExtension::kPlayoutDelayDefaultId = 6;
74
isheriff6f8d6862016-05-26 11:24:55 -070075bool RtpExtension::IsSupportedForAudio(const std::string& uri) {
solenbergd4adce42016-11-17 06:26:52 -080076 return uri == webrtc::RtpExtension::kAudioLevelUri ||
isheriff6f8d6862016-05-26 11:24:55 -070077 uri == webrtc::RtpExtension::kTransportSequenceNumberUri;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020078}
79
isheriff6f8d6862016-05-26 11:24:55 -070080bool RtpExtension::IsSupportedForVideo(const std::string& uri) {
81 return uri == webrtc::RtpExtension::kTimestampOffsetUri ||
82 uri == webrtc::RtpExtension::kAbsSendTimeUri ||
83 uri == webrtc::RtpExtension::kVideoRotationUri ||
isheriff6b4b5f32016-06-08 00:24:21 -070084 uri == webrtc::RtpExtension::kTransportSequenceNumberUri ||
85 uri == webrtc::RtpExtension::kPlayoutDelayUri;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020086}
87
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22 +000088VideoStream::VideoStream()
89 : width(0),
90 height(0),
91 max_framerate(-1),
92 min_bitrate_bps(-1),
93 target_bitrate_bps(-1),
94 max_bitrate_bps(-1),
95 max_qp(-1) {}
96
97VideoStream::~VideoStream() = default;
98
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +000099std::string VideoStream::ToString() const {
100 std::stringstream ss;
101 ss << "{width: " << width;
102 ss << ", height: " << height;
103 ss << ", max_framerate: " << max_framerate;
104 ss << ", min_bitrate_bps:" << min_bitrate_bps;
105 ss << ", target_bitrate_bps:" << target_bitrate_bps;
106 ss << ", max_bitrate_bps:" << max_bitrate_bps;
107 ss << ", max_qp: " << max_qp;
108
pbos@webrtc.org931e3da2014-11-06 09:35:08 +0000109 ss << ", temporal_layer_thresholds_bps: [";
pbos@webrtc.orgb7ed7792014-10-31 13:08:10 +0000110 for (size_t i = 0; i < temporal_layer_thresholds_bps.size(); ++i) {
111 ss << temporal_layer_thresholds_bps[i];
112 if (i != temporal_layer_thresholds_bps.size() - 1)
pbos@webrtc.org931e3da2014-11-06 09:35:08 +0000113 ss << ", ";
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +0000114 }
pbos@webrtc.org931e3da2014-11-06 09:35:08 +0000115 ss << ']';
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +0000116
117 ss << '}';
118 return ss.str();
119}
pbos@webrtc.orgad3b5a52014-10-24 09:23:21 +0000120
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22 +0000121VideoEncoderConfig::VideoEncoderConfig()
Erik Språng143cec12015-04-28 10:01:41 +0200122 : content_type(ContentType::kRealtimeVideo),
kthelgason29a44e32016-09-27 03:52:02 -0700123 encoder_specific_settings(nullptr),
skvlad3abb7642016-06-16 12:08:03 -0700124 min_transmit_bitrate_bps(0),
perkjfa10b552016-10-02 23:45:26 -0700125 max_bitrate_bps(0),
126 number_of_streams(0) {}
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22 +0000127
solenberg940b6d62016-10-25 11:19:07 -0700128VideoEncoderConfig::VideoEncoderConfig(VideoEncoderConfig&&) = default;
129
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22 +0000130VideoEncoderConfig::~VideoEncoderConfig() = default;
131
pbos@webrtc.orgad3b5a52014-10-24 09:23:21 +0000132std::string VideoEncoderConfig::ToString() const {
133 std::stringstream ss;
perkjfa10b552016-10-02 23:45:26 -0700134 ss << "{content_type: ";
pbos@webrtc.orgad3b5a52014-10-24 09:23:21 +0000135 switch (content_type) {
Erik Språng143cec12015-04-28 10:01:41 +0200136 case ContentType::kRealtimeVideo:
pbos@webrtc.orgad3b5a52014-10-24 09:23:21 +0000137 ss << "kRealtimeVideo";
138 break;
Erik Språng143cec12015-04-28 10:01:41 +0200139 case ContentType::kScreen:
pbos@webrtc.orgad3b5a52014-10-24 09:23:21 +0000140 ss << "kScreenshare";
141 break;
142 }
143 ss << ", encoder_specific_settings: ";
144 ss << (encoder_specific_settings != NULL ? "(ptr)" : "NULL");
145
146 ss << ", min_transmit_bitrate_bps: " << min_transmit_bitrate_bps;
147 ss << '}';
148 return ss.str();
149}
150
solenberg940b6d62016-10-25 11:19:07 -0700151VideoEncoderConfig::VideoEncoderConfig(const VideoEncoderConfig&) = default;
152
kthelgason29a44e32016-09-27 03:52:02 -0700153void VideoEncoderConfig::EncoderSpecificSettings::FillEncoderSpecificSettings(
154 VideoCodec* codec) const {
155 if (codec->codecType == kVideoCodecH264) {
hta527d3472016-11-16 23:23:04 -0800156 FillVideoCodecH264(codec->H264());
kthelgason29a44e32016-09-27 03:52:02 -0700157 } else if (codec->codecType == kVideoCodecVP8) {
hta527d3472016-11-16 23:23:04 -0800158 FillVideoCodecVp8(codec->VP8());
kthelgason29a44e32016-09-27 03:52:02 -0700159 } else if (codec->codecType == kVideoCodecVP9) {
hta527d3472016-11-16 23:23:04 -0800160 FillVideoCodecVp9(codec->VP9());
kthelgason29a44e32016-09-27 03:52:02 -0700161 } else {
162 RTC_NOTREACHED() << "Encoder specifics set/used for unknown codec type.";
163 }
164}
165
166void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecH264(
167 VideoCodecH264* h264_settings) const {
168 RTC_NOTREACHED();
169}
170
171void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp8(
172 VideoCodecVP8* vp8_settings) const {
173 RTC_NOTREACHED();
174}
175
176void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp9(
177 VideoCodecVP9* vp9_settings) const {
178 RTC_NOTREACHED();
179}
180
181VideoEncoderConfig::H264EncoderSpecificSettings::H264EncoderSpecificSettings(
182 const VideoCodecH264& specifics)
183 : specifics_(specifics) {}
184
185void VideoEncoderConfig::H264EncoderSpecificSettings::FillVideoCodecH264(
186 VideoCodecH264* h264_settings) const {
187 *h264_settings = specifics_;
188}
189
190VideoEncoderConfig::Vp8EncoderSpecificSettings::Vp8EncoderSpecificSettings(
191 const VideoCodecVP8& specifics)
192 : specifics_(specifics) {}
193
194void VideoEncoderConfig::Vp8EncoderSpecificSettings::FillVideoCodecVp8(
195 VideoCodecVP8* vp8_settings) const {
196 *vp8_settings = specifics_;
197}
198
199VideoEncoderConfig::Vp9EncoderSpecificSettings::Vp9EncoderSpecificSettings(
200 const VideoCodecVP9& specifics)
201 : specifics_(specifics) {}
202
203void VideoEncoderConfig::Vp9EncoderSpecificSettings::FillVideoCodecVp9(
204 VideoCodecVP9* vp9_settings) const {
205 *vp9_settings = specifics_;
206}
207
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +0000208} // namespace webrtc