forked from AlexWoo/nginx-rtmp-module
-
Notifications
You must be signed in to change notification settings - Fork 42
/
ngx_live_relay.h
99 lines (70 loc) · 2.91 KB
/
ngx_live_relay.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* Copyright (C) AlexWoo(Wu Jie) [email protected]
*/
#ifndef _NGX_LIVE_RELAY_H_INCLUDE_
#define _NGX_LIVE_RELAY_H_INCLUDE_
#include <ngx_core.h>
#include "ngx_rtmp.h"
#define NGX_LIVE_RELAY_HTTPFLV 0
#define NGX_LIVE_RELAY_RTMP 1
#define NGX_LIVE_RELAY_MAXTYPE 2
typedef struct {
// reconnect
ngx_event_t reconnect;
ngx_flag_t successd; // connect successd
/*
* connect failed for first time, reconnect immediately
* then reconnect after failed_reconect
* then reconnect after 2 * failed_reconect
* then reconnect after 2 * 2 * failed_reconect
* ...
* when failed_reconnect is bigger than relay_reconnect
* then use relay_reconnect as failed_reconect
*
* connect failed not include connect timeout
*/
ngx_msec_t failed_reconnect; // reconnect timeout
ngx_flag_t failed_delay;
ngx_flag_t giveup; // no need to reconnect
// base para
ngx_str_t domain;
ngx_str_t app;
ngx_str_t args; // rtmp app args
ngx_str_t name;
ngx_str_t pargs;
// other para
ngx_str_t referer; // rtmp page_url
ngx_str_t user_agent; // rtmp flashver
ngx_str_t swf_url; // rtmp swf_url
uint32_t acodecs;
uint32_t vcodecs;
void *tag;
ngx_uint_t idx;
} ngx_live_relay_ctx_t;
typedef struct {
ngx_request_url_t url;
in_port_t port;
ngx_uint_t relay_type;
} ngx_live_relay_url_t;
typedef struct {
ngx_msec_t failed_reconnect;
ngx_msec_t relay_reconnect;
} ngx_live_relay_app_conf_t;
extern ngx_module_t ngx_live_relay_module;
ngx_int_t ngx_live_relay_create_httpflv(ngx_rtmp_session_t *rs,
ngx_live_relay_t *relay, ngx_live_relay_url_t *url);
ngx_int_t ngx_live_relay_create_rtmp(ngx_rtmp_session_t *rs,
ngx_live_relay_t *relay, ngx_live_relay_url_t *url);
ngx_int_t ngx_live_relay_create(ngx_rtmp_session_t *rs,
ngx_live_relay_t *relay);
ngx_int_t ngx_live_relay_play_local(ngx_rtmp_session_t *rs);
ngx_int_t ngx_live_relay_publish_local(ngx_rtmp_session_t *rs);
typedef ngx_int_t (*ngx_live_pull_pt)(ngx_rtmp_session_t *s);
typedef ngx_int_t (*ngx_live_push_pt)(ngx_rtmp_session_t *s);
typedef ngx_int_t (*ngx_live_pull_close_pt)(ngx_rtmp_session_t *s);
typedef ngx_int_t (*ngx_live_push_close_pt)(ngx_rtmp_session_t *s);
extern ngx_live_push_pt ngx_live_push;
extern ngx_live_pull_pt ngx_live_pull;
extern ngx_live_push_close_pt ngx_live_push_close;
extern ngx_live_pull_close_pt ngx_live_pull_close;
#endif