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

Side by Side Diff: media/cast/cast_defines.h

Issue 62843002: Cast: Added support for AES-CTR crypto. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 7 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
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_CAST_DEFINES_H_ 5 #ifndef MEDIA_CAST_CAST_DEFINES_H_
6 #define MEDIA_CAST_CAST_DEFINES_H_ 6 #define MEDIA_CAST_CAST_DEFINES_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 10
(...skipping 28 matching lines...) Expand all
39 kDefaultRtpMaxDelayMs = 100, 39 kDefaultRtpMaxDelayMs = 100,
40 }; 40 };
41 41
42 const uint16 kRtcpCastAllPacketsLost = 0xffff; 42 const uint16 kRtcpCastAllPacketsLost = 0xffff;
43 43
44 const size_t kMinLengthOfRtcp = 8; 44 const size_t kMinLengthOfRtcp = 8;
45 45
46 // Basic RTP header + cast header. 46 // Basic RTP header + cast header.
47 const size_t kMinLengthOfRtp = 12 + 6; 47 const size_t kMinLengthOfRtp = 12 + 6;
48 48
49 const size_t kAesKeySize = 16;
50
49 // Each uint16 represents one packet id within a cast frame. 51 // Each uint16 represents one packet id within a cast frame.
50 typedef std::set<uint16> PacketIdSet; 52 typedef std::set<uint16> PacketIdSet;
51 // Each uint8 represents one cast frame. 53 // Each uint8 represents one cast frame.
52 typedef std::map<uint8, PacketIdSet> MissingFramesAndPacketsMap; 54 typedef std::map<uint8, PacketIdSet> MissingFramesAndPacketsMap;
53 55
54 // TODO(pwestin): Re-factor the functions bellow into a class with static 56 // TODO(pwestin): Re-factor the functions bellow into a class with static
55 // methods. 57 // methods.
56 58
57 // January 1970, in NTP seconds. 59 // January 1970, in NTP seconds.
58 // Network Time Protocol (NTP), which is in seconds relative to 0h UTC on 60 // Network Time Protocol (NTP), which is in seconds relative to 0h UTC on
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 int64 ntp_time_us = static_cast<int64>(ntp_seconds) * 125 int64 ntp_time_us = static_cast<int64>(ntp_seconds) *
124 base::Time::kMicrosecondsPerSecond + 126 base::Time::kMicrosecondsPerSecond +
125 static_cast<int64>(ntp_fractions) / kMagicFractionalUnit; 127 static_cast<int64>(ntp_fractions) / kMagicFractionalUnit;
126 128
127 base::TimeDelta elapsed_since_unix_epoch = 129 base::TimeDelta elapsed_since_unix_epoch =
128 base::TimeDelta::FromMicroseconds(ntp_time_us - 130 base::TimeDelta::FromMicroseconds(ntp_time_us -
129 (kUnixEpochInNtpSeconds * base::Time::kMicrosecondsPerSecond)); 131 (kUnixEpochInNtpSeconds * base::Time::kMicrosecondsPerSecond));
130 return base::TimeTicks::UnixEpoch() + elapsed_since_unix_epoch; 132 return base::TimeTicks::UnixEpoch() + elapsed_since_unix_epoch;
131 } 133 }
132 134
135 inline std::string GetAesNounce(uint32 frame_id, const std::string& iv_mask) {
wtc 2013/11/13 20:57:17 Nit: this function should be documented. Nounce =
pwestin 2013/11/15 19:38:17 Done.
136 std::string aes_ivec(kAesKeySize, 0);
wtc 2013/11/13 20:57:17 What does "ivec" stands for?
pwestin 2013/11/15 19:38:17 Done.
137
138 aes_ivec[11] = frame_id & 0xff;
wtc 2013/11/13 20:57:17 Nit: it may be useful to add a comment to point ou
pwestin 2013/11/15 19:38:17 Done.
139 aes_ivec[10] = (frame_id >> 8) & 0xff;
140 aes_ivec[9] = (frame_id >> 16) & 0xff;
141 aes_ivec[8] = (frame_id >> 24) & 0xff;
142
143 for (size_t i = 0; i < kAesKeySize; ++i) {
wtc 2013/11/13 20:57:17 OK, after reading this function, I am now sure we
pwestin 2013/11/15 19:38:17 Done.
144 aes_ivec[i] ^= iv_mask[i];
145 }
146 return aes_ivec;
147 }
148
133 } // namespace cast 149 } // namespace cast
134 } // namespace media 150 } // namespace media
135 151
136 #endif // MEDIA_CAST_CAST_DEFINES_H_ 152 #endif // MEDIA_CAST_CAST_DEFINES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698