@@ -432,6 +432,13 @@ player_predestroy_cb(struct rtpp_stats *rtpp_stats)
432432 CALL_SMETHOD (rtpp_stats , updatebyname , "nplrs_destroyed" , 1 );
433433}
434434
435+ static enum pproc_action
436+ drop_packets (const struct pkt_proc_ctx * pktxp )
437+ {
438+
439+ return (PPROC_ACT_DROP );
440+ }
441+
435442static int
436443rtpp_stream_handle_play (struct rtpp_stream * self , const char * codecs ,
437444 const char * pname , int playcount , struct rtpp_command * cmd , int ptime )
@@ -447,13 +454,21 @@ rtpp_stream_handle_play(struct rtpp_stream *self, const char *codecs,
447454 .ptime = ptime };
448455
449456 PUB2PVT (self , pvt );
457+
458+ const struct packet_processor_if drop_on_pa_poi = {
459+ .descr = "drop_packets(player_active)" ,
460+ .arg = (void * )pvt ,
461+ .key = (void * )(pvt + 2 ),
462+ .enqueue = & drop_packets
463+ };
464+
450465 pthread_mutex_lock (& pvt -> lock );
451466 plerror = "reason unknown" ;
452467 while (* codecs != '\0' ) {
453468 n = strtol (codecs , & cp , 10 );
454469 if (cp == codecs ) {
455470 plerror = "invalid codecs" ;
456- break ;
471+ goto e0 ;
457472 }
458473 codecs = cp ;
459474 if (* codecs != '\0' )
@@ -466,16 +481,21 @@ rtpp_stream_handle_play(struct rtpp_stream *self, const char *codecs,
466481 plerror = "rtpp_server_ctor() failed" ;
467482 if (sca .result == RTPP_SERV_NOENT )
468483 continue ;
469- break ;
484+ goto e0 ;
470485 }
471486 rsrv -> stuid = self -> stuid ;
472487 ssrc = CALL_SMETHOD (rsrv , get_ssrc );
473488 seq = CALL_SMETHOD (rsrv , get_seq );
474489 _s_rtps (pvt , rsrv -> sruid , 0 );
490+ int regres = CALL_SMETHOD (self -> pproc_manager -> reverse , reg , PPROC_ORD_PLAY ,
491+ & drop_on_pa_poi );
492+ if (regres < 0 ) {
493+ plerror = "pproc_manager->reg() method failed" ;
494+ goto e1 ;
495+ }
475496 if (CALL_METHOD (pvt -> servers_wrt , reg , rsrv -> rcnt , rsrv -> sruid ) != 0 ) {
476- RTPP_OBJ_DECREF (rsrv );
477497 plerror = "servers_wrt->reg() method failed" ;
478- break ;
498+ goto e2 ;
479499 }
480500 if (pvt -> rtps .inact == 0 ) {
481501 CALL_SMETHOD (rsrv , start , cmd -> dtime -> mono );
@@ -490,6 +510,12 @@ rtpp_stream_handle_play(struct rtpp_stream *self, const char *codecs,
490510 playcount , pname , n , ssrc , seq );
491511 return 0 ;
492512 }
513+ goto e0 ;
514+ e2 :
515+ CALL_SMETHOD (self -> pproc_manager -> reverse , unreg , drop_on_pa_poi .key );
516+ e1 :
517+ RTPP_OBJ_DECREF (rsrv );
518+ e0 :
493519 pthread_mutex_unlock (& pvt -> lock );
494520 RTPP_LOG (pvt -> pub .log , RTPP_LOG_ERR , "can't create player: %s" , plerror );
495521 return -1 ;
@@ -508,6 +534,7 @@ rtpp_stream_handle_noplay(struct rtpp_stream *self)
508534 ruid = pvt -> rtps .uid ;
509535 pthread_mutex_unlock (& pvt -> lock );
510536 if (ruid != RTPP_UID_NONE ) {
537+ CALL_SMETHOD (self -> pproc_manager -> reverse , unreg , pvt + 2 );
511538 if (CALL_METHOD (pvt -> servers_wrt , unreg , ruid ) != NULL ) {
512539 pthread_mutex_lock (& pvt -> lock );
513540 if (pvt -> rtps .uid == ruid ) {
@@ -545,6 +572,7 @@ rtpp_stream_finish_playback(struct rtpp_stream *self, uint64_t sruid)
545572 PUB2PVT (self , pvt );
546573 pthread_mutex_lock (& pvt -> lock );
547574 if (pvt -> rtps .uid != RTPP_UID_NONE && pvt -> rtps .uid == sruid ) {
575+ CALL_SMETHOD (self -> pproc_manager -> reverse , unreg , pvt + 2 );
548576 _s_rtps (pvt , RTPP_UID_NONE , 1 );
549577 RTPP_LOG (pvt -> pub .log , RTPP_LOG_INFO ,
550578 "player at port %d has finished" , self -> port );
0 commit comments