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.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, Change virtual public to public. 4.0.109
* v4.0, 2021-05-14, Refine id and vid for statistic. 4.0.108

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

@ -594,7 +594,7 @@ srs_error_t SrsRtcPlayStream::cycle()
}
// Wait for amount of packets.
SrsRtpPacket2* pkt = NULL;
SrsRtpPacket* pkt = NULL;
consumer->dump_packet(&pkt);
if (!pkt) {
// 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;
@ -1287,7 +1287,7 @@ srs_error_t SrsRtcPublishStream::on_rtp_plaintext(char* plaintext, int nb_plaint
}
// Allocate packet form cache.
SrsRtpPacket2* pkt = new SrsRtpPacket2();
SrsRtpPacket* pkt = new SrsRtpPacket();
// Copy the packet body.
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;
}
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;
@ -1389,7 +1389,7 @@ srs_error_t SrsRtcPublishStream::check_send_nacks()
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.
if (buf->empty()) {
@ -2503,7 +2503,7 @@ void SrsRtcConnection::simulate_player_drop_packet(SrsRtpHeader* h, int nn_bytes
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;

@ -53,7 +53,7 @@ class SrsRtcServer;
class SrsRtcConnection;
class SrsSharedPtrMessage;
class SrsRtcStream;
class SrsRtpPacket2;
class SrsRtpPacket;
class ISrsCodec;
class SrsRtpNackForReceiver;
class SrsRtpIncommingVideoFrame;
@ -266,7 +266,7 @@ public:
public:
virtual srs_error_t cycle();
private:
srs_error_t send_packet(SrsRtpPacket2*& pkt);
srs_error_t send_packet(SrsRtpPacket*& pkt);
public:
// Directly set the status of track, generally for init to set the default value.
void set_all_tracks_status(bool status);
@ -310,7 +310,7 @@ private:
};
// A RTC publish stream, client push and publish stream to SRS.
class SrsRtcPublishStream : public ISrsRtpPacketDecodeHandler
class SrsRtcPublishStream : public ISrsRtspPacketDecodeHandler
, public ISrsRtcPublishStream, public ISrsRtcPLIWorkerHandler
{
private:
@ -367,11 +367,11 @@ private:
// @remark We copy the plaintext, user should free it.
srs_error_t on_rtp_plaintext(char* plaintext, int nb_plaintext);
private:
srs_error_t do_on_rtp_plaintext(SrsRtpPacket2*& pkt, SrsBuffer* buf);
srs_error_t do_on_rtp_plaintext(SrsRtpPacket*& pkt, SrsBuffer* buf);
public:
srs_error_t check_send_nacks();
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:
srs_error_t send_periodic_twcc();
public:
@ -547,7 +547,7 @@ public:
// Simulate the NACK to drop nn packets.
void simulate_nack_drop(int nn);
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.
void set_all_tracks_status(std::string stream_uri, bool is_publish, bool status);
private:
@ -579,7 +579,7 @@ public:
// When stop publish by RTC.
virtual void on_stop_publish(SrsRtcConnection* session, SrsRtcPublishStream* publisher, SrsRequest* req) = 0;
// 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)
virtual srs_error_t on_before_play(SrsRtcConnection* session, SrsRequest* req) = 0;
// When start player by RTC.

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

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

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

@ -175,9 +175,9 @@ SrsRtcConsumer::~SrsRtcConsumer()
{
source->on_consumer_destroy(this);
vector<SrsRtpPacket2*>::iterator it;
vector<SrsRtpPacket*>::iterator it;
for (it = queue.begin(); it != queue.end(); ++it) {
SrsRtpPacket2* pkt = *it;
SrsRtpPacket* pkt = *it;
srs_freep(pkt);
}
@ -189,7 +189,7 @@ void SrsRtcConsumer::update_source_id()
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;
@ -206,7 +206,7 @@ srs_error_t SrsRtcConsumer::enqueue(SrsRtpPacket2* pkt)
return err;
}
srs_error_t SrsRtcConsumer::dump_packet(SrsRtpPacket2** ppkt)
srs_error_t SrsRtcConsumer::dump_packet(SrsRtpPacket** ppkt)
{
srs_error_t err = srs_success;
@ -574,7 +574,7 @@ void SrsRtcStream::set_publish_stream(ISrsRtcPublishStream* 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;
@ -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) {
SrsAudioFrame* out_audio = *it;
SrsRtpPacket2* pkt = new SrsRtpPacket2();
SrsAutoFree(SrsRtpPacket2, pkt);
SrsRtpPacket* pkt = new SrsRtpPacket();
SrsAutoFree(SrsRtpPacket, pkt);
if ((err = package_opus(out_audio, pkt)) != srs_success) {
err = srs_error_wrap(err, "package opus");
@ -867,7 +867,7 @@ srs_error_t SrsRtcFromRtmpBridger::transcode(SrsAudioFrame* audio)
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;
@ -879,7 +879,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_opus(SrsAudioFrame* audio, SrsRtpPack
pkt->header.set_timestamp(audio->dts * 48);
SrsRtpRawPayload* raw = new SrsRtpRawPayload();
pkt->set_payload(raw, SrsRtpPacketPayloadTypeRaw);
pkt->set_payload(raw, SrsRtspPacketPayloadTypeRaw);
srs_assert(audio->nb_samples == 1);
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.
if (has_idr) {
SrsRtpPacket2* pkt = new SrsRtpPacket2();
SrsAutoFree(SrsRtpPacket2, pkt);
SrsRtpPacket* pkt = new SrsRtpPacket();
SrsAutoFree(SrsRtpPacket, pkt);
if ((err = package_stap_a(source_, msg, pkt)) != srs_success) {
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.
vector<SrsRtpPacket2*> pkts;
vector<SrsRtpPacket*> pkts;
if (merge_nalus && nn_samples > 1) {
if ((err = package_nalus(msg, samples, pkts)) != srs_success) {
return srs_error_wrap(err, "package nalus as one");
@ -989,7 +989,7 @@ srs_error_t SrsRtcFromRtmpBridger::filter(SrsSharedPtrMessage* msg, SrsFormat* f
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;
@ -1014,7 +1014,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_stap_a(SrsRtcStream* source, SrsShare
pkt->header.set_timestamp(msg->timestamp * 90);
SrsRtpSTAPPayload* stap = new SrsRtpSTAPPayload();
pkt->set_payload(stap, SrsRtpPacketPayloadTypeSTAP);
pkt->set_payload(stap, SrsRtspPacketPayloadTypeSTAP);
uint8_t header = sps[0];
stap->nri = (SrsAvcNaluType)header;
@ -1048,7 +1048,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_stap_a(SrsRtcStream* source, SrsShare
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;
@ -1084,7 +1084,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_nalus(SrsSharedPtrMessage* msg, const
if (nn_bytes < kRtpMaxPayloadSize) {
// Package NALUs in a single RTP packet.
SrsRtpPacket2* pkt = new SrsRtpPacket2();
SrsRtpPacket* pkt = new SrsRtpPacket();
pkts.push_back(pkt);
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->header.set_sequence(video_sequence++);
pkt->header.set_timestamp(msg->timestamp * 90);
pkt->set_payload(raw, SrsRtpPacketPayloadTypeNALU);
pkt->set_payload(raw, SrsRtspPacketPayloadTypeNALU);
pkt->wrap(msg);
} else {
// 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);
}
SrsRtpPacket2* pkt = new SrsRtpPacket2();
SrsRtpPacket* pkt = new SrsRtpPacket();
pkts.push_back(pkt);
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->end = bool(i == num_of_packet - 1);
pkt->set_payload(fua, SrsRtpPacketPayloadTypeFUA);
pkt->set_payload(fua, SrsRtspPacketPayloadTypeFUA);
pkt->wrap(msg);
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
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;
SrsRtpPacket2* pkt = new SrsRtpPacket2();
SrsRtpPacket* pkt = new SrsRtpPacket();
pkts.push_back(pkt);
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);
SrsRtpRawPayload* raw = new SrsRtpRawPayload();
pkt->set_payload(raw, SrsRtpPacketPayloadTypeRaw);
pkt->set_payload(raw, SrsRtspPacketPayloadTypeRaw);
raw->payload = sample->bytes;
raw->nn_payload = sample->size;
@ -1168,7 +1168,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_single_nalu(SrsSharedPtrMessage* msg,
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;
@ -1181,7 +1181,7 @@ srs_error_t SrsRtcFromRtmpBridger::package_fu_a(SrsSharedPtrMessage* msg, SrsSam
for (int i = 0; i < num_of_packet; ++i) {
int packet_size = srs_min(nb_left, fu_payload_size);
SrsRtpPacket2* pkt = new SrsRtpPacket2();
SrsRtpPacket* pkt = new SrsRtpPacket();
pkts.push_back(pkt);
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);
SrsRtpFUAPayload2* fua = new SrsRtpFUAPayload2();
pkt->set_payload(fua, SrsRtpPacketPayloadTypeFUA2);
pkt->set_payload(fua, SrsRtspPacketPayloadTypeFUA2);
fua->nri = (SrsAvcNaluType)header;
fua->nalu_type = (SrsAvcNaluType)nal_type;
@ -1210,13 +1210,13 @@ srs_error_t SrsRtcFromRtmpBridger::package_fu_a(SrsSharedPtrMessage* msg, SrsSam
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;
// TODO: FIXME: Consume a range of packets.
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) {
err = srs_error_wrap(err, "consume sps/pps");
break;
@ -1224,7 +1224,7 @@ srs_error_t SrsRtcFromRtmpBridger::consume_packets(vector<SrsRtpPacket2*>& pkts)
}
for (int i = 0; i < (int)pkts.size(); i++) {
SrsRtpPacket2* pkt = pkts[i];
SrsRtpPacket* pkt = pkts[i];
srs_freep(pkt);
}
@ -1288,7 +1288,7 @@ srs_error_t SrsRtmpFromRtcBridger::on_publish()
return err;
}
srs_error_t SrsRtmpFromRtcBridger::on_rtp(SrsRtpPacket2 *pkt)
srs_error_t SrsRtmpFromRtcBridger::on_rtp(SrsRtpPacket *pkt)
{
srs_error_t err = srs_success;
@ -1311,7 +1311,7 @@ void SrsRtmpFromRtcBridger::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;
@ -1377,12 +1377,12 @@ void SrsRtmpFromRtcBridger::packet_aac(SrsCommonMessage* audio, char* data, int
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;
// TODO: Only copy when need
SrsRtpPacket2* pkt = src->copy();
SrsRtpPacket* pkt = src->copy();
if (pkt->is_keyframe()) {
return packet_video_key_frame(pkt);
@ -1415,7 +1415,7 @@ srs_error_t SrsRtmpFromRtcBridger::packet_video(SrsRtpPacket2* src)
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;
@ -1519,7 +1519,7 @@ srs_error_t SrsRtmpFromRtcBridger::packet_video_rtmp(const uint16_t start, const
for (uint16_t i = 0; i < cnt; ++i) {
uint16_t sn = start + i;
uint16_t index = cache_index(sn);
SrsRtpPacket2* pkt = cache_video_pkts_[index].pkt;
SrsRtpPacket* pkt = cache_video_pkts_[index].pkt;
// calculate nalu len
SrsRtpFUAPayload2* fua_payload = dynamic_cast<SrsRtpFUAPayload2*>(pkt->payload());
if (fua_payload) {
@ -1547,7 +1547,7 @@ srs_error_t SrsRtmpFromRtcBridger::packet_video_rtmp(const uint16_t start, const
}
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.create_payload(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;
for (uint16_t i = 0; i < cnt; ++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].pkt = NULL;
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;
for (uint16_t i = 0; i < cnt; ++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());
if (fua_payload) {
if (fua_payload->start) {
@ -2262,11 +2262,11 @@ std::string SrsRtcRecvTrack::get_track_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;
SrsRtpPacket2* pkt = *ppkt;
SrsRtpPacket* pkt = *ppkt;
uint16_t seq = pkt->header.get_sequence();
SrsRtpNackInfo* nack_info = nack_receiver_->find(seq);
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.
if (buf->empty()) {
@ -2325,10 +2325,10 @@ void SrsRtcAudioRecvTrack::on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffe
}
*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;
@ -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.
if (buf->empty()) {
@ -2374,17 +2374,17 @@ void SrsRtcVideoRecvTrack::on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffe
if (v == kStapA) {
*ppayload = new SrsRtpSTAPPayload();
*ppt = SrsRtpPacketPayloadTypeSTAP;
*ppt = SrsRtspPacketPayloadTypeSTAP;
} else if (v == kFuA) {
*ppayload = new SrsRtpFUAPayload2();
*ppt = SrsRtpPacketPayloadTypeFUA2;
*ppt = SrsRtspPacketPayloadTypeFUA2;
} else {
*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;
@ -2446,9 +2446,9 @@ bool SrsRtcSendTrack::has_ssrc(uint32_t 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) {
return pkt;
@ -2489,11 +2489,11 @@ std::string SrsRtcSendTrack::get_track_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;
SrsRtpPacket2* pkt = *ppkt;
SrsRtpPacket* pkt = *ppkt;
uint16_t seq = pkt->header.get_sequence();
// 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) {
uint16_t seq = lost_seqs.at(i);
SrsRtpPacket2* pkt = fetch_rtp_packet(seq);
SrsRtpPacket* pkt = fetch_rtp_packet(seq);
if (pkt == NULL) {
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;
@ -2573,7 +2573,7 @@ srs_error_t SrsRtcAudioSendTrack::on_rtp(SrsRtpPacket2* pkt)
return err;
}
srs_error_t SrsRtcAudioSendTrack::on_rtcp(SrsRtpPacket2* pkt)
srs_error_t SrsRtcAudioSendTrack::on_rtcp(SrsRtpPacket* pkt)
{
srs_error_t err = srs_success;
// 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;
@ -2617,7 +2617,7 @@ srs_error_t SrsRtcVideoSendTrack::on_rtp(SrsRtpPacket2* pkt)
return err;
}
srs_error_t SrsRtcVideoSendTrack::on_rtcp(SrsRtpPacket2* pkt)
srs_error_t SrsRtcVideoSendTrack::on_rtcp(SrsRtpPacket* pkt)
{
srs_error_t err = srs_success;
// process rtcp

@ -46,7 +46,7 @@ class SrsMessageArray;
class SrsRtcStream;
class SrsRtcFromRtmpBridger;
class SrsAudioTranscoder;
class SrsRtpPacket2;
class SrsRtpPacket;
class SrsSample;
class SrsRtcStreamDescription;
class SrsRtcTrackDescription;
@ -88,7 +88,7 @@ class SrsRtcConsumer
{
private:
SrsRtcStream* source;
std::vector<SrsRtpPacket2*> queue;
std::vector<SrsRtpPacket*> queue;
// when source id changed, notice all consumers
bool should_update_source_id;
// The cond wait for mw.
@ -107,9 +107,9 @@ public:
virtual void update_source_id();
// Put RTP packet into queue.
// @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.
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.
virtual void wait(int nb_msgs);
public:
@ -170,7 +170,7 @@ public:
virtual ~ISrsRtcSourceBridger();
public:
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;
};
@ -248,7 +248,7 @@ public:
ISrsRtcPublishStream* publish_stream();
void set_publish_stream(ISrsRtcPublishStream* v);
// 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
bool has_stream_desc();
void set_stream_desc(SrsRtcStreamDescription* stream_desc);
@ -287,16 +287,16 @@ public:
virtual srs_error_t on_audio(SrsSharedPtrMessage* msg);
private:
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:
virtual srs_error_t on_video(SrsSharedPtrMessage* msg);
private:
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_nalus(SrsSharedPtrMessage* msg, const std::vector<SrsSample*>& samples, std::vector<SrsRtpPacket2*>& pkts);
srs_error_t package_single_nalu(SrsSharedPtrMessage* msg, SrsSample* sample, std::vector<SrsRtpPacket2*>& pkts);
srs_error_t package_fu_a(SrsSharedPtrMessage* msg, SrsSample* sample, int fu_payload_size, std::vector<SrsRtpPacket2*>& pkts);
srs_error_t consume_packets(std::vector<SrsRtpPacket2*>& pkts);
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<SrsRtpPacket*>& 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<SrsRtpPacket*>& pkts);
srs_error_t consume_packets(std::vector<SrsRtpPacket*>& pkts);
};
class SrsRtmpFromRtcBridger : public ISrsRtcSourceBridger
@ -315,7 +315,7 @@ private:
bool in_use;
uint16_t sn;
uint32_t ts;
SrsRtpPacket2* pkt;
SrsRtpPacket* pkt;
};
const static uint16_t s_cache_size = 512;
RtcPacketCache cache_video_pkts_[s_cache_size];
@ -329,13 +329,13 @@ public:
srs_error_t initialize(SrsRequest* r);
public:
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();
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);
srs_error_t packet_video(SrsRtpPacket2* pkt);
srs_error_t packet_video_key_frame(SrsRtpPacket2* pkt);
srs_error_t packet_video(SrsRtpPacket* pkt);
srs_error_t packet_video_key_frame(SrsRtpPacket* pkt);
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);
void clear_cached_video();
@ -554,35 +554,35 @@ public:
public:
// 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.
srs_error_t on_nack(SrsRtpPacket2** ppkt);
srs_error_t on_nack(SrsRtpPacket** ppkt);
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;
protected:
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:
SrsRtcAudioRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc);
virtual ~SrsRtcAudioRecvTrack();
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:
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();
};
class SrsRtcVideoRecvTrack : public SrsRtcRecvTrack, public ISrsRtpPacketDecodeHandler
class SrsRtcVideoRecvTrack : public SrsRtcRecvTrack, public ISrsRtspPacketDecodeHandler
{
public:
SrsRtcVideoRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* stream_descs);
virtual ~SrsRtcVideoRecvTrack();
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:
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();
};
@ -608,17 +608,17 @@ public:
// SrsRtcSendTrack::set_nack_no_copy
void set_nack_no_copy(bool v) { nack_no_copy_ = v; }
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 get_track_status();
std::string get_track_id();
public:
// 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.
srs_error_t on_nack(SrsRtpPacket2** ppkt);
srs_error_t on_nack(SrsRtpPacket** ppkt);
public:
virtual srs_error_t on_rtp(SrsRtpPacket2* pkt) = 0;
virtual srs_error_t on_rtcp(SrsRtpPacket2* pkt) = 0;
virtual srs_error_t on_rtp(SrsRtpPacket* 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);
};
@ -628,8 +628,8 @@ public:
SrsRtcAudioSendTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc);
virtual ~SrsRtcAudioSendTrack();
public:
virtual srs_error_t on_rtp(SrsRtpPacket2* pkt);
virtual srs_error_t on_rtcp(SrsRtpPacket2* pkt);
virtual srs_error_t on_rtp(SrsRtpPacket* pkt);
virtual srs_error_t on_rtcp(SrsRtpPacket* pkt);
};
class SrsRtcVideoSendTrack : public SrsRtcSendTrack
@ -638,8 +638,8 @@ public:
SrsRtcVideoSendTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc);
virtual ~SrsRtcVideoSendTrack();
public:
virtual srs_error_t on_rtp(SrsRtpPacket2* pkt);
virtual srs_error_t on_rtcp(SrsRtpPacket2* pkt);
virtual srs_error_t on_rtp(SrsRtpPacket* pkt);
virtual srs_error_t on_rtcp(SrsRtpPacket* pkt);
};
class SrsRtcSSRCGenerator

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

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

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

@ -760,18 +760,18 @@ ISrsRtpPayloader::~ISrsRtpPayloader()
{
}
ISrsRtpPacketDecodeHandler::ISrsRtpPacketDecodeHandler()
ISrsRtspPacketDecodeHandler::ISrsRtspPacketDecodeHandler()
{
}
ISrsRtpPacketDecodeHandler::~ISrsRtpPacketDecodeHandler()
ISrsRtspPacketDecodeHandler::~ISrsRtspPacketDecodeHandler()
{
}
SrsRtpPacket2::SrsRtpPacket2()
SrsRtpPacket::SrsRtpPacket()
{
payload_ = NULL;
payload_type_ = SrsRtpPacketPayloadTypeUnknown;
payload_type_ = SrsRtspPacketPayloadTypeUnknown;
shared_buffer_ = NULL;
actual_buffer_size_ = 0;
@ -783,13 +783,13 @@ SrsRtpPacket2::SrsRtpPacket2()
++_srs_pps_objs_rtps->sugar;
}
SrsRtpPacket2::~SrsRtpPacket2()
SrsRtpPacket::~SrsRtpPacket()
{
srs_freep(payload_);
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.
actual_buffer_size_ = size;
@ -814,14 +814,14 @@ char* SrsRtpPacket2::wrap(int size)
return shared_buffer_->payload;
}
char* SrsRtpPacket2::wrap(char* data, int size)
char* SrsRtpPacket::wrap(char* data, int size)
{
char* buf = wrap(size);
memcpy(buf, data, size);
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,
// 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;
}
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,
// because we had clear it in recycle.
@ -861,7 +861,7 @@ SrsRtpPacket2* SrsRtpPacket2::copy()
return cp;
}
void SrsRtpPacket2::set_padding(int size)
void SrsRtpPacket::set_padding(int size)
{
header.set_padding(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);
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;
}
bool SrsRtpPacket2::is_audio()
bool SrsRtpPacket::is_audio()
{
return frame_type == SrsFrameTypeAudio;
}
void SrsRtpPacket2::set_extension_types(SrsRtpExtensionTypes* v)
void SrsRtpPacket::set_extension_types(SrsRtpExtensionTypes* v)
{
return header.set_extensions(v);
}
uint64_t SrsRtpPacket2::nb_bytes()
uint64_t SrsRtpPacket::nb_bytes()
{
if (!cached_payload_size) {
int nn_payload = (payload_? payload_->nb_bytes():0);
@ -901,7 +901,7 @@ uint64_t SrsRtpPacket2::nb_bytes()
return cached_payload_size;
}
srs_error_t SrsRtpPacket2::encode(SrsBuffer* buf)
srs_error_t SrsRtpPacket::encode(SrsBuffer* buf)
{
srs_error_t err = srs_success;
@ -925,7 +925,7 @@ srs_error_t SrsRtpPacket2::encode(SrsBuffer* buf)
return err;
}
srs_error_t SrsRtpPacket2::decode(SrsBuffer* buf)
srs_error_t SrsRtpPacket::decode(SrsBuffer* buf)
{
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.
if (!payload_) {
payload_ = new SrsRtpRawPayload();
payload_type_ = SrsRtpPacketPayloadTypeRaw;
payload_type_ = SrsRtspPacketPayloadTypeRaw;
}
if ((err = payload_->decode(buf)) != srs_success) {
@ -959,7 +959,7 @@ srs_error_t SrsRtpPacket2::decode(SrsBuffer* buf)
return err;
}
bool SrsRtpPacket2::is_keyframe()
bool SrsRtpPacket::is_keyframe()
{
// False if audio packet
if(SrsFrameTypeAudio == frame_type) {

@ -33,7 +33,7 @@
#include <list>
#include <vector>
class SrsRtpPacket2;
class SrsRtpPacket;
// The RTP packet max size, should never exceed this size.
const int kRtpPacketSize = 1500;
@ -262,35 +262,35 @@ public:
};
// The payload type, for performance to avoid dynamic cast.
enum SrsRtpPacketPayloadType
enum SrsRtspPacketPayloadType
{
SrsRtpPacketPayloadTypeRaw,
SrsRtpPacketPayloadTypeFUA2,
SrsRtpPacketPayloadTypeFUA,
SrsRtpPacketPayloadTypeNALU,
SrsRtpPacketPayloadTypeSTAP,
SrsRtpPacketPayloadTypeUnknown,
SrsRtspPacketPayloadTypeRaw,
SrsRtspPacketPayloadTypeFUA2,
SrsRtspPacketPayloadTypeFUA,
SrsRtspPacketPayloadTypeNALU,
SrsRtspPacketPayloadTypeSTAP,
SrsRtspPacketPayloadTypeUnknown,
};
class ISrsRtpPacketDecodeHandler
class ISrsRtspPacketDecodeHandler
{
public:
ISrsRtpPacketDecodeHandler();
virtual ~ISrsRtpPacketDecodeHandler();
ISrsRtspPacketDecodeHandler();
virtual ~ISrsRtspPacketDecodeHandler();
public:
// 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.
class SrsRtpPacket2
class SrsRtpPacket
{
// RTP packet fields.
public:
SrsRtpHeader header;
private:
ISrsRtpPayloader* payload_;
SrsRtpPacketPayloadType payload_type_;
SrsRtspPacketPayloadType payload_type_;
private:
// 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.
@ -310,10 +310,10 @@ private:
// The cached payload size for packet.
int cached_payload_size;
// The helper handler for decoder, use RAW payload if NULL.
ISrsRtpPacketDecodeHandler* decode_handler;
ISrsRtspPacketDecodeHandler* decode_handler;
public:
SrsRtpPacket2();
virtual ~SrsRtpPacket2();
SrsRtpPacket();
virtual ~SrsRtpPacket();
public:
// Wrap buffer to shared_message, which is managed by us.
char* wrap(int size);
@ -321,20 +321,20 @@ public:
// Wrap the shared message, we copy it.
char* wrap(SrsSharedPtrMessage* msg);
// Copy the RTP packet.
virtual SrsRtpPacket2* copy();
virtual SrsRtpPacket* copy();
public:
// 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.
// @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_; }
// Set the padding of RTP packet.
void set_padding(int size);
// Increase the padding of RTP packet.
void add_padding(int size);
// Set the decode handler.
void set_decode_handler(ISrsRtpPacketDecodeHandler* h);
void set_decode_handler(ISrsRtspPacketDecodeHandler* h);
// Whether the packet is Audio packet.
bool is_audio();
// 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;
padding = 0;
@ -139,13 +139,13 @@ SrsRtpPacket::SrsRtpPacket()
completed = false;
}
SrsRtpPacket::~SrsRtpPacket()
SrsRtspPacket::~SrsRtspPacket()
{
srs_freep(payload);
srs_freep(audio);
}
void SrsRtpPacket::copy(SrsRtpPacket* src)
void SrsRtspPacket::copy(SrsRtspPacket* src)
{
version = src->version;
padding = src->padding;
@ -164,7 +164,7 @@ void SrsRtpPacket::copy(SrsRtpPacket* src)
audio = new SrsAudioFrame();
}
void SrsRtpPacket::reap(SrsRtpPacket* src)
void SrsRtspPacket::reap(SrsRtspPacket* src)
{
copy(src);
@ -177,7 +177,7 @@ void SrsRtpPacket::reap(SrsRtpPacket* src)
src->audio = NULL;
}
srs_error_t SrsRtpPacket::decode(SrsBuffer* stream)
srs_error_t SrsRtspPacket::decode(SrsBuffer* stream)
{
srs_error_t err = srs_success;
@ -212,7 +212,7 @@ srs_error_t SrsRtpPacket::decode(SrsBuffer* stream)
return err;
}
srs_error_t SrsRtpPacket::decode_97(SrsBuffer* stream)
srs_error_t SrsRtspPacket::decode_97(SrsBuffer* stream)
{
srs_error_t err = srs_success;
@ -264,7 +264,7 @@ srs_error_t SrsRtpPacket::decode_97(SrsBuffer* stream)
return err;
}
srs_error_t SrsRtpPacket::decode_96(SrsBuffer* stream)
srs_error_t SrsRtspPacket::decode_96(SrsBuffer* stream)
{
srs_error_t err = srs_success;

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

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

Loading…
Cancel
Save