forked from klaxa/mkvserver_mk2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publisher.h
51 lines (33 loc) · 1.11 KB
/
publisher.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
#ifndef PUBLISHER_H
#define PUBLISHER_H
#include <libavformat/avformat.h>
#include "buffer.h"
#define MAX_CLIENTS 16
#define BUFFER_SEGMENTS 10
struct Client {
struct AVFormatContext *ofmt_ctx;
struct Buffer *buffer;
enum State state;
pthread_mutex_t state_lock;
int id;
int current_segment_id;
};
struct PublisherContext {
struct Client subscribers[MAX_CLIENTS];
struct Buffer *buffer;
struct Buffer *fs_buffer; // fast start buffer;
int nb_threads;
int current_segment_id;
int shutdown;
};
void client_print(struct Client *c);
void client_disconnect(struct Client *c);
void client_set_state(struct Client *c, enum State state);
void publisher_init(struct PublisherContext **pub);
int publisher_reserve_client(struct PublisherContext *pub);
void publisher_cancel_reserve(struct PublisherContext *pub);
void publisher_add_client(struct PublisherContext *pub, AVFormatContext *ofmt_ctx);
void publisher_free(struct PublisherContext *pub);
void publish(struct PublisherContext *pub);
char *publisher_gen_status_json(struct PublisherContext *pub);
#endif // PUBLISHER_H