-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestream.h
145 lines (121 loc) · 4.12 KB
/
restream.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#ifndef _INCLUDE_RESTREAM_H_
#define _INCLUDE_RESTREAM_H_
#define _GNU_SOURCE
#include <pthread.h>
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libavfilter/buffersink.h>
#include <libavfilter/buffersrc.h>
#include <libavutil/opt.h>
#include <libavutil/imgutils.h>
#include <libavutil/pixdesc.h>
#include <libavutil/timestamp.h>
#include <libavutil/time.h>
#include <libavutil/mem.h>
#include <libswscale/swscale.h>
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include <sys/time.h>
#include <time.h>
#define SLEEP(seconds, nanoseconds) { \
struct timespec tv; \
tv.tv_sec = (seconds); \
tv.tv_nsec = (nanoseconds); \
while (nanosleep(&tv, &tv) == -1); \
}
/* values of boolean */
#ifndef FALSE
#define FALSE 0
#endif
#ifndef TRUE
#define TRUE 1
#endif
enum PIPE_STATUS{
PIPE_IS_OPEN,
PIPE_IS_CLOSED,
PIPE_NEEDS_RESET
};
enum READER_STATUS{
READER_STATUS_CLOSED,
READER_STATUS_PAUSED,
READER_STATUS_OPEN,
READER_STATUS_INACTIVE,
READER_STATUS_READING,
READER_STATUS_READBYTE
};
enum READER_ACTION{
READER_ACTION_START,
READER_ACTION_OPEN,
READER_ACTION_CLOSE,
READER_ACTION_END,
READER_ACTION_BYTE
};
typedef struct StreamContext {
AVCodecContext *dec_ctx;
AVCodecContext *enc_ctx;
} StreamContext;
struct guide_item {
char *movie1_filename;
char *movie2_filename;
char *movie1_displayname;
char *movie2_displayname;
char *guide_filename;
char *guide_displayname;
char time1_st[25];
char time1_en[25];
char time2_st[25];
char time2_en[25];
};
typedef struct ctx_restream {
char *in_filename;
char *out_filename;
AVFormatContext *ifmt_ctx;
AVFormatContext *ofmt_ctx;
AVOutputFormat *ofmt;
AVPacket pkt;
int stream_index;
int audio_index;
int video_index;
StreamContext *stream_ctx;
int stream_count;
int64_t time_start;
int64_t dts_start;
int64_t dts_last;
int64_t dts_base;
unsigned int rand_seed;
struct playlist_item *playlist;
char *playlist_dir;
char *function_name;
int finish;
int playlist_count;
int playlist_index;
char *playlist_sort_method; //a =alpha, r = random
struct guide_item *guide_info;
volatile enum PIPE_STATUS pipe_state;
volatile enum READER_STATUS reader_status;
volatile enum READER_ACTION reader_action;
int64_t watchdog_reader;
int64_t watchdog_playlist;
int64_t connect_start;
int soft_restart;
pthread_t reader_thread;
pthread_t process_playlist_thread;
pthread_mutex_t mutex_reader; /* mutex used with the output reader */
} ctx_restream;
/**********************************************************/
struct channel_context {
struct channel_item *channel_info;
int channel_count;
};
/* Global shutdown flag*/
volatile int finish; /*Stop movie playing*/
volatile int thread_count;
int restrm_interrupt(void *ctx);
#endif