-
Notifications
You must be signed in to change notification settings - Fork 1
/
libplayer-testvdr.c
221 lines (204 loc) · 5.49 KB
/
libplayer-testvdr.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
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
/*
* GeeXboX libplayer: a multimedia A/V abstraction layer API.
* Copyright (C) 2008-2009 Davide Cavalca <davide AT geexbox.org>
*
* This file is part of libplayer.
*
* libplayer is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* libplayer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with libplayer; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdlib.h>
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <string.h>
#if defined (HAVE_WIN_XCB) && defined (USE_XLIB_HACK)
#include <X11/Xlib.h>
#endif /* HAVE_WIN_XCB && USE_XLIB_HACK */
#include "player.h"
static uint32_t
getch (void)
{
struct termios oldt, newt;
uint32_t ch = 0;
uint32_t val = 0;
int n;
tcgetattr (STDIN_FILENO, &oldt);
newt = oldt;
newt.c_lflag &= ~(ICANON | ECHO);
tcsetattr (STDIN_FILENO, TCSANOW, &newt);
n = read (STDIN_FILENO, &ch, sizeof (ch));
putchar ('\n');
while (ch)
{
val <<= 8;
val += ch & 0xFF;
ch >>= 8;
}
tcsetattr (STDIN_FILENO, TCSANOW, &oldt);
return val;
}
static int
event_cb (player_event_t e, pl_unused void *data)
{
printf ("Received event (%i): ", e);
switch (e)
{
case PLAYER_EVENT_UNKNOWN:
printf ("unknown event\n");
break;
case PLAYER_EVENT_PLAYBACK_START:
printf ("playback started\n");
break;
case PLAYER_EVENT_PLAYBACK_STOP:
printf ("playback stopped\n");
break;
case PLAYER_EVENT_PLAYBACK_FINISHED:
printf ("playback finished\n");
break;
case PLAYER_EVENT_PLAYLIST_FINISHED:
printf ("playlist finished\n");
break;
case PLAYER_EVENT_PLAYBACK_PAUSE:
printf ("playback paused\n");
break;
case PLAYER_EVENT_PLAYBACK_UNPAUSE:
printf ("playback unpaused\n");
break;
}
return 0;
}
int
main (pl_unused int argc, pl_unused char **argv)
{
player_t *player;
player_init_param_t param;
player_type_t type = PLAYER_TYPE_XINE;
player_verbosity_level_t verbosity = PLAYER_MSG_INFO;
mrl_t *mrl = NULL;
mrl_resource_tv_args_t *args;
uint32_t input;
#if defined (HAVE_WIN_XCB) && defined (USE_XLIB_HACK)
XInitThreads ();
#endif /* HAVE_WIN_XCB && USE_XLIB_HACK */
memset (¶m, 0, sizeof (player_init_param_t));
param.ao = PLAYER_AO_ALSA;
param.vo = PLAYER_VO_X11;
param.event_cb = event_cb;
player = player_init (type, verbosity, ¶m);
args = calloc (1, sizeof (mrl_resource_tv_args_t));
args->device = strdup ("/tmp/vdr-xine/stream");
args->driver = strdup ("demux:mpeg_pes");
mrl = mrl_new (player, MRL_RESOURCE_VDR, args);
player_mrl_set (player, mrl);
player_playback_start (player);
for (;;)
{
input = getch ();
switch (input)
{
case 0x1B5B41: /* UP */
player_vdr (player, PLAYER_VDR_UP);
printf ("UP\n");
break;
case 0x1B5B42: /* DOWN */
player_vdr (player, PLAYER_VDR_DOWN);
printf ("DOWN\n");
break;
case 0x1B5B44: /* LEFT */
player_vdr (player, PLAYER_VDR_LEFT);
printf ("LEFT\n");
break;
case 0x1B5B43: /* RIGHT */
player_vdr (player, PLAYER_VDR_RIGHT);
printf ("RIGHT\n");
break;
case 0xA: /* ENTER */
player_vdr (player, PLAYER_VDR_OK);
printf ("OK\n");
break;
case 0x20: /* SPACE */
player_vdr (player, PLAYER_VDR_MENU);
printf ("MENU\n");
break;
case 0x7F: /* BACKSPACE */
player_vdr (player, PLAYER_VDR_BACK);
printf ("BACK\n");
break;
case 0x30: /* 0 */
player_vdr (player, PLAYER_VDR_0);
printf ("0\n");
break;
case 0x31: /* 1 */
player_vdr (player, PLAYER_VDR_1);
printf ("1\n");
break;
case 0x32: /* 2 */
player_vdr (player, PLAYER_VDR_2);
printf ("1\n");
break;
case 0x33: /* 3 */
player_vdr (player, PLAYER_VDR_3);
printf ("1\n");
break;
case 0x34: /* 4 */
player_vdr (player, PLAYER_VDR_4);
printf ("1\n");
break;
case 0x35: /* 5 */
player_vdr (player, PLAYER_VDR_5);
printf ("1\n");
break;
case 0x36: /* 6 */
player_vdr (player, PLAYER_VDR_6);
printf ("1\n");
break;
case 0x37: /* 7 */
player_vdr (player, PLAYER_VDR_7);
printf ("1\n");
break;
case 0x38: /* 8 */
player_vdr (player, PLAYER_VDR_8);
printf ("1\n");
break;
case 0x39: /* 9 */
player_vdr (player, PLAYER_VDR_9);
printf ("1\n");
break;
case 0x71: /* Q */
player_vdr (player, PLAYER_VDR_RED);
printf ("Q\n");
break;
case 0x77: /* W */
player_vdr (player, PLAYER_VDR_GREEN);
printf ("W\n");
break;
case 0x65: /* E */
player_vdr (player, PLAYER_VDR_YELLOW);
printf ("E\n");
break;
case 0x72: /* R */
player_vdr (player, PLAYER_VDR_BLUE);
printf ("R\n");
break;
case 0x1B: /* ESC */
printf ("QUIT\n");
player_playback_stop (player);
player_uninit (player);
return EXIT_SUCCESS;
default:
fprintf (stderr, "ERROR: Command unknown %x\n", input);
}
}
}