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 // Each uint16 represents one packet id within a cast frame.
51 typedef std::set
<uint16
> PacketIdSet
;
52 // Each uint8 represents one cast frame.
53 typedef std::map
<uint8
, PacketIdSet
> MissingFramesAndPacketsMap
;
55 class FrameIdWrapHelperTest
;
57 // TODO(miu): UGLY IN-LINE DEFINITION IN HEADER FILE! Move to appropriate
58 // location, separated into .h and .cc files.
59 class FrameIdWrapHelper
{
62 : largest_frame_id_seen_(kStartFrameId
) {}
64 uint32
MapTo32bitsFrameId(const uint8 over_the_wire_frame_id
) {
65 uint32 ret
= (largest_frame_id_seen_
& ~0xff) | over_the_wire_frame_id
;
66 // Add 1000 to both sides to avoid underflows.
67 if (1000 + ret
- largest_frame_id_seen_
> 1000 + 127) {
69 } else if (1000 + ret
- largest_frame_id_seen_
< 1000 - 128) {
72 if (1000 + ret
- largest_frame_id_seen_
> 1000) {
73 largest_frame_id_seen_
= ret
;
79 friend class FrameIdWrapHelperTest
;
80 static const uint32 kStartFrameId
= UINT32_C(0xffffffff);
82 uint32 largest_frame_id_seen_
;
84 DISALLOW_COPY_AND_ASSIGN(FrameIdWrapHelper
);
90 #endif // MEDIA_CAST_NET_CAST_TRANSPORT_DEFINES_H_