Skip to content

Commit 9daa6dd

Browse files
committed
[dev] refactor the calling order of modules (developing).
1 parent fb6311f commit 9daa6dd

File tree

4 files changed

+39
-109
lines changed

4 files changed

+39
-109
lines changed

Diff for: config

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ RTMP_DEPS=" \
4747
$ngx_addon_dir/ngx_rtmp_record_module.h \
4848
$ngx_addon_dir/ngx_rtmp_gop_cache_module.h \
4949
$ngx_addon_dir/ngx_rtmp_relay_module.h \
50-
$ngx_addon_dir/ngx_rtmp_exec_module.h \
5150
$ngx_addon_dir/ngx_rtmp_streams.h \
5251
$ngx_addon_dir/ngx_rtmp_bitop.h \
5352
$ngx_addon_dir/ngx_rtmp_proxy_protocol.h \

Diff for: ngx_http_flv_live_module.c

-54
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
#include <ngx_core.h>
88
#include <ngx_http.h>
99
#include "ngx_http_flv_live_module.h"
10-
#include "ngx_rtmp_relay_module.h"
11-
#include "ngx_rtmp_exec_module.h"
1210
#include "ngx_rtmp_bandwidth.h"
1311

1412

@@ -198,7 +196,6 @@ static void ngx_http_flv_live_free_request(ngx_rtmp_session_t *s);
198196

199197

200198
static void ngx_http_flv_live_play_handler(ngx_event_t *ev);
201-
static void ngx_http_flv_live_exec_pull_handler(ngx_event_t *ev);
202199
static void ngx_http_flv_live_read_handler(ngx_event_t *rev);
203200
static void ngx_http_flv_live_write_handler(ngx_event_t *wev);
204201

@@ -1074,13 +1071,9 @@ ngx_http_flv_live_join(ngx_rtmp_session_t *s, u_char *name,
10741071
unsigned int publisher)
10751072
{
10761073
ngx_rtmp_live_ctx_t *ctx;
1077-
ngx_http_flv_live_ctx_t *hctx;
1078-
ngx_http_request_t *r;
10791074
ngx_rtmp_live_stream_t **stream;
10801075
ngx_rtmp_live_app_conf_t *lacf;
10811076

1082-
ngx_rtmp_relay_app_conf_t *racf;
1083-
ngx_rtmp_exec_app_conf_t *eacf;
10841077
ngx_flag_t create;
10851078

10861079
/* only for subscribers */
@@ -1114,26 +1107,6 @@ ngx_http_flv_live_join(ngx_rtmp_session_t *s, u_char *name,
11141107
ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0,
11151108
"flv live: join '%s'", name);
11161109

1117-
racf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_relay_module);
1118-
eacf = ngx_rtmp_get_module_app_conf(s, ngx_rtmp_exec_module);
1119-
if (racf && racf->pulls.nelts) {
1120-
create = 1;
1121-
}
1122-
1123-
if (!create && eacf && eacf->conf[NGX_RTMP_EXEC_PULL].nelts > 0) {
1124-
create = 1;
1125-
1126-
r = s->data;
1127-
hctx = ngx_http_get_module_ctx(r, ngx_http_flv_live_module);
1128-
1129-
ngx_memzero(&hctx->play, sizeof(ngx_event_t));
1130-
hctx->play.handler = ngx_http_flv_live_exec_pull_handler;
1131-
hctx->play.log = s->connection->log;
1132-
hctx->play.data = s->connection;
1133-
1134-
ngx_add_timer(&hctx->play, s->timeout);
1135-
}
1136-
11371110
stream = ngx_rtmp_live_get_stream(s, name,
11381111
lacf->idle_streams || s->wait_notify_play || create);
11391112

@@ -1579,33 +1552,6 @@ ngx_http_flv_live_play_handler(ngx_event_t *ev)
15791552
}
15801553

15811554

1582-
void
1583-
ngx_http_flv_live_exec_pull_handler(ngx_event_t *ev)
1584-
{
1585-
ngx_connection_t *c;
1586-
ngx_http_request_t *r;
1587-
ngx_rtmp_session_t *s;
1588-
ngx_http_flv_live_ctx_t *ctx;
1589-
1590-
c = ev->data;
1591-
if (c->destroyed) {
1592-
return;
1593-
}
1594-
1595-
r = c->data;
1596-
ctx = ngx_http_get_module_ctx(r, ngx_http_flv_live_module);
1597-
s = ctx->s;
1598-
1599-
if (ev->timer_set) {
1600-
ngx_del_timer(ev);
1601-
}
1602-
1603-
if (!ctx->header_sent) {
1604-
ngx_rtmp_finalize_session(s);
1605-
}
1606-
}
1607-
1608-
16091555
void
16101556
ngx_http_flv_live_read_handler(ngx_event_t *rev)
16111557
{

Diff for: ngx_rtmp_exec_module.c

+39-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include "ngx_rtmp_cmd_module.h"
1010
#include "ngx_rtmp_record_module.h"
1111
#include "ngx_rtmp_eval.h"
12-
#include "ngx_rtmp_exec_module.h"
1312
#include <stdlib.h>
1413

1514
#ifdef NGX_LINUX
@@ -48,6 +47,22 @@ static char *ngx_rtmp_exec_kill_signal(ngx_conf_t *cf, ngx_command_t *cmd,
4847
#define NGX_RTMP_EXEC_PLAYING 0x02
4948

5049

50+
enum {
51+
NGX_RTMP_EXEC_PUSH,
52+
NGX_RTMP_EXEC_PULL,
53+
54+
NGX_RTMP_EXEC_PUBLISH,
55+
NGX_RTMP_EXEC_PUBLISH_DONE,
56+
NGX_RTMP_EXEC_PLAY,
57+
NGX_RTMP_EXEC_PLAY_DONE,
58+
NGX_RTMP_EXEC_RECORD_DONE,
59+
60+
NGX_RTMP_EXEC_MAX,
61+
62+
NGX_RTMP_EXEC_STATIC
63+
};
64+
65+
5166
typedef struct {
5267
ngx_str_t id;
5368
ngx_uint_t type;
@@ -84,6 +99,29 @@ typedef struct {
8499
} ngx_rtmp_exec_main_conf_t;
85100

86101

102+
typedef struct ngx_rtmp_exec_pull_ctx_s ngx_rtmp_exec_pull_ctx_t;
103+
104+
struct ngx_rtmp_exec_pull_ctx_s {
105+
ngx_pool_t *pool;
106+
ngx_uint_t counter;
107+
ngx_str_t name;
108+
ngx_str_t app;
109+
ngx_array_t pull_exec; /* ngx_rtmp_exec_t */
110+
ngx_rtmp_exec_pull_ctx_t *next;
111+
};
112+
113+
114+
typedef struct {
115+
ngx_int_t active;
116+
ngx_array_t conf[NGX_RTMP_EXEC_MAX];
117+
/* ngx_rtmp_exec_conf_t */
118+
ngx_flag_t respawn;
119+
ngx_flag_t options;
120+
ngx_uint_t nbuckets;
121+
ngx_rtmp_exec_pull_ctx_t **pull;
122+
} ngx_rtmp_exec_app_conf_t;
123+
124+
87125
typedef struct {
88126
ngx_uint_t flags;
89127
ngx_str_t path; /* /tmp/rec/myfile-123.flv */

Diff for: ngx_rtmp_exec_module.h

-53
This file was deleted.

0 commit comments

Comments
 (0)