1 /*
2 * Only a sample!
3 *
4 * This file is part of MPlayer.
5 *
6 * MPlayer is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * MPlayer is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #include "config.h"
22
23 #include <stdio.h>
24 #include "libmpcodecs/img_format.h"
25 #include "tv.h"
26
27 static tvi_handle_t *tvi_init_dummy(tv_param_t* tv_param);
28 /* information about this file */
29 const tvi_info_t tvi_info_dummy = {
30 tvi_init_dummy,
31 "NULL-TV",
32 "dummy",
33 "alex",
34 NULL
35 };
36
37 /* private data's */
38 typedef struct priv {
39 int width;
40 int height;
41 } priv_t;
42
43 #include "tvi_def.h"
44
45 /* handler creator - entry point ! */
tvi_init_dummy(tv_param_t * tv_param)46 static tvi_handle_t *tvi_init_dummy(tv_param_t* tv_param)
47 {
48 return tv_new_handle(sizeof(priv_t), &functions);
49 }
50
51 /* initialisation */
init(priv_t * priv)52 static int init(priv_t *priv)
53 {
54 priv->width = 320;
55 priv->height = 200;
56 return 1;
57 }
58
59 /* that's the real start, we'got the format parameters (checked with control) */
start(priv_t * priv)60 static int start(priv_t *priv)
61 {
62 return 1;
63 }
64
uninit(priv_t * priv)65 static int uninit(priv_t *priv)
66 {
67 return 1;
68 }
69
control(priv_t * priv,int cmd,void * arg)70 static int control(priv_t *priv, int cmd, void *arg)
71 {
72 switch(cmd)
73 {
74 case TVI_CONTROL_IS_VIDEO:
75 return TVI_CONTROL_TRUE;
76 case TVI_CONTROL_VID_GET_FORMAT:
77 // *(int *)arg = IMGFMT_YV12;
78 *(int *)arg = IMGFMT_YV12;
79 return TVI_CONTROL_TRUE;
80 case TVI_CONTROL_VID_SET_FORMAT:
81 {
82 // int req_fmt = *(int *)arg;
83 int req_fmt = *(int *)arg;
84 if (req_fmt != IMGFMT_YV12)
85 return TVI_CONTROL_FALSE;
86 return TVI_CONTROL_TRUE;
87 }
88 case TVI_CONTROL_VID_SET_WIDTH:
89 priv->width = *(int *)arg;
90 return TVI_CONTROL_TRUE;
91 case TVI_CONTROL_VID_GET_WIDTH:
92 *(int *)arg = priv->width;
93 return TVI_CONTROL_TRUE;
94 case TVI_CONTROL_VID_SET_HEIGHT:
95 priv->height = *(int *)arg;
96 return TVI_CONTROL_TRUE;
97 case TVI_CONTROL_VID_GET_HEIGHT:
98 *(int *)arg = priv->height;
99 return TVI_CONTROL_TRUE;
100 case TVI_CONTROL_VID_CHK_WIDTH:
101 case TVI_CONTROL_VID_CHK_HEIGHT:
102 return TVI_CONTROL_TRUE;
103 case TVI_CONTROL_TUN_SET_NORM:
104 return TVI_CONTROL_TRUE;
105 }
106 return TVI_CONTROL_UNKNOWN;
107 }
108
grab_video_frame(priv_t * priv,char * buffer,int len)109 static double grab_video_frame(priv_t *priv, char *buffer, int len)
110 {
111 memset(buffer, 0x42, len);
112 return 1;
113 }
114
get_video_framesize(priv_t * priv)115 static int get_video_framesize(priv_t *priv)
116 {
117 /* YV12 */
118 return priv->width * priv->height * 12 / 8;
119 }
120
grab_audio_frame(priv_t * priv,char * buffer,int len)121 static double grab_audio_frame(priv_t *priv, char *buffer, int len)
122 {
123 memset(buffer, 0x42, len);
124 return 1;
125 }
126
get_audio_framesize(priv_t * priv)127 static int get_audio_framesize(priv_t *priv)
128 {
129 return 1;
130 }
131