summaryrefslogtreecommitdiffstats
path: root/media/cast/net/rtp/rtp_header_parser.h
blob: fd235c2aa59bdab11e1ae17f3aac403736b295b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Utility parser for rtp packetizer unittests
#ifndef MEDIA_CAST_NET_RTP_RTP_HEADER_PARSER_H_
#define MEDIA_CAST_NET_RTP_RTP_HEADER_PARSER_H_

#include "base/basictypes.h"
#include "media/cast/net/cast_transport_defines.h"

namespace media {
namespace cast {

// TODO(miu): Kill this and use RtpCastHeader instead.
struct RtpCastTestHeader {
  RtpCastTestHeader();
  ~RtpCastTestHeader();
  // Cast specific.
  bool is_key_frame;
  uint32 frame_id;
  uint16 packet_id;
  uint16 max_packet_id;
  bool is_reference;  // Set to true if the previous frame is not available,
                      // and the reference frame id  is available.
  uint32 reference_frame_id;

  // Rtp Generic.
  bool marker;
  uint16 sequence_number;
  uint32 rtp_timestamp;
  uint32 ssrc;
  int payload_type;
  uint8 num_csrcs;
  uint8 audio_num_energy;
  int header_length;
};

// TODO(miu): Kill this and use RtpParser instead.
class RtpHeaderParser {
 public:
  RtpHeaderParser(const uint8* rtpData, size_t rtpDataLength);
  ~RtpHeaderParser();

  bool Parse(RtpCastTestHeader* parsed_packet) const;

 private:
  bool ParseCommon(RtpCastTestHeader* parsed_packet) const;
  bool ParseCast(RtpCastTestHeader* parsed_packet) const;
  const uint8* const rtp_data_begin_;
  size_t length_;

  mutable FrameIdWrapHelper frame_id_wrap_helper_;
  mutable FrameIdWrapHelper reference_frame_id_wrap_helper_;

  DISALLOW_COPY_AND_ASSIGN(RtpHeaderParser);
};

}  // namespace cast
}  // namespace media

#endif  // MEDIA_CAST_NET_RTP_RTP_HEADER_PARSER_H_