@@ -1178,6 +1178,7 @@ static ngx_int_t
11781178ngx_rtmp_live_data (ngx_rtmp_session_t * s , ngx_rtmp_header_t * h ,
11791179 ngx_chain_t * in , ngx_rtmp_amf_elt_t * out_elts , ngx_uint_t out_elts_size )
11801180{
1181+ ngx_rtmp_live_proc_handler_t * handler ;
11811182 ngx_rtmp_live_ctx_t * ctx , * pctx ;
11821183 ngx_chain_t * data , * rpkt ;
11831184 ngx_rtmp_core_srv_conf_t * cscf ;
@@ -1190,6 +1191,7 @@ ngx_rtmp_live_data(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
11901191 ngx_uint_t peers ;
11911192 uint32_t delta ;
11921193 ngx_rtmp_live_chunk_stream_t * cs ;
1194+ ngx_http_request_t * http_request ;
11931195#ifdef NGX_DEBUG
11941196 u_char * msg_type ;
11951197
@@ -1254,19 +1256,41 @@ ngx_rtmp_live_data(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
12541256 delta = ch .timestamp - cs -> timestamp ;
12551257
12561258 rpkt = ngx_rtmp_append_shared_bufs (cscf , data , in );
1257- ngx_rtmp_prepare_message (s , & ch , NULL , rpkt );
12581259
12591260 for (pctx = ctx -> stream -> ctx ; pctx ; pctx = pctx -> next ) {
12601261 if (pctx == ctx || pctx -> paused ) {
12611262 continue ;
12621263 }
12631264
12641265 ss = pctx -> session ;
1265-
1266- if (ngx_rtmp_send_message (ss , rpkt , prio ) != NGX_OK ) {
1267- ++ pctx -> ndropped ;
1268- cs -> dropped += delta ;
1269- continue ;
1266+ handler = ngx_rtmp_live_proc_handlers [pctx -> protocol ];
1267+ if (pctx -> protocol == NGX_RTMP_PROTOCOL_HTTP ) {
1268+ http_request = ss -> data ;
1269+ if (http_request == NULL || (http_request -> connection && http_request -> connection -> destroyed )) {
1270+ continue ;
1271+ }
1272+ handler -> meta = handler -> append_message_pt (ss ,& ch ,NULL ,rpkt );
1273+ if (handler -> meta == NULL ) {
1274+ continue ;
1275+ }
1276+ if (handler -> meta ) {
1277+ if (handler -> send_message_pt (ss ,handler -> meta ,0 ) != NGX_OK ) {
1278+ ++ pctx -> ndropped ;
1279+ cs -> dropped += delta ;
1280+ handler -> free_message_pt (ss , handler -> meta );
1281+ handler -> meta = NULL ;
1282+ continue ;
1283+ }
1284+ handler -> free_message_pt (ss , handler -> meta );
1285+ handler -> meta = NULL ;
1286+ }
1287+ } else {
1288+ ngx_rtmp_prepare_message (s , & ch , NULL , rpkt );
1289+ if (ngx_rtmp_send_message (ss , rpkt , prio ) != NGX_OK ) {
1290+ ++ pctx -> ndropped ;
1291+ cs -> dropped += delta ;
1292+ continue ;
1293+ }
12701294 }
12711295
12721296 cs -> timestamp += delta ;
0 commit comments