annotate input/lirc.c @ 30432:ebb651f9e2ab

Declare support for the pixel formats: PIX_FMT_YUVJ420P PIX_FMT_YUVJ422P PIX_FMT_YUVJ440P PIX_FMT_YUVJ444P in the isSupported{In,Out} macros. These pixel formats are not true pixel formats but hacks specific to JPEG in libavcodec. They are deprecated and should be removed (that is from libavcodec first and libswscale second)... but they must be tested by swscale-test. See thread: Subject: [FFmpeg-devel] [PATCH] Extend show_pix_fmts() to make it print the input/output support Date: 2010-01-30 15:54:08 GMT
author stefano
date Sun, 31 Jan 2010 10:16:05 +0000
parents 0f1b5b68af32
children ca614fc25817
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28112
142c53391eb7 Add standard GPL license header.
diego
parents: 20191
diff changeset
1 /*
142c53391eb7 Add standard GPL license header.
diego
parents: 20191
diff changeset
2 * This file is part of MPlayer.
142c53391eb7 Add standard GPL license header.
diego
parents: 20191
diff changeset
3 *
142c53391eb7 Add standard GPL license header.
diego
parents: 20191
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
142c53391eb7 Add standard GPL license header.
diego
parents: 20191
diff changeset
5 * it under the terms of the GNU General Public License as published by
142c53391eb7 Add standard GPL license header.
diego
parents: 20191
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
142c53391eb7 Add standard GPL license header.
diego
parents: 20191
diff changeset
7 * (at your option) any later version.
142c53391eb7 Add standard GPL license header.
diego
parents: 20191
diff changeset
8 *
142c53391eb7 Add standard GPL license header.
diego
parents: 20191
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
142c53391eb7 Add standard GPL license header.
diego
parents: 20191
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
142c53391eb7 Add standard GPL license header.
diego
parents: 20191
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
142c53391eb7 Add standard GPL license header.
diego
parents: 20191
diff changeset
12 * GNU General Public License for more details.
142c53391eb7 Add standard GPL license header.
diego
parents: 20191
diff changeset
13 *
142c53391eb7 Add standard GPL license header.
diego
parents: 20191
diff changeset
14 * You should have received a copy of the GNU General Public License along
142c53391eb7 Add standard GPL license header.
diego
parents: 20191
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
142c53391eb7 Add standard GPL license header.
diego
parents: 20191
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
142c53391eb7 Add standard GPL license header.
diego
parents: 20191
diff changeset
17 */
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
18
16860
a68ede010f66 Unify include paths, -I.. is in CFLAGS.
diego
parents: 15825
diff changeset
19 #include "config.h"
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
20
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
21 #include <lirc/lirc_client.h>
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
22 #include <errno.h>
28345
3a08f32c8fa1 Do not use select n lirc code, instead set the fd non-blocking.
reimar
parents: 28321
diff changeset
23 #include <fcntl.h>
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
24 #include <stdio.h>
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
25 #include <string.h>
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
26 #include <unistd.h>
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
27 #include <stdlib.h>
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
28
16860
a68ede010f66 Unify include paths, -I.. is in CFLAGS.
diego
parents: 15825
diff changeset
29 #include "mp_msg.h"
a68ede010f66 Unify include paths, -I.. is in CFLAGS.
diego
parents: 15825
diff changeset
30 #include "help_mp.h"
7883
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
31 #include "input.h"
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
32
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
33 static struct lirc_config *lirc_config;
4823
d25b898c4c44 Make old and new lirc support independant from each other
albeu
parents: 4526
diff changeset
34 char *lirc_configfile;
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
35
7883
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
36 static char* cmd_buf = NULL;
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
37
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28355
diff changeset
38 int
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
39 mp_input_lirc_init(void) {
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
40 int lirc_sock;
28345
3a08f32c8fa1 Do not use select n lirc code, instead set the fd non-blocking.
reimar
parents: 28321
diff changeset
41 int mode;
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
42
20185
b6eed21e0535 slight overall verbosity reduction
diego
parents: 19801
diff changeset
43 mp_msg(MSGT_LIRC,MSGL_V,MSGTR_SettingUpLIRC);
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
44 if((lirc_sock=lirc_init("mplayer",1))==-1){
20185
b6eed21e0535 slight overall verbosity reduction
diego
parents: 19801
diff changeset
45 mp_msg(MSGT_LIRC,MSGL_ERR,MSGTR_LIRCopenfailed);
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
46 return -1;
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
47 }
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
48
28355
418d7d213966 Move setting of O_NONBLOCK before lirc_readconfig, this avoids a memleak
reimar
parents: 28354
diff changeset
49 mode = fcntl(lirc_sock, F_GETFL);
418d7d213966 Move setting of O_NONBLOCK before lirc_readconfig, this avoids a memleak
reimar
parents: 28354
diff changeset
50 if (mode < 0 || fcntl(lirc_sock, F_SETFL, mode | O_NONBLOCK) < 0) {
418d7d213966 Move setting of O_NONBLOCK before lirc_readconfig, this avoids a memleak
reimar
parents: 28354
diff changeset
51 mp_msg(MSGT_LIRC, MSGL_ERR, "setting non-blocking mode failed: %s\n",
418d7d213966 Move setting of O_NONBLOCK before lirc_readconfig, this avoids a memleak
reimar
parents: 28354
diff changeset
52 strerror(errno));
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
53 lirc_deinit();
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
54 return -1;
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
55 }
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
56
28355
418d7d213966 Move setting of O_NONBLOCK before lirc_readconfig, this avoids a memleak
reimar
parents: 28354
diff changeset
57 if(lirc_readconfig( lirc_configfile,&lirc_config,NULL )!=0 ){
418d7d213966 Move setting of O_NONBLOCK before lirc_readconfig, this avoids a memleak
reimar
parents: 28354
diff changeset
58 mp_msg(MSGT_LIRC,MSGL_ERR,MSGTR_LIRCcfgerr,
418d7d213966 Move setting of O_NONBLOCK before lirc_readconfig, this avoids a memleak
reimar
parents: 28354
diff changeset
59 lirc_configfile == NULL ? "~/.lircrc" : lirc_configfile);
28345
3a08f32c8fa1 Do not use select n lirc code, instead set the fd non-blocking.
reimar
parents: 28321
diff changeset
60 lirc_deinit();
3a08f32c8fa1 Do not use select n lirc code, instead set the fd non-blocking.
reimar
parents: 28321
diff changeset
61 return -1;
3a08f32c8fa1 Do not use select n lirc code, instead set the fd non-blocking.
reimar
parents: 28321
diff changeset
62 }
3a08f32c8fa1 Do not use select n lirc code, instead set the fd non-blocking.
reimar
parents: 28321
diff changeset
63
7883
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
64 return lirc_sock;
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
65 }
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
66
7883
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
67 int mp_input_lirc_read(int fd,char* dest, int s) {
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
68 int r,cl = 0;
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
69 char *code = NULL,*c = NULL;
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
70
7883
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
71 // We have something in the buffer return it
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
72 if(cmd_buf != NULL) {
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
73 int l = strlen(cmd_buf), w = l > s ? s : l;
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
74 memcpy(dest,cmd_buf,w);
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
75 l -= w;
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
76 if(l > 0)
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
77 memmove(cmd_buf,&cmd_buf[w],l+1);
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
78 else {
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
79 free(cmd_buf);
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
80 cmd_buf = NULL;
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
81 }
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
82 return w;
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
83 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28355
diff changeset
84
28321
1dc02f91a9b4 Fix typo: pool -> poll
reimar
parents: 28112
diff changeset
85 // Nothing in the buffer, poll the lirc fd
7883
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
86 if(lirc_nextcode(&code) != 0) {
28354
5b1f6e52673b Fix an MSGT_INPUT to MSGT_LIRC in lirc.c
reimar
parents: 28345
diff changeset
87 mp_msg(MSGT_LIRC,MSGL_ERR,"Lirc error :(\n");
7883
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
88 return MP_INPUT_DEAD;
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
89 }
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
90
7883
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
91 if(!code) return MP_INPUT_NOTHING;
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
92
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
93 // We put all cmds in a single buffer separated by \n
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
94 while((r = lirc_code2char(lirc_config,code,&c))==0 && c!=NULL) {
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
95 int l = strlen(c);
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
96 if(l <= 0)
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
97 continue;
7883
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
98 cmd_buf = realloc(cmd_buf,cl+l+2);
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
99 memcpy(&cmd_buf[cl],c,l);
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
100 cl += l+1;
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
101 cmd_buf[cl-1] = '\n';
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
102 cmd_buf[cl] = '\0';
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
103 }
7883
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
104
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
105 free(code);
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
106
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
107 if(r < 0)
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
108 return MP_INPUT_DEAD;
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
109 else if(cmd_buf) // return the first command in the buffer
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
110 return mp_input_lirc_read(fd,dest,s);
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
111 else
15825
8549fc0fb5b1 consume empty lirc events at once.
reimar
parents: 7883
diff changeset
112 return MP_INPUT_RETRY;
7883
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
113
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
114 }
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
115
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
116 void
7883
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
117 mp_input_lirc_close(int fd) {
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
118 if(cmd_buf) {
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
119 free(cmd_buf);
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
120 cmd_buf = NULL;
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
121 }
7883
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
122 lirc_freeconfig(lirc_config);
d375383e1a48 rewrote the lirc code to remove the fork
arpi
parents: 5196
diff changeset
123 lirc_deinit();
4432
5105f5da01d6 Added lirc support in input
albeu
parents:
diff changeset
124 }