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

SquashSRS4: Support RTC2RTMP.

This commit is contained in:
winlin 2021-05-01 22:15:57 +08:00
parent 0b62216999
commit 74bb47c13f
22 changed files with 1246 additions and 844 deletions

View file

@ -650,9 +650,8 @@ public:
virtual bool is_avc_codec_ok();
};
/**
* A frame, consists of a codec and a group of samples.
*/
// A frame, consists of a codec and a group of samples.
// TODO: FIXME: Rename to packet to follow names of FFmpeg, which means before decoding or after decoding.
class SrsFrame
{
public:
@ -677,9 +676,8 @@ public:
virtual srs_error_t add_sample(char* bytes, int size);
};
/**
* A audio frame, besides a frame, contains the audio frame info, such as frame type.
*/
// A audio frame, besides a frame, contains the audio frame info, such as frame type.
// TODO: FIXME: Rename to packet to follow names of FFmpeg, which means before decoding or after decoding.
class SrsAudioFrame : public SrsFrame
{
public:
@ -691,9 +689,8 @@ public:
virtual SrsAudioCodecConfig* acodec();
};
/**
* A video frame, besides a frame, contains the video frame info, such as frame type.
*/
// A video frame, besides a frame, contains the video frame info, such as frame type.
// TODO: FIXME: Rename to packet to follow names of FFmpeg, which means before decoding or after decoding.
class SrsVideoFrame : public SrsFrame
{
public:

View file

@ -1054,6 +1054,33 @@ srs_error_t SrsRtpPacket2::decode(SrsBuffer* buf)
return err;
}
bool SrsRtpPacket2::is_keyframe()
{
// False if audio packet
if(SrsFrameTypeAudio == frame_type) {
return false;
}
// It's normal H264 video rtp packet
if (nalu_type == kStapA) {
SrsRtpSTAPPayload* stap_payload = dynamic_cast<SrsRtpSTAPPayload*>(payload_);
if(NULL != stap_payload->get_sps() || NULL != stap_payload->get_pps()) {
return true;
}
} else if (nalu_type == kFuA) {
SrsRtpFUAPayload2* fua_payload = dynamic_cast<SrsRtpFUAPayload2*>(payload_);
if(SrsAvcNaluTypeIDR == fua_payload->nalu_type) {
return true;
}
} else {
if((SrsAvcNaluTypeIDR == nalu_type) || (SrsAvcNaluTypeSPS == nalu_type) || (SrsAvcNaluTypePPS == nalu_type)) {
return true;
}
}
return false;
}
SrsRtpObjectCacheManager<SrsRtpPacket2>* _srs_rtp_cache = new SrsRtpObjectCacheManager<SrsRtpPacket2>(sizeof(SrsRtpPacket2));
SrsRtpObjectCacheManager<SrsRtpRawPayload>* _srs_rtp_raw_cache = new SrsRtpObjectCacheManager<SrsRtpRawPayload>(sizeof(SrsRtpRawPayload));
SrsRtpObjectCacheManager<SrsRtpFUAPayload2>* _srs_rtp_fua_cache = new SrsRtpObjectCacheManager<SrsRtpFUAPayload2>(sizeof(SrsRtpFUAPayload2));

View file

@ -353,6 +353,8 @@ public:
virtual uint64_t nb_bytes();
virtual srs_error_t encode(SrsBuffer* buf);
virtual srs_error_t decode(SrsBuffer* buf);
public:
bool is_keyframe();
};
// For object cache manager to stat the object dropped.