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

Side by Side Diff: webrtc/media/base/codec.cc

Issue 2483173002: Negotiate H264 profiles in SDP (Closed)
Patch Set: Rebase Created 4 years, 1 month 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/media/base/codec.h ('k') | webrtc/media/engine/fakewebrtcvideoengine.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/media/base/codec.h" 11 #include "webrtc/media/base/codec.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <sstream> 14 #include <sstream>
15 15
16 #include "webrtc/base/common.h" 16 #include "webrtc/base/common.h"
17 #include "webrtc/base/logging.h" 17 #include "webrtc/base/logging.h"
18 #include "webrtc/base/stringencode.h" 18 #include "webrtc/base/stringencode.h"
19 #include "webrtc/base/stringutils.h" 19 #include "webrtc/base/stringutils.h"
20 #include "webrtc/common_video/h264/profile_level_id.h"
20 21
21 namespace cricket { 22 namespace cricket {
22 23
24 const int kFirstDynamicPayloadId = 96;
23 const int kMaxPayloadId = 127; 25 const int kMaxPayloadId = 127;
24 26
25 bool FeedbackParam::operator==(const FeedbackParam& other) const { 27 bool FeedbackParam::operator==(const FeedbackParam& other) const {
26 return _stricmp(other.id().c_str(), id().c_str()) == 0 && 28 return _stricmp(other.id().c_str(), id().c_str()) == 0 &&
27 _stricmp(other.param().c_str(), param().c_str()) == 0; 29 _stricmp(other.param().c_str(), param().c_str()) == 0;
28 } 30 }
29 31
30 bool FeedbackParams::operator==(const FeedbackParams& other) const { 32 bool FeedbackParams::operator==(const FeedbackParams& other) const {
31 return params_ == other.params_; 33 return params_ == other.params_;
32 } 34 }
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 std::string VideoCodec::ToString() const { 198 std::string VideoCodec::ToString() const {
197 std::ostringstream os; 199 std::ostringstream os;
198 os << "VideoCodec[" << id << ":" << name << "]"; 200 os << "VideoCodec[" << id << ":" << name << "]";
199 return os.str(); 201 return os.str();
200 } 202 }
201 203
202 VideoCodec::VideoCodec(int id, const std::string& name) 204 VideoCodec::VideoCodec(int id, const std::string& name)
203 : Codec(id, name, kVideoCodecClockrate) {} 205 : Codec(id, name, kVideoCodecClockrate) {}
204 206
205 VideoCodec::VideoCodec(const std::string& name) 207 VideoCodec::VideoCodec(const std::string& name)
206 : VideoCodec(0 /* id */, name) {} 208 : VideoCodec(kFirstDynamicPayloadId, name) {}
hta-webrtc 2016/11/11 12:07:49 We can't pile all the codecs on payload 96, so som
magjed_webrtc 2016/11/12 16:46:25 Right, this is a non-final payload assignment. Thi
207 209
208 VideoCodec::VideoCodec() : Codec() { 210 VideoCodec::VideoCodec() : Codec() {
209 clockrate = kVideoCodecClockrate; 211 clockrate = kVideoCodecClockrate;
210 } 212 }
211 213
212 VideoCodec::VideoCodec(const VideoCodec& c) = default; 214 VideoCodec::VideoCodec(const VideoCodec& c) = default;
213 VideoCodec::VideoCodec(VideoCodec&& c) = default; 215 VideoCodec::VideoCodec(VideoCodec&& c) = default;
214 VideoCodec& VideoCodec::operator=(const VideoCodec& c) = default; 216 VideoCodec& VideoCodec::operator=(const VideoCodec& c) = default;
215 VideoCodec& VideoCodec::operator=(VideoCodec&& c) = default; 217 VideoCodec& VideoCodec::operator=(VideoCodec&& c) = default;
216 218
217 bool VideoCodec::operator==(const VideoCodec& c) const { 219 bool VideoCodec::operator==(const VideoCodec& c) const {
218 return Codec::operator==(c); 220 return Codec::operator==(c);
219 } 221 }
220 222
223 bool VideoCodec::Matches(const VideoCodec& other) const {
224 if (!Codec::Matches(other))
225 return false;
226 if (!CodecNamesEq(name.c_str(), kH264CodecName))
227 return true;
228 const rtc::Optional<webrtc::H264::ProfileLevelId> profile_level_id =
229 webrtc::H264::ParseSdpProfileLevelId(params);
230 const rtc::Optional<webrtc::H264::ProfileLevelId> other_profile_level_id =
231 webrtc::H264::ParseSdpProfileLevelId(other.params);
232 // Compare H264 profiles, but not levels.
233 return profile_level_id && other_profile_level_id &&
234 profile_level_id->profile == other_profile_level_id->profile;
235 }
236
221 VideoCodec VideoCodec::CreateRtxCodec(int rtx_payload_type, 237 VideoCodec VideoCodec::CreateRtxCodec(int rtx_payload_type,
222 int associated_payload_type) { 238 int associated_payload_type) {
223 VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName); 239 VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName);
224 rtx_codec.SetParam(kCodecParamAssociatedPayloadType, associated_payload_type); 240 rtx_codec.SetParam(kCodecParamAssociatedPayloadType, associated_payload_type);
225 return rtx_codec; 241 return rtx_codec;
226 } 242 }
227 243
228 VideoCodec::CodecType VideoCodec::GetCodecType() const { 244 VideoCodec::CodecType VideoCodec::GetCodecType() const {
229 const char* payload_name = name.c_str(); 245 const char* payload_name = name.c_str();
230 if (_stricmp(payload_name, kRedCodecName) == 0) { 246 if (_stricmp(payload_name, kRedCodecName) == 0) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 if (CodecNamesEq(name.c_str(), kVp8CodecName)) { 326 if (CodecNamesEq(name.c_str(), kVp8CodecName)) {
311 return webrtc::kVideoCodecVP8; 327 return webrtc::kVideoCodecVP8;
312 } else if (CodecNamesEq(name.c_str(), kVp9CodecName)) { 328 } else if (CodecNamesEq(name.c_str(), kVp9CodecName)) {
313 return webrtc::kVideoCodecVP9; 329 return webrtc::kVideoCodecVP9;
314 } else if (CodecNamesEq(name.c_str(), kH264CodecName)) { 330 } else if (CodecNamesEq(name.c_str(), kH264CodecName)) {
315 return webrtc::kVideoCodecH264; 331 return webrtc::kVideoCodecH264;
316 } 332 }
317 return webrtc::kVideoCodecUnknown; 333 return webrtc::kVideoCodecUnknown;
318 } 334 }
319 335
320 bool IsCodecSupported(const std::vector<VideoCodec>& supported_codecs, 336 const VideoCodec* FindMatchingCodec(
321 const VideoCodec& codec) { 337 const std::vector<VideoCodec>& supported_codecs,
322 return std::any_of(supported_codecs.begin(), supported_codecs.end(), 338 const VideoCodec& codec) {
323 [&codec](const VideoCodec& supported_codec) -> bool { 339 for (const VideoCodec& supported_codec : supported_codecs) {
324 return CodecNamesEq(codec.name, supported_codec.name); 340 if (supported_codec.Matches(codec))
325 }); 341 return &supported_codec;
342 }
343 return nullptr;
326 } 344 }
327 345
328 } // namespace cricket 346 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/base/codec.h ('k') | webrtc/media/engine/fakewebrtcvideoengine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698