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.
5 #ifndef MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_PACKETIZER_RTP_PACKETIZER_H_
6 #define MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_PACKETIZER_RTP_PACKETIZER_H_
12 #include "base/time/time.h"
13 #include "media/cast/transport/rtp_sender/packet_storage/packet_storage.h"
21 struct RtpPacketizerConfig {
22 RtpPacketizerConfig();
23 ~RtpPacketizerConfig();
28 uint16 max_payload_length;
29 uint16 sequence_number;
36 VideoCodec video_codec;
40 AudioCodec audio_codec;
43 // This object is only called from the main cast thread.
44 // This class break encoded audio and video frames into packets and add an RTP
45 // header to each packet.
48 RtpPacketizer(PacedSender* const transport,
49 PacketStorage* packet_storage,
50 RtpPacketizerConfig rtp_packetizer_config);
53 // The video_frame objects ownership is handled by the main cast thread.
54 void IncomingEncodedVideoFrame(const EncodedVideoFrame* video_frame,
55 const base::TimeTicks& capture_time);
57 // The audio_frame objects ownership is handled by the main cast thread.
58 void IncomingEncodedAudioFrame(const EncodedAudioFrame* audio_frame,
59 const base::TimeTicks& recorded_time);
61 bool LastSentTimestamp(base::TimeTicks* time_sent,
62 uint32* rtp_timestamp) const;
64 // Return the next sequence number, and increment by one. Enables unique
65 // incremental sequence numbers for every packet (including retransmissions).
66 uint16 NextSequenceNumber();
68 int send_packets_count() { return send_packets_count_; }
70 size_t send_octet_count() { return send_octet_count_; }
73 void Cast(bool is_key,
75 uint32 reference_frame_id,
77 const std::string& data);
79 void BuildCommonRTPheader(Packet* packet, bool marker_bit, uint32 time_stamp);
81 RtpPacketizerConfig config_;
82 PacedSender* const transport_; // Not owned by this class.
83 PacketStorage* packet_storage_;
85 base::TimeTicks time_last_sent_rtp_timestamp_;
86 uint16 sequence_number_;
87 uint32 rtp_timestamp_;
90 int send_packets_count_;
91 size_t send_octet_count_;
94 } // namespace transport
98 #endif // MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_PACKETIZER_RTP_PACKETIZER_H_