mirror of
https://github.com/ossrs/srs.git
synced 2025-02-15 04:42:04 +00:00
RTC: Refine RTP packet decoder to track and stream
This commit is contained in:
parent
0fe85a295c
commit
40ea0b67f9
3 changed files with 36 additions and 11 deletions
|
@ -1310,16 +1310,9 @@ void SrsRtcPublishStream::on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffer
|
||||||
SrsRtcVideoRecvTrack* video_track = get_video_track(ssrc);
|
SrsRtcVideoRecvTrack* video_track = get_video_track(ssrc);
|
||||||
|
|
||||||
if (audio_track) {
|
if (audio_track) {
|
||||||
*ppayload = new SrsRtpRawPayload();
|
audio_track->on_before_decode_payload(pkt, buf, ppayload);
|
||||||
} else if (video_track) {
|
} else if (video_track) {
|
||||||
uint8_t v = (uint8_t)pkt->nalu_type;
|
video_track->on_before_decode_payload(pkt, buf, ppayload);
|
||||||
if (v == kStapA) {
|
|
||||||
*ppayload = new SrsRtpSTAPPayload();
|
|
||||||
} else if (v == kFuA) {
|
|
||||||
*ppayload = new SrsRtpFUAPayload2();
|
|
||||||
} else {
|
|
||||||
*ppayload = new SrsRtpRawPayload();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1831,6 +1831,16 @@ SrsRtcAudioRecvTrack::~SrsRtcAudioRecvTrack()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsRtcAudioRecvTrack::on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload)
|
||||||
|
{
|
||||||
|
// No payload, ignore.
|
||||||
|
if (buf->empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
*ppayload = new SrsRtpRawPayload();
|
||||||
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcAudioRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket2* pkt)
|
srs_error_t SrsRtcAudioRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket2* pkt)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
@ -1875,6 +1885,23 @@ SrsRtcVideoRecvTrack::~SrsRtcVideoRecvTrack()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SrsRtcVideoRecvTrack::on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload)
|
||||||
|
{
|
||||||
|
// No payload, ignore.
|
||||||
|
if (buf->empty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t v = (uint8_t)pkt->nalu_type;
|
||||||
|
if (v == kStapA) {
|
||||||
|
*ppayload = new SrsRtpSTAPPayload();
|
||||||
|
} else if (v == kFuA) {
|
||||||
|
*ppayload = new SrsRtpFUAPayload2();
|
||||||
|
} else {
|
||||||
|
*ppayload = new SrsRtpRawPayload();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
srs_error_t SrsRtcVideoRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket2* pkt)
|
srs_error_t SrsRtcVideoRecvTrack::on_rtp(SrsRtcStream* source, SrsRtpPacket2* pkt)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include <srs_app_rtc_sdp.hpp>
|
#include <srs_app_rtc_sdp.hpp>
|
||||||
#include <srs_service_st.hpp>
|
#include <srs_service_st.hpp>
|
||||||
#include <srs_app_source.hpp>
|
#include <srs_app_source.hpp>
|
||||||
|
#include <srs_kernel_rtc_rtp.hpp>
|
||||||
|
|
||||||
class SrsRequest;
|
class SrsRequest;
|
||||||
class SrsMetaCache;
|
class SrsMetaCache;
|
||||||
|
@ -531,21 +532,25 @@ 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
|
class SrsRtcAudioRecvTrack : virtual public SrsRtcRecvTrack, virtual public ISrsRtpPacketDecodeHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SrsRtcAudioRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc);
|
SrsRtcAudioRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* track_desc);
|
||||||
virtual ~SrsRtcAudioRecvTrack();
|
virtual ~SrsRtcAudioRecvTrack();
|
||||||
|
public:
|
||||||
|
virtual void on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload);
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_rtp(SrsRtcStream* source, SrsRtpPacket2* pkt);
|
virtual srs_error_t on_rtp(SrsRtcStream* source, SrsRtpPacket2* pkt);
|
||||||
virtual srs_error_t check_send_nacks();
|
virtual srs_error_t check_send_nacks();
|
||||||
};
|
};
|
||||||
|
|
||||||
class SrsRtcVideoRecvTrack : public SrsRtcRecvTrack
|
class SrsRtcVideoRecvTrack : virtual public SrsRtcRecvTrack, virtual public ISrsRtpPacketDecodeHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SrsRtcVideoRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* stream_descs);
|
SrsRtcVideoRecvTrack(SrsRtcConnection* session, SrsRtcTrackDescription* stream_descs);
|
||||||
virtual ~SrsRtcVideoRecvTrack();
|
virtual ~SrsRtcVideoRecvTrack();
|
||||||
|
public:
|
||||||
|
virtual void on_before_decode_payload(SrsRtpPacket2* pkt, SrsBuffer* buf, ISrsRtpPayloader** ppayload);
|
||||||
public:
|
public:
|
||||||
virtual srs_error_t on_rtp(SrsRtcStream* source, SrsRtpPacket2* pkt);
|
virtual srs_error_t on_rtp(SrsRtcStream* source, SrsRtpPacket2* pkt);
|
||||||
virtual srs_error_t check_send_nacks();
|
virtual srs_error_t check_send_nacks();
|
||||||
|
|
Loading…
Reference in a new issue