Skip to content

Commit c544a69

Browse files
committed
add monitor module for monitor publisher and player buffer, if buffered, record in buffer log
1 parent 6c99cd1 commit c544a69

7 files changed

+401
-2
lines changed

config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ RTMP_CORE_MODULES=" \
2626
ngx_rtmp_dash_module \
2727
ngx_rtmp_shared_module \
2828
ngx_rtmp_gop_module \
29+
ngx_rtmp_monitor_module \
2930
"
3031

3132

@@ -53,6 +54,7 @@ RTMP_DEPS=" \
5354
$ngx_addon_dir/ngx_rtmp_streams.h \
5455
$ngx_addon_dir/ngx_rtmp_bitop.h \
5556
$ngx_addon_dir/ngx_rtmp_proxy_protocol.h \
57+
$ngx_addon_dir/ngx_rtmp_monitor_module.h \
5658
$ngx_addon_dir/hls/ngx_rtmp_mpegts.h \
5759
$ngx_addon_dir/dash/ngx_rtmp_mp4.h \
5860
$ngx_addon_dir/http/ngx_http_set_header.h \
@@ -96,6 +98,7 @@ RTMP_CORE_SRCS=" \
9698
$ngx_addon_dir/ngx_live.c \
9799
$ngx_addon_dir/ngx_rtmp_shared_module.c \
98100
$ngx_addon_dir/ngx_rtmp_gop_module.c \
101+
$ngx_addon_dir/ngx_rtmp_monitor_module.c \
99102
$ngx_addon_dir/ngx_rtmp_auth_request_module.c \
100103
$ngx_addon_dir/ngx_rtmp_dynamic.c \
101104
"

http/ngx_http_flv_live_module.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "ngx_rtmp_cmd_module.h"
1212
#include "ngx_rbuf.h"
1313
#include "ngx_http_set_header.h"
14+
#include "ngx_rtmp_monitor_module.h"
1415

1516

1617
static char *ngx_http_flv_live(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
@@ -226,6 +227,8 @@ ngx_http_flv_live_prepare_out_chain(ngx_http_request_t *r,
226227
(*ll)->buf->last = p;
227228
(*ll)->buf->flush = 1;
228229

230+
ngx_rtmp_monitor_frame(s, &frame->hdr, NULL, frame->av_header, 0);
231+
229232
return head;
230233

231234
falied:

ngx_rtmp_codec_module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ ngx_rtmp_codec_meta_data(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
853853
ctx->width = (ngx_uint_t) v.width;
854854
ctx->height = (ngx_uint_t) v.height;
855855
ctx->duration = (ngx_uint_t) v.duration;
856-
ctx->frame_rate = (ngx_uint_t) v.frame_rate;
856+
ctx->frame_rate = v.frame_rate;
857857
ctx->video_data_rate = (ngx_uint_t) v.video_data_rate;
858858
ctx->video_codec_id = (ngx_uint_t) v.video_codec_id_n;
859859
ctx->audio_data_rate = (ngx_uint_t) v.audio_data_rate;

ngx_rtmp_codec_module.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ typedef struct {
5353
ngx_uint_t width;
5454
ngx_uint_t height;
5555
ngx_uint_t duration;
56-
ngx_uint_t frame_rate;
56+
double frame_rate;
5757
ngx_uint_t video_data_rate;
5858
ngx_uint_t video_codec_id;
5959
ngx_uint_t audio_data_rate;

ngx_rtmp_handler.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "ngx_rtmp.h"
1010
#include "ngx_rtmp_amf.h"
1111
#include "ngx_rbuf.h"
12+
#include "ngx_rtmp_monitor_module.h"
1213

1314

1415
static void ngx_rtmp_recv(ngx_event_t *rev);
@@ -649,6 +650,8 @@ ngx_rtmp_prepare_out_chain(ngx_rtmp_session_t *s, ngx_rtmp_frame_t *frame)
649650
(*ll)->buf->last = l->buf->last;
650651
}
651652

653+
ngx_rtmp_monitor_frame(s, &frame->hdr, NULL, frame->av_header, 0);
654+
652655
return head;
653656

654657
failed:

0 commit comments

Comments
 (0)