OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_CAST_NET_RTP_RTP_PACKETIZER_H_ | 5 #ifndef MEDIA_CAST_NET_RTP_RTP_PACKETIZER_H_ |
6 #define MEDIA_CAST_NET_RTP_RTP_PACKETIZER_H_ | 6 #define MEDIA_CAST_NET_RTP_RTP_PACKETIZER_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
11 | 11 |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "media/cast/net/rtp/packet_storage.h" | 13 #include "media/cast/net/rtp/packet_storage.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class TickClock; | 16 class TickClock; |
17 } | 17 } |
18 | 18 |
19 namespace media { | 19 namespace media { |
20 namespace cast { | 20 namespace cast { |
21 | 21 |
22 class PacedSender; | 22 class PacedSender; |
23 | 23 |
24 struct RtpPacketizerConfig { | 24 struct RtpPacketizerConfig { |
25 RtpPacketizerConfig(); | 25 RtpPacketizerConfig(); |
26 ~RtpPacketizerConfig(); | 26 ~RtpPacketizerConfig(); |
27 | 27 |
28 // General. | 28 // General. |
29 int payload_type; | 29 int payload_type; |
30 uint16 max_payload_length; | 30 uint16_t max_payload_length; |
31 uint16 sequence_number; | 31 uint16_t sequence_number; |
32 | 32 |
33 // SSRC. | 33 // SSRC. |
34 unsigned int ssrc; | 34 unsigned int ssrc; |
35 }; | 35 }; |
36 | 36 |
37 // This object is only called from the main cast thread. | 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 | 38 // This class break encoded audio and video frames into packets and add an RTP |
39 // header to each packet. | 39 // header to each packet. |
40 class RtpPacketizer { | 40 class RtpPacketizer { |
41 public: | 41 public: |
42 RtpPacketizer(PacedSender* const transport, | 42 RtpPacketizer(PacedSender* const transport, |
43 PacketStorage* packet_storage, | 43 PacketStorage* packet_storage, |
44 RtpPacketizerConfig rtp_packetizer_config); | 44 RtpPacketizerConfig rtp_packetizer_config); |
45 ~RtpPacketizer(); | 45 ~RtpPacketizer(); |
46 | 46 |
47 void SendFrameAsPackets(const EncodedFrame& frame); | 47 void SendFrameAsPackets(const EncodedFrame& frame); |
48 | 48 |
49 // Return the next sequence number, and increment by one. Enables unique | 49 // Return the next sequence number, and increment by one. Enables unique |
50 // incremental sequence numbers for every packet (including retransmissions). | 50 // incremental sequence numbers for every packet (including retransmissions). |
51 uint16 NextSequenceNumber(); | 51 uint16_t NextSequenceNumber(); |
52 | 52 |
53 size_t send_packet_count() const { return send_packet_count_; } | 53 size_t send_packet_count() const { return send_packet_count_; } |
54 size_t send_octet_count() const { return send_octet_count_; } | 54 size_t send_octet_count() const { return send_octet_count_; } |
55 | 55 |
56 private: | 56 private: |
57 void BuildCommonRTPheader(Packet* packet, bool marker_bit, uint32 time_stamp); | 57 void BuildCommonRTPheader(Packet* packet, |
| 58 bool marker_bit, |
| 59 uint32_t time_stamp); |
58 | 60 |
59 RtpPacketizerConfig config_; | 61 RtpPacketizerConfig config_; |
60 PacedSender* const transport_; // Not owned by this class. | 62 PacedSender* const transport_; // Not owned by this class. |
61 PacketStorage* packet_storage_; | 63 PacketStorage* packet_storage_; |
62 | 64 |
63 uint16 sequence_number_; | 65 uint16_t sequence_number_; |
64 uint32 rtp_timestamp_; | 66 uint32_t rtp_timestamp_; |
65 uint16 packet_id_; | 67 uint16_t packet_id_; |
66 | 68 |
67 size_t send_packet_count_; | 69 size_t send_packet_count_; |
68 size_t send_octet_count_; | 70 size_t send_octet_count_; |
69 }; | 71 }; |
70 | 72 |
71 } // namespace cast | 73 } // namespace cast |
72 } // namespace media | 74 } // namespace media |
73 | 75 |
74 #endif // MEDIA_CAST_NET_RTP_RTP_PACKETIZER_H_ | 76 #endif // MEDIA_CAST_NET_RTP_RTP_PACKETIZER_H_ |
OLD | NEW |