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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_header_extension.cc

Issue 2462663002: Ensure one does not register same rtp header extension with different id (Closed)
Patch Set: 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 | « no previous file | webrtc/video/video_send_stream_tests.cc » ('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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 <assert.h> 11 #include <assert.h>
12 12
13 #include "webrtc/base/checks.h"
13 #include "webrtc/common_types.h" 14 #include "webrtc/common_types.h"
14 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h" 15 #include "webrtc/modules/rtp_rtcp/source/rtp_header_extension.h"
15 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" 16 #include "webrtc/modules/rtp_rtcp/source/rtp_utility.h"
16 17
17 namespace webrtc { 18 namespace webrtc {
18 19
20 constexpr uint8_t RtpHeaderExtensionMap::kInvalidId;
21
19 RtpHeaderExtensionMap::RtpHeaderExtensionMap() { 22 RtpHeaderExtensionMap::RtpHeaderExtensionMap() {
20 } 23 }
21 24
22 RtpHeaderExtensionMap::~RtpHeaderExtensionMap() { 25 RtpHeaderExtensionMap::~RtpHeaderExtensionMap() {
23 Erase(); 26 Erase();
24 } 27 }
25 28
26 void RtpHeaderExtensionMap::Erase() { 29 void RtpHeaderExtensionMap::Erase() {
27 while (!extensionMap_.empty()) { 30 while (!extensionMap_.empty()) {
28 std::map<uint8_t, HeaderExtension*>::iterator it = 31 std::map<uint8_t, HeaderExtension*>::iterator it =
(...skipping 12 matching lines...) Expand all
41 if (it != extensionMap_.end()) { 44 if (it != extensionMap_.end()) {
42 if (it->second->type != type) { 45 if (it->second->type != type) {
43 // An extension is already registered with the same id 46 // An extension is already registered with the same id
44 // but a different type, so return failure. 47 // but a different type, so return failure.
45 return -1; 48 return -1;
46 } 49 }
47 // This extension type is already registered with this id, 50 // This extension type is already registered with this id,
48 // so return success. 51 // so return success.
49 return 0; 52 return 0;
50 } 53 }
54 RTC_DCHECK_EQ(kInvalidId, GetId(type));
51 extensionMap_[id] = new HeaderExtension(type); 55 extensionMap_[id] = new HeaderExtension(type);
52 return 0; 56 return 0;
53 } 57 }
54 58
55 int32_t RtpHeaderExtensionMap::Deregister(const RTPExtensionType type) { 59 int32_t RtpHeaderExtensionMap::Deregister(const RTPExtensionType type) {
56 uint8_t id; 60 uint8_t id;
57 if (GetId(type, &id) != 0) { 61 if (GetId(type, &id) != 0) {
58 return 0; 62 return 0;
59 } 63 }
60 std::map<uint8_t, HeaderExtension*>::iterator it = 64 std::map<uint8_t, HeaderExtension*>::iterator it =
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 assert(map); 146 assert(map);
143 std::map<uint8_t, HeaderExtension*>::const_iterator it = 147 std::map<uint8_t, HeaderExtension*>::const_iterator it =
144 extensionMap_.begin(); 148 extensionMap_.begin();
145 while (it != extensionMap_.end()) { 149 while (it != extensionMap_.end()) {
146 HeaderExtension* extension = it->second; 150 HeaderExtension* extension = it->second;
147 map->Register(extension->type, it->first); 151 map->Register(extension->type, it->first);
148 it++; 152 it++;
149 } 153 }
150 } 154 }
151 } // namespace webrtc 155 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/video/video_send_stream_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698