@@ -43,8 +43,9 @@ static char *ngx_rtmp_gop_cache_merge_app_conf(ngx_conf_t *cf,
4343 void * parent , void * child );
4444
4545
46- extern ngx_rtmp_process_handler_t * ngx_rtmp_process_handlers [2 ];
47- extern ngx_module_t ngx_http_flv_live_module ;
46+ extern ngx_rtmp_live_process_handler_t * ngx_rtmp_live_process_handlers
47+ [NGX_RTMP_PROTOCOL_HTTP + 1 ];
48+ extern ngx_module_t ngx_http_flv_live_module ;
4849
4950
5051static ngx_command_t ngx_rtmp_gop_cache_commands [] = {
@@ -579,21 +580,21 @@ ngx_rtmp_gop_cache_frame(ngx_rtmp_session_t *s, ngx_uint_t prio,
579580void
580581ngx_rtmp_gop_cache_send (ngx_rtmp_session_t * s )
581582{
582- ngx_rtmp_session_t * rs ;
583- ngx_chain_t * pkt , * apkt , * meta , * header ;
584- ngx_rtmp_live_ctx_t * ctx , * pub_ctx ;
585- ngx_http_flv_live_ctx_t * hflctx ;
586- ngx_rtmp_gop_cache_ctx_t * gctx ;
587- ngx_rtmp_live_app_conf_t * lacf ;
588- ngx_rtmp_gop_cache_t * cache ;
589- ngx_rtmp_gop_frame_t * gop_frame ;
590- ngx_rtmp_header_t ch , lh ;
591- ngx_uint_t meta_version ;
592- uint32_t delta ;
593- ngx_int_t csidx ;
594- ngx_rtmp_live_chunk_stream_t * cs ;
595- ngx_rtmp_process_handler_t * handler ;
596- ngx_http_request_t * r ;
583+ ngx_rtmp_session_t * rs ;
584+ ngx_chain_t * pkt , * apkt , * meta , * header ;
585+ ngx_rtmp_live_ctx_t * ctx , * pub_ctx ;
586+ ngx_http_flv_live_ctx_t * hflctx ;
587+ ngx_rtmp_gop_cache_ctx_t * gctx ;
588+ ngx_rtmp_live_app_conf_t * lacf ;
589+ ngx_rtmp_gop_cache_t * cache ;
590+ ngx_rtmp_gop_frame_t * gop_frame ;
591+ ngx_rtmp_header_t ch , lh ;
592+ ngx_uint_t meta_version ;
593+ uint32_t delta ;
594+ ngx_int_t csidx ;
595+ ngx_rtmp_live_chunk_stream_t * cs ;
596+ ngx_rtmp_live_process_handler_t * handler ;
597+ ngx_http_request_t * r ;
597598
598599 lacf = ngx_rtmp_get_module_app_conf (s , ngx_rtmp_live_module );
599600 if (lacf == NULL ) {
@@ -616,7 +617,7 @@ ngx_rtmp_gop_cache_send(ngx_rtmp_session_t *s)
616617 pub_ctx = ctx -> stream -> pub_ctx ;
617618 rs = pub_ctx -> session ;
618619 s -> publisher = rs ;
619- handler = ngx_rtmp_process_handlers [ctx -> protocol ];
620+ handler = ngx_rtmp_live_process_handlers [ctx -> protocol ];
620621
621622 gctx = ngx_rtmp_get_module_ctx (rs , ngx_rtmp_gop_cache_module );
622623 if (gctx == NULL ) {
@@ -627,7 +628,7 @@ ngx_rtmp_gop_cache_send(ngx_rtmp_session_t *s)
627628 if (ctx -> protocol == NGX_RTMP_PROTOCOL_HTTP ) {
628629 r = s -> data ;
629630 if (r == NULL || (r -> connection && r -> connection -> destroyed )) {
630- return ;
631+ goto clear ;
631632 }
632633
633634 hflctx = ngx_http_get_module_ctx (r , ngx_http_flv_live_module );
@@ -653,9 +654,6 @@ ngx_rtmp_gop_cache_send(ngx_rtmp_session_t *s)
653654 if (handler -> send_message_pt (s , meta , 0 ) == NGX_OK ) {
654655 ctx -> meta_version = meta_version ;
655656 }
656-
657- handler -> free_message_pt (s , meta );
658- meta = NULL ;
659657 }
660658
661659 for (gop_frame = cache -> frame_head ;
@@ -693,11 +691,6 @@ ngx_rtmp_gop_cache_send(ngx_rtmp_session_t *s)
693691 cs -> active = 1 ;
694692 s -> current_time = cs -> timestamp ;
695693 }
696-
697- if (apkt ) {
698- handler -> free_message_pt (s , apkt );
699- apkt = NULL ;
700- }
701694 }
702695
703696 pkt = handler -> append_message_pt (s , & ch , & lh , gop_frame -> frame );
@@ -706,12 +699,7 @@ ngx_rtmp_gop_cache_send(ngx_rtmp_session_t *s)
706699
707700 cs -> dropped += delta ;
708701
709- return ;
710- }
711-
712- if (pkt ) {
713- handler -> free_message_pt (s , pkt );
714- pkt = NULL ;
702+ goto clear ;
715703 }
716704
717705 ngx_log_error (NGX_LOG_INFO , s -> connection -> log , 0 ,
@@ -726,6 +714,22 @@ ngx_rtmp_gop_cache_send(ngx_rtmp_session_t *s)
726714 s -> current_time = cs -> timestamp ;
727715 }
728716 }
717+
718+ return ;
719+
720+ clear :
721+
722+ if (meta ) {
723+ handler -> free_message_pt (s , meta );
724+ }
725+
726+ if (pkt ) {
727+ handler -> free_message_pt (s , pkt );
728+ }
729+
730+ if (apkt ) {
731+ handler -> free_message_pt (s , apkt );
732+ }
729733}
730734
731735
0 commit comments