mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
SRT: Refine packet error handler.
This commit is contained in:
parent
9a0db5a14f
commit
8437370c1e
2 changed files with 16 additions and 6 deletions
|
@ -312,6 +312,7 @@ srs_error_t SrsMpegtsSrtConn::playing()
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: FIXME: It's not atomic and has risk between multiple source checking.
|
||||||
srs_error_t SrsMpegtsSrtConn::acquire_publish()
|
srs_error_t SrsMpegtsSrtConn::acquire_publish()
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
@ -370,8 +371,6 @@ srs_error_t SrsMpegtsSrtConn::do_publishing()
|
||||||
}
|
}
|
||||||
|
|
||||||
pprint->elapse();
|
pprint->elapse();
|
||||||
|
|
||||||
// reportable
|
|
||||||
if (pprint->can_print()) {
|
if (pprint->can_print()) {
|
||||||
SrsSrtStat s;
|
SrsSrtStat s;
|
||||||
if ((err = s.fetch(srt_fd_, true)) != srs_success) {
|
if ((err = s.fetch(srt_fd_, true)) != srs_success) {
|
||||||
|
@ -485,9 +484,19 @@ srs_error_t SrsMpegtsSrtConn::on_srt_packet(char* buf, int nb_buf)
|
||||||
{
|
{
|
||||||
srs_error_t err = srs_success;
|
srs_error_t err = srs_success;
|
||||||
|
|
||||||
// Check srt payload, mpegts must be N times of SRS_TS_PACKET_SIZE, and the first byte must be 0x47
|
// Ignore if invalid length.
|
||||||
if ((nb_buf <= 0) || (nb_buf % SRS_TS_PACKET_SIZE != 0) || (buf[0] != 0x47)) {
|
if (nb_buf <= 0) {
|
||||||
return srs_error_new(ERROR_SRT_CONN, "invalid ts packet");
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check srt payload, mpegts must be N times of SRS_TS_PACKET_SIZE
|
||||||
|
if ((nb_buf % SRS_TS_PACKET_SIZE) != 0) {
|
||||||
|
return srs_error_new(ERROR_SRT_CONN, "invalid ts packet len=%d", nb_buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check srt payload, the first byte must be 0x47
|
||||||
|
if (buf[0] != 0x47) {
|
||||||
|
return srs_error_new(ERROR_SRT_CONN, "invalid ts packet first=%#x", (uint8_t)buf[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
SrsSrtPacket* packet = new SrsSrtPacket();
|
SrsSrtPacket* packet = new SrsSrtPacket();
|
||||||
|
|
|
@ -287,7 +287,8 @@ srs_error_t SrsRtmpFromSrtBridge::on_packet(SrsSrtPacket *pkt)
|
||||||
SrsBuffer* stream = new SrsBuffer(p, SRS_TS_PACKET_SIZE);
|
SrsBuffer* stream = new SrsBuffer(p, SRS_TS_PACKET_SIZE);
|
||||||
SrsAutoFree(SrsBuffer, stream);
|
SrsAutoFree(SrsBuffer, stream);
|
||||||
|
|
||||||
// process each ts packet
|
// Process each ts packet. Note that the jitter of UDP may cause video glitch when packet loss or wrong seq. We
|
||||||
|
// don't handle it because SRT will, see tlpkdrop at https://github.com/ossrs/srs/wiki/v5_EN_SRTParams
|
||||||
if ((err = ts_ctx_->decode(stream, this)) != srs_success) {
|
if ((err = ts_ctx_->decode(stream, this)) != srs_success) {
|
||||||
srs_warn("parse ts packet err=%s", srs_error_desc(err).c_str());
|
srs_warn("parse ts packet err=%s", srs_error_desc(err).c_str());
|
||||||
srs_error_reset(err);
|
srs_error_reset(err);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue