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

RTC: Refine audio to RTP packet base.

This commit is contained in:
winlin 2020-05-13 20:13:25 +08:00
parent 588d17c09d
commit 54d8c36905
7 changed files with 129 additions and 190 deletions

View file

@ -280,6 +280,7 @@ SrsRtpPacket2::SrsRtpPacket2()
nalu_type = SrsAvcNaluTypeReserved;
original_bytes = NULL;
frame_type = SrsFrameTypeReserved;
cache_raw = new SrsRtpRawPayload();
cache_fua = new SrsRtpFUAPayload2();
@ -350,6 +351,11 @@ void SrsRtpPacket2::set_decode_handler(ISrsRtpPacketDecodeHandler* h)
decode_handler = h;
}
bool SrsRtpPacket2::is_audio()
{
return frame_type == SrsFrameTypeAudio;
}
int SrsRtpPacket2::nb_bytes()
{
if (!cache_payload) {

View file

@ -115,12 +115,14 @@ public:
ISrsCodec* payload;
// TODO: FIXME: Merge into rtp_header.
int padding;
// Decoder helper.
// Helper fields.
public:
// The first byte as nalu type, for video decoder only.
SrsAvcNaluType nalu_type;
// The original bytes for decoder or bridger only, we will free it.
char* original_bytes;
// The frame type, for RTMP bridger or SFU source.
SrsFrameType frame_type;
// Fast cache for performance.
private:
// Cache frequently used payload for performance.
@ -145,6 +147,8 @@ public:
SrsRtpFUAPayload2* reuse_fua();
// Set the decode handler.
void set_decode_handler(ISrsRtpPacketDecodeHandler* h);
// Whether the packet is Audio packet.
bool is_audio();
// interface ISrsEncoder
public:
virtual int nb_bytes();