Revision 10c75ef7 chunker_player/chunker_player.h

View differences:

chunker_player/chunker_player.h
1 1
#ifndef _CHUNKER_PLAYER_H
2 2
#define _CHUNKER_PLAYER_H
3 3

  
4

  
5
#include <stdio.h>
6
#include <unistd.h>
7
#include <sys/types.h>
8
#include <sys/socket.h>
9
#include <sys/select.h>
10
#include <arpa/inet.h>
11
#include <microhttpd.h>
12
#include "external_chunk_transcoding.h"
13
#include "frame.h"
14

  
15
#define PLAYER_FAIL_RETURN -1
16
#define PLAYER_OK_RETURN 0
17

  
18
// #define FULLSCREEN_WIDTH 640
19
// #define FULLSCREEN_HEIGHT 480
20

  
21
int FullscreenWidth = 0;
22
int FullscreenHeight = 0;
23

  
24
AVCodecContext  *aCodecCtx;
25
SDL_Thread *video_thread;
26
uint8_t *outbuf_audio;
27

  
28
int window_width, window_height;
29

  
30
#define SDL_AUDIO_BUFFER_SIZE 1024
31

  
32
#define MAX_TOLLERANCE 40
33
#define AUDIO	1
34
#define VIDEO	2
35
#define QUEUE_MAX_SIZE 3000
36
#define LOSS_HISTORY_MAX_SIZE 100
37

  
38
#define FULLSCREEN_ICON_FILE "icons/fullscreen32.png"
39
#define NOFULLSCREEN_ICON_FILE "icons/nofullscreen32.png"
40
#define FULLSCREEN_HOVER_ICON_FILE "icons/fullscreen32.png"
41
#define NOFULLSCREEN_HOVER_ICON_FILE "icons/nofullscreen32.png"
42

  
43
#define CHANNEL_UP_ICON_FILE "icons/up_16.png"
44
#define CHANNEL_DOWN_ICON_FILE "icons/down_16.png"
45

  
46
#define DEFAULT_CHANNEL_EXEC_PATH "../OfferStreamer/"
47
#define DEFAULT_CHANNEL_EXEC_NAME "offerstreamer-ml-monl-http"
48
#define DEFAULT_CONF_FILENAME "channels.conf"
49

  
50
#define DEFAULT_WIDTH 704
51
#define DEFAULT_HEIGHT 576
52
#define DEFAULT_RATIO 1.22
53

  
54
#define BUTTONS_LAYER_OFFSET 10
55
#define BUTTONS_CONTAINER_HEIGHT 40
56
#define BUTTONS_CONTAINER_WIDTH 100
57

  
58
// typedef enum Status { STOPPED, RUNNING, PAUSED } Status;
59

  
60
// #define DEBUG_AUDIO
61
// #define DEBUG_VIDEO
62
// #define DEBUG_QUEUE
63
// #define DEBUG_SOURCE
64
// #define DEBUG_STATS
65
//#define DEBUG_AUDIO_BUFFER
66
// #define DEBUG_CHUNKER
67

  
68

  
69
short int QueueFillingMode=1;
70
short int QueueStopped=0;
71

  
72
typedef struct PacketQueue {
73
	AVPacketList *first_pkt;
74
	AVPacketList *last_pkt;
75
	int nb_packets;
76
	int size;
77
	SDL_mutex *mutex;
78
	short int queueType;
79
	int last_frame_extracted; //HINT THIS SHOULD BE MORE THAN 4 BYTES
80
	int total_lost_frames;
81
	int loss_history[LOSS_HISTORY_MAX_SIZE];
82
	int instant_lost_frames;
83
	int history_index;
84
	double density;
85
} PacketQueue;
86

  
87
typedef struct threadVal {
88
	int width;
89
	int height;
90
	// float aspect_ratio;
91
} ThreadVal;
92

  
93
ThreadVal VideoCallbackThreadParams;
94

  
95
int AudioQueueOffset=0;
96
PacketQueue audioq;
97
PacketQueue videoq;
98
AVPacket AudioPkt, VideoPkt;
99
int quit = 0;
100
int SaveYUV=0;
101
int AVPlaying = 0;
102
char YUVFileName[256];
103

  
104
int queue_filling_threshold = 0;
105

  
106
SDL_Surface *screen;
107
SDL_Overlay *yuv_overlay;
108
SDL_Rect    rect;
109
SDL_Rect *initRect = NULL;
110
SDL_AudioSpec spec;
111

  
112
struct SwsContext *img_convert_ctx = NULL;
113
float ratio;
114

  
115
//SDL_mutex *timing_mutex;
116

  
117
int got_sigint = 0;
118

  
119
long long DeltaTime;
120
short int FirstTimeAudio=1, FirstTime = 1;
121

  
122
int dimAudioQ;
123
float deltaAudioQ;
124
float deltaAudioQError=0;
125

  
126
void SaveFrame(AVFrame *pFrame, int width, int height);
127

  
128
// other GUI staff
129
SDL_Cursor *init_system_cursor(const char *image[]);
130
void refresh_fullscreen_button(int hover);
131
void toggle_fullscreen();
132
void aspect_ratio_resize(float aspect_ratio, int width, int height, int* out_width, int* out_height);
133
int FullscreenMode = 0; // fullscreen vs windowized flag
134

  
135
SDL_Cursor *defaultCursor;
136
SDL_Cursor *handCursor;
137
int silentMode = 0;
138

  
139
typedef struct SButton
140
{
141
	int Hover;
142
	int Visible;
143
	int XOffset;
144
	SDL_Rect ButtonIconBox;
145
	SDL_Surface* ButtonIcon;
146
	SDL_Surface* ButtonHoverIcon;
147
	struct SButton* ToggledButton;
148
	void (*HoverCallback)();
149
	void (*LButtonUpCallback)();
150
} SButton;
151

  
152
#define FULLSCREEN_BUTTON_INDEX 0
153
#define NO_FULLSCREEN_BUTTON_INDEX 1
154
#define CHANNEL_UP_BUTTON_INDEX 2
155
#define CHANNEL_DOWN_BUTTON_INDEX 3
156

  
157
#define NBUTTONS 4
158

  
159
SButton Buttons[NBUTTONS];
160

  
161
#define MAIN_FONT_FILE "mainfont.ttf"
162
#define MAIN_FONT_SIZE 18
163
SDL_Surface *ChannelTitleSurface = NULL;
164
SDL_Rect ChannelTitleRect;
165
SDL_Color ChannelTitleColor = { 255, 255, 255 }; 
166
SDL_Color ChannelTitleBgColor = { 0, 0, 0 };
167
TTF_Font *MainFont = NULL;
168

  
169
/* XPM */
170
static char *handXPM[] = {
171
/* columns rows colors chars-per-pixel */
172
"32 32 3 1",
173
"  c black",
174
". c gray100",
175
"X c None",
176
/* pixels */
177
"XXXXX  XXXXXXXXXXXXXXXXXXXXXXXXX",
178
"XXXX .. XXXXXXXXXXXXXXXXXXXXXXXX",
179
"XXXX .. XXXXXXXXXXXXXXXXXXXXXXXX",
180
"XXXX .. XXXXXXXXXXXXXXXXXXXXXXXX",
181
"XXXX .. XXXXXXXXXXXXXXXXXXXXXXXX",
182
"XXXX ..   XXXXXXXXXXXXXXXXXXXXXX",
183
"XXXX .. ..   XXXXXXXXXXXXXXXXXXX",
184
"XXXX .. .. ..  XXXXXXXXXXXXXXXXX",
185
"XXXX .. .. .. . XXXXXXXXXXXXXXXX",
186
"   X .. .. .. .. XXXXXXXXXXXXXXX",
187
" ..  ........ .. XXXXXXXXXXXXXXX",
188
" ... ........... XXXXXXXXXXXXXXX",
189
"X .. ........... XXXXXXXXXXXXXXX",
190
"XX . ........... XXXXXXXXXXXXXXX",
191
"XX ............. XXXXXXXXXXXXXXX",
192
"XXX ............ XXXXXXXXXXXXXXX",
193
"XXX ........... XXXXXXXXXXXXXXXX",
194
"XXXX .......... XXXXXXXXXXXXXXXX",
195
"XXXX .......... XXXXXXXXXXXXXXXX",
196
"XXXXX ........ XXXXXXXXXXXXXXXXX",
197
"XXXXX ........ XXXXXXXXXXXXXXXXX",
198
"XXXXX          XXXXXXXXXXXXXXXXX",
199
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
200
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
201
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
202
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
203
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
204
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
205
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
206
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
207
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
208
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
209
"0,0"
210
};
4
#include "player_defines.h"
5
#include <SDL.h>
6
#include <SDL_mutex.h>
211 7

  
212 8
typedef struct SChannel
213 9
{
......
218 14
	float Ratio;
219 15
	int SampleRate;
220 16
	short int AudioChannels;
17
	int Index;
221 18
} SChannel;
222 19

  
223
SChannel Channels[255];
224
int NChannels = 0;
225
int SelectedChannel = -1;
226
char OfferStreamerPath[255];
227
char OfferStreamerFilename[255];
20
SDL_mutex *OverlayMutex;
21
SDL_Overlay *YUVOverlay;
22
SDL_Rect OverlayRect;
23
SDL_Surface *MainScreen;
24
int SilentMode;
25
int queue_filling_threshold;
26
char YUVFileName[256];
27
int SaveYUV;
28
int quit;
29
short int QueueFillingMode;
30
int P2PProcessID;
31

  
32
#ifdef __WIN32__
33
#define KILL_PROCESS(pid) {char command_name[255]; sprintf(command_name, "taskkill /pid %d /F", pid); system(command_name);}
34
#define KILLALL(pname) {char command_name[255]; sprintf(command_name, "taskkill /im %s /F", pname); system(command_name);}
35
#endif
36
#ifdef __LINUX__
37
#define KILL_PROCESS(pid) {char command_name[255]; sprintf(command_name, "kill %d", pid); system(command_name);}
38
#define KILLALL(pname) {char command_name[255]; sprintf(command_name, "killall %s -9", pname); system(command_name);}
39
#endif
40
#ifdef __MACOS__
41
#define KILL_PROCESS(pid) {char command_name[255]; sprintf(command_name, "kill %d", pid); system(command_name);}
42
#define KILLALL(pname) {char command_name[255]; sprintf(command_name, "killall %s -9", pname); system(command_name);}
43
#endif
44

  
228 45

  
229
int parse_conf();
230
int switch_channel(SChannel* channel);
231
int P2PProcessID = -1;
232 46

  
233
void refresh_channel_buttons(int hover);
234 47

  
235
void zap_up();
236
void zap_down();
237
void redraw_buttons();
238
int InitCodecs(int width, int height, int sample_rate, short audio_channels);
48
SChannel Channels[MAX_CHANNELS_NUM];
49
int NChannels;
50
int SelectedChannel;
51
char OfferStreamerPath[255];
52
char OfferStreamerFilename[255];
53
int FullscreenMode; // fullscreen vs windowized flag
54
int window_width, window_height;
55
int HttpPort;
239 56

  
240
SDL_mutex *RedrawMutex;
57
void ZapDown();
58
void ZapUp();
59
int ParseConf();
60
int SwitchChannel(SChannel* channel);
241 61

  
242
#endif
62
#endif // _CHUNKER_PLAYER_H

Also available in: Unified diff