-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstream.c
93 lines (71 loc) · 2.1 KB
/
stream.c
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
#include "getstream.h"
#include "output.h"
void stream_send(void *data, void *arg) {
struct stream_s *stream=arg;
GList *ol=g_list_first(stream->output);
while(ol) {
struct output_s *o=ol->data;
output_send(o, data);
ol=g_list_next(ol);
}
}
static void stream_init_pat(struct stream_s *stream);
static void stream_send_pat(int fd, short event, void *arg) {
struct stream_s *stream=arg;
struct pat_s *pat;
int pkts;
GList *il;
pat=pat_new();
for(il=g_list_first(stream->input);il;il=g_list_next(il)) {
struct input_s *input=il->data;
if (input->type == INPUT_PNR) {
unsigned int pmtpid=pmt_get_pmtpid(input->pnr.program);
pat_add_program(pat, input->pnr.pnr, pmtpid);
}
}
/* FIXME - we should take care on the PAT version and Transport ID */
pkts=pat_send(pat, stream->patcc, 0, 0, stream_send, stream);
pat_free(pat);
stream->patcc=(stream->patcc+pkts)&TS_CC_MASK;
stream_init_pat(stream);
}
static void stream_init_pat(struct stream_s *stream) {
struct timeval tv;
#define PAT_INTERVAL 500
tv.tv_usec=PAT_INTERVAL*1000;
tv.tv_sec=0;
evtimer_set(&stream->patevent, stream_send_pat, stream);
evtimer_add(&stream->patevent, &tv);
}
/*
* Called initially on programm start to initialize all input
* filter and outputs before the first TS packets get forwarded
*/
void stream_init(struct stream_s *stream) {
GList *il=g_list_first(stream->input);
GList *ol=g_list_first(stream->output);
while(ol) {
struct output_s *output=ol->data;
output_init(output);
ol=g_list_next(ol);
}
/*
* FIXME - In case we dont have filters we might want to hand
* out the output_??? function onto the input functions to pass
* onto the demux or PMT parsing. This would eliminate the
* stream_send function and save CPU cycles.
*/
while(il) {
struct input_s *input=il->data;
input_init(input);
il=g_list_next(il);
}
/*
* If we not only have static content in our stream we might need to
* send out PATs on a regular basis - Initialize the PAT timer for this stream
*/
if (stream->psineeded)
stream_init_pat(stream);
/* FIXME SAP init ? */
/* FIXME filter init ? */
}