Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: webrtc/config.cc

Issue 3004723002: Move RtpExtension to api/ directory and config.h/.cc to call/. (Closed)
Patch Set: Fix nit. Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/config.h ('k') | webrtc/config_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 <algorithm>
13 #include <sstream>
14 #include <string>
15
16 #include "webrtc/rtc_base/checks.h"
17
18 namespace webrtc {
19 std::string NackConfig::ToString() const {
20 std::stringstream ss;
21 ss << "{rtp_history_ms: " << rtp_history_ms;
22 ss << '}';
23 return ss.str();
24 }
25
26 std::string UlpfecConfig::ToString() const {
27 std::stringstream ss;
28 ss << "{ulpfec_payload_type: " << ulpfec_payload_type;
29 ss << ", red_payload_type: " << red_payload_type;
30 ss << ", red_rtx_payload_type: " << red_rtx_payload_type;
31 ss << '}';
32 return ss.str();
33 }
34
35 bool UlpfecConfig::operator==(const UlpfecConfig& other) const {
36 return ulpfec_payload_type == other.ulpfec_payload_type &&
37 red_payload_type == other.red_payload_type &&
38 red_rtx_payload_type == other.red_rtx_payload_type;
39 }
40
41 std::string RtpExtension::ToString() const {
42 std::stringstream ss;
43 ss << "{uri: " << uri;
44 ss << ", id: " << id;
45 if (encrypt) {
46 ss << ", encrypt";
47 }
48 ss << '}';
49 return ss.str();
50 }
51
52 const char RtpExtension::kAudioLevelUri[] =
53 "urn:ietf:params:rtp-hdrext:ssrc-audio-level";
54 const int RtpExtension::kAudioLevelDefaultId = 1;
55
56 const char RtpExtension::kTimestampOffsetUri[] =
57 "urn:ietf:params:rtp-hdrext:toffset";
58 const int RtpExtension::kTimestampOffsetDefaultId = 2;
59
60 const char RtpExtension::kAbsSendTimeUri[] =
61 "http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time";
62 const int RtpExtension::kAbsSendTimeDefaultId = 3;
63
64 const char RtpExtension::kVideoRotationUri[] = "urn:3gpp:video-orientation";
65 const int RtpExtension::kVideoRotationDefaultId = 4;
66
67 const char RtpExtension::kTransportSequenceNumberUri[] =
68 "http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01";
69 const int RtpExtension::kTransportSequenceNumberDefaultId = 5;
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 const char RtpExtension::kVideoContentTypeUri[] =
80 "http://www.webrtc.org/experiments/rtp-hdrext/video-content-type";
81 const int RtpExtension::kVideoContentTypeDefaultId = 7;
82
83 const char RtpExtension::kVideoTimingUri[] =
84 "http://www.webrtc.org/experiments/rtp-hdrext/video-timing";
85 const int RtpExtension::kVideoTimingDefaultId = 8;
86
87 const char RtpExtension::kEncryptHeaderExtensionsUri[] =
88 "urn:ietf:params:rtp-hdrext:encrypt";
89
90 const int RtpExtension::kMinId = 1;
91 const int RtpExtension::kMaxId = 14;
92
93 bool RtpExtension::IsSupportedForAudio(const std::string& uri) {
94 return uri == webrtc::RtpExtension::kAudioLevelUri ||
95 uri == webrtc::RtpExtension::kTransportSequenceNumberUri;
96 }
97
98 bool RtpExtension::IsSupportedForVideo(const std::string& uri) {
99 return uri == webrtc::RtpExtension::kTimestampOffsetUri ||
100 uri == webrtc::RtpExtension::kAbsSendTimeUri ||
101 uri == webrtc::RtpExtension::kVideoRotationUri ||
102 uri == webrtc::RtpExtension::kTransportSequenceNumberUri ||
103 uri == webrtc::RtpExtension::kPlayoutDelayUri ||
104 uri == webrtc::RtpExtension::kVideoContentTypeUri ||
105 uri == webrtc::RtpExtension::kVideoTimingUri;
106 }
107
108 bool RtpExtension::IsEncryptionSupported(const std::string& uri) {
109 return uri == webrtc::RtpExtension::kAudioLevelUri ||
110 uri == webrtc::RtpExtension::kTimestampOffsetUri ||
111 #if !defined(ENABLE_EXTERNAL_AUTH)
112 // TODO(jbauch): Figure out a way to always allow "kAbsSendTimeUri"
113 // here and filter out later if external auth is really used in
114 // srtpfilter. External auth is used by Chromium and replaces the
115 // extension header value of "kAbsSendTimeUri", so it must not be
116 // encrypted (which can't be done by Chromium).
117 uri == webrtc::RtpExtension::kAbsSendTimeUri ||
118 #endif
119 uri == webrtc::RtpExtension::kVideoRotationUri ||
120 uri == webrtc::RtpExtension::kTransportSequenceNumberUri ||
121 uri == webrtc::RtpExtension::kPlayoutDelayUri ||
122 uri == webrtc::RtpExtension::kVideoContentTypeUri;
123 }
124
125 const RtpExtension* RtpExtension::FindHeaderExtensionByUri(
126 const std::vector<RtpExtension>& extensions,
127 const std::string& uri) {
128 for (const auto& extension : extensions) {
129 if (extension.uri == uri) {
130 return &extension;
131 }
132 }
133 return nullptr;
134 }
135
136 std::vector<RtpExtension> RtpExtension::FilterDuplicateNonEncrypted(
137 const std::vector<RtpExtension>& extensions) {
138 std::vector<RtpExtension> filtered;
139 for (auto extension = extensions.begin(); extension != extensions.end();
140 ++extension) {
141 if (extension->encrypt) {
142 filtered.push_back(*extension);
143 continue;
144 }
145
146 // Only add non-encrypted extension if no encrypted with the same URI
147 // is also present...
148 if (std::find_if(extension + 1, extensions.end(),
149 [extension](const RtpExtension& check) {
150 return extension->uri == check.uri;
151 }) != extensions.end()) {
152 continue;
153 }
154
155 // ...and has not been added before.
156 if (!FindHeaderExtensionByUri(filtered, extension->uri)) {
157 filtered.push_back(*extension);
158 }
159 }
160 return filtered;
161 }
162
163 VideoStream::VideoStream()
164 : width(0),
165 height(0),
166 max_framerate(-1),
167 min_bitrate_bps(-1),
168 target_bitrate_bps(-1),
169 max_bitrate_bps(-1),
170 max_qp(-1) {}
171
172 VideoStream::~VideoStream() = default;
173
174 std::string VideoStream::ToString() const {
175 std::stringstream ss;
176 ss << "{width: " << width;
177 ss << ", height: " << height;
178 ss << ", max_framerate: " << max_framerate;
179 ss << ", min_bitrate_bps:" << min_bitrate_bps;
180 ss << ", target_bitrate_bps:" << target_bitrate_bps;
181 ss << ", max_bitrate_bps:" << max_bitrate_bps;
182 ss << ", max_qp: " << max_qp;
183
184 ss << ", temporal_layer_thresholds_bps: [";
185 for (size_t i = 0; i < temporal_layer_thresholds_bps.size(); ++i) {
186 ss << temporal_layer_thresholds_bps[i];
187 if (i != temporal_layer_thresholds_bps.size() - 1)
188 ss << ", ";
189 }
190 ss << ']';
191
192 ss << '}';
193 return ss.str();
194 }
195
196 VideoEncoderConfig::VideoEncoderConfig()
197 : content_type(ContentType::kRealtimeVideo),
198 encoder_specific_settings(nullptr),
199 min_transmit_bitrate_bps(0),
200 max_bitrate_bps(0),
201 number_of_streams(0) {}
202
203 VideoEncoderConfig::VideoEncoderConfig(VideoEncoderConfig&&) = default;
204
205 VideoEncoderConfig::~VideoEncoderConfig() = default;
206
207 std::string VideoEncoderConfig::ToString() const {
208 std::stringstream ss;
209 ss << "{content_type: ";
210 switch (content_type) {
211 case ContentType::kRealtimeVideo:
212 ss << "kRealtimeVideo";
213 break;
214 case ContentType::kScreen:
215 ss << "kScreenshare";
216 break;
217 }
218 ss << ", encoder_specific_settings: ";
219 ss << (encoder_specific_settings != NULL ? "(ptr)" : "NULL");
220
221 ss << ", min_transmit_bitrate_bps: " << min_transmit_bitrate_bps;
222 ss << '}';
223 return ss.str();
224 }
225
226 VideoEncoderConfig::VideoEncoderConfig(const VideoEncoderConfig&) = default;
227
228 void VideoEncoderConfig::EncoderSpecificSettings::FillEncoderSpecificSettings(
229 VideoCodec* codec) const {
230 if (codec->codecType == kVideoCodecH264) {
231 FillVideoCodecH264(codec->H264());
232 } else if (codec->codecType == kVideoCodecVP8) {
233 FillVideoCodecVp8(codec->VP8());
234 } else if (codec->codecType == kVideoCodecVP9) {
235 FillVideoCodecVp9(codec->VP9());
236 } else {
237 RTC_NOTREACHED() << "Encoder specifics set/used for unknown codec type.";
238 }
239 }
240
241 void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecH264(
242 VideoCodecH264* h264_settings) const {
243 RTC_NOTREACHED();
244 }
245
246 void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp8(
247 VideoCodecVP8* vp8_settings) const {
248 RTC_NOTREACHED();
249 }
250
251 void VideoEncoderConfig::EncoderSpecificSettings::FillVideoCodecVp9(
252 VideoCodecVP9* vp9_settings) const {
253 RTC_NOTREACHED();
254 }
255
256 VideoEncoderConfig::H264EncoderSpecificSettings::H264EncoderSpecificSettings(
257 const VideoCodecH264& specifics)
258 : specifics_(specifics) {}
259
260 void VideoEncoderConfig::H264EncoderSpecificSettings::FillVideoCodecH264(
261 VideoCodecH264* h264_settings) const {
262 *h264_settings = specifics_;
263 }
264
265 VideoEncoderConfig::Vp8EncoderSpecificSettings::Vp8EncoderSpecificSettings(
266 const VideoCodecVP8& specifics)
267 : specifics_(specifics) {}
268
269 void VideoEncoderConfig::Vp8EncoderSpecificSettings::FillVideoCodecVp8(
270 VideoCodecVP8* vp8_settings) const {
271 *vp8_settings = specifics_;
272 }
273
274 VideoEncoderConfig::Vp9EncoderSpecificSettings::Vp9EncoderSpecificSettings(
275 const VideoCodecVP9& specifics)
276 : specifics_(specifics) {}
277
278 void VideoEncoderConfig::Vp9EncoderSpecificSettings::FillVideoCodecVp9(
279 VideoCodecVP9* vp9_settings) const {
280 *vp9_settings = specifics_;
281 }
282
283 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/config.h ('k') | webrtc/config_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698