mirror of
https://github.com/zotanmew/nginx-rtmp-module.git
synced 2024-05-11 06:41:08 +02:00
improved vod scheduling: added dry buffer event
This commit is contained in:
parent
7f447bbe95
commit
24539ca116
|
@ -178,6 +178,8 @@ typedef struct {
|
|||
ngx_str_t *addr_text;
|
||||
int connected;
|
||||
|
||||
ngx_event_t *posted_dry_events;
|
||||
|
||||
/* client buffer time in msec */
|
||||
uint32_t buflen;
|
||||
|
||||
|
|
|
@ -537,6 +537,8 @@ ngx_rtmp_send(ngx_event_t *wev)
|
|||
if (wev->active) {
|
||||
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);
|
||||
static ngx_int_t ngx_rtmp_mp4_parse_mp4a(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);
|
||||
static ngx_int_t ngx_rtmp_mp4_parse_esds(ngx_rtmp_session_t *s, u_char *pos,
|
||||
u_char *last);
|
||||
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','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','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('.','m','p','3'), ngx_rtmp_mp4_parse_mp3 },
|
||||
{ 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
|
||||
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;
|
||||
u_char fhdr[5];
|
||||
size_t fhdr_size;
|
||||
ngx_int_t rc;
|
||||
ngx_uint_t n, abs_frame, active;
|
||||
|
||||
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_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);
|
||||
|
||||
if (rc == NGX_AGAIN) {
|
||||
goto full;
|
||||
}
|
||||
|
||||
t->header_sent = 1;
|
||||
|
||||
goto next;
|
||||
|
@ -2192,9 +2207,13 @@ ngx_rtmp_mp4_send(ngx_event_t *e)
|
|||
out = ngx_rtmp_append_shared_bufs(cscf, NULL, &in);
|
||||
|
||||
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);
|
||||
|
||||
if (rc == NGX_AGAIN) {
|
||||
goto full;
|
||||
}
|
||||
|
||||
if (ngx_rtmp_mp4_next(s, t) != NGX_OK) {
|
||||
continue;
|
||||
}
|
||||
|
@ -2225,6 +2244,14 @@ again:
|
|||
ngx_rtmp_send_user_stream_eof(s, NGX_RTMP_MSID);
|
||||
|
||||
ngx_rtmp_send_status(s, "NetStream.Play.Stop", "status", "Stopped");
|
||||
|
||||
return;
|
||||
|
||||
full:
|
||||
ngx_post_event(e, &s->posted_dry_events);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue