mirror of
https://github.com/arut/nginx-rtmp-module.git
synced 2025-08-06 15:00:18 +08:00
improved vod scheduling: added dry buffer event
This commit is contained in:
@ -178,6 +178,8 @@ typedef struct {
|
|||||||
ngx_str_t *addr_text;
|
ngx_str_t *addr_text;
|
||||||
int connected;
|
int connected;
|
||||||
|
|
||||||
|
ngx_event_t *posted_dry_events;
|
||||||
|
|
||||||
/* client buffer time in msec */
|
/* client buffer time in msec */
|
||||||
uint32_t buflen;
|
uint32_t buflen;
|
||||||
|
|
||||||
|
@ -537,6 +537,8 @@ ngx_rtmp_send(ngx_event_t *wev)
|
|||||||
if (wev->active) {
|
if (wev->active) {
|
||||||
ngx_del_event(wev, NGX_WRITE_EVENT, 0);
|
ngx_del_event(wev, NGX_WRITE_EVENT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngx_event_process_posted((ngx_cycle_t *) ngx_cycle, &s->posted_dry_events);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -244,6 +244,8 @@ static ngx_int_t ngx_rtmp_mp4_parse_avcC(ngx_rtmp_session_t *s, u_char *pos,
|
|||||||
u_char *last);
|
u_char *last);
|
||||||
static ngx_int_t ngx_rtmp_mp4_parse_mp4a(ngx_rtmp_session_t *s, u_char *pos,
|
static ngx_int_t ngx_rtmp_mp4_parse_mp4a(ngx_rtmp_session_t *s, u_char *pos,
|
||||||
u_char *last);
|
u_char *last);
|
||||||
|
static ngx_int_t ngx_rtmp_mp4_parse_mp4v(ngx_rtmp_session_t *s, u_char *pos,
|
||||||
|
u_char *last);
|
||||||
static ngx_int_t ngx_rtmp_mp4_parse_esds(ngx_rtmp_session_t *s, u_char *pos,
|
static ngx_int_t ngx_rtmp_mp4_parse_esds(ngx_rtmp_session_t *s, u_char *pos,
|
||||||
u_char *last);
|
u_char *last);
|
||||||
static ngx_int_t ngx_rtmp_mp4_parse_mp3(ngx_rtmp_session_t *s, u_char *pos,
|
static ngx_int_t ngx_rtmp_mp4_parse_mp3(ngx_rtmp_session_t *s, u_char *pos,
|
||||||
@ -282,6 +284,7 @@ static ngx_rtmp_mp4_box_t ngx_rtmp_mp4_boxes[] = {
|
|||||||
{ ngx_rtmp_mp4_make_tag('a','v','c','1'), ngx_rtmp_mp4_parse_avc1 },
|
{ ngx_rtmp_mp4_make_tag('a','v','c','1'), ngx_rtmp_mp4_parse_avc1 },
|
||||||
{ ngx_rtmp_mp4_make_tag('a','v','c','C'), ngx_rtmp_mp4_parse_avcC },
|
{ ngx_rtmp_mp4_make_tag('a','v','c','C'), ngx_rtmp_mp4_parse_avcC },
|
||||||
{ ngx_rtmp_mp4_make_tag('m','p','4','a'), ngx_rtmp_mp4_parse_mp4a },
|
{ ngx_rtmp_mp4_make_tag('m','p','4','a'), ngx_rtmp_mp4_parse_mp4a },
|
||||||
|
{ ngx_rtmp_mp4_make_tag('m','p','4','v'), ngx_rtmp_mp4_parse_mp4v },
|
||||||
{ ngx_rtmp_mp4_make_tag('e','s','d','s'), ngx_rtmp_mp4_parse_esds },
|
{ ngx_rtmp_mp4_make_tag('e','s','d','s'), ngx_rtmp_mp4_parse_esds },
|
||||||
{ ngx_rtmp_mp4_make_tag('.','m','p','3'), ngx_rtmp_mp4_parse_mp3 },
|
{ ngx_rtmp_mp4_make_tag('.','m','p','3'), ngx_rtmp_mp4_parse_mp3 },
|
||||||
{ ngx_rtmp_mp4_make_tag('n','m','o','s'), ngx_rtmp_mp4_parse_nmos },
|
{ ngx_rtmp_mp4_make_tag('n','m','o','s'), ngx_rtmp_mp4_parse_nmos },
|
||||||
@ -647,6 +650,13 @@ ngx_rtmp_mp4_parse_avc1(ngx_rtmp_session_t *s, u_char *pos, u_char *last)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static ngx_int_t
|
||||||
|
ngx_rtmp_mp4_parse_mp4v(ngx_rtmp_session_t *s, u_char *pos, u_char *last)
|
||||||
|
{
|
||||||
|
return ngx_rtmp_mp4_parse_video(s, pos, last, NGX_RTMP_VIDEO_H264);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static ngx_int_t
|
static ngx_int_t
|
||||||
ngx_rtmp_mp4_parse_avcC(ngx_rtmp_session_t *s, u_char *pos, u_char *last)
|
ngx_rtmp_mp4_parse_avcC(ngx_rtmp_session_t *s, u_char *pos, u_char *last)
|
||||||
{
|
{
|
||||||
@ -2039,6 +2049,7 @@ ngx_rtmp_mp4_send(ngx_event_t *e)
|
|||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
u_char fhdr[5];
|
u_char fhdr[5];
|
||||||
size_t fhdr_size;
|
size_t fhdr_size;
|
||||||
|
ngx_int_t rc;
|
||||||
ngx_uint_t n, abs_frame, active;
|
ngx_uint_t n, abs_frame, active;
|
||||||
|
|
||||||
s = e->data;
|
s = e->data;
|
||||||
@ -2129,9 +2140,13 @@ ngx_rtmp_mp4_send(ngx_event_t *e)
|
|||||||
ngx_rtmp_append_shared_bufs(cscf, out, &in);
|
ngx_rtmp_append_shared_bufs(cscf, out, &in);
|
||||||
|
|
||||||
ngx_rtmp_prepare_message(s, &h, NULL, out);
|
ngx_rtmp_prepare_message(s, &h, NULL, out);
|
||||||
ngx_rtmp_send_message(s, out, 0);
|
rc = ngx_rtmp_send_message(s, out, 0);
|
||||||
ngx_rtmp_free_shared_chain(cscf, out);
|
ngx_rtmp_free_shared_chain(cscf, out);
|
||||||
|
|
||||||
|
if (rc == NGX_AGAIN) {
|
||||||
|
goto full;
|
||||||
|
}
|
||||||
|
|
||||||
t->header_sent = 1;
|
t->header_sent = 1;
|
||||||
|
|
||||||
goto next;
|
goto next;
|
||||||
@ -2192,9 +2207,13 @@ ngx_rtmp_mp4_send(ngx_event_t *e)
|
|||||||
out = ngx_rtmp_append_shared_bufs(cscf, NULL, &in);
|
out = ngx_rtmp_append_shared_bufs(cscf, NULL, &in);
|
||||||
|
|
||||||
ngx_rtmp_prepare_message(s, &h, abs_frame ? NULL : &lh, out);
|
ngx_rtmp_prepare_message(s, &h, abs_frame ? NULL : &lh, out);
|
||||||
ngx_rtmp_send_message(s, out, 0);
|
rc = ngx_rtmp_send_message(s, out, 0);
|
||||||
ngx_rtmp_free_shared_chain(cscf, out);
|
ngx_rtmp_free_shared_chain(cscf, out);
|
||||||
|
|
||||||
|
if (rc == NGX_AGAIN) {
|
||||||
|
goto full;
|
||||||
|
}
|
||||||
|
|
||||||
if (ngx_rtmp_mp4_next(s, t) != NGX_OK) {
|
if (ngx_rtmp_mp4_next(s, t) != NGX_OK) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -2225,6 +2244,14 @@ again:
|
|||||||
ngx_rtmp_send_user_stream_eof(s, NGX_RTMP_MSID);
|
ngx_rtmp_send_user_stream_eof(s, NGX_RTMP_MSID);
|
||||||
|
|
||||||
ngx_rtmp_send_status(s, "NetStream.Play.Stop", "status", "Stopped");
|
ngx_rtmp_send_status(s, "NetStream.Play.Stop", "status", "Stopped");
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
full:
|
||||||
|
ngx_post_event(e, &s->posted_dry_events);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user