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

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

Issue 2761143002: Support encrypted RTP extensions (RFC 6904) (Closed)
Patch Set: Updated comment. Created 3 years, 7 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
OLDNEW
(Empty)
1 /*
2 * Copyright (c) 2017 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
11 #include <algorithm>
12
13 #include "webrtc/base/gunit.h"
14 #include "webrtc/media/base/fakertp.h"
15
16 void CompareHeaderExtensions(const char* packet1, const char* packet2,
17 const std::vector<int> encrypted_headers, bool expect_equal) {
pthatcher1 2017/05/05 21:26:38 Shouldn't we be passing in sizes with these packet
joachim 2017/05/06 14:52:33 Done.
18 // RTP extension headers are the same.
19 EXPECT_EQ(0, memcmp(packet1 + 12, packet2 + 12, 4));
20 // Check for one-byte header extensions.
21 EXPECT_EQ('\xBE', packet1[12]);
22 EXPECT_EQ('\xDE', packet1[13]);
23 // Determine position and size of extension headers.
24 size_t extension_words = packet1[14] << 8 | packet1[15];
25 const char* extension_data1 = packet1 + 12 + 4;
26 const char* extension_end1 = extension_data1 + extension_words * 4;
27 const char* extension_data2 = packet2 + 12 + 4;
pthatcher1 2017/05/05 21:26:38 It would be a lot nicer to have something in media
joachim 2017/05/06 14:52:33 As this is quite some work to implement including
28 while (extension_data1 < extension_end1) {
29 uint8_t id = (*extension_data1 & 0xf0) >> 4;
30 uint8_t len = (*extension_data1 & 0x0f) +1;
31 extension_data1++;
32 extension_data2++;
33 EXPECT_LE(extension_data1, extension_end1);
34 if (id == 15) {
35 // Finished parsing.
36 break;
37 }
38
39 // The header extension doesn't get encrypted if the id is not in the
40 // list of header extensions to encrypt.
41 if (expect_equal ||
42 std::find(encrypted_headers.begin(), encrypted_headers.end(), id)
43 == encrypted_headers.end()) {
44 EXPECT_EQ(0, memcmp(extension_data1, extension_data2, len));
45 } else {
46 EXPECT_NE(0, memcmp(extension_data1, extension_data2, len));
47 }
48
49 extension_data1 += len;
50 extension_data2 += len;
51 // Skip padding.
52 while (extension_data1 < extension_end1 && *extension_data1 == 0) {
53 extension_data1++;
54 extension_data2++;
55 }
56 }
57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698