Line data Source code
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 :
15 : #include "webrtc/base/checks.h"
16 :
17 : namespace webrtc {
18 0 : std::string NackConfig::ToString() const {
19 0 : std::stringstream ss;
20 0 : ss << "{rtp_history_ms: " << rtp_history_ms;
21 0 : ss << '}';
22 0 : return ss.str();
23 : }
24 :
25 0 : std::string UlpfecConfig::ToString() const {
26 0 : std::stringstream ss;
27 0 : ss << "{ulpfec_payload_type: " << ulpfec_payload_type;
28 0 : ss << ", red_payload_type: " << red_payload_type;
29 0 : ss << ", red_rtx_payload_type: " << red_rtx_payload_type;
30 0 : ss << '}';
31 0 : return ss.str();
32 : }
33 :
34 0 : bool UlpfecConfig::operator==(const UlpfecConfig& other) const {
35 0 : return ulpfec_payload_type == other.ulpfec_payload_type &&
36 0 : red_payload_type == other.red_payload_type &&
37 0 : red_rtx_payload_type == other.red_rtx_payload_type;
38 : }
39 :
40 0 : std::string RtpExtension::ToString() const {
41 0 : std::stringstream ss;
42 0 : ss << "{uri: " << uri;
43 0 : ss << ", id: " << id;
44 0 : ss << '}';
45 0 : return ss.str();
46 : }
47 :
48 : const char* RtpExtension::kAudioLevelUri =
49 : "urn:ietf:params:rtp-hdrext:ssrc-audio-level";
50 : const int RtpExtension::kAudioLevelDefaultId = 1;
51 :
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 :
67 : const char* RtpExtension::kRtpStreamIdUri =
68 : "urn:ietf:params:rtp-hdrext:sdes:rtp-stream-id";
69 : const int RtpExtension::kRtpStreamIdDefaultId = 6;
70 :
71 : // This extension allows applications to adaptively limit the playout delay
72 : // on frames as per the current needs. For example, a gaming application
73 : // has very different needs on end-to-end delay compared to a video-conference
74 : // application.
75 : const char* RtpExtension::kPlayoutDelayUri =
76 : "http://www.webrtc.org/experiments/rtp-hdrext/playout-delay";
77 : const int RtpExtension::kPlayoutDelayDefaultId = 6;
78 :
79 0 : bool RtpExtension::IsSupportedForAudio(const std::string& uri) {
80 0 : return uri == webrtc::RtpExtension::kAudioLevelUri ||
81 0 : uri == webrtc::RtpExtension::kTransportSequenceNumberUri ||
82 0 : uri == webrtc::RtpExtension::kRtpStreamIdUri;
83 : }
84 :
85 0 : bool RtpExtension::IsSupportedForVideo(const std::string& uri) {
86 0 : return uri == webrtc::RtpExtension::kTimestampOffsetUri ||
87 0 : uri == webrtc::RtpExtension::kAbsSendTimeUri ||
88 0 : uri == webrtc::RtpExtension::kVideoRotationUri ||
89 0 : uri == webrtc::RtpExtension::kTransportSequenceNumberUri ||
90 0 : uri == webrtc::RtpExtension::kPlayoutDelayUri ||
91 0 : uri == webrtc::RtpExtension::kRtpStreamIdUri;
92 : }
93 :
94 0 : VideoStream::VideoStream()
95 : : width(0),
96 : height(0),
97 : max_framerate(-1),
98 : min_bitrate_bps(-1),
99 : target_bitrate_bps(-1),
100 : max_bitrate_bps(-1),
101 0 : max_qp(-1) {
102 0 : rid[0] = '\0';
103 0 : }
104 :
105 : VideoStream::~VideoStream() = default;
106 :
107 0 : std::string VideoStream::ToString() const {
108 0 : std::stringstream ss;
109 0 : ss << "{width: " << width;
110 0 : ss << ", height: " << height;
111 0 : ss << ", max_framerate: " << max_framerate;
112 0 : ss << ", min_bitrate_bps:" << min_bitrate_bps;
113 0 : ss << ", target_bitrate_bps:" << target_bitrate_bps;
114 0 : ss << ", max_bitrate_bps:" << max_bitrate_bps;
115 0 : ss << ", max_qp: " << max_qp;
116 0 : ss << ", rid: " << rid;
117 :
118 0 : ss << ", temporal_layer_thresholds_bps: [";
119 0 : for (size_t i = 0; i < temporal_layer_thresholds_bps.size(); ++i) {
120 0 : ss << temporal_layer_thresholds_bps[i];
121 0 : if (i != temporal_layer_thresholds_bps.size() - 1)
122 0 : ss << ", ";
123 : }
124 0 : ss << ']';
125 :
126 0 : ss << '}';
127 0 : return ss.str();
128 : }
129 :
130 0 : VideoEncoderConfig::VideoEncoderConfig()
131 : : content_type(ContentType::kRealtimeVideo),
132 : encoder_specific_settings(nullptr),
133 : min_transmit_bitrate_bps(0),
134 : max_bitrate_bps(0),
135 0 : number_of_streams(0) {}
136 :
137 : VideoEncoderConfig::VideoEncoderConfig(VideoEncoderConfig&&) = default;
138 :
139 : VideoEncoderConfig::~VideoEncoderConfig() = default;
140 :
141 0 : std::string VideoEncoderConfig::ToString() const {
142 0 : std::stringstream ss;
143 0 : ss << "{content_type: ";
144 0 : switch (content_type) {
145 : case ContentType::kRealtimeVideo:
146 0 : ss << "kRealtimeVideo";
147 0 : break;
148 : case ContentType::kScreen:
149 0 : ss << "kScreenshare";
150 0 : break;
151 : }
152 0 : ss << ", encoder_specific_settings: ";
153 0 : ss << (encoder_specific_settings != NULL ? "(ptr)" : "NULL");
154 :
155 0 : ss << ", min_transmit_bitrate_bps: " << min_transmit_bitrate_bps;
156 0 : ss << '}';
157 0 : return ss.str();
158 : }
159 :
160 : VideoEncoderConfig::VideoEncoderConfig(const VideoEncoderConfig&) = default;
161 :
162 0 : void VideoEncoderConfig::EncoderSpecificSettings::FillEncoderSpecificSettings(
163 : VideoCodec* codec) const {
164 0 : if (codec->codecType == kVideoCodecH264) {
165 0 : FillVideoCodecH264(codec->H264());
166 0 : } else if (codec->codecType == kVideoCodecVP8) {
167 0 : FillVideoCodecVp8(codec->VP8());
168 0 : } else if (codec->codecType == kVideoCodecVP9) {
169 0 : FillVideoCodecVp9(codec->VP9());
170 : } else {
171 0 : RTC_NOTREACHED() << "Encoder specifics set/used for unknown codec type.";
172 : }
173 0 : }
174 :
175 0 : void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecH264(
176 : VideoCodecH264* h264_settings) const {
177 0 : RTC_NOTREACHED();
178 0 : }
179 :
180 0 : void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp8(
181 : VideoCodecVP8* vp8_settings) const {
182 0 : RTC_NOTREACHED();
183 0 : }
184 :
185 0 : void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp9(
186 : VideoCodecVP9* vp9_settings) const {
187 0 : RTC_NOTREACHED();
188 0 : }
189 :
190 0 : VideoEncoderConfig::H264EncoderSpecificSettings::H264EncoderSpecificSettings(
191 0 : const VideoCodecH264& specifics)
192 0 : : specifics_(specifics) {}
193 :
194 0 : void VideoEncoderConfig::H264EncoderSpecificSettings::FillVideoCodecH264(
195 : VideoCodecH264* h264_settings) const {
196 0 : *h264_settings = specifics_;
197 0 : }
198 :
199 0 : VideoEncoderConfig::Vp8EncoderSpecificSettings::Vp8EncoderSpecificSettings(
200 0 : const VideoCodecVP8& specifics)
201 0 : : specifics_(specifics) {}
202 :
203 0 : void VideoEncoderConfig::Vp8EncoderSpecificSettings::FillVideoCodecVp8(
204 : VideoCodecVP8* vp8_settings) const {
205 0 : *vp8_settings = specifics_;
206 0 : }
207 :
208 0 : VideoEncoderConfig::Vp9EncoderSpecificSettings::Vp9EncoderSpecificSettings(
209 0 : const VideoCodecVP9& specifics)
210 0 : : specifics_(specifics) {}
211 :
212 0 : void VideoEncoderConfig::Vp9EncoderSpecificSettings::FillVideoCodecVp9(
213 : VideoCodecVP9* vp9_settings) const {
214 0 : *vp9_settings = specifics_;
215 0 : }
216 :
217 : } // namespace webrtc
|