OLD | NEW |
---|---|
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 Loading... | |
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 kAesBlockSize = 16; | |
50 const size_t kAesKeySize = 16; | |
51 | |
49 // Each uint16 represents one packet id within a cast frame. | 52 // Each uint16 represents one packet id within a cast frame. |
50 typedef std::set<uint16> PacketIdSet; | 53 typedef std::set<uint16> PacketIdSet; |
51 // Each uint8 represents one cast frame. | 54 // Each uint8 represents one cast frame. |
52 typedef std::map<uint8, PacketIdSet> MissingFramesAndPacketsMap; | 55 typedef std::map<uint8, PacketIdSet> MissingFramesAndPacketsMap; |
53 | 56 |
54 // TODO(pwestin): Re-factor the functions bellow into a class with static | 57 // TODO(pwestin): Re-factor the functions bellow into a class with static |
55 // methods. | 58 // methods. |
56 | 59 |
57 // January 1970, in NTP seconds. | 60 // January 1970, in NTP seconds. |
58 // Network Time Protocol (NTP), which is in seconds relative to 0h UTC on | 61 // 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 Loading... | |
123 int64 ntp_time_us = static_cast<int64>(ntp_seconds) * | 126 int64 ntp_time_us = static_cast<int64>(ntp_seconds) * |
124 base::Time::kMicrosecondsPerSecond + | 127 base::Time::kMicrosecondsPerSecond + |
125 static_cast<int64>(ntp_fractions) / kMagicFractionalUnit; | 128 static_cast<int64>(ntp_fractions) / kMagicFractionalUnit; |
126 | 129 |
127 base::TimeDelta elapsed_since_unix_epoch = | 130 base::TimeDelta elapsed_since_unix_epoch = |
128 base::TimeDelta::FromMicroseconds(ntp_time_us - | 131 base::TimeDelta::FromMicroseconds(ntp_time_us - |
129 (kUnixEpochInNtpSeconds * base::Time::kMicrosecondsPerSecond)); | 132 (kUnixEpochInNtpSeconds * base::Time::kMicrosecondsPerSecond)); |
130 return base::TimeTicks::UnixEpoch() + elapsed_since_unix_epoch; | 133 return base::TimeTicks::UnixEpoch() + elapsed_since_unix_epoch; |
131 } | 134 } |
132 | 135 |
136 inline std::string GetAesNonce(uint32 frame_id, const std::string& iv_mask) { | |
137 std::string aes_iv_mask(kAesBlockSize, 0); | |
wtc
2013/11/15 20:13:37
This variable should be named just "aes_iv" or "ae
pwestin
2013/11/15 22:11:10
Done.
| |
138 | |
139 // Serializing frame_id in big-endian order (aes_ivec[8] is the most | |
wtc
2013/11/15 20:13:37
aes_ivec => aes_iv or aes_nonce
pwestin
2013/11/15 22:11:10
Done.
| |
140 // significant byte of frame_id). | |
141 aes_iv_mask[11] = frame_id & 0xff; | |
142 aes_iv_mask[10] = (frame_id >> 8) & 0xff; | |
143 aes_iv_mask[9] = (frame_id >> 16) & 0xff; | |
144 aes_iv_mask[8] = (frame_id >> 24) & 0xff; | |
145 | |
146 for (size_t i = 0; i < kAesBlockSize; ++i) { | |
147 aes_iv_mask[i] ^= iv_mask[i]; | |
148 } | |
149 return aes_iv_mask; | |
150 } | |
151 | |
133 } // namespace cast | 152 } // namespace cast |
134 } // namespace media | 153 } // namespace media |
135 | 154 |
136 #endif // MEDIA_CAST_CAST_DEFINES_H_ | 155 #endif // MEDIA_CAST_CAST_DEFINES_H_ |
OLD | NEW |