@@ -312,6 +312,7 @@ srs_error_t SrsMpegtsSrtConn::playing()
312
312
return err;
313
313
}
314
314
315
+ // TODO: FIXME: It's not atomic and has risk between multiple source checking.
315
316
srs_error_t SrsMpegtsSrtConn::acquire_publish ()
316
317
{
317
318
srs_error_t err = srs_success;
@@ -370,8 +371,6 @@ srs_error_t SrsMpegtsSrtConn::do_publishing()
370
371
}
371
372
372
373
pprint->elapse ();
373
-
374
- // reportable
375
374
if (pprint->can_print ()) {
376
375
SrsSrtStat s;
377
376
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)
485
484
{
486
485
srs_error_t err = srs_success;
487
486
488
- // Check srt payload, mpegts must be N times of SRS_TS_PACKET_SIZE, and the first byte must be 0x47
489
- if ((nb_buf <= 0 ) || (nb_buf % SRS_TS_PACKET_SIZE != 0 ) || (buf[0 ] != 0x47 )) {
490
- return srs_error_new (ERROR_SRT_CONN, " invalid ts packet" );
487
+ // Ignore if invalid length.
488
+ if (nb_buf <= 0 ) {
489
+ return err;
490
+ }
491
+
492
+ // Check srt payload, mpegts must be N times of SRS_TS_PACKET_SIZE
493
+ if ((nb_buf % SRS_TS_PACKET_SIZE) != 0 ) {
494
+ return srs_error_new (ERROR_SRT_CONN, " invalid ts packet len=%d" , nb_buf);
495
+ }
496
+
497
+ // Check srt payload, the first byte must be 0x47
498
+ if (buf[0 ] != 0x47 ) {
499
+ return srs_error_new (ERROR_SRT_CONN, " invalid ts packet first=%#x" , (uint8_t )buf[0 ]);
491
500
}
492
501
493
502
SrsSrtPacket* packet = new SrsSrtPacket ();
0 commit comments