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

Side by Side Diff: media/cast/transport/cast_transport_defines.h

Issue 138843011: Cast: Adding helper crypto classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile issues Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « media/cast/transport/cast_transport.gyp ('k') | media/cast/transport/transport_audio_sender.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 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_DEFINES_H_ 5 #ifndef MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_DEFINES_H_
6 #define MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_DEFINES_H_ 6 #define MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_DEFINES_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
11 #include <string>
11 12
12 #include "base/basictypes.h" 13 #include "base/basictypes.h"
13 #include "base/time/time.h" 14 #include "base/time/time.h"
14 15
15 namespace media { 16 namespace media {
16 namespace cast { 17 namespace cast {
17 namespace transport { 18 namespace transport {
18 19
19 // TODO(mikhal): Implement and add more types. 20 // TODO(mikhal): Implement and add more types.
20 enum CastTransportStatus { 21 enum CastTransportStatus {
21 TRANSPORT_UNINITIALIZED = 0, 22 TRANSPORT_UNINITIALIZED = 0,
22 TRANSPORT_INITIALIZED, 23 TRANSPORT_INITIALIZED,
23 TRANSPORT_INVALID_CRYPTO_CONFIG, 24 TRANSPORT_INVALID_CRYPTO_CONFIG,
24 TRANSPORT_SOCKET_ERROR 25 TRANSPORT_SOCKET_ERROR
25 }; 26 };
26 27
27 const size_t kMaxIpPacketSize = 1500; 28 const size_t kMaxIpPacketSize = 1500;
28 // Each uint16 represents one packet id within a cast frame. 29 // Each uint16 represents one packet id within a cast frame.
29 typedef std::set<uint16> PacketIdSet; 30 typedef std::set<uint16> PacketIdSet;
30 // Each uint8 represents one cast frame. 31 // Each uint8 represents one cast frame.
31 typedef std::map<uint8, PacketIdSet> MissingFramesAndPacketsMap; 32 typedef std::map<uint8, PacketIdSet> MissingFramesAndPacketsMap;
32 33
34 // Crypto.
35 const size_t kAesBlockSize = 16;
36 const size_t kAesKeySize = 16;
37
38 inline std::string GetAesNonce(uint32 frame_id, const std::string& iv_mask) {
39 std::string aes_nonce(kAesBlockSize, 0);
40
41 // Serializing frame_id in big-endian order (aes_nonce[8] is the most
42 // significant byte of frame_id).
43 aes_nonce[11] = frame_id & 0xff;
44 aes_nonce[10] = (frame_id >> 8) & 0xff;
45 aes_nonce[9] = (frame_id >> 16) & 0xff;
46 aes_nonce[8] = (frame_id >> 24) & 0xff;
47
48 for (size_t i = 0; i < kAesBlockSize; ++i) {
49 aes_nonce[i] ^= iv_mask[i];
50 }
51 return aes_nonce;
52 }
53
33 // Rtcp defines. 54 // Rtcp defines.
34 55
35 enum RtcpPacketTypes { 56 enum RtcpPacketTypes {
36 kPacketTypeLow = 194, // SMPTE time-code mapping. 57 kPacketTypeLow = 194, // SMPTE time-code mapping.
37 kPacketTypeInterArrivalJitterReport = 195, 58 kPacketTypeInterArrivalJitterReport = 195,
38 kPacketTypeSenderReport = 200, 59 kPacketTypeSenderReport = 200,
39 kPacketTypeReceiverReport = 201, 60 kPacketTypeReceiverReport = 201,
40 kPacketTypeSdes = 202, 61 kPacketTypeSdes = 202,
41 kPacketTypeBye = 203, 62 kPacketTypeBye = 203,
42 kPacketTypeApplicationDefined = 204, 63 kPacketTypeApplicationDefined = 204,
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 base::TimeDelta recorded_delta = time_ticks - zero_time; 142 base::TimeDelta recorded_delta = time_ticks - zero_time;
122 // Timestamp is in 90 KHz for video. 143 // Timestamp is in 90 KHz for video.
123 return static_cast<uint32>(recorded_delta.InMilliseconds() * 90); 144 return static_cast<uint32>(recorded_delta.InMilliseconds() * 90);
124 } 145 }
125 146
126 } // namespace transport 147 } // namespace transport
127 } // namespace cast 148 } // namespace cast
128 } // namespace media 149 } // namespace media
129 150
130 #endif // MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_DEFINES_H_ 151 #endif // MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_DEFINES_H_
OLDNEW
« no previous file with comments | « media/cast/transport/cast_transport.gyp ('k') | media/cast/transport/transport_audio_sender.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698