blob: 9959009ca8155e13286838e9f1dc12c766d3c2d5 (
plain)
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
|
#include "config.h"
#ifndef __MIAV_MULTIPLEXER_H__
#define __MIAV_MULTIPLEXER_H__
#include "iso11172-1.h"
#include "iso11172-2.h"
#include "iso11172-3.h"
#include "file.h"
#include "multicast.h"
#include "info.h"
#include "frame.h"
#include "threadsafe_queue_priority.h"
#define PACKETS_PER_PACK 3
#define AUDIO_PACKET_FREQUENCY 10
#define SYSTEM_HEADER_FREQUENCY 5
#define PACKET_SIZE 2028
#define NUM_TYPES 2
typedef enum {
TYPE_VIDEO,
TYPE_AUDIO
} StreamType;
class Multiplexer {
public:
Multiplexer(File *file, Multicast *m, Info *info, volatile bool *running,
ThreadSafeQueuePriority *video_queue,
ThreadSafeQueuePriority *audio_queue);
~Multiplexer();
void multiplex();
private:
int Write(void* data, int size);
int Write(char* data, int size);
int Write(unsigned long long int val);
int Write(long long int val);
int Write(long int val);
int Write(unsigned long int val);
int Write(int val);
int Write(unsigned int val);
int Write(short int val);
int Write(unsigned short int val);
unsigned long long int SCR;
double written[NUM_TYPES];
void iso11172_stream();
bool pack();
void system_header();
bool packet();
bool packet(StreamType type);
unsigned int write_system_header;
unsigned int write_audio_packet;
Frame *getFrame(StreamType type);
int read_stream(char *buf, unsigned int size, StreamType type);
Frame *frame[NUM_TYPES];
unsigned int frame_number[NUM_TYPES];
unsigned int read[NUM_TYPES];
File *file;
Multicast *multicast;
Info *info;
volatile bool *running;
bool audio_header_read;
ThreadSafeQueuePriority *queue[NUM_TYPES];
};
#endif
|