1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

RTC: Use shared message for RTP packet

This commit is contained in:
winlin 2020-05-14 14:26:19 +08:00
parent 4e1935f678
commit f794a7d3a7
8 changed files with 195 additions and 59 deletions

View file

@ -265,6 +265,14 @@ uint8_t SrsRtpHeader::get_padding_length() const
return padding_length;
}
ISrsRtpPayloader::ISrsRtpPayloader()
{
}
ISrsRtpPayloader::~ISrsRtpPayloader()
{
}
ISrsRtpPacketDecodeHandler::ISrsRtpPacketDecodeHandler()
{
}
@ -359,6 +367,24 @@ bool SrsRtpPacket2::is_audio()
return frame_type == SrsFrameTypeAudio;
}
SrsRtpPacket2* SrsRtpPacket2::copy()
{
SrsRtpPacket2* cp = new SrsRtpPacket2();
cp->rtp_header = rtp_header;
cp->payload = payload? payload->copy():NULL;
cp->padding = padding;
cp->nalu_type = nalu_type;
cp->original_msg = original_msg? original_msg->copy():NULL;
cp->frame_type = frame_type;
cp->cache_payload = cache_payload;
cp->decode_handler = decode_handler;
return cp;
}
int SrsRtpPacket2::nb_bytes()
{
if (!cache_payload) {
@ -469,6 +495,16 @@ srs_error_t SrsRtpRawPayload::decode(SrsBuffer* buf)
return srs_success;
}
ISrsRtpPayloader* SrsRtpRawPayload::copy()
{
SrsRtpRawPayload* cp = new SrsRtpRawPayload();
cp->payload = payload;
cp->nn_payload = nn_payload;
return cp;
}
SrsRtpRawNALUs::SrsRtpRawNALUs()
{
cursor = 0;
@ -591,6 +627,22 @@ srs_error_t SrsRtpRawNALUs::decode(SrsBuffer* buf)
return srs_success;
}
ISrsRtpPayloader* SrsRtpRawNALUs::copy()
{
SrsRtpRawNALUs* cp = new SrsRtpRawNALUs();
cp->nn_bytes = nn_bytes;
cp->cursor = cursor;
int nn_nalus = (int)nalus.size();
for (int i = 0; i < nn_nalus; i++) {
SrsSample* p = nalus[i];
cp->nalus.push_back(p->copy());
}
return cp;
}
SrsRtpSTAPPayload::SrsRtpSTAPPayload()
{
nri = (SrsAvcNaluType)0;
@ -715,6 +767,21 @@ srs_error_t SrsRtpSTAPPayload::decode(SrsBuffer* buf)
return srs_success;
}
ISrsRtpPayloader* SrsRtpSTAPPayload::copy()
{
SrsRtpSTAPPayload* cp = new SrsRtpSTAPPayload();
cp->nri = nri;
int nn_nalus = (int)nalus.size();
for (int i = 0; i < nn_nalus; i++) {
SrsSample* p = nalus[i];
cp->nalus.push_back(p->copy());
}
return cp;
}
SrsRtpFUAPayload::SrsRtpFUAPayload()
{
start = end = false;
@ -809,6 +876,24 @@ srs_error_t SrsRtpFUAPayload::decode(SrsBuffer* buf)
return srs_success;
}
ISrsRtpPayloader* SrsRtpFUAPayload::copy()
{
SrsRtpFUAPayload* cp = new SrsRtpFUAPayload();
cp->nri = nri;
cp->start = start;
cp->end = end;
cp->nalu_type = nalu_type;
int nn_nalus = (int)nalus.size();
for (int i = 0; i < nn_nalus; i++) {
SrsSample* p = nalus[i];
cp->nalus.push_back(p->copy());
}
return cp;
}
SrsRtpFUAPayload2::SrsRtpFUAPayload2()
{
start = end = false;
@ -886,3 +971,17 @@ srs_error_t SrsRtpFUAPayload2::decode(SrsBuffer* buf)
return srs_success;
}
ISrsRtpPayloader* SrsRtpFUAPayload2::copy()
{
SrsRtpFUAPayload2* cp = new SrsRtpFUAPayload2();
cp->nri = nri;
cp->start = start;
cp->end = end;
cp->nalu_type = nalu_type;
cp->payload = payload;
cp->size = size;
return cp;
}