|
|
|
@ -97,6 +97,15 @@ public:
|
|
|
|
|
uint8_t get_padding_length() const;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ISrsRtpPayloader : public ISrsCodec
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
ISrsRtpPayloader();
|
|
|
|
|
virtual ~ISrsRtpPayloader();
|
|
|
|
|
public:
|
|
|
|
|
virtual ISrsRtpPayloader* copy() = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ISrsRtpPacketDecodeHandler
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
@ -104,7 +113,7 @@ public:
|
|
|
|
|
virtual ~ISrsRtpPacketDecodeHandler();
|
|
|
|
|
public:
|
|
|
|
|
// We don't know the actual payload, so we depends on external handler.
|
|
|
|
|
virtual void on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffer* buf, ISrsCodec** ppayload) = 0;
|
|
|
|
|
virtual void on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload) = 0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class SrsRtpPacket2
|
|
|
|
@ -113,7 +122,7 @@ class SrsRtpPacket2
|
|
|
|
|
public:
|
|
|
|
|
// TODO: FIXME: Rename to header.
|
|
|
|
|
SrsRtpHeader rtp_header;
|
|
|
|
|
ISrsCodec* payload;
|
|
|
|
|
ISrsRtpPayloader* payload;
|
|
|
|
|
// TODO: FIXME: Merge into rtp_header.
|
|
|
|
|
int padding;
|
|
|
|
|
// Helper fields.
|
|
|
|
@ -121,6 +130,7 @@ 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.
|
|
|
|
|
// TODO: FIXME: Should covert to shared prt message.
|
|
|
|
|
char* original_bytes;
|
|
|
|
|
// The original msg for bridger only, we will free it.
|
|
|
|
|
SrsSharedPtrMessage* original_msg;
|
|
|
|
@ -152,6 +162,8 @@ public:
|
|
|
|
|
void set_decode_handler(ISrsRtpPacketDecodeHandler* h);
|
|
|
|
|
// Whether the packet is Audio packet.
|
|
|
|
|
bool is_audio();
|
|
|
|
|
// Copy the RTP packet.
|
|
|
|
|
SrsRtpPacket2* copy();
|
|
|
|
|
// interface ISrsEncoder
|
|
|
|
|
public:
|
|
|
|
|
virtual int nb_bytes();
|
|
|
|
@ -160,7 +172,7 @@ public:
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Single payload data.
|
|
|
|
|
class SrsRtpRawPayload : public ISrsCodec
|
|
|
|
|
class SrsRtpRawPayload : public ISrsRtpPayloader
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
// The RAW payload, directly point to the shared memory.
|
|
|
|
@ -170,15 +182,16 @@ public:
|
|
|
|
|
public:
|
|
|
|
|
SrsRtpRawPayload();
|
|
|
|
|
virtual ~SrsRtpRawPayload();
|
|
|
|
|
// interface ISrsEncoder
|
|
|
|
|
// interface ISrsRtpPayloader
|
|
|
|
|
public:
|
|
|
|
|
virtual int nb_bytes();
|
|
|
|
|
virtual srs_error_t encode(SrsBuffer* buf);
|
|
|
|
|
virtual srs_error_t decode(SrsBuffer* buf);
|
|
|
|
|
virtual ISrsRtpPayloader* copy();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Multiple NALUs, automatically insert 001 between NALUs.
|
|
|
|
|
class SrsRtpRawNALUs : public ISrsCodec
|
|
|
|
|
class SrsRtpRawNALUs : public ISrsRtpPayloader
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
// We will manage the samples, but the sample itself point to the shared memory.
|
|
|
|
@ -194,15 +207,16 @@ public:
|
|
|
|
|
uint8_t skip_first_byte();
|
|
|
|
|
// We will manage the returned samples, if user want to manage it, please copy it.
|
|
|
|
|
srs_error_t read_samples(std::vector<SrsSample*>& samples, int packet_size);
|
|
|
|
|
// interface ISrsEncoder
|
|
|
|
|
// interface ISrsRtpPayloader
|
|
|
|
|
public:
|
|
|
|
|
virtual int nb_bytes();
|
|
|
|
|
virtual srs_error_t encode(SrsBuffer* buf);
|
|
|
|
|
virtual srs_error_t decode(SrsBuffer* buf);
|
|
|
|
|
virtual ISrsRtpPayloader* copy();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// STAP-A, for multiple NALUs.
|
|
|
|
|
class SrsRtpSTAPPayload : public ISrsCodec
|
|
|
|
|
class SrsRtpSTAPPayload : public ISrsRtpPayloader
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
// The NRI in NALU type.
|
|
|
|
@ -216,16 +230,17 @@ public:
|
|
|
|
|
public:
|
|
|
|
|
SrsSample* get_sps();
|
|
|
|
|
SrsSample* get_pps();
|
|
|
|
|
// interface ISrsEncoder
|
|
|
|
|
// interface ISrsRtpPayloader
|
|
|
|
|
public:
|
|
|
|
|
virtual int nb_bytes();
|
|
|
|
|
virtual srs_error_t encode(SrsBuffer* buf);
|
|
|
|
|
virtual srs_error_t decode(SrsBuffer* buf);
|
|
|
|
|
virtual ISrsRtpPayloader* copy();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// FU-A, for one NALU with multiple fragments.
|
|
|
|
|
// With more than one payload.
|
|
|
|
|
class SrsRtpFUAPayload : public ISrsCodec
|
|
|
|
|
class SrsRtpFUAPayload : public ISrsRtpPayloader
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
// The NRI in NALU type.
|
|
|
|
@ -240,16 +255,17 @@ public:
|
|
|
|
|
public:
|
|
|
|
|
SrsRtpFUAPayload();
|
|
|
|
|
virtual ~SrsRtpFUAPayload();
|
|
|
|
|
// interface ISrsEncoder
|
|
|
|
|
// interface ISrsRtpPayloader
|
|
|
|
|
public:
|
|
|
|
|
virtual int nb_bytes();
|
|
|
|
|
virtual srs_error_t encode(SrsBuffer* buf);
|
|
|
|
|
virtual srs_error_t decode(SrsBuffer* buf);
|
|
|
|
|
virtual ISrsRtpPayloader* copy();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// FU-A, for one NALU with multiple fragments.
|
|
|
|
|
// With only one payload.
|
|
|
|
|
class SrsRtpFUAPayload2 : public ISrsCodec
|
|
|
|
|
class SrsRtpFUAPayload2 : public ISrsRtpPayloader
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
// The NRI in NALU type.
|
|
|
|
@ -264,11 +280,12 @@ public:
|
|
|
|
|
public:
|
|
|
|
|
SrsRtpFUAPayload2();
|
|
|
|
|
virtual ~SrsRtpFUAPayload2();
|
|
|
|
|
// interface ISrsEncoder
|
|
|
|
|
// interface ISrsRtpPayloader
|
|
|
|
|
public:
|
|
|
|
|
virtual int nb_bytes();
|
|
|
|
|
virtual srs_error_t encode(SrsBuffer* buf);
|
|
|
|
|
virtual srs_error_t decode(SrsBuffer* buf);
|
|
|
|
|
virtual ISrsRtpPayloader* copy();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|