Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / media / cast / net / rtp / rtp_packetizer.h
blob034a74a2a50decfec20c0e7b277f616a276f502d
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_RTP_RTP_PACKETIZER_H_
6 #define MEDIA_CAST_NET_RTP_RTP_PACKETIZER_H_
8 #include <cmath>
9 #include <list>
10 #include <map>
12 #include "base/time/time.h"
13 #include "media/cast/net/rtp/packet_storage.h"
15 namespace base {
16 class TickClock;
19 namespace media {
20 namespace cast {
22 class PacedSender;
24 struct RtpPacketizerConfig {
25 RtpPacketizerConfig();
26 ~RtpPacketizerConfig();
28 // General.
29 int payload_type;
30 uint16 max_payload_length;
31 uint16 sequence_number;
33 // SSRC.
34 unsigned int ssrc;
37 // This object is only called from the main cast thread.
38 // This class break encoded audio and video frames into packets and add an RTP
39 // header to each packet.
40 class RtpPacketizer {
41 public:
42 RtpPacketizer(PacedSender* const transport,
43 PacketStorage* packet_storage,
44 RtpPacketizerConfig rtp_packetizer_config);
45 ~RtpPacketizer();
47 void SendFrameAsPackets(const EncodedFrame& frame);
49 // Return the next sequence number, and increment by one. Enables unique
50 // incremental sequence numbers for every packet (including retransmissions).
51 uint16 NextSequenceNumber();
53 size_t send_packet_count() const { return send_packet_count_; }
54 size_t send_octet_count() const { return send_octet_count_; }
56 private:
57 void BuildCommonRTPheader(Packet* packet, bool marker_bit, uint32 time_stamp);
59 RtpPacketizerConfig config_;
60 PacedSender* const transport_; // Not owned by this class.
61 PacketStorage* packet_storage_;
63 uint16 sequence_number_;
64 uint32 rtp_timestamp_;
65 uint16 packet_id_;
67 size_t send_packet_count_;
68 size_t send_octet_count_;
71 } // namespace cast
72 } // namespace media
74 #endif // MEDIA_CAST_NET_RTP_RTP_PACKETIZER_H_