OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_TRANSPORT_RTP_SENDER_RTP_PACKETIZER_RTP_PACKETIZER_H_ | 5 #ifndef MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_PACKETIZER_RTP_PACKETIZER_H_ |
6 #define MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_PACKETIZER_RTP_PACKETIZER_H_ | 6 #define MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_PACKETIZER_RTP_PACKETIZER_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // This object is only called from the main cast thread. | 48 // This object is only called from the main cast thread. |
49 // This class break encoded audio and video frames into packets and add an RTP | 49 // This class break encoded audio and video frames into packets and add an RTP |
50 // header to each packet. | 50 // header to each packet. |
51 class RtpPacketizer { | 51 class RtpPacketizer { |
52 public: | 52 public: |
53 RtpPacketizer(PacedSender* const transport, | 53 RtpPacketizer(PacedSender* const transport, |
54 PacketStorage* packet_storage, | 54 PacketStorage* packet_storage, |
55 RtpPacketizerConfig rtp_packetizer_config); | 55 RtpPacketizerConfig rtp_packetizer_config); |
56 ~RtpPacketizer(); | 56 ~RtpPacketizer(); |
57 | 57 |
58 // The video_frame objects ownership is handled by the main cast thread. | 58 void SendFrameAsPackets(const EncodedFrame& frame); |
59 void IncomingEncodedVideoFrame(const EncodedVideoFrame* video_frame, | |
60 const base::TimeTicks& capture_time); | |
61 | |
62 // The audio_frame objects ownership is handled by the main cast thread. | |
63 void IncomingEncodedAudioFrame(const EncodedAudioFrame* audio_frame, | |
64 const base::TimeTicks& recorded_time); | |
65 | 59 |
66 bool LastSentTimestamp(base::TimeTicks* time_sent, | 60 bool LastSentTimestamp(base::TimeTicks* time_sent, |
67 uint32* rtp_timestamp) const; | 61 uint32* rtp_timestamp) const; |
68 | 62 |
69 // Return the next sequence number, and increment by one. Enables unique | 63 // Return the next sequence number, and increment by one. Enables unique |
70 // incremental sequence numbers for every packet (including retransmissions). | 64 // incremental sequence numbers for every packet (including retransmissions). |
71 uint16 NextSequenceNumber(); | 65 uint16 NextSequenceNumber(); |
72 | 66 |
73 int send_packets_count() { return send_packets_count_; } | 67 int send_packets_count() { return send_packets_count_; } |
74 | 68 |
75 size_t send_octet_count() { return send_octet_count_; } | 69 size_t send_octet_count() { return send_octet_count_; } |
76 | 70 |
77 private: | 71 private: |
78 void Cast(bool is_key, | |
79 uint32 frame_id, | |
80 uint32 reference_frame_id, | |
81 uint32 timestamp, | |
82 const std::string& data, | |
83 const base::TimeTicks& capture_time); | |
84 | |
85 void BuildCommonRTPheader(Packet* packet, bool marker_bit, uint32 time_stamp); | 72 void BuildCommonRTPheader(Packet* packet, bool marker_bit, uint32 time_stamp); |
86 | 73 |
87 RtpPacketizerConfig config_; | 74 RtpPacketizerConfig config_; |
88 PacedSender* const transport_; // Not owned by this class. | 75 PacedSender* const transport_; // Not owned by this class. |
89 PacketStorage* packet_storage_; | 76 PacketStorage* packet_storage_; |
90 | 77 |
91 base::TimeTicks time_last_sent_rtp_timestamp_; | 78 base::TimeTicks time_last_sent_rtp_timestamp_; |
92 uint16 sequence_number_; | 79 uint16 sequence_number_; |
93 uint32 rtp_timestamp_; | 80 uint32 rtp_timestamp_; |
94 uint16 packet_id_; | 81 uint16 packet_id_; |
95 | 82 |
96 int send_packets_count_; | 83 int send_packets_count_; |
97 size_t send_octet_count_; | 84 size_t send_octet_count_; |
98 }; | 85 }; |
99 | 86 |
100 } // namespace transport | 87 } // namespace transport |
101 } // namespace cast | 88 } // namespace cast |
102 } // namespace media | 89 } // namespace media |
103 | 90 |
104 #endif // MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_PACKETIZER_RTP_PACKETIZER_H_ | 91 #endif // MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_PACKETIZER_RTP_PACKETIZER_H_ |
OLD | NEW |