#ifndef MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_DEFINES_H_
#define MEDIA_CAST_TRANSPORT_CAST_TRANSPORT_DEFINES_H_
-#include <list>
#include <map>
#include <set>
+#include <string>
#include "base/basictypes.h"
#include "base/time/time.h"
// Each uint8 represents one cast frame.
typedef std::map<uint8, PacketIdSet> MissingFramesAndPacketsMap;
+// Crypto.
+const size_t kAesBlockSize = 16;
+const size_t kAesKeySize = 16;
+
+inline std::string GetAesNonce(uint32 frame_id, const std::string& iv_mask) {
+ std::string aes_nonce(kAesBlockSize, 0);
+
+ // Serializing frame_id in big-endian order (aes_nonce[8] is the most
+ // significant byte of frame_id).
+ aes_nonce[11] = frame_id & 0xff;
+ aes_nonce[10] = (frame_id >> 8) & 0xff;
+ aes_nonce[9] = (frame_id >> 16) & 0xff;
+ aes_nonce[8] = (frame_id >> 24) & 0xff;
+
+ for (size_t i = 0; i < kAesBlockSize; ++i) {
+ aes_nonce[i] ^= iv_mask[i];
+ }
+ return aes_nonce;
+}
+
// Rtcp defines.
enum RtcpPacketTypes {
// Each uint8 represents one cast frame.
typedef std::map<uint8, PacketIdSet> MissingFramesAndPacketsMap;
-
class FrameIdWrapHelper {
public:
FrameIdWrapHelper()
- : first_(true),
- frame_id_wrap_count_(0),
- range_(kLowRange) {}
+ : first_(true), frame_id_wrap_count_(0), range_(kLowRange) {}
uint32 MapTo32bitsFrameId(const uint8 over_the_wire_frame_id) {
if (first_) {
}
private:
- enum Range {
- kLowRange,
- kMiddleRange,
- kHighRange,
- };
+ enum Range { kLowRange, kMiddleRange, kHighRange, };
static const uint8 kLowRangeThreshold = 0x0f;
static const uint8 kHighRangeThreshold = 0xf0;
bool first_;
uint32 frame_id_wrap_count_;
Range range_;
+
+ DISALLOW_COPY_AND_ASSIGN(FrameIdWrapHelper);
};
inline uint32 GetVideoRtpTimestamp(const base::TimeTicks& time_ticks) {