1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_CAST_NET_CAST_TRANSPORT_DEFINES_H_
6 #define MEDIA_CAST_NET_CAST_TRANSPORT_DEFINES_H_
14 #include "base/basictypes.h"
15 #include "base/time/time.h"
20 // TODO(mikhal): Implement and add more types.
21 enum CastTransportStatus {
22 TRANSPORT_AUDIO_UNINITIALIZED = 0,
23 TRANSPORT_VIDEO_UNINITIALIZED,
24 TRANSPORT_AUDIO_INITIALIZED,
25 TRANSPORT_VIDEO_INITIALIZED,
26 TRANSPORT_INVALID_CRYPTO_CONFIG,
27 TRANSPORT_SOCKET_ERROR,
28 CAST_TRANSPORT_STATUS_LAST = TRANSPORT_SOCKET_ERROR
31 const size_t kMaxIpPacketSize = 1500;
32 // Each uint16 represents one packet id within a cast frame.
33 typedef std::set<uint16> PacketIdSet;
34 // Each uint8 represents one cast frame.
35 typedef std::map<uint8, PacketIdSet> MissingFramesAndPacketsMap;
39 enum RtcpPacketFields {
40 kPacketTypeLow = 194, // SMPTE time-code mapping.
41 kPacketTypeSenderReport = 200,
42 kPacketTypeReceiverReport = 201,
43 kPacketTypeApplicationDefined = 204,
44 kPacketTypeGenericRtpFeedback = 205,
45 kPacketTypePayloadSpecific = 206,
47 kPacketTypeHigh = 210, // Port Mapping.
50 enum RtcpPacketField {
56 kRtcpReceiverLog = 0x80000,
59 // Each uint16 represents one packet id within a cast frame.
60 typedef std::set<uint16> PacketIdSet;
61 // Each uint8 represents one cast frame.
62 typedef std::map<uint8, PacketIdSet> MissingFramesAndPacketsMap;
64 class FrameIdWrapHelperTest;
66 // TODO(miu): UGLY IN-LINE DEFINITION IN HEADER FILE! Move to appropriate
67 // location, separated into .h and .cc files.
68 class FrameIdWrapHelper {
71 : largest_frame_id_seen_(kStartFrameId) {}
73 uint32 MapTo32bitsFrameId(const uint8 over_the_wire_frame_id) {
74 uint32 ret = (largest_frame_id_seen_ & ~0xff) | over_the_wire_frame_id;
75 // Add 1000 to both sides to avoid underflows.
76 if (1000 + ret - largest_frame_id_seen_ > 1000 + 127) {
78 } else if (1000 + ret - largest_frame_id_seen_ < 1000 - 128) {
81 if (1000 + ret - largest_frame_id_seen_ > 1000) {
82 largest_frame_id_seen_ = ret;
88 friend class FrameIdWrapHelperTest;
89 static const uint32 kStartFrameId = UINT32_C(0xffffffff);
91 uint32 largest_frame_id_seen_;
93 DISALLOW_COPY_AND_ASSIGN(FrameIdWrapHelper);
96 inline uint32 GetVideoRtpTimestamp(const base::TimeTicks& time_ticks) {
97 base::TimeTicks zero_time;
98 base::TimeDelta recorded_delta = time_ticks - zero_time;
99 // Timestamp is in 90 KHz for video.
100 return static_cast<uint32>(recorded_delta.InMilliseconds() * 90);
106 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_DEFINES_H_