SquashSRS4: Rename SrsRtpPacket2 to SrsRtpPacket.

pull/2363/head
winlin 4 years ago
parent 6a980683f7
commit a1d7fe46c1

@ -182,6 +182,7 @@ The ports used by SRS:
## V4 changes ## V4 changes
* v4.0, 2021-05-15, Rename SrsRtpPacket2 to SrsRtpPacket. 4.0.111
* v4.0, 2021-05-14, RTC: Remove [Object Cache Pool](https://github.com/ossrs/srs/commit/14bfc98122bba369572417c19ebb2a61b373fc45#commitcomment-47655008), no effect. 4.0.110 * v4.0, 2021-05-14, RTC: Remove [Object Cache Pool](https://github.com/ossrs/srs/commit/14bfc98122bba369572417c19ebb2a61b373fc45#commitcomment-47655008), no effect. 4.0.110
* v4.0, 2021-05-14, Change virtual public to public. 4.0.109 * v4.0, 2021-05-14, Change virtual public to public. 4.0.109
* v4.0, 2021-05-14, Refine id and vid for statistic. 4.0.108 * v4.0, 2021-05-14, Refine id and vid for statistic. 4.0.108

@ -77,7 +77,7 @@
#define STREAM_TYPE_AUDIO_PCM 0x9c #define STREAM_TYPE_AUDIO_PCM 0x9c
class SrsConfDirective; class SrsConfDirective;
class SrsRtpPacket; class SrsRtspPacket;
class SrsRtmpClient; class SrsRtmpClient;
class SrsRawH264Stream; class SrsRawH264Stream;
class SrsRawAacStream; class SrsRawAacStream;
@ -108,7 +108,7 @@ class SrsGb28181Caster;
//ps rtp header packet parse //ps rtp header packet parse
class SrsPsRtpPacket: public SrsRtpPacket class SrsPsRtpPacket: public SrsRtspPacket
{ {
public: public:
SrsPsRtpPacket(); SrsPsRtpPacket();

@ -594,7 +594,7 @@ srs_error_t SrsRtcPlayStream::cycle()
} }
// Wait for amount of packets. // Wait for amount of packets.
SrsRtpPacket2* pkt = NULL; SrsRtpPacket* pkt = NULL;
consumer->dump_packet(&pkt); consumer->dump_packet(&pkt);
if (!pkt) { if (!pkt) {
// TODO: FIXME: We should check the quit event. // TODO: FIXME: We should check the quit event.
@ -618,7 +618,7 @@ srs_error_t SrsRtcPlayStream::cycle()
} }
} }
srs_error_t SrsRtcPlayStream::send_packet(SrsRtpPacket2*& pkt) srs_error_t SrsRtcPlayStream::send_packet(SrsRtpPacket*& pkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -1287,7 +1287,7 @@ srs_error_t SrsRtcPublishStream::on_rtp_plaintext(char* plaintext, int nb_plaint
} }
// Allocate packet form cache. // Allocate packet form cache.
SrsRtpPacket2* pkt = new SrsRtpPacket2(); SrsRtpPacket* pkt = new SrsRtpPacket();
// Copy the packet body. // Copy the packet body.
char* p = pkt->wrap(plaintext, nb_plaintext); char* p = pkt->wrap(plaintext, nb_plaintext);
@ -1305,7 +1305,7 @@ srs_error_t SrsRtcPublishStream::on_rtp_plaintext(char* plaintext, int nb_plaint
return err; return err;
} }
srs_error_t SrsRtcPublishStream::do_on_rtp_plaintext(SrsRtpPacket2*& pkt, SrsBuffer* buf) srs_error_t SrsRtcPublishStream::do_on_rtp_plaintext(SrsRtpPacket*& pkt, SrsBuffer* buf)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -1389,7 +1389,7 @@ srs_error_t SrsRtcPublishStream::check_send_nacks()
return err; return err;
} }
void SrsRtcPublishStream::on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtpPacketPayloadType* ppt) void SrsRtcPublishStream::on_before_decode_payload(SrsRtpPacket* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtspPacketPayloadType* ppt)
{ {
// No payload, ignore. // No payload, ignore.
if (buf->empty()) { if (buf->empty()) {
@ -2503,7 +2503,7 @@ void SrsRtcConnection::simulate_player_drop_packet(SrsRtpHeader* h, int nn_bytes
nn_simulate_player_nack_drop--; nn_simulate_player_nack_drop--;
} }
srs_error_t SrsRtcConnection::do_send_packet(SrsRtpPacket2* pkt) srs_error_t SrsRtcConnection::do_send_packet(SrsRtpPacket* pkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;

@ -53,7 +53,7 @@ class SrsRtcServer;
class SrsRtcConnection; class SrsRtcConnection;
class SrsSharedPtrMessage; class SrsSharedPtrMessage;
class SrsRtcStream; class SrsRtcStream;
class SrsRtpPacket2; class SrsRtpPacket;
class ISrsCodec; class ISrsCodec;
class SrsRtpNackForReceiver; class SrsRtpNackForReceiver;
class SrsRtpIncommingVideoFrame; class SrsRtpIncommingVideoFrame;
@ -266,7 +266,7 @@ public:
public: public:
virtual srs_error_t cycle(); virtual srs_error_t cycle();
private: private:
srs_error_t send_packet(SrsRtpPacket2*& pkt); srs_error_t send_packet(SrsRtpPacket*& pkt);
public: public:
// Directly set the status of track, generally for init to set the default value. // Directly set the status of track, generally for init to set the default value.
void set_all_tracks_status(bool status); void set_all_tracks_status(bool status);
@ -310,7 +310,7 @@ private:
}; };
// A RTC publish stream, client push and publish stream to SRS. // A RTC publish stream, client push and publish stream to SRS.
class SrsRtcPublishStream : public ISrsRtpPacketDecodeHandler class SrsRtcPublishStream : public ISrsRtspPacketDecodeHandler
, public ISrsRtcPublishStream, public ISrsRtcPLIWorkerHandler , public ISrsRtcPublishStream, public ISrsRtcPLIWorkerHandler
{ {
private: private:
@ -367,11 +367,11 @@ private:
// @remark We copy the plaintext, user should free it. // @remark We copy the plaintext, user should free it.
srs_error_t on_rtp_plaintext(char* plaintext, int nb_plaintext); srs_error_t on_rtp_plaintext(char* plaintext, int nb_plaintext);
private: private:
srs_error_t do_on_rtp_plaintext(SrsRtpPacket2*& pkt, SrsBuffer* buf); srs_error_t do_on_rtp_plaintext(SrsRtpPacket*& pkt, SrsBuffer* buf);
public: public:
srs_error_t check_send_nacks(); srs_error_t check_send_nacks();
public: public:
virtual void on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtpPacketPayloadType* ppt); virtual void on_before_decode_payload(SrsRtpPacket* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtspPacketPayloadType* ppt);
private: private:
srs_error_t send_periodic_twcc(); srs_error_t send_periodic_twcc();
public: public:
@ -547,7 +547,7 @@ public:
// Simulate the NACK to drop nn packets. // Simulate the NACK to drop nn packets.
void simulate_nack_drop(int nn); void simulate_nack_drop(int nn);
void simulate_player_drop_packet(SrsRtpHeader* h, int nn_bytes); void simulate_player_drop_packet(SrsRtpHeader* h, int nn_bytes);
srs_error_t do_send_packet(SrsRtpPacket2* pkt); srs_error_t do_send_packet(SrsRtpPacket* pkt);
// Directly set the status of play track, generally for init to set the default value. // Directly set the status of play track, generally for init to set the default value.
void set_all_tracks_status(std::string stream_uri, bool is_publish, bool status); void set_all_tracks_status(std::string stream_uri, bool is_publish, bool status);
private: private:
@ -579,7 +579,7 @@ public:
// When stop publish by RTC. // When stop publish by RTC.
virtual void on_stop_publish(SrsRtcConnection* session, SrsRtcPublishStream* publisher, SrsRequest* req) = 0; virtual void on_stop_publish(SrsRtcConnection* session, SrsRtcPublishStream* publisher, SrsRequest* req) = 0;
// When got RTP plaintext packet. // When got RTP plaintext packet.
virtual srs_error_t on_rtp_packet(SrsRtcConnection* session, SrsRtcPublishStream* publisher, SrsRequest* req, SrsRtpPacket2* pkt) = 0; virtual srs_error_t on_rtp_packet(SrsRtcConnection* session, SrsRtcPublishStream* publisher, SrsRequest* req, SrsRtpPacket* pkt) = 0;
// When before play by RTC. (wait source to ready in cascade scenario) // When before play by RTC. (wait source to ready in cascade scenario)
virtual srs_error_t on_before_play(SrsRtcConnection* session, SrsRequest* req) = 0; virtual srs_error_t on_before_play(SrsRtcConnection* session, SrsRequest* req) = 0;
// When start player by RTC. // When start player by RTC.

@ -44,7 +44,7 @@ class SrsRtpFrameBuffer;
class SrsRtpDecodingState; class SrsRtpDecodingState;
class SrsGb28181RtmpMuxer; class SrsGb28181RtmpMuxer;
class VCMPacket; class VCMPacket;
class SrsRtpPacket2; class SrsRtpPacket;
///jittbuffer ///jittbuffer

@ -47,14 +47,14 @@ SrsRtpRingBuffer::SrsRtpRingBuffer(int capacity)
capacity_ = (uint16_t)capacity; capacity_ = (uint16_t)capacity;
initialized_ = false; initialized_ = false;
queue_ = new SrsRtpPacket2*[capacity_]; queue_ = new SrsRtpPacket*[capacity_];
memset(queue_, 0, sizeof(SrsRtpPacket2*) * capacity); memset(queue_, 0, sizeof(SrsRtpPacket*) * capacity);
} }
SrsRtpRingBuffer::~SrsRtpRingBuffer() SrsRtpRingBuffer::~SrsRtpRingBuffer()
{ {
for (int i = 0; i < capacity_; ++i) { for (int i = 0; i < capacity_; ++i) {
SrsRtpPacket2* pkt = queue_[i]; SrsRtpPacket* pkt = queue_[i];
srs_freep(pkt); srs_freep(pkt);
} }
srs_freepa(queue_); srs_freepa(queue_);
@ -77,9 +77,9 @@ void SrsRtpRingBuffer::advance_to(uint16_t seq)
begin = seq; begin = seq;
} }
void SrsRtpRingBuffer::set(uint16_t at, SrsRtpPacket2* pkt) void SrsRtpRingBuffer::set(uint16_t at, SrsRtpPacket* pkt)
{ {
SrsRtpPacket2* p = queue_[at % capacity_]; SrsRtpPacket* p = queue_[at % capacity_];
srs_freep(p); srs_freep(p);
queue_[at % capacity_] = pkt; queue_[at % capacity_] = pkt;
@ -143,7 +143,7 @@ bool SrsRtpRingBuffer::update(uint16_t seq, uint16_t& nack_first, uint16_t& nack
return true; return true;
} }
SrsRtpPacket2* SrsRtpRingBuffer::at(uint16_t seq) { SrsRtpPacket* SrsRtpRingBuffer::at(uint16_t seq) {
return queue_[seq % capacity_]; return queue_[seq % capacity_];
} }
@ -165,7 +165,7 @@ void SrsRtpRingBuffer::clear_histroy(uint16_t seq)
{ {
// TODO FIXME Did not consider loopback // TODO FIXME Did not consider loopback
for (uint16_t i = 0; i < capacity_; i++) { for (uint16_t i = 0; i < capacity_; i++) {
SrsRtpPacket2* p = queue_[i]; SrsRtpPacket* p = queue_[i];
if (p && p->header.get_sequence() < seq) { if (p && p->header.get_sequence() < seq) {
srs_freep(p); srs_freep(p);
queue_[i] = NULL; queue_[i] = NULL;
@ -176,7 +176,7 @@ void SrsRtpRingBuffer::clear_histroy(uint16_t seq)
void SrsRtpRingBuffer::clear_all_histroy() void SrsRtpRingBuffer::clear_all_histroy()
{ {
for (uint16_t i = 0; i < capacity_; i++) { for (uint16_t i = 0; i < capacity_; i++) {
SrsRtpPacket2* p = queue_[i]; SrsRtpPacket* p = queue_[i];
if (p) { if (p) {
srs_freep(p); srs_freep(p);
queue_[i] = NULL; queue_[i] = NULL;

@ -33,7 +33,7 @@
#include <srs_kernel_rtc_rtp.hpp> #include <srs_kernel_rtc_rtp.hpp>
#include <srs_kernel_rtc_rtcp.hpp> #include <srs_kernel_rtc_rtcp.hpp>
class SrsRtpPacket2; class SrsRtpPacket;
class SrsRtpQueue; class SrsRtpQueue;
class SrsRtpRingBuffer; class SrsRtpRingBuffer;
@ -51,7 +51,7 @@ private:
// Capacity of the ring-buffer. // Capacity of the ring-buffer.
uint16_t capacity_; uint16_t capacity_;
// Ring bufer. // Ring bufer.
SrsRtpPacket2** queue_; SrsRtpPacket** queue_;
// Increase one when uint16 flip back, for get_extended_highest_sequence. // Increase one when uint16 flip back, for get_extended_highest_sequence.
uint64_t nn_seq_flip_backs; uint64_t nn_seq_flip_backs;
// Whether initialized, because we use uint16 so we can't use -1. // Whether initialized, because we use uint16 so we can't use -1.
@ -74,7 +74,7 @@ public:
// Move the low position of buffer to seq. // Move the low position of buffer to seq.
void advance_to(uint16_t seq); void advance_to(uint16_t seq);
// Free the packet at position. // Free the packet at position.
void set(uint16_t at, SrsRtpPacket2* pkt); void set(uint16_t at, SrsRtpPacket* pkt);
void remove(uint16_t at); void remove(uint16_t at);
// The highest sequence number, calculate the flip back base. // The highest sequence number, calculate the flip back base.
uint32_t get_extended_highest_sequence(); uint32_t get_extended_highest_sequence();
@ -82,7 +82,7 @@ public:
// @return If false, the seq is too old. // @return If false, the seq is too old.
bool update(uint16_t seq, uint16_t& nack_first, uint16_t& nack_last); bool update(uint16_t seq, uint16_t& nack_first, uint16_t& nack_last);
// Get the packet by seq. // Get the packet by seq.
SrsRtpPacket2* at(uint16_t seq); SrsRtpPacket* at(uint16_t seq);
public: public:
// TODO: FIXME: Refine it? // TODO: FIXME: Refine it?
void notify_nack_list_full(); void notify_nack_list_full();

@ -175,9 +175,9 @@ SrsRtcConsumer::~SrsRtcConsumer()
{ {
source->on_consumer_destroy(this); source->on_consumer_destroy(this);
vector<SrsRtpPacket2*>::iterator it; vector<SrsRtpPacket*>::iterator it;
for (it = queue.begin(); it != queue.end(); ++it) { for (it = queue.begin(); it != queue.end(); ++it) {
SrsRtpPacket2* pkt = *it; SrsRtpPacket* pkt = *it;
srs_freep(pkt); srs_freep(pkt);
} }
@ -189,7 +189,7 @@ void SrsRtcConsumer::update_source_id()
should_update_source_id = true; should_update_source_id = true;
} }
srs_error_t SrsRtcConsumer::enqueue(SrsRtpPacket2* pkt) srs_error_t SrsRtcConsumer::enqueue(SrsRtpPacket* pkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -206,7 +206,7 @@ srs_error_t SrsRtcConsumer::enqueue(SrsRtpPacket2* pkt)
return err; return err;
} }
srs_error_t SrsRtcConsumer::dump_packet(SrsRtpPacket2** ppkt) srs_error_t SrsRtcConsumer::dump_packet(SrsRtpPacket** ppkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -574,7 +574,7 @@ void SrsRtcStream::set_publish_stream(ISrsRtcPublishStream* v)
publish_stream_ = v; publish_stream_ = v;
} }
srs_error_t SrsRtcStream::on_rtp(SrsRtpPacket2* pkt) srs_error_t SrsRtcStream::on_rtp(SrsRtpPacket* pkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -848,8 +848,8 @@ srs_error_t SrsRtcFromRtmpBridger::transcode(SrsAudioFrame* audio)
for (std::vector<SrsAudioFrame*>::iterator it = out_audios.begin(); it != out_audios.end(); ++it) { for (std::vector<SrsAudioFrame*>::iterator it = out_audios.begin(); it != out_audios.end(); ++it) {
SrsAudioFrame* out_audio = *it; SrsAudioFrame* out_audio = *it;
SrsRtpPacket2* pkt = new SrsRtpPacket2(); SrsRtpPacket* pkt = new SrsRtpPacket();
SrsAutoFree(SrsRtpPacket2, pkt); SrsAutoFree(SrsRtpPacket, pkt);
if ((err = package_opus(out_audio, pkt)) != srs_success) { if ((err = package_opus(out_audio, pkt)) != srs_success) {
err = srs_error_wrap(err, "package opus"); err = srs_error_wrap(err, "package opus");
@ -867,7 +867,7 @@ srs_error_t SrsRtcFromRtmpBridger::transcode(SrsAudioFrame* audio)
return err; return err;
} }
srs_error_t SrsRtcFromRtmpBridger::package_opus(SrsAudioFrame* audio, SrsRtpPacket2* pkt) srs_error_t SrsRtcFromRtmpBridger::package_opus(SrsAudioFrame* audio, SrsRtpPacket* pkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -879,7 +879,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_opus(SrsAudioFrame* audio, SrsRtpPack
pkt->header.set_timestamp(audio->dts * 48); pkt->header.set_timestamp(audio->dts * 48);
SrsRtpRawPayload* raw = new SrsRtpRawPayload(); SrsRtpRawPayload* raw = new SrsRtpRawPayload();
pkt->set_payload(raw, SrsRtpPacketPayloadTypeRaw); pkt->set_payload(raw, SrsRtspPacketPayloadTypeRaw);
srs_assert(audio->nb_samples == 1); srs_assert(audio->nb_samples == 1);
raw->payload = pkt->wrap(audio->samples[0].bytes, audio->samples[0].size); raw->payload = pkt->wrap(audio->samples[0].bytes, audio->samples[0].size);
@ -911,8 +911,8 @@ srs_error_t SrsRtcFromRtmpBridger::on_video(SrsSharedPtrMessage* msg)
// Well, for each IDR, we append a SPS/PPS before it, which is packaged in STAP-A. // Well, for each IDR, we append a SPS/PPS before it, which is packaged in STAP-A.
if (has_idr) { if (has_idr) {
SrsRtpPacket2* pkt = new SrsRtpPacket2(); SrsRtpPacket* pkt = new SrsRtpPacket();
SrsAutoFree(SrsRtpPacket2, pkt); SrsAutoFree(SrsRtpPacket, pkt);
if ((err = package_stap_a(source_, msg, pkt)) != srs_success) { if ((err = package_stap_a(source_, msg, pkt)) != srs_success) {
return srs_error_wrap(err, "package stap-a"); return srs_error_wrap(err, "package stap-a");
@ -924,7 +924,7 @@ srs_error_t SrsRtcFromRtmpBridger::on_video(SrsSharedPtrMessage* msg)
} }
// If merge Nalus, we pcakges all NALUs(samples) as one NALU, in a RTP or FUA packet. // If merge Nalus, we pcakges all NALUs(samples) as one NALU, in a RTP or FUA packet.
vector<SrsRtpPacket2*> pkts; vector<SrsRtpPacket*> pkts;
if (merge_nalus && nn_samples > 1) { if (merge_nalus && nn_samples > 1) {
if ((err = package_nalus(msg, samples, pkts)) != srs_success) { if ((err = package_nalus(msg, samples, pkts)) != srs_success) {
return srs_error_wrap(err, "package nalus as one"); return srs_error_wrap(err, "package nalus as one");
@ -989,7 +989,7 @@ srs_error_t SrsRtcFromRtmpBridger::filter(SrsSharedPtrMessage* msg, SrsFormat* f
return err; return err;
} }
srs_error_t SrsRtcFromRtmpBridger::package_stap_a(SrsRtcStream* source, SrsSharedPtrMessage* msg, SrsRtpPacket2* pkt) srs_error_t SrsRtcFromRtmpBridger::package_stap_a(SrsRtcStream* source, SrsSharedPtrMessage* msg, SrsRtpPacket* pkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -1014,7 +1014,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_stap_a(SrsRtcStream* source, SrsShare
pkt->header.set_timestamp(msg->timestamp * 90); pkt->header.set_timestamp(msg->timestamp * 90);
SrsRtpSTAPPayload* stap = new SrsRtpSTAPPayload(); SrsRtpSTAPPayload* stap = new SrsRtpSTAPPayload();
pkt->set_payload(stap, SrsRtpPacketPayloadTypeSTAP); pkt->set_payload(stap, SrsRtspPacketPayloadTypeSTAP);
uint8_t header = sps[0]; uint8_t header = sps[0];
stap->nri = (SrsAvcNaluType)header; stap->nri = (SrsAvcNaluType)header;
@ -1048,7 +1048,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_stap_a(SrsRtcStream* source, SrsShare
return err; return err;
} }
srs_error_t SrsRtcFromRtmpBridger::package_nalus(SrsSharedPtrMessage* msg, const vector<SrsSample*>& samples, vector<SrsRtpPacket2*>& pkts) srs_error_t SrsRtcFromRtmpBridger::package_nalus(SrsSharedPtrMessage* msg, const vector<SrsSample*>& samples, vector<SrsRtpPacket*>& pkts)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -1084,7 +1084,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_nalus(SrsSharedPtrMessage* msg, const
if (nn_bytes < kRtpMaxPayloadSize) { if (nn_bytes < kRtpMaxPayloadSize) {
// Package NALUs in a single RTP packet. // Package NALUs in a single RTP packet.
SrsRtpPacket2* pkt = new SrsRtpPacket2(); SrsRtpPacket* pkt = new SrsRtpPacket();
pkts.push_back(pkt); pkts.push_back(pkt);
pkt->header.set_payload_type(kVideoPayloadType); pkt->header.set_payload_type(kVideoPayloadType);
@ -1093,7 +1093,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_nalus(SrsSharedPtrMessage* msg, const
pkt->nalu_type = (SrsAvcNaluType)first_nalu_type; pkt->nalu_type = (SrsAvcNaluType)first_nalu_type;
pkt->header.set_sequence(video_sequence++); pkt->header.set_sequence(video_sequence++);
pkt->header.set_timestamp(msg->timestamp * 90); pkt->header.set_timestamp(msg->timestamp * 90);
pkt->set_payload(raw, SrsRtpPacketPayloadTypeNALU); pkt->set_payload(raw, SrsRtspPacketPayloadTypeNALU);
pkt->wrap(msg); pkt->wrap(msg);
} else { } else {
// We must free it, should never use RTP packets to free it, // We must free it, should never use RTP packets to free it,
@ -1118,7 +1118,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_nalus(SrsSharedPtrMessage* msg, const
return srs_error_wrap(err, "read samples %d bytes, left %d, total %d", packet_size, nb_left, nn_bytes); return srs_error_wrap(err, "read samples %d bytes, left %d, total %d", packet_size, nb_left, nn_bytes);
} }
SrsRtpPacket2* pkt = new SrsRtpPacket2(); SrsRtpPacket* pkt = new SrsRtpPacket();
pkts.push_back(pkt); pkts.push_back(pkt);
pkt->header.set_payload_type(kVideoPayloadType); pkt->header.set_payload_type(kVideoPayloadType);
@ -1133,7 +1133,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_nalus(SrsSharedPtrMessage* msg, const
fua->start = bool(i == 0); fua->start = bool(i == 0);
fua->end = bool(i == num_of_packet - 1); fua->end = bool(i == num_of_packet - 1);
pkt->set_payload(fua, SrsRtpPacketPayloadTypeFUA); pkt->set_payload(fua, SrsRtspPacketPayloadTypeFUA);
pkt->wrap(msg); pkt->wrap(msg);
nb_left -= packet_size; nb_left -= packet_size;
@ -1144,11 +1144,11 @@ srs_error_t SrsRtcFromRtmpBridger::package_nalus(SrsSharedPtrMessage* msg, const
} }
// Single NAL Unit Packet @see https://tools.ietf.org/html/rfc6184#section-5.6 // Single NAL Unit Packet @see https://tools.ietf.org/html/rfc6184#section-5.6
srs_error_t SrsRtcFromRtmpBridger::package_single_nalu(SrsSharedPtrMessage* msg, SrsSample* sample, vector<SrsRtpPacket2*>& pkts) srs_error_t SrsRtcFromRtmpBridger::package_single_nalu(SrsSharedPtrMessage* msg, SrsSample* sample, vector<SrsRtpPacket*>& pkts)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
SrsRtpPacket2* pkt = new SrsRtpPacket2(); SrsRtpPacket* pkt = new SrsRtpPacket();
pkts.push_back(pkt); pkts.push_back(pkt);
pkt->header.set_payload_type(kVideoPayloadType); pkt->header.set_payload_type(kVideoPayloadType);
@ -1158,7 +1158,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_single_nalu(SrsSharedPtrMessage* msg,
pkt->header.set_timestamp(msg->timestamp * 90); pkt->header.set_timestamp(msg->timestamp * 90);
SrsRtpRawPayload* raw = new SrsRtpRawPayload(); SrsRtpRawPayload* raw = new SrsRtpRawPayload();
pkt->set_payload(raw, SrsRtpPacketPayloadTypeRaw); pkt->set_payload(raw, SrsRtspPacketPayloadTypeRaw);
raw->payload = sample->bytes; raw->payload = sample->bytes;
raw->nn_payload = sample->size; raw->nn_payload = sample->size;
@ -1168,7 +1168,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_single_nalu(SrsSharedPtrMessage* msg,
return err; return err;
} }
srs_error_t SrsRtcFromRtmpBridger::package_fu_a(SrsSharedPtrMessage* msg, SrsSample* sample, int fu_payload_size, vector<SrsRtpPacket2*>& pkts) srs_error_t SrsRtcFromRtmpBridger::package_fu_a(SrsSharedPtrMessage* msg, SrsSample* sample, int fu_payload_size, vector<SrsRtpPacket*>& pkts)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -1181,7 +1181,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_fu_a(SrsSharedPtrMessage* msg, SrsSam
for (int i = 0; i < num_of_packet; ++i) { for (int i = 0; i < num_of_packet; ++i) {
int packet_size = srs_min(nb_left, fu_payload_size); int packet_size = srs_min(nb_left, fu_payload_size);
SrsRtpPacket2* pkt = new SrsRtpPacket2(); SrsRtpPacket* pkt = new SrsRtpPacket();
pkts.push_back(pkt); pkts.push_back(pkt);
pkt->header.set_payload_type(kVideoPayloadType); pkt->header.set_payload_type(kVideoPayloadType);
@ -1191,7 +1191,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_fu_a(SrsSharedPtrMessage* msg, SrsSam
pkt->header.set_timestamp(msg->timestamp * 90); pkt->header.set_timestamp(msg->timestamp * 90);
SrsRtpFUAPayload2* fua = new SrsRtpFUAPayload2(); SrsRtpFUAPayload2* fua = new SrsRtpFUAPayload2();
pkt->set_payload(fua, SrsRtpPacketPayloadTypeFUA2); pkt->set_payload(fua, SrsRtspPacketPayloadTypeFUA2);
fua->nri = (SrsAvcNaluType)header; fua->nri = (SrsAvcNaluType)header;
fua->nalu_type = (SrsAvcNaluType)nal_type; fua->nalu_type = (SrsAvcNaluType)nal_type;
@ -1210,13 +1210,13 @@ srs_error_t SrsRtcFromRtmpBridger::package_fu_a(SrsSharedPtrMessage* msg, SrsSam
return err; return err;
} }
srs_error_t SrsRtcFromRtmpBridger::consume_packets(vector<SrsRtpPacket2*>& pkts) srs_error_t SrsRtcFromRtmpBridger::consume_packets(vector<SrsRtpPacket*>& pkts)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
// TODO: FIXME: Consume a range of packets. // TODO: FIXME: Consume a range of packets.
for (int i = 0; i < (int)pkts.size(); i++) { for (int i = 0; i < (int)pkts.size(); i++) {
SrsRtpPacket2* pkt = pkts[i]; SrsRtpPacket* pkt = pkts[i];
if ((err = source_->on_rtp(pkt)) != srs_success) { if ((err = source_->on_rtp(pkt)) != srs_success) {
err = srs_error_wrap(err, "consume sps/pps"); err = srs_error_wrap(err, "consume sps/pps");
break; break;
@ -1224,7 +1224,7 @@ srs_error_t SrsRtcFromRtmpBridger::consume_packets(vector<SrsRtpPacket2*>& pkts)
} }
for (int i = 0; i < (int)pkts.size(); i++) { for (int i = 0; i < (int)pkts.size(); i++) {
SrsRtpPacket2* pkt = pkts[i]; SrsRtpPacket* pkt = pkts[i];
srs_freep(pkt); srs_freep(pkt);
} }
@ -1288,7 +1288,7 @@ srs_error_t SrsRtmpFromRtcBridger::on_publish()
return err; return err;
} }
srs_error_t SrsRtmpFromRtcBridger::on_rtp(SrsRtpPacket2 *pkt) srs_error_t SrsRtmpFromRtcBridger::on_rtp(SrsRtpPacket *pkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -1311,7 +1311,7 @@ void SrsRtmpFromRtcBridger::on_unpublish()
source_->on_unpublish(); source_->on_unpublish();
} }
srs_error_t SrsRtmpFromRtcBridger::trancode_audio(SrsRtpPacket2 *pkt) srs_error_t SrsRtmpFromRtcBridger::trancode_audio(SrsRtpPacket *pkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -1377,12 +1377,12 @@ void SrsRtmpFromRtcBridger::packet_aac(SrsCommonMessage* audio, char* data, int
audio->size = rtmp_len; audio->size = rtmp_len;
} }
srs_error_t SrsRtmpFromRtcBridger::packet_video(SrsRtpPacket2* src) srs_error_t SrsRtmpFromRtcBridger::packet_video(SrsRtpPacket* src)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
// TODO: Only copy when need // TODO: Only copy when need
SrsRtpPacket2* pkt = src->copy(); SrsRtpPacket* pkt = src->copy();
if (pkt->is_keyframe()) { if (pkt->is_keyframe()) {
return packet_video_key_frame(pkt); return packet_video_key_frame(pkt);
@ -1415,7 +1415,7 @@ srs_error_t SrsRtmpFromRtcBridger::packet_video(SrsRtpPacket2* src)
return err; return err;
} }
srs_error_t SrsRtmpFromRtcBridger::packet_video_key_frame(SrsRtpPacket2* pkt) srs_error_t SrsRtmpFromRtcBridger::packet_video_key_frame(SrsRtpPacket* pkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -1519,7 +1519,7 @@ srs_error_t SrsRtmpFromRtcBridger::packet_video_rtmp(const uint16_t start, const
for (uint16_t i = 0; i < cnt; ++i) { for (uint16_t i = 0; i < cnt; ++i) {
uint16_t sn = start + i; uint16_t sn = start + i;
uint16_t index = cache_index(sn); uint16_t index = cache_index(sn);
SrsRtpPacket2* pkt = cache_video_pkts_[index].pkt; SrsRtpPacket* pkt = cache_video_pkts_[index].pkt;
// calculate nalu len // calculate nalu len
SrsRtpFUAPayload2* fua_payload = dynamic_cast<SrsRtpFUAPayload2*>(pkt->payload()); SrsRtpFUAPayload2* fua_payload = dynamic_cast<SrsRtpFUAPayload2*>(pkt->payload());
if (fua_payload) { if (fua_payload) {
@ -1547,7 +1547,7 @@ srs_error_t SrsRtmpFromRtcBridger::packet_video_rtmp(const uint16_t start, const
} }
SrsCommonMessage rtmp; SrsCommonMessage rtmp;
SrsRtpPacket2* header = cache_video_pkts_[cache_index(start)].pkt; SrsRtpPacket* header = cache_video_pkts_[cache_index(start)].pkt;
rtmp.header.initialize_video(nb_payload, header->header.get_timestamp() / 90, 1); rtmp.header.initialize_video(nb_payload, header->header.get_timestamp() / 90, 1);
rtmp.create_payload(nb_payload); rtmp.create_payload(nb_payload);
rtmp.size = nb_payload; rtmp.size = nb_payload;
@ -1566,7 +1566,7 @@ srs_error_t SrsRtmpFromRtcBridger::packet_video_rtmp(const uint16_t start, const
int nalu_len = 0; int nalu_len = 0;
for (uint16_t i = 0; i < cnt; ++i) { for (uint16_t i = 0; i < cnt; ++i) {
uint16_t index = cache_index((start + i)); uint16_t index = cache_index((start + i));
SrsRtpPacket2* pkt = cache_video_pkts_[index].pkt; SrsRtpPacket* pkt = cache_video_pkts_[index].pkt;
cache_video_pkts_[index].in_use = false; cache_video_pkts_[index].in_use = false;
cache_video_pkts_[index].pkt = NULL; cache_video_pkts_[index].pkt = NULL;
cache_video_pkts_[index].ts = 0; cache_video_pkts_[index].ts = 0;
@ -1682,7 +1682,7 @@ bool SrsRtmpFromRtcBridger::check_frame_complete(const uint16_t start, const uin
uint16_t fu_e_c = 0; uint16_t fu_e_c = 0;
for (uint16_t i = 0; i < cnt; ++i) { for (uint16_t i = 0; i < cnt; ++i) {
int index = cache_index((start + i)); int index = cache_index((start + i));
SrsRtpPacket2* pkt = cache_video_pkts_[index].pkt; SrsRtpPacket* pkt = cache_video_pkts_[index].pkt;
SrsRtpFUAPayload2* fua_payload = dynamic_cast<SrsRtpFUAPayload2*>(pkt->payload()); SrsRtpFUAPayload2* fua_payload = dynamic_cast<SrsRtpFUAPayload2*>(pkt->payload());
if (fua_payload) { if (fua_payload) {
if (fua_payload->start) { if (fua_payload->start) {
@ -2262,11 +2262,11 @@ std::string SrsRtcRecvTrack::get_track_id()
return track_desc_->id_; return track_desc_->id_;
} }
srs_error_t SrsRtcRecvTrack::on_nack(SrsRtpPacket2** ppkt) srs_error_t SrsRtcRecvTrack::on_nack(SrsRtpPacket** ppkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
SrsRtpPacket2* pkt = *ppkt; SrsRtpPacket* pkt = *ppkt;
uint16_t seq = pkt->header.get_sequence(); uint16_t seq = pkt->header.get_sequence();
SrsRtpNackInfo* nack_info = nack_receiver_->find(seq); SrsRtpNackInfo* nack_info = nack_receiver_->find(seq);
if (nack_info) { if (nack_info) {
@ -2317,7 +2317,7 @@ SrsRtcAudioRecvTrack::~SrsRtcAudioRecvTrack()
{ {
} }
void SrsRtcAudioRecvTrack::on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtpPacketPayloadType* ppt) void SrsRtcAudioRecvTrack::on_before_decode_payload(SrsRtpPacket* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtspPacketPayloadType* ppt)
{ {
// No payload, ignore. // No payload, ignore.
if (buf->empty()) { if (buf->empty()) {
@ -2325,10 +2325,10 @@ void SrsRtcAudioRecvTrack::on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffe
} }
*ppayload = new SrsRtpRawPayload(); *ppayload = new SrsRtpRawPayload();
*ppt = SrsRtpPacketPayloadTypeRaw; *ppt = SrsRtspPacketPayloadTypeRaw;
} }
srs_error_t SrsRtcAudioRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket2* pkt) srs_error_t SrsRtcAudioRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket* pkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -2362,7 +2362,7 @@ SrsRtcVideoRecvTrack::~SrsRtcVideoRecvTrack()
{ {
} }
void SrsRtcVideoRecvTrack::on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtpPacketPayloadType* ppt) void SrsRtcVideoRecvTrack::on_before_decode_payload(SrsRtpPacket* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtspPacketPayloadType* ppt)
{ {
// No payload, ignore. // No payload, ignore.
if (buf->empty()) { if (buf->empty()) {
@ -2374,17 +2374,17 @@ void SrsRtcVideoRecvTrack::on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffe
if (v == kStapA) { if (v == kStapA) {
*ppayload = new SrsRtpSTAPPayload(); *ppayload = new SrsRtpSTAPPayload();
*ppt = SrsRtpPacketPayloadTypeSTAP; *ppt = SrsRtspPacketPayloadTypeSTAP;
} else if (v == kFuA) { } else if (v == kFuA) {
*ppayload = new SrsRtpFUAPayload2(); *ppayload = new SrsRtpFUAPayload2();
*ppt = SrsRtpPacketPayloadTypeFUA2; *ppt = SrsRtspPacketPayloadTypeFUA2;
} else { } else {
*ppayload = new SrsRtpRawPayload(); *ppayload = new SrsRtpRawPayload();
*ppt = SrsRtpPacketPayloadTypeRaw; *ppt = SrsRtspPacketPayloadTypeRaw;
} }
} }
srs_error_t SrsRtcVideoRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket2* pkt) srs_error_t SrsRtcVideoRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket* pkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -2446,9 +2446,9 @@ bool SrsRtcSendTrack::has_ssrc(uint32_t ssrc)
return track_desc_->has_ssrc(ssrc); return track_desc_->has_ssrc(ssrc);
} }
SrsRtpPacket2* SrsRtcSendTrack::fetch_rtp_packet(uint16_t seq) SrsRtpPacket* SrsRtcSendTrack::fetch_rtp_packet(uint16_t seq)
{ {
SrsRtpPacket2* pkt = rtp_queue_->at(seq); SrsRtpPacket* pkt = rtp_queue_->at(seq);
if (pkt == NULL) { if (pkt == NULL) {
return pkt; return pkt;
@ -2489,11 +2489,11 @@ std::string SrsRtcSendTrack::get_track_id()
return track_desc_->id_; return track_desc_->id_;
} }
srs_error_t SrsRtcSendTrack::on_nack(SrsRtpPacket2** ppkt) srs_error_t SrsRtcSendTrack::on_nack(SrsRtpPacket** ppkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
SrsRtpPacket2* pkt = *ppkt; SrsRtpPacket* pkt = *ppkt;
uint16_t seq = pkt->header.get_sequence(); uint16_t seq = pkt->header.get_sequence();
// insert into video_queue and audio_queue // insert into video_queue and audio_queue
@ -2516,7 +2516,7 @@ srs_error_t SrsRtcSendTrack::on_recv_nack(const vector<uint16_t>& lost_seqs)
for(int i = 0; i < (int)lost_seqs.size(); ++i) { for(int i = 0; i < (int)lost_seqs.size(); ++i) {
uint16_t seq = lost_seqs.at(i); uint16_t seq = lost_seqs.at(i);
SrsRtpPacket2* pkt = fetch_rtp_packet(seq); SrsRtpPacket* pkt = fetch_rtp_packet(seq);
if (pkt == NULL) { if (pkt == NULL) {
continue; continue;
} }
@ -2545,7 +2545,7 @@ SrsRtcAudioSendTrack::~SrsRtcAudioSendTrack()
{ {
} }
srs_error_t SrsRtcAudioSendTrack::on_rtp(SrsRtpPacket2* pkt) srs_error_t SrsRtcAudioSendTrack::on_rtp(SrsRtpPacket* pkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -2573,7 +2573,7 @@ srs_error_t SrsRtcAudioSendTrack::on_rtp(SrsRtpPacket2* pkt)
return err; return err;
} }
srs_error_t SrsRtcAudioSendTrack::on_rtcp(SrsRtpPacket2* pkt) srs_error_t SrsRtcAudioSendTrack::on_rtcp(SrsRtpPacket* pkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
// process rtcp // process rtcp
@ -2589,7 +2589,7 @@ SrsRtcVideoSendTrack::~SrsRtcVideoSendTrack()
{ {
} }
srs_error_t SrsRtcVideoSendTrack::on_rtp(SrsRtpPacket2* pkt) srs_error_t SrsRtcVideoSendTrack::on_rtp(SrsRtpPacket* pkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -2617,7 +2617,7 @@ srs_error_t SrsRtcVideoSendTrack::on_rtp(SrsRtpPacket2* pkt)
return err; return err;
} }
srs_error_t SrsRtcVideoSendTrack::on_rtcp(SrsRtpPacket2* pkt) srs_error_t SrsRtcVideoSendTrack::on_rtcp(SrsRtpPacket* pkt)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
// process rtcp // process rtcp

@ -46,7 +46,7 @@ class SrsMessageArray;
class SrsRtcStream; class SrsRtcStream;
class SrsRtcFromRtmpBridger; class SrsRtcFromRtmpBridger;
class SrsAudioTranscoder; class SrsAudioTranscoder;
class SrsRtpPacket2; class SrsRtpPacket;
class SrsSample; class SrsSample;
class SrsRtcStreamDescription; class SrsRtcStreamDescription;
class SrsRtcTrackDescription; class SrsRtcTrackDescription;
@ -88,7 +88,7 @@ class SrsRtcConsumer
{ {
private: private:
SrsRtcStream* source; SrsRtcStream* source;
std::vector<SrsRtpPacket2*> queue; std::vector<SrsRtpPacket*> queue;
// when source id changed, notice all consumers // when source id changed, notice all consumers
bool should_update_source_id; bool should_update_source_id;
// The cond wait for mw. // The cond wait for mw.
@ -107,9 +107,9 @@ public:
virtual void update_source_id(); virtual void update_source_id();
// Put RTP packet into queue. // Put RTP packet into queue.
// @note We do not drop packet here, but drop it in sender. // @note We do not drop packet here, but drop it in sender.
srs_error_t enqueue(SrsRtpPacket2* pkt); srs_error_t enqueue(SrsRtpPacket* pkt);
// For RTC, we only got one packet, because there is not many packets in queue. // For RTC, we only got one packet, because there is not many packets in queue.
virtual srs_error_t dump_packet(SrsRtpPacket2** ppkt); virtual srs_error_t dump_packet(SrsRtpPacket** ppkt);
// Wait for at-least some messages incoming in queue. // Wait for at-least some messages incoming in queue.
virtual void wait(int nb_msgs); virtual void wait(int nb_msgs);
public: public:
@ -170,7 +170,7 @@ public:
virtual ~ISrsRtcSourceBridger(); virtual ~ISrsRtcSourceBridger();
public: public:
virtual srs_error_t on_publish() = 0; virtual srs_error_t on_publish() = 0;
virtual srs_error_t on_rtp(SrsRtpPacket2 *pkt) = 0; virtual srs_error_t on_rtp(SrsRtpPacket *pkt) = 0;
virtual void on_unpublish() = 0; virtual void on_unpublish() = 0;
}; };
@ -248,7 +248,7 @@ public:
ISrsRtcPublishStream* publish_stream(); ISrsRtcPublishStream* publish_stream();
void set_publish_stream(ISrsRtcPublishStream* v); void set_publish_stream(ISrsRtcPublishStream* v);
// Consume the shared RTP packet, user must free it. // Consume the shared RTP packet, user must free it.
srs_error_t on_rtp(SrsRtpPacket2* pkt); srs_error_t on_rtp(SrsRtpPacket* pkt);
// Set and get stream description for souce // Set and get stream description for souce
bool has_stream_desc(); bool has_stream_desc();
void set_stream_desc(SrsRtcStreamDescription* stream_desc); void set_stream_desc(SrsRtcStreamDescription* stream_desc);
@ -287,16 +287,16 @@ public:
virtual srs_error_t on_audio(SrsSharedPtrMessage* msg); virtual srs_error_t on_audio(SrsSharedPtrMessage* msg);
private: private:
srs_error_t transcode(SrsAudioFrame* audio); srs_error_t transcode(SrsAudioFrame* audio);
srs_error_t package_opus(SrsAudioFrame* audio, SrsRtpPacket2* pkt); srs_error_t package_opus(SrsAudioFrame* audio, SrsRtpPacket* pkt);
public: public:
virtual srs_error_t on_video(SrsSharedPtrMessage* msg); virtual srs_error_t on_video(SrsSharedPtrMessage* msg);
private: private:
srs_error_t filter(SrsSharedPtrMessage* msg, SrsFormat* format, bool& has_idr, std::vector<SrsSample*>& samples); srs_error_t filter(SrsSharedPtrMessage* msg, SrsFormat* format, bool& has_idr, std::vector<SrsSample*>& samples);
srs_error_t package_stap_a(SrsRtcStream* source, SrsSharedPtrMessage* msg, SrsRtpPacket2* pkt); srs_error_t package_stap_a(SrsRtcStream* source, SrsSharedPtrMessage* msg, SrsRtpPacket* pkt);
srs_error_t package_nalus(SrsSharedPtrMessage* msg, const std::vector<SrsSample*>& samples, std::vector<SrsRtpPacket2*>& pkts); srs_error_t package_nalus(SrsSharedPtrMessage* msg, const std::vector<SrsSample*>& samples, std::vector<SrsRtpPacket*>& pkts);
srs_error_t package_single_nalu(SrsSharedPtrMessage* msg, SrsSample* sample, std::vector<SrsRtpPacket2*>& pkts); srs_error_t package_single_nalu(SrsSharedPtrMessage* msg, SrsSample* sample, std::vector<SrsRtpPacket*>& pkts);
srs_error_t package_fu_a(SrsSharedPtrMessage* msg, SrsSample* sample, int fu_payload_size, std::vector<SrsRtpPacket2*>& pkts); srs_error_t package_fu_a(SrsSharedPtrMessage* msg, SrsSample* sample, int fu_payload_size, std::vector<SrsRtpPacket*>& pkts);
srs_error_t consume_packets(std::vector<SrsRtpPacket2*>& pkts); srs_error_t consume_packets(std::vector<SrsRtpPacket*>& pkts);
}; };
class SrsRtmpFromRtcBridger : public ISrsRtcSourceBridger class SrsRtmpFromRtcBridger : public ISrsRtcSourceBridger
@ -315,7 +315,7 @@ private:
bool in_use; bool in_use;
uint16_t sn; uint16_t sn;
uint32_t ts; uint32_t ts;
SrsRtpPacket2* pkt; SrsRtpPacket* pkt;
}; };
const static uint16_t s_cache_size = 512; const static uint16_t s_cache_size = 512;
RtcPacketCache cache_video_pkts_[s_cache_size]; RtcPacketCache cache_video_pkts_[s_cache_size];
@ -329,13 +329,13 @@ public:
srs_error_t initialize(SrsRequest* r); srs_error_t initialize(SrsRequest* r);
public: public:
virtual srs_error_t on_publish(); virtual srs_error_t on_publish();
virtual srs_error_t on_rtp(SrsRtpPacket2 *pkt); virtual srs_error_t on_rtp(SrsRtpPacket *pkt);
virtual void on_unpublish(); virtual void on_unpublish();
private: private:
srs_error_t trancode_audio(SrsRtpPacket2 *pkt); srs_error_t trancode_audio(SrsRtpPacket *pkt);
void packet_aac(SrsCommonMessage* audio, char* data, int len, uint32_t pts, bool is_header); void packet_aac(SrsCommonMessage* audio, char* data, int len, uint32_t pts, bool is_header);
srs_error_t packet_video(SrsRtpPacket2* pkt); srs_error_t packet_video(SrsRtpPacket* pkt);
srs_error_t packet_video_key_frame(SrsRtpPacket2* pkt); srs_error_t packet_video_key_frame(SrsRtpPacket* pkt);
srs_error_t packet_video_rtmp(const uint16_t start, const uint16_t end); srs_error_t packet_video_rtmp(const uint16_t start, const uint16_t end);
int32_t find_next_lost_sn(uint16_t current_sn, uint16_t& end_sn); int32_t find_next_lost_sn(uint16_t current_sn, uint16_t& end_sn);
void clear_cached_video(); void clear_cached_video();
@ -554,35 +554,35 @@ public:
public: public:
// Note that we can set the pkt to NULL to avoid copy, for example, if the NACK cache the pkt and // Note that we can set the pkt to NULL to avoid copy, for example, if the NACK cache the pkt and
// set to NULL, nack nerver copy it but set the pkt to NULL. // set to NULL, nack nerver copy it but set the pkt to NULL.
srs_error_t on_nack(SrsRtpPacket2** ppkt); srs_error_t on_nack(SrsRtpPacket** ppkt);
public: public:
virtual srs_error_t on_rtp(SrsRtcStream* source, SrsRtpPacket2* pkt) = 0; virtual srs_error_t on_rtp(SrsRtcStream* source, SrsRtpPacket* pkt) = 0;
virtual srs_error_t check_send_nacks() = 0; virtual srs_error_t check_send_nacks() = 0;
protected: protected:
virtual srs_error_t do_check_send_nacks(uint32_t& timeout_nacks); virtual srs_error_t do_check_send_nacks(uint32_t& timeout_nacks);
}; };
class SrsRtcAudioRecvTrack : public SrsRtcRecvTrack, public ISrsRtpPacketDecodeHandler class SrsRtcAudioRecvTrack : public SrsRtcRecvTrack, public ISrsRtspPacketDecodeHandler
{ {
public: public:
SrsRtcAudioRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc); SrsRtcAudioRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc);
virtual ~SrsRtcAudioRecvTrack(); virtual ~SrsRtcAudioRecvTrack();
public: public:
virtual void on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtpPacketPayloadType* ppt); virtual void on_before_decode_payload(SrsRtpPacket* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtspPacketPayloadType* ppt);
public: public:
virtual srs_error_t on_rtp(SrsRtcStream* source, SrsRtpPacket2* pkt); virtual srs_error_t on_rtp(SrsRtcStream* source, SrsRtpPacket* pkt);
virtual srs_error_t check_send_nacks(); virtual srs_error_t check_send_nacks();
}; };
class SrsRtcVideoRecvTrack : public SrsRtcRecvTrack, public ISrsRtpPacketDecodeHandler class SrsRtcVideoRecvTrack : public SrsRtcRecvTrack, public ISrsRtspPacketDecodeHandler
{ {
public: public:
SrsRtcVideoRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* stream_descs); SrsRtcVideoRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* stream_descs);
virtual ~SrsRtcVideoRecvTrack(); virtual ~SrsRtcVideoRecvTrack();
public: public:
virtual void on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtpPacketPayloadType* ppt); virtual void on_before_decode_payload(SrsRtpPacket* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtspPacketPayloadType* ppt);
public: public:
virtual srs_error_t on_rtp(SrsRtcStream* source, SrsRtpPacket2* pkt); virtual srs_error_t on_rtp(SrsRtcStream* source, SrsRtpPacket* pkt);
virtual srs_error_t check_send_nacks(); virtual srs_error_t check_send_nacks();
}; };
@ -608,17 +608,17 @@ public:
// SrsRtcSendTrack::set_nack_no_copy // SrsRtcSendTrack::set_nack_no_copy
void set_nack_no_copy(bool v) { nack_no_copy_ = v; } void set_nack_no_copy(bool v) { nack_no_copy_ = v; }
bool has_ssrc(uint32_t ssrc); bool has_ssrc(uint32_t ssrc);
SrsRtpPacket2* fetch_rtp_packet(uint16_t seq); SrsRtpPacket* fetch_rtp_packet(uint16_t seq);
bool set_track_status(bool active); bool set_track_status(bool active);
bool get_track_status(); bool get_track_status();
std::string get_track_id(); std::string get_track_id();
public: public:
// Note that we can set the pkt to NULL to avoid copy, for example, if the NACK cache the pkt and // Note that we can set the pkt to NULL to avoid copy, for example, if the NACK cache the pkt and
// set to NULL, nack nerver copy it but set the pkt to NULL. // set to NULL, nack nerver copy it but set the pkt to NULL.
srs_error_t on_nack(SrsRtpPacket2** ppkt); srs_error_t on_nack(SrsRtpPacket** ppkt);
public: public:
virtual srs_error_t on_rtp(SrsRtpPacket2* pkt) = 0; virtual srs_error_t on_rtp(SrsRtpPacket* pkt) = 0;
virtual srs_error_t on_rtcp(SrsRtpPacket2* pkt) = 0; virtual srs_error_t on_rtcp(SrsRtpPacket* pkt) = 0;
virtual srs_error_t on_recv_nack(const std::vector<uint16_t>& lost_seqs); virtual srs_error_t on_recv_nack(const std::vector<uint16_t>& lost_seqs);
}; };
@ -628,8 +628,8 @@ public:
SrsRtcAudioSendTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc); SrsRtcAudioSendTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc);
virtual ~SrsRtcAudioSendTrack(); virtual ~SrsRtcAudioSendTrack();
public: public:
virtual srs_error_t on_rtp(SrsRtpPacket2* pkt); virtual srs_error_t on_rtp(SrsRtpPacket* pkt);
virtual srs_error_t on_rtcp(SrsRtpPacket2* pkt); virtual srs_error_t on_rtcp(SrsRtpPacket* pkt);
}; };
class SrsRtcVideoSendTrack : public SrsRtcSendTrack class SrsRtcVideoSendTrack : public SrsRtcSendTrack
@ -638,8 +638,8 @@ public:
SrsRtcVideoSendTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc); SrsRtcVideoSendTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc);
virtual ~SrsRtcVideoSendTrack(); virtual ~SrsRtcVideoSendTrack();
public: public:
virtual srs_error_t on_rtp(SrsRtpPacket2* pkt); virtual srs_error_t on_rtp(SrsRtpPacket* pkt);
virtual srs_error_t on_rtcp(SrsRtpPacket2* pkt); virtual srs_error_t on_rtcp(SrsRtpPacket* pkt);
}; };
class SrsRtcSSRCGenerator class SrsRtcSSRCGenerator

@ -53,7 +53,7 @@ SrsRtpConn::SrsRtpConn(SrsRtspConn* r, int p, int sid)
stream_id = sid; stream_id = sid;
// TODO: support listen at <[ip:]port> // TODO: support listen at <[ip:]port>
listener = new SrsUdpListener(this, srs_any_address_for_listener(), p); listener = new SrsUdpListener(this, srs_any_address_for_listener(), p);
cache = new SrsRtpPacket(); cache = new SrsRtspPacket();
pprint = SrsPithyPrint::create_caster(); pprint = SrsPithyPrint::create_caster();
} }
@ -83,14 +83,14 @@ srs_error_t SrsRtpConn::on_udp_packet(const sockaddr* from, const int fromlen, c
if (true) { if (true) {
SrsBuffer stream(buf, nb_buf); SrsBuffer stream(buf, nb_buf);
SrsRtpPacket pkt; SrsRtspPacket pkt;
if ((err = pkt.decode(&stream)) != srs_success) { if ((err = pkt.decode(&stream)) != srs_success) {
return srs_error_wrap(err, "decode"); return srs_error_wrap(err, "decode");
} }
if (pkt.chunked) { if (pkt.chunked) {
if (!cache) { if (!cache) {
cache = new SrsRtpPacket(); cache = new SrsRtspPacket();
} }
cache->copy(&pkt); cache->copy(&pkt);
cache->payload->append(pkt.payload->bytes(), pkt.payload->length()); cache->payload->append(pkt.payload->bytes(), pkt.payload->length());
@ -106,7 +106,7 @@ srs_error_t SrsRtpConn::on_udp_packet(const sockaddr* from, const int fromlen, c
} }
} else { } else {
srs_freep(cache); srs_freep(cache);
cache = new SrsRtpPacket(); cache = new SrsRtspPacket();
cache->reap(&pkt); cache->reap(&pkt);
} }
} }
@ -119,7 +119,7 @@ srs_error_t SrsRtpConn::on_udp_packet(const sockaddr* from, const int fromlen, c
} }
// always free it. // always free it.
SrsAutoFree(SrsRtpPacket, cache); SrsAutoFree(SrsRtspPacket, cache);
err = rtsp->on_rtp_packet(cache, stream_id); err = rtsp->on_rtp_packet(cache, stream_id);
if (err != srs_success) { if (err != srs_success) {
@ -380,7 +380,7 @@ srs_error_t SrsRtspConn::do_cycle()
return err; return err;
} }
srs_error_t SrsRtspConn::on_rtp_packet(SrsRtpPacket* pkt, int stream_id) srs_error_t SrsRtspConn::on_rtp_packet(SrsRtspPacket* pkt, int stream_id)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -438,7 +438,7 @@ srs_error_t SrsRtspConn::cycle()
return err; return err;
} }
srs_error_t SrsRtspConn::on_rtp_video(SrsRtpPacket* pkt, int64_t dts, int64_t pts) srs_error_t SrsRtspConn::on_rtp_video(SrsRtspPacket* pkt, int64_t dts, int64_t pts)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -457,7 +457,7 @@ srs_error_t SrsRtspConn::on_rtp_video(SrsRtpPacket* pkt, int64_t dts, int64_t pt
return err; return err;
} }
srs_error_t SrsRtspConn::on_rtp_audio(SrsRtpPacket* pkt, int64_t dts) srs_error_t SrsRtspConn::on_rtp_audio(SrsRtspPacket* pkt, int64_t dts)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -476,7 +476,7 @@ srs_error_t SrsRtspConn::on_rtp_audio(SrsRtpPacket* pkt, int64_t dts)
return err; return err;
} }
srs_error_t SrsRtspConn::kickoff_audio_cache(SrsRtpPacket* pkt, int64_t dts) srs_error_t SrsRtspConn::kickoff_audio_cache(SrsRtspPacket* pkt, int64_t dts)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;

@ -39,7 +39,7 @@ class SrsRtspConn;
class SrsRtspStack; class SrsRtspStack;
class SrsRtspCaster; class SrsRtspCaster;
class SrsConfDirective; class SrsConfDirective;
class SrsRtpPacket; class SrsRtspPacket;
class SrsRequest; class SrsRequest;
class SrsStSocket; class SrsStSocket;
class SrsRtmpClient; class SrsRtmpClient;
@ -60,7 +60,7 @@ private:
SrsPithyPrint* pprint; SrsPithyPrint* pprint;
SrsUdpListener* listener; SrsUdpListener* listener;
SrsRtspConn* rtsp; SrsRtspConn* rtsp;
SrsRtpPacket* cache; SrsRtspPacket* cache;
int stream_id; int stream_id;
int _port; int _port;
public: public:
@ -153,14 +153,14 @@ private:
virtual srs_error_t do_cycle(); virtual srs_error_t do_cycle();
// internal methods // internal methods
public: public:
virtual srs_error_t on_rtp_packet(SrsRtpPacket* pkt, int stream_id); virtual srs_error_t on_rtp_packet(SrsRtspPacket* pkt, int stream_id);
// Interface ISrsOneCycleThreadHandler // Interface ISrsOneCycleThreadHandler
public: public:
virtual srs_error_t cycle(); virtual srs_error_t cycle();
private: private:
virtual srs_error_t on_rtp_video(SrsRtpPacket* pkt, int64_t dts, int64_t pts); virtual srs_error_t on_rtp_video(SrsRtspPacket* pkt, int64_t dts, int64_t pts);
virtual srs_error_t on_rtp_audio(SrsRtpPacket* pkt, int64_t dts); virtual srs_error_t on_rtp_audio(SrsRtspPacket* pkt, int64_t dts);
virtual srs_error_t kickoff_audio_cache(SrsRtpPacket* pkt, int64_t dts); virtual srs_error_t kickoff_audio_cache(SrsRtspPacket* pkt, int64_t dts);
private: private:
virtual srs_error_t write_sequence_header(); virtual srs_error_t write_sequence_header();
virtual srs_error_t write_h264_sps_pps(uint32_t dts, uint32_t pts); virtual srs_error_t write_h264_sps_pps(uint32_t dts, uint32_t pts);

@ -26,6 +26,6 @@
#define VERSION_MAJOR 4 #define VERSION_MAJOR 4
#define VERSION_MINOR 0 #define VERSION_MINOR 0
#define VERSION_REVISION 110 #define VERSION_REVISION 111
#endif #endif

@ -760,18 +760,18 @@ ISrsRtpPayloader::~ISrsRtpPayloader()
{ {
} }
ISrsRtpPacketDecodeHandler::ISrsRtpPacketDecodeHandler() ISrsRtspPacketDecodeHandler::ISrsRtspPacketDecodeHandler()
{ {
} }
ISrsRtpPacketDecodeHandler::~ISrsRtpPacketDecodeHandler() ISrsRtspPacketDecodeHandler::~ISrsRtspPacketDecodeHandler()
{ {
} }
SrsRtpPacket2::SrsRtpPacket2() SrsRtpPacket::SrsRtpPacket()
{ {
payload_ = NULL; payload_ = NULL;
payload_type_ = SrsRtpPacketPayloadTypeUnknown; payload_type_ = SrsRtspPacketPayloadTypeUnknown;
shared_buffer_ = NULL; shared_buffer_ = NULL;
actual_buffer_size_ = 0; actual_buffer_size_ = 0;
@ -783,13 +783,13 @@ SrsRtpPacket2::SrsRtpPacket2()
++_srs_pps_objs_rtps->sugar; ++_srs_pps_objs_rtps->sugar;
} }
SrsRtpPacket2::~SrsRtpPacket2() SrsRtpPacket::~SrsRtpPacket()
{ {
srs_freep(payload_); srs_freep(payload_);
srs_freep(shared_buffer_); srs_freep(shared_buffer_);
} }
char* SrsRtpPacket2::wrap(int size) char* SrsRtpPacket::wrap(int size)
{ {
// The buffer size is larger or equals to the size of packet. // The buffer size is larger or equals to the size of packet.
actual_buffer_size_ = size; actual_buffer_size_ = size;
@ -814,14 +814,14 @@ char* SrsRtpPacket2::wrap(int size)
return shared_buffer_->payload; return shared_buffer_->payload;
} }
char* SrsRtpPacket2::wrap(char* data, int size) char* SrsRtpPacket::wrap(char* data, int size)
{ {
char* buf = wrap(size); char* buf = wrap(size);
memcpy(buf, data, size); memcpy(buf, data, size);
return buf; return buf;
} }
char* SrsRtpPacket2::wrap(SrsSharedPtrMessage* msg) char* SrsRtpPacket::wrap(SrsSharedPtrMessage* msg)
{ {
// Generally, the wrap(msg) is used for RTMP to RTC, which is not generated by RTC, // Generally, the wrap(msg) is used for RTMP to RTC, which is not generated by RTC,
// so we do not recycle the msg. It's ok to directly free the msg, event the msg is // so we do not recycle the msg. It's ok to directly free the msg, event the msg is
@ -836,9 +836,9 @@ char* SrsRtpPacket2::wrap(SrsSharedPtrMessage* msg)
return msg->payload; return msg->payload;
} }
SrsRtpPacket2* SrsRtpPacket2::copy() SrsRtpPacket* SrsRtpPacket::copy()
{ {
SrsRtpPacket2* cp = new SrsRtpPacket2(); SrsRtpPacket* cp = new SrsRtpPacket();
// We got packet from cache, the payload and message MUST be NULL, // We got packet from cache, the payload and message MUST be NULL,
// because we had clear it in recycle. // because we had clear it in recycle.
@ -861,7 +861,7 @@ SrsRtpPacket2* SrsRtpPacket2::copy()
return cp; return cp;
} }
void SrsRtpPacket2::set_padding(int size) void SrsRtpPacket::set_padding(int size)
{ {
header.set_padding(size); header.set_padding(size);
if (cached_payload_size) { if (cached_payload_size) {
@ -869,7 +869,7 @@ void SrsRtpPacket2::set_padding(int size)
} }
} }
void SrsRtpPacket2::add_padding(int size) void SrsRtpPacket::add_padding(int size)
{ {
header.set_padding(header.get_padding() + size); header.set_padding(header.get_padding() + size);
if (cached_payload_size) { if (cached_payload_size) {
@ -877,22 +877,22 @@ void SrsRtpPacket2::add_padding(int size)
} }
} }
void SrsRtpPacket2::set_decode_handler(ISrsRtpPacketDecodeHandler* h) void SrsRtpPacket::set_decode_handler(ISrsRtspPacketDecodeHandler* h)
{ {
decode_handler = h; decode_handler = h;
} }
bool SrsRtpPacket2::is_audio() bool SrsRtpPacket::is_audio()
{ {
return frame_type == SrsFrameTypeAudio; return frame_type == SrsFrameTypeAudio;
} }
void SrsRtpPacket2::set_extension_types(SrsRtpExtensionTypes* v) void SrsRtpPacket::set_extension_types(SrsRtpExtensionTypes* v)
{ {
return header.set_extensions(v); return header.set_extensions(v);
} }
uint64_t SrsRtpPacket2::nb_bytes() uint64_t SrsRtpPacket::nb_bytes()
{ {
if (!cached_payload_size) { if (!cached_payload_size) {
int nn_payload = (payload_? payload_->nb_bytes():0); int nn_payload = (payload_? payload_->nb_bytes():0);
@ -901,7 +901,7 @@ uint64_t SrsRtpPacket2::nb_bytes()
return cached_payload_size; return cached_payload_size;
} }
srs_error_t SrsRtpPacket2::encode(SrsBuffer* buf) srs_error_t SrsRtpPacket::encode(SrsBuffer* buf)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -925,7 +925,7 @@ srs_error_t SrsRtpPacket2::encode(SrsBuffer* buf)
return err; return err;
} }
srs_error_t SrsRtpPacket2::decode(SrsBuffer* buf) srs_error_t SrsRtpPacket::decode(SrsBuffer* buf)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -949,7 +949,7 @@ srs_error_t SrsRtpPacket2::decode(SrsBuffer* buf)
// By default, we always use the RAW payload. // By default, we always use the RAW payload.
if (!payload_) { if (!payload_) {
payload_ = new SrsRtpRawPayload(); payload_ = new SrsRtpRawPayload();
payload_type_ = SrsRtpPacketPayloadTypeRaw; payload_type_ = SrsRtspPacketPayloadTypeRaw;
} }
if ((err = payload_->decode(buf)) != srs_success) { if ((err = payload_->decode(buf)) != srs_success) {
@ -959,7 +959,7 @@ srs_error_t SrsRtpPacket2::decode(SrsBuffer* buf)
return err; return err;
} }
bool SrsRtpPacket2::is_keyframe() bool SrsRtpPacket::is_keyframe()
{ {
// False if audio packet // False if audio packet
if(SrsFrameTypeAudio == frame_type) { if(SrsFrameTypeAudio == frame_type) {

@ -33,7 +33,7 @@
#include <list> #include <list>
#include <vector> #include <vector>
class SrsRtpPacket2; class SrsRtpPacket;
// The RTP packet max size, should never exceed this size. // The RTP packet max size, should never exceed this size.
const int kRtpPacketSize = 1500; const int kRtpPacketSize = 1500;
@ -262,35 +262,35 @@ public:
}; };
// The payload type, for performance to avoid dynamic cast. // The payload type, for performance to avoid dynamic cast.
enum SrsRtpPacketPayloadType enum SrsRtspPacketPayloadType
{ {
SrsRtpPacketPayloadTypeRaw, SrsRtspPacketPayloadTypeRaw,
SrsRtpPacketPayloadTypeFUA2, SrsRtspPacketPayloadTypeFUA2,
SrsRtpPacketPayloadTypeFUA, SrsRtspPacketPayloadTypeFUA,
SrsRtpPacketPayloadTypeNALU, SrsRtspPacketPayloadTypeNALU,
SrsRtpPacketPayloadTypeSTAP, SrsRtspPacketPayloadTypeSTAP,
SrsRtpPacketPayloadTypeUnknown, SrsRtspPacketPayloadTypeUnknown,
}; };
class ISrsRtpPacketDecodeHandler class ISrsRtspPacketDecodeHandler
{ {
public: public:
ISrsRtpPacketDecodeHandler(); ISrsRtspPacketDecodeHandler();
virtual ~ISrsRtpPacketDecodeHandler(); virtual ~ISrsRtspPacketDecodeHandler();
public: public:
// We don't know the actual payload, so we depends on external handler. // We don't know the actual payload, so we depends on external handler.
virtual void on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtpPacketPayloadType* ppt) = 0; virtual void on_before_decode_payload(SrsRtpPacket* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload, SrsRtspPacketPayloadType* ppt) = 0;
}; };
// The RTP packet with cached shared message. // The RTP packet with cached shared message.
class SrsRtpPacket2 class SrsRtpPacket
{ {
// RTP packet fields. // RTP packet fields.
public: public:
SrsRtpHeader header; SrsRtpHeader header;
private: private:
ISrsRtpPayloader* payload_; ISrsRtpPayloader* payload_;
SrsRtpPacketPayloadType payload_type_; SrsRtspPacketPayloadType payload_type_;
private: private:
// The original shared message, all RTP packets can refer to its data. // The original shared message, all RTP packets can refer to its data.
// Note that the size of shared msg, is not the packet size, it's a larger aligned buffer. // Note that the size of shared msg, is not the packet size, it's a larger aligned buffer.
@ -310,10 +310,10 @@ private:
// The cached payload size for packet. // The cached payload size for packet.
int cached_payload_size; int cached_payload_size;
// The helper handler for decoder, use RAW payload if NULL. // The helper handler for decoder, use RAW payload if NULL.
ISrsRtpPacketDecodeHandler* decode_handler; ISrsRtspPacketDecodeHandler* decode_handler;
public: public:
SrsRtpPacket2(); SrsRtpPacket();
virtual ~SrsRtpPacket2(); virtual ~SrsRtpPacket();
public: public:
// Wrap buffer to shared_message, which is managed by us. // Wrap buffer to shared_message, which is managed by us.
char* wrap(int size); char* wrap(int size);
@ -321,20 +321,20 @@ public:
// Wrap the shared message, we copy it. // Wrap the shared message, we copy it.
char* wrap(SrsSharedPtrMessage* msg); char* wrap(SrsSharedPtrMessage* msg);
// Copy the RTP packet. // Copy the RTP packet.
virtual SrsRtpPacket2* copy(); virtual SrsRtpPacket* copy();
public: public:
// Parse the TWCC extension, ignore by default. // Parse the TWCC extension, ignore by default.
void enable_twcc_decode() { header.enable_twcc_decode(); } // SrsRtpPacket2::enable_twcc_decode void enable_twcc_decode() { header.enable_twcc_decode(); } // SrsRtpPacket::enable_twcc_decode
// Get and set the payload of packet. // Get and set the payload of packet.
// @remark Note that return NULL if no payload. // @remark Note that return NULL if no payload.
void set_payload(ISrsRtpPayloader* p, SrsRtpPacketPayloadType pt) { payload_ = p; payload_type_ = pt; } void set_payload(ISrsRtpPayloader* p, SrsRtspPacketPayloadType pt) { payload_ = p; payload_type_ = pt; }
ISrsRtpPayloader* payload() { return payload_; } ISrsRtpPayloader* payload() { return payload_; }
// Set the padding of RTP packet. // Set the padding of RTP packet.
void set_padding(int size); void set_padding(int size);
// Increase the padding of RTP packet. // Increase the padding of RTP packet.
void add_padding(int size); void add_padding(int size);
// Set the decode handler. // Set the decode handler.
void set_decode_handler(ISrsRtpPacketDecodeHandler* h); void set_decode_handler(ISrsRtspPacketDecodeHandler* h);
// Whether the packet is Audio packet. // Whether the packet is Audio packet.
bool is_audio(); bool is_audio();
// Set RTP header extensions for encoding or decoding header extension // Set RTP header extensions for encoding or decoding header extension

@ -120,7 +120,7 @@ std::string srs_generate_rtsp_method_str(SrsRtspMethod method)
} }
} }
SrsRtpPacket::SrsRtpPacket() SrsRtspPacket::SrsRtspPacket()
{ {
version = 2; version = 2;
padding = 0; padding = 0;
@ -139,13 +139,13 @@ SrsRtpPacket::SrsRtpPacket()
completed = false; completed = false;
} }
SrsRtpPacket::~SrsRtpPacket() SrsRtspPacket::~SrsRtspPacket()
{ {
srs_freep(payload); srs_freep(payload);
srs_freep(audio); srs_freep(audio);
} }
void SrsRtpPacket::copy(SrsRtpPacket* src) void SrsRtspPacket::copy(SrsRtspPacket* src)
{ {
version = src->version; version = src->version;
padding = src->padding; padding = src->padding;
@ -164,7 +164,7 @@ void SrsRtpPacket::copy(SrsRtpPacket* src)
audio = new SrsAudioFrame(); audio = new SrsAudioFrame();
} }
void SrsRtpPacket::reap(SrsRtpPacket* src) void SrsRtspPacket::reap(SrsRtspPacket* src)
{ {
copy(src); copy(src);
@ -177,7 +177,7 @@ void SrsRtpPacket::reap(SrsRtpPacket* src)
src->audio = NULL; src->audio = NULL;
} }
srs_error_t SrsRtpPacket::decode(SrsBuffer* stream) srs_error_t SrsRtspPacket::decode(SrsBuffer* stream)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -212,7 +212,7 @@ srs_error_t SrsRtpPacket::decode(SrsBuffer* stream)
return err; return err;
} }
srs_error_t SrsRtpPacket::decode_97(SrsBuffer* stream) srs_error_t SrsRtspPacket::decode_97(SrsBuffer* stream)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;
@ -264,7 +264,7 @@ srs_error_t SrsRtpPacket::decode_97(SrsBuffer* stream)
return err; return err;
} }
srs_error_t SrsRtpPacket::decode_96(SrsBuffer* stream) srs_error_t SrsRtspPacket::decode_96(SrsBuffer* stream)
{ {
srs_error_t err = srs_success; srs_error_t err = srs_success;

@ -128,7 +128,7 @@ enum SrsRtspTokenState
// The rtp packet. // The rtp packet.
// 5. RTP Data Transfer Protocol, @see rfc3550-2003-rtp.pdf, page 12 // 5. RTP Data Transfer Protocol, @see rfc3550-2003-rtp.pdf, page 12
class SrsRtpPacket class SrsRtspPacket
{ {
public: public:
// The version (V): 2 bits // The version (V): 2 bits
@ -255,13 +255,13 @@ public:
// The audio samples, one rtp packets may contains multiple audio samples. // The audio samples, one rtp packets may contains multiple audio samples.
SrsAudioFrame* audio; SrsAudioFrame* audio;
public: public:
SrsRtpPacket(); SrsRtspPacket();
virtual ~SrsRtpPacket(); virtual ~SrsRtspPacket();
public: public:
// copy the header from src. // copy the header from src.
virtual void copy(SrsRtpPacket* src); virtual void copy(SrsRtspPacket* src);
// reap the src to this packet, reap the payload. // reap the src to this packet, reap the payload.
virtual void reap(SrsRtpPacket* src); virtual void reap(SrsRtspPacket* src);
// decode rtp packet from stream. // decode rtp packet from stream.
virtual srs_error_t decode(SrsBuffer* stream); virtual srs_error_t decode(SrsBuffer* stream);
private: private:

@ -731,20 +731,20 @@ VOID TEST(KernelRTCTest, NACKFetchRTPPacket)
// The RTP queue will free the packet. // The RTP queue will free the packet.
if (true) { if (true) {
SrsRtpPacket2* pkt = new SrsRtpPacket2(); SrsRtpPacket* pkt = new SrsRtpPacket();
pkt->header.set_sequence(100); pkt->header.set_sequence(100);
track->rtp_queue_->set(pkt->header.get_sequence(), pkt); track->rtp_queue_->set(pkt->header.get_sequence(), pkt);
} }
// If sequence not match, packet not found. // If sequence not match, packet not found.
if (true) { if (true) {
SrsRtpPacket2* pkt = track->fetch_rtp_packet(10); SrsRtpPacket* pkt = track->fetch_rtp_packet(10);
EXPECT_TRUE(pkt == NULL); EXPECT_TRUE(pkt == NULL);
} }
// The sequence matched, we got the packet. // The sequence matched, we got the packet.
if (true) { if (true) {
SrsRtpPacket2* pkt = track->fetch_rtp_packet(100); SrsRtpPacket* pkt = track->fetch_rtp_packet(100);
EXPECT_TRUE(pkt != NULL); EXPECT_TRUE(pkt != NULL);
} }
@ -752,7 +752,7 @@ VOID TEST(KernelRTCTest, NACKFetchRTPPacket)
if (true) { if (true) {
// The sequence is the "same", 1100%1000 is 100, // The sequence is the "same", 1100%1000 is 100,
// so we can also get it from the RTP queue. // so we can also get it from the RTP queue.
SrsRtpPacket2* pkt = track->rtp_queue_->at(1100); SrsRtpPacket* pkt = track->rtp_queue_->at(1100);
EXPECT_TRUE(pkt != NULL); EXPECT_TRUE(pkt != NULL);
// But the track requires exactly match, so it returns NULL. // But the track requires exactly match, so it returns NULL.

Loading…
Cancel
Save