#ifndef MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_PACKETIZER_RTP_PACKETIZER_H_
#define MEDIA_CAST_TRANSPORT_RTP_SENDER_RTP_PACKETIZER_RTP_PACKETIZER_H_
#include <cmath>
#include <list>
#include <map>
#include "base/time/time.h"
#include "media/cast/transport/rtp_sender/packet_storage/packet_storage.h"
namespace base {
class TickClock;
}
namespace media {
namespace cast {
class LoggingImpl;
namespace transport {
class PacedSender;
struct RtpPacketizerConfig {
RtpPacketizerConfig();
~RtpPacketizerConfig();
bool audio;
int payload_type;
uint16 max_payload_length;
uint16 sequence_number;
int frequency;
unsigned int ssrc;
VideoCodec video_codec;
uint8 channels;
AudioCodec audio_codec;
};
class RtpPacketizer {
public:
RtpPacketizer(PacedSender* const transport,
PacketStorage* packet_storage,
RtpPacketizerConfig rtp_packetizer_config,
base::TickClock* clock,
LoggingImpl* logging);
~RtpPacketizer();
void IncomingEncodedVideoFrame(const EncodedVideoFrame* video_frame,
const base::TimeTicks& capture_time);
void IncomingEncodedAudioFrame(const EncodedAudioFrame* audio_frame,
const base::TimeTicks& recorded_time);
bool LastSentTimestamp(base::TimeTicks* time_sent,
uint32* rtp_timestamp) const;
uint16 NextSequenceNumber();
int send_packets_count() { return send_packets_count_; }
size_t send_octet_count() { return send_octet_count_; }
private:
void Cast(bool is_key,
uint32 frame_id,
uint32 reference_frame_id,
uint32 timestamp,
const std::string& data);
void BuildCommonRTPheader(Packet* packet, bool marker_bit, uint32 time_stamp);
RtpPacketizerConfig config_;
PacedSender* const transport_;
PacketStorage* packet_storage_;
base::TickClock* const clock_;
LoggingImpl* const logging_;
base::TimeTicks time_last_sent_rtp_timestamp_;
uint16 sequence_number_;
uint32 rtp_timestamp_;
uint16 packet_id_;
int send_packets_count_;
size_t send_octet_count_;
};
}
}
}
#endif