forked from im-pingo/nginx-rtmp-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ngx_hls_live_module.h
95 lines (80 loc) · 2.99 KB
/
ngx_hls_live_module.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
/*
* Copyright (C) Pingo (cczjp89@gmail.com)
*/
#ifndef _NGX_HLS_LIVE_MODULE_H_INCLUDE_
#define _NGX_HLS_LIVE_MODULE_H_INCLUDE_
#define ngx_hls_live_next(s, pos) ((pos + 1) % s->out_queue)
#define ngx_hls_live_prev(s, pos) (pos == 0 ? s->out_queue - 1 : pos - 1)
typedef struct ngx_hls_live_frag_s ngx_hls_live_frag_t;
typedef struct ngx_hls_live_play_s ngx_hls_live_play_t;
struct ngx_hls_live_play_s {
ngx_str_t name;
/* connection parameters */
ngx_rtmp_addr_conf_t *addr_conf;
ngx_str_t app;
ngx_str_t stream;
ngx_str_t args;
ngx_str_t flashver;
ngx_str_t swf_url;
ngx_str_t tc_url;
uint32_t acodecs;
uint32_t vcodecs;
ngx_str_t page_url;
ngx_str_t domain;
ngx_str_t serverid;
ngx_log_t *log;
};
struct ngx_hls_live_frag_s {
ngx_uint_t ref;
ngx_hls_live_frag_t *next;
time_t last_modified_time;
uint64_t id;
uint64_t key_id;
double duration;
unsigned active:1;
unsigned discont:1; /* before */
ngx_uint_t length;
ngx_chain_t *out;
ngx_uint_t content_last;
ngx_uint_t content_pos;
ngx_mpegts_frame_t *content[0];
};
struct ngx_hls_live_ctx_s {
unsigned opened:1;
unsigned playing:1;
ngx_buf_t *patpmt;
ngx_rtmp_session_t *session;
ngx_str_t sid;
ngx_live_stream_t *stream;
ngx_str_t name;
uint64_t nfrag;
uint64_t frag_ts;
uint64_t key_id;
ngx_uint_t nfrags;
ngx_hls_live_frag_t **frags; /* circular 2 * winfrags + 1 */
ngx_hls_live_frag_t *frag;
ngx_uint_t audio_cc;
ngx_uint_t video_cc;
ngx_uint_t key_frags;
uint64_t aframe_base;
uint64_t aframe_num;
ngx_buf_t *aframe;
uint64_t aframe_pts;
ngx_event_t ev;
ngx_msec_t timeout;
ngx_msec_t last_time;
time_t playlist_modified_time;
ngx_buf_t *playlist;
ngx_hls_live_ctx_t *next;
};
ngx_int_t ngx_hls_live_write_playlist(ngx_rtmp_session_t *s, ngx_buf_t *out,
time_t *last_modified_time);
ngx_hls_live_frag_t* ngx_hls_live_find_frag(ngx_rtmp_session_t *s,
ngx_str_t *name);
ngx_chain_t* ngx_hls_live_prepare_frag(ngx_rtmp_session_t *s,
ngx_hls_live_frag_t *frag);
void ngx_hls_live_free_frag(ngx_hls_live_frag_t *frag);
ngx_rtmp_session_t* ngx_hls_live_fetch_session(ngx_str_t *server,
ngx_str_t *stream, ngx_str_t *session);
void ngx_rtmp_shared_acquire_frag(ngx_hls_live_frag_t *frag);
#endif