@@ -43,8 +43,9 @@ static char *ngx_rtmp_gop_cache_merge_app_conf(ngx_conf_t *cf,
43
43
void * parent , void * child );
44
44
45
45
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 ;
48
49
49
50
50
51
static 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,
579
580
void
580
581
ngx_rtmp_gop_cache_send (ngx_rtmp_session_t * s )
581
582
{
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 ;
597
598
598
599
lacf = ngx_rtmp_get_module_app_conf (s , ngx_rtmp_live_module );
599
600
if (lacf == NULL ) {
@@ -616,7 +617,7 @@ ngx_rtmp_gop_cache_send(ngx_rtmp_session_t *s)
616
617
pub_ctx = ctx -> stream -> pub_ctx ;
617
618
rs = pub_ctx -> session ;
618
619
s -> publisher = rs ;
619
- handler = ngx_rtmp_process_handlers [ctx -> protocol ];
620
+ handler = ngx_rtmp_live_process_handlers [ctx -> protocol ];
620
621
621
622
gctx = ngx_rtmp_get_module_ctx (rs , ngx_rtmp_gop_cache_module );
622
623
if (gctx == NULL ) {
@@ -627,7 +628,7 @@ ngx_rtmp_gop_cache_send(ngx_rtmp_session_t *s)
627
628
if (ctx -> protocol == NGX_RTMP_PROTOCOL_HTTP ) {
628
629
r = s -> data ;
629
630
if (r == NULL || (r -> connection && r -> connection -> destroyed )) {
630
- return ;
631
+ goto clear ;
631
632
}
632
633
633
634
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)
653
654
if (handler -> send_message_pt (s , meta , 0 ) == NGX_OK ) {
654
655
ctx -> meta_version = meta_version ;
655
656
}
656
-
657
- handler -> free_message_pt (s , meta );
658
- meta = NULL ;
659
657
}
660
658
661
659
for (gop_frame = cache -> frame_head ;
@@ -693,11 +691,6 @@ ngx_rtmp_gop_cache_send(ngx_rtmp_session_t *s)
693
691
cs -> active = 1 ;
694
692
s -> current_time = cs -> timestamp ;
695
693
}
696
-
697
- if (apkt ) {
698
- handler -> free_message_pt (s , apkt );
699
- apkt = NULL ;
700
- }
701
694
}
702
695
703
696
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)
706
699
707
700
cs -> dropped += delta ;
708
701
709
- return ;
710
- }
711
-
712
- if (pkt ) {
713
- handler -> free_message_pt (s , pkt );
714
- pkt = NULL ;
702
+ goto clear ;
715
703
}
716
704
717
705
ngx_log_error (NGX_LOG_INFO , s -> connection -> log , 0 ,
@@ -726,6 +714,22 @@ ngx_rtmp_gop_cache_send(ngx_rtmp_session_t *s)
726
714
s -> current_time = cs -> timestamp ;
727
715
}
728
716
}
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
+ }
729
733
}
730
734
731
735
0 commit comments