blob: 04f6a66935e40ab93f3195eb9fbdf47f2748cdf3 [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
brandtr76648da2016-10-20 04:54:48 -070034std::string FlexfecConfig::ToString() const {
35 std::stringstream ss;
36 ss << "{flexfec_payload_type: " << flexfec_payload_type;
37 ss << ", flexfec_ssrc: " << flexfec_ssrc;
38 ss << ", protected_media_ssrcs: [";
39 size_t i = 0;
40 for (; i + 1 < protected_media_ssrcs.size(); ++i)
41 ss << protected_media_ssrcs[i] << ", ";
42 if (!protected_media_ssrcs.empty())
43 ss << protected_media_ssrcs[i];
44 ss << "]}";
45 return ss.str();
46}
47
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +000048std::string RtpExtension::ToString() const {
49 std::stringstream ss;
isheriff6f8d6862016-05-26 11:24:55 -070050 ss << "{uri: " << uri;
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +000051 ss << ", id: " << id;
52 ss << '}';
53 return ss.str();
54}
55
isheriff6f8d6862016-05-26 11:24:55 -070056const char* RtpExtension::kAudioLevelUri =
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020057 "urn:ietf:params:rtp-hdrext:ssrc-audio-level";
isheriff6f8d6862016-05-26 11:24:55 -070058const int RtpExtension::kAudioLevelDefaultId = 1;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020059
isheriff6f8d6862016-05-26 11:24:55 -070060const char* RtpExtension::kTimestampOffsetUri =
61 "urn:ietf:params:rtp-hdrext:toffset";
62const int RtpExtension::kTimestampOffsetDefaultId = 2;
63
64const char* RtpExtension::kAbsSendTimeUri =
65 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time";
66const int RtpExtension::kAbsSendTimeDefaultId = 3;
67
68const char* RtpExtension::kVideoRotationUri = "urn:3gpp:video-orientation";
69const int RtpExtension::kVideoRotationDefaultId = 4;
70
71const char* RtpExtension::kTransportSequenceNumberUri =
72 "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01";
73const int RtpExtension::kTransportSequenceNumberDefaultId = 5;
74
isheriff6b4b5f32016-06-08 00:24:21 -070075// This extension allows applications to adaptively limit the playout delay
76// on frames as per the current needs. For example, a gaming application
77// has very different needs on end-to-end delay compared to a video-conference
78// application.
79const char* RtpExtension::kPlayoutDelayUri =
80 "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay";
81const int RtpExtension::kPlayoutDelayDefaultId = 6;
82
isheriff6f8d6862016-05-26 11:24:55 -070083bool RtpExtension::IsSupportedForAudio(const std::string& uri) {
84 return uri == webrtc::RtpExtension::kAbsSendTimeUri ||
85 uri == webrtc::RtpExtension::kAudioLevelUri ||
86 uri == webrtc::RtpExtension::kTransportSequenceNumberUri;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020087}
88
isheriff6f8d6862016-05-26 11:24:55 -070089bool RtpExtension::IsSupportedForVideo(const std::string& uri) {
90 return uri == webrtc::RtpExtension::kTimestampOffsetUri ||
91 uri == webrtc::RtpExtension::kAbsSendTimeUri ||
92 uri == webrtc::RtpExtension::kVideoRotationUri ||
isheriff6b4b5f32016-06-08 00:24:21 -070093 uri == webrtc::RtpExtension::kTransportSequenceNumberUri ||
94 uri == webrtc::RtpExtension::kPlayoutDelayUri;
Fredrik Solenberg23fba1f2015-04-29 15:24:01 +020095}
96
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22 +000097VideoStream::VideoStream()
98 : width(0),
99 height(0),
100 max_framerate(-1),
101 min_bitrate_bps(-1),
102 target_bitrate_bps(-1),
103 max_bitrate_bps(-1),
104 max_qp(-1) {}
105
106VideoStream::~VideoStream() = default;
107
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +0000108std::string VideoStream::ToString() const {
109 std::stringstream ss;
110 ss << "{width: " << width;
111 ss << ", height: " << height;
112 ss << ", max_framerate: " << max_framerate;
113 ss << ", min_bitrate_bps:" << min_bitrate_bps;
114 ss << ", target_bitrate_bps:" << target_bitrate_bps;
115 ss << ", max_bitrate_bps:" << max_bitrate_bps;
116 ss << ", max_qp: " << max_qp;
117
pbos@webrtc.org931e3da2014-11-06 09:35:08 +0000118 ss << ", temporal_layer_thresholds_bps: [";
pbos@webrtc.orgb7ed7792014-10-31 13:08:10 +0000119 for (size_t i = 0; i < temporal_layer_thresholds_bps.size(); ++i) {
120 ss << temporal_layer_thresholds_bps[i];
121 if (i != temporal_layer_thresholds_bps.size() - 1)
pbos@webrtc.org931e3da2014-11-06 09:35:08 +0000122 ss << ", ";
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +0000123 }
pbos@webrtc.org931e3da2014-11-06 09:35:08 +0000124 ss << ']';
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +0000125
126 ss << '}';
127 return ss.str();
128}
pbos@webrtc.orgad3b5a52014-10-24 09:23:21 +0000129
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22 +0000130VideoEncoderConfig::VideoEncoderConfig()
Erik Språng143cec12015-04-28 10:01:41 +0200131 : content_type(ContentType::kRealtimeVideo),
kthelgason29a44e32016-09-27 03:52:02 -0700132 encoder_specific_settings(nullptr),
skvlad3abb7642016-06-16 12:08:03 -0700133 min_transmit_bitrate_bps(0),
perkjfa10b552016-10-02 23:45:26 -0700134 max_bitrate_bps(0),
135 number_of_streams(0) {}
kwiberg@webrtc.orgac2d27d2015-02-26 13:59:22 +0000136
137VideoEncoderConfig::~VideoEncoderConfig() = default;
138
pbos@webrtc.orgad3b5a52014-10-24 09:23:21 +0000139std::string VideoEncoderConfig::ToString() const {
140 std::stringstream ss;
perkjfa10b552016-10-02 23:45:26 -0700141 ss << "{content_type: ";
pbos@webrtc.orgad3b5a52014-10-24 09:23:21 +0000142 switch (content_type) {
Erik Språng143cec12015-04-28 10:01:41 +0200143 case ContentType::kRealtimeVideo:
pbos@webrtc.orgad3b5a52014-10-24 09:23:21 +0000144 ss << "kRealtimeVideo";
145 break;
Erik Språng143cec12015-04-28 10:01:41 +0200146 case ContentType::kScreen:
pbos@webrtc.orgad3b5a52014-10-24 09:23:21 +0000147 ss << "kScreenshare";
148 break;
149 }
150 ss << ", encoder_specific_settings: ";
151 ss << (encoder_specific_settings != NULL ? "(ptr)" : "NULL");
152
153 ss << ", min_transmit_bitrate_bps: " << min_transmit_bitrate_bps;
154 ss << '}';
155 return ss.str();
156}
157
kthelgason29a44e32016-09-27 03:52:02 -0700158void VideoEncoderConfig::EncoderSpecificSettings::FillEncoderSpecificSettings(
159 VideoCodec* codec) const {
160 if (codec->codecType == kVideoCodecH264) {
161 FillVideoCodecH264(&codec->codecSpecific.H264);
162 } else if (codec->codecType == kVideoCodecVP8) {
163 FillVideoCodecVp8(&codec->codecSpecific.VP8);
164 } else if (codec->codecType == kVideoCodecVP9) {
165 FillVideoCodecVp9(&codec->codecSpecific.VP9);
166 } else {
167 RTC_NOTREACHED() << "Encoder specifics set/used for unknown codec type.";
168 }
169}
170
171void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecH264(
172 VideoCodecH264* h264_settings) const {
173 RTC_NOTREACHED();
174}
175
176void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp8(
177 VideoCodecVP8* vp8_settings) const {
178 RTC_NOTREACHED();
179}
180
181void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp9(
182 VideoCodecVP9* vp9_settings) const {
183 RTC_NOTREACHED();
184}
185
186VideoEncoderConfig::H264EncoderSpecificSettings::H264EncoderSpecificSettings(
187 const VideoCodecH264& specifics)
188 : specifics_(specifics) {}
189
190void VideoEncoderConfig::H264EncoderSpecificSettings::FillVideoCodecH264(
191 VideoCodecH264* h264_settings) const {
192 *h264_settings = specifics_;
193}
194
195VideoEncoderConfig::Vp8EncoderSpecificSettings::Vp8EncoderSpecificSettings(
196 const VideoCodecVP8& specifics)
197 : specifics_(specifics) {}
198
199void VideoEncoderConfig::Vp8EncoderSpecificSettings::FillVideoCodecVp8(
200 VideoCodecVP8* vp8_settings) const {
201 *vp8_settings = specifics_;
202}
203
204VideoEncoderConfig::Vp9EncoderSpecificSettings::Vp9EncoderSpecificSettings(
205 const VideoCodecVP9& specifics)
206 : specifics_(specifics) {}
207
208void VideoEncoderConfig::Vp9EncoderSpecificSettings::FillVideoCodecVp9(
209 VideoCodecVP9* vp9_settings) const {
210 *vp9_settings = specifics_;
211}
212
pbos@webrtc.org1e92b0a2014-05-15 09:35:06 +0000213} // namespace webrtc