| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MEDIA_CAST_RTP_SENDER_RTP_PACKETIZER_RTP_PACKETIZER_H_ | |
| 6 #define MEDIA_CAST_RTP_SENDER_RTP_PACKETIZER_RTP_PACKETIZER_H_ | |
| 7 | |
| 8 #include <cmath> | |
| 9 #include <list> | |
| 10 #include <map> | |
| 11 | |
| 12 #include "base/time/time.h" | |
| 13 #include "media/cast/rtp_common/rtp_defines.h" | |
| 14 #include "media/cast/rtp_sender/packet_storage/packet_storage.h" | |
| 15 #include "media/cast/rtp_sender/rtp_packetizer/rtp_packetizer_config.h" | |
| 16 | |
| 17 namespace media { | |
| 18 namespace cast { | |
| 19 | |
| 20 class PacedPacketSender; | |
| 21 | |
| 22 // This object is only called from the main cast thread. | |
| 23 // This class break encoded audio and video frames into packets and add an RTP | |
| 24 // header to each packet. | |
| 25 class RtpPacketizer { | |
| 26 public: | |
| 27 RtpPacketizer(PacedPacketSender* transport, | |
| 28 PacketStorage* packet_storage, | |
| 29 RtpPacketizerConfig rtp_packetizer_config); | |
| 30 ~RtpPacketizer(); | |
| 31 | |
| 32 // The video_frame objects ownership is handled by the main cast thread. | |
| 33 void IncomingEncodedVideoFrame(const EncodedVideoFrame* video_frame, | |
| 34 const base::TimeTicks& capture_time); | |
| 35 | |
| 36 // The audio_frame objects ownership is handled by the main cast thread. | |
| 37 void IncomingEncodedAudioFrame(const EncodedAudioFrame* audio_frame, | |
| 38 const base::TimeTicks& recorded_time); | |
| 39 | |
| 40 bool LastSentTimestamp(base::TimeTicks* time_sent, | |
| 41 uint32* rtp_timestamp) const; | |
| 42 | |
| 43 // Return the next sequence number, and increment by one. Enables unique | |
| 44 // incremental sequence numbers for every packet (including retransmissions). | |
| 45 uint16 NextSequenceNumber(); | |
| 46 | |
| 47 int send_packets_count() { return send_packets_count_; } | |
| 48 | |
| 49 size_t send_octet_count() { return send_octet_count_; } | |
| 50 | |
| 51 private: | |
| 52 void Cast(bool is_key, uint32 frame_id, uint32 reference_frame_id, | |
| 53 uint32 timestamp, const std::string& data); | |
| 54 | |
| 55 void BuildCommonRTPheader(std::vector<uint8>* packet, bool marker_bit, | |
| 56 uint32 time_stamp); | |
| 57 | |
| 58 RtpPacketizerConfig config_; | |
| 59 PacedPacketSender* transport_; | |
| 60 PacketStorage* packet_storage_; | |
| 61 | |
| 62 base::TimeTicks time_last_sent_rtp_timestamp_; | |
| 63 uint16 sequence_number_; | |
| 64 uint32 rtp_timestamp_; | |
| 65 uint16 packet_id_; | |
| 66 | |
| 67 int send_packets_count_; | |
| 68 size_t send_octet_count_; | |
| 69 }; | |
| 70 | |
| 71 } // namespace cast | |
| 72 } // namespace media | |
| 73 | |
| 74 #endif // MEDIA_CAST_RTP_SENDER_RTP_PACKETIZER_RTP_PACKETIZER_H_ | |
| OLD | NEW |