Skip to content

Commit ac13bbf

Browse files
committed
merged master into sync
o sync # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. # # Lines starting with '#' will be ignored, and an empty message aborts # the commit.
2 parents 9652689 + 17886de commit ac13bbf

16 files changed

+1744
-429
lines changed

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
## nginx-rtmp-module
33

44

5-
### Project page:
5+
### Project blog:
66

7-
http://arut.github.com/nginx-rtmp-module
7+
http://rarut.wordpress.com
88

99
### Wiki manual:
1010

11-
https://github.com/arut/nginx-rtmp-module/wiki
11+
https://github.com/arut/nginx-rtmp-module/wiki/Directives
1212

1313
### Features:
1414

@@ -19,17 +19,19 @@
1919
* Stream relay support for distributed
2020
streaming: push & pull models
2121

22-
* Recording published streams in FLV file
22+
* Recording streams in multiple FLVs
2323

2424
* H264/AAC support
2525

2626
* Online transcoding with FFmpeg
2727

2828
* HLS (HTTP Live Streaming) support;
29-
experimental; requires recent libavformat
29+
requires recent libavformat
3030
(>= 53.31.100) from ffmpeg (ffmpeg.org)
3131

32-
* HTTP callbacks on publish/play/record
32+
* HTTP callbacks (publish/play/record etc)
33+
34+
* Running external programs on certain events (exec)
3335

3436
* Advanced buffering techniques
3537
to keep memory allocations at a minimum
@@ -44,6 +46,8 @@
4446
* Statistics in XML/XSL in machine- & human-
4547
readable form
4648

49+
* Linux/FreeBSD/MacOS
50+
4751

4852
### Build:
4953

@@ -197,7 +201,7 @@ rtmp_auto_push directive.
197201
}
198202

199203

200-
# HLS (experimental)
204+
# HLS
201205

202206
# HLS requires libavformat & should be configured as a separate
203207
# NGINX module in addition to nginx-rtmp-module:

config

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ CORE_MODULES="$CORE_MODULES
55
ngx_rtmp_core_module \
66
ngx_rtmp_cmd_module \
77
ngx_rtmp_access_module \
8+
ngx_rtmp_record_module \
89
ngx_rtmp_live_module \
910
ngx_rtmp_play_module \
1011
ngx_rtmp_flv_module \
1112
ngx_rtmp_mp4_module \
12-
ngx_rtmp_record_module \
1313
ngx_rtmp_netcall_module \
14-
ngx_rtmp_notify_module \
1514
ngx_rtmp_relay_module \
1615
ngx_rtmp_exec_module \
1716
ngx_rtmp_codec_module \
17+
ngx_rtmp_auto_push_module \
18+
ngx_rtmp_enotify_module \
19+
ngx_rtmp_notify_module \
1820
"
1921

2022

@@ -31,23 +33,25 @@ NGX_ADDON_SRCS="$NGX_ADDON_SRCS \
3133
$ngx_addon_dir/ngx_rtmp_amf.c \
3234
$ngx_addon_dir/ngx_rtmp_send.c \
3335
$ngx_addon_dir/ngx_rtmp_shared.c \
36+
$ngx_addon_dir/ngx_rtmp_eval.c \
3437
$ngx_addon_dir/ngx_rtmp_receive.c \
3538
$ngx_addon_dir/ngx_rtmp_core_module.c \
3639
$ngx_addon_dir/ngx_rtmp_cmd_module.c \
3740
$ngx_addon_dir/ngx_rtmp_access_module.c \
41+
$ngx_addon_dir/ngx_rtmp_record_module.c \
3842
$ngx_addon_dir/ngx_rtmp_live_module.c \
3943
$ngx_addon_dir/ngx_rtmp_play_module.c \
4044
$ngx_addon_dir/ngx_rtmp_flv_module.c \
4145
$ngx_addon_dir/ngx_rtmp_mp4_module.c \
42-
$ngx_addon_dir/ngx_rtmp_record_module.c \
4346
$ngx_addon_dir/ngx_rtmp_netcall_module.c \
44-
$ngx_addon_dir/ngx_rtmp_notify_module.c \
4547
$ngx_addon_dir/ngx_rtmp_stat_module.c \
4648
$ngx_addon_dir/ngx_rtmp_relay_module.c \
4749
$ngx_addon_dir/ngx_rtmp_bandwidth.c \
4850
$ngx_addon_dir/ngx_rtmp_exec_module.c \
4951
$ngx_addon_dir/ngx_rtmp_codec_module.c \
5052
$ngx_addon_dir/ngx_rtmp_auto_push_module.c \
53+
$ngx_addon_dir/ngx_rtmp_enotify_module.c \
54+
$ngx_addon_dir/ngx_rtmp_notify_module.c \
5155
"
5256
CFLAGS="$CFLAGS -I$ngx_addon_dir"
5357

ngx_rtmp.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ ngx_rtmp_merge_applications(ngx_conf_t *cf, ngx_array_t *applications,
317317
ngx_rtmp_conf_ctx_t *ctx, saved;
318318
ngx_rtmp_core_app_conf_t **cacfp;
319319
ngx_uint_t n;
320+
ngx_rtmp_core_app_conf_t *cacf;
320321

321322
if (applications == NULL) {
322323
return NGX_CONF_OK;
@@ -335,6 +336,14 @@ ngx_rtmp_merge_applications(ngx_conf_t *cf, ngx_array_t *applications,
335336
if (rv != NGX_CONF_OK) {
336337
return rv;
337338
}
339+
340+
cacf = (*cacfp)->app_conf[ngx_rtmp_core_module.ctx_index];
341+
rv = ngx_rtmp_merge_applications(cf, &cacf->applications,
342+
(*cacfp)->app_conf,
343+
module, ctx_index);
344+
if (rv != NGX_CONF_OK) {
345+
return rv;
346+
}
338347
}
339348

340349
*ctx = saved;

ngx_rtmp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ typedef struct {
209209

210210
/* auto-pushed? */
211211
unsigned auto_pushed:1;
212+
unsigned relay:1;
212213

213214
/* input stream 0 (reserved by RTMP spec)
214215
* is used as free chain link */
@@ -294,6 +295,7 @@ typedef struct ngx_rtmp_core_srv_conf_s {
294295

295296

296297
typedef struct {
298+
ngx_array_t applications; /* ngx_rtmp_core_app_conf_t */
297299
ngx_str_t name;
298300
void **app_conf;
299301
} ngx_rtmp_core_app_conf_t;
@@ -326,6 +328,7 @@ typedef struct {
326328
#define NGX_RTMP_MAIN_CONF 0x02000000
327329
#define NGX_RTMP_SRV_CONF 0x04000000
328330
#define NGX_RTMP_APP_CONF 0x08000000
331+
#define NGX_RTMP_REC_CONF 0x10000000
329332

330333

331334
#define NGX_RTMP_MAIN_CONF_OFFSET offsetof(ngx_rtmp_conf_ctx_t, main_conf)

ngx_rtmp_auto_push_module.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ ngx_rtmp_auto_push_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v)
400400
ngx_rtmp_auto_push_conf_t *apcf;
401401
ngx_rtmp_auto_push_ctx_t *ctx;
402402

403-
if (s->auto_pushed) {
403+
if (s->auto_pushed || s->relay) {
404404
goto next;
405405
}
406406

ngx_rtmp_cmd_module.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ ngx_rtmp_cmd_connect(ngx_rtmp_session_t *s, ngx_rtmp_connect_t *v)
200200

201201
cscf = ngx_rtmp_get_module_srv_conf(s, ngx_rtmp_core_module);
202202

203-
ngx_log_debug8(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
203+
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
204204
"connect: app='%s' flashver='%s' swf_url='%s' "
205205
"tc_url='%s' page_url='%s' acodecs=%uD vcodecs=%uD "
206206
"object_encoding=%ui",
@@ -327,7 +327,7 @@ ngx_rtmp_cmd_create_stream(ngx_rtmp_session_t *s, ngx_rtmp_create_stream_t *v)
327327
h.csid = NGX_RTMP_CMD_CSID_AMF_INI;
328328
h.type = NGX_RTMP_MSG_AMF_CMD;
329329

330-
ngx_log_debug0(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
330+
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
331331
"createStream");
332332

333333
/* send result with standard stream */
@@ -415,6 +415,9 @@ ngx_rtmp_cmd_delete_stream(ngx_rtmp_session_t *s, ngx_rtmp_delete_stream_t *v)
415415
{
416416
ngx_rtmp_close_stream_t cv;
417417

418+
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
419+
"deleteStream");
420+
418421
/* chain close_stream */
419422
cv.stream = 0;
420423
return ngx_rtmp_close_stream
@@ -523,7 +526,7 @@ ngx_rtmp_cmd_publish(ngx_rtmp_session_t *s, ngx_rtmp_publish_t *v)
523526
out_inf, sizeof(out_inf) },
524527
};
525528

526-
ngx_log_debug4(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
529+
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
527530
"publish: name='%s' args='%s' type=%s silent=%d",
528531
v->name, v->args, v->type, v->silent);
529532

@@ -621,7 +624,7 @@ ngx_rtmp_cmd_fcpublish(ngx_rtmp_session_t *s, ngx_rtmp_fcpublish_t *v)
621624
out_inf, sizeof(out_inf) },
622625
};
623626

624-
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
627+
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
625628
"fcpublish: name='%s'", v->name);
626629

627630
/* send onFCPublish reply */
@@ -801,8 +804,8 @@ ngx_rtmp_cmd_play(ngx_rtmp_session_t *s, ngx_rtmp_play_t *v)
801804
out4_inf, sizeof(out4_inf) },
802805
};
803806

804-
ngx_log_debug6(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
805-
"cmd: play name='%s' args='%s' start=%i duration=%i "
807+
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
808+
"play name='%s' args='%s' start=%i duration=%i "
806809
"reset=%i silent=%i",
807810
v->name, v->args, (ngx_int_t) v->start,
808811
(ngx_int_t) v->duration, (ngx_int_t) v->reset,
@@ -934,7 +937,7 @@ ngx_rtmp_cmd_fcsubscribe(ngx_rtmp_session_t *s, ngx_rtmp_fcsubscribe_t *v)
934937
sizeof(out_inf) },
935938
};
936939

937-
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
940+
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
938941
"fcsubscribe: name='%s'", v->name);
939942

940943
/* send onFCSubscribe reply */
@@ -1038,6 +1041,10 @@ ngx_rtmp_cmd_pause(ngx_rtmp_session_t *s, ngx_rtmp_pause_t *v)
10381041
out_inf, sizeof(out_inf) },
10391042
};
10401043

1044+
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
1045+
"pause: state='%i' position=%i",
1046+
v->pause, (ngx_int_t) v->position);
1047+
10411048
/* send onStatus reply */
10421049
ngx_memzero(&h, sizeof(h));
10431050
h.type = NGX_RTMP_MSG_AMF_CMD;
@@ -1068,6 +1075,9 @@ static ngx_int_t
10681075
ngx_rtmp_cmd_disconnect(ngx_rtmp_session_t *s, ngx_rtmp_header_t *h,
10691076
ngx_chain_t *in)
10701077
{
1078+
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
1079+
"disconnect");
1080+
10711081
return ngx_rtmp_delete_stream
10721082
? ngx_rtmp_delete_stream(s, NULL)
10731083
: NGX_OK;
@@ -1152,6 +1162,9 @@ ngx_rtmp_cmd_seek(ngx_rtmp_session_t *s, ngx_rtmp_seek_t *v)
11521162
out_inf, sizeof(out_inf) },
11531163
};
11541164

1165+
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
1166+
"seek: offset=%i", (ngx_int_t) v->offset);
1167+
11551168
/* send onStatus reply */
11561169
ngx_memzero(&h, sizeof(h));
11571170
h.type = NGX_RTMP_MSG_AMF_CMD;

ngx_rtmp_core_module.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,13 @@ ngx_rtmp_core_create_app_conf(ngx_conf_t *cf)
282282
return NULL;
283283
}
284284

285+
if (ngx_array_init(&conf->applications, cf->pool, 1,
286+
sizeof(ngx_rtmp_core_app_conf_t *))
287+
!= NGX_OK)
288+
{
289+
return NULL;
290+
}
291+
285292
return conf;
286293
}
287294

0 commit comments

Comments
 (0)