summaryrefslogtreecommitdiffstats
path: root/stream/tvi_dummy.c
blob: 95c94890708880910be38064c0dc2df4fd099f4e (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
/*
 * Only a sample!
 *
 * This file is part of MPlayer.
 *
 * MPlayer is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * MPlayer 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 General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#include "config.h"

#include <stdio.h>
#include "libmpcodecs/img_format.h"
#include "tv.h"

static tvi_handle_t *tvi_init_dummy(tv_param_t* tv_param);
/* information about this file */
const tvi_info_t tvi_info_dummy = {
	tvi_init_dummy,
	"NULL-TV",
	"dummy",
	"alex",
	NULL
};

/* private data's */
typedef struct priv {
    int width;
    int height;
} priv_t;

#include "tvi_def.h"

/* handler creator - entry point ! */
static tvi_handle_t *tvi_init_dummy(tv_param_t* tv_param)
{
    return tv_new_handle(sizeof(priv_t), &functions);
}

/* initialisation */
static int init(priv_t *priv)
{
    priv->width = 320;
    priv->height = 200;
    return 1;
}

/* that's the real start, we'got the format parameters (checked with control) */
static int start(priv_t *priv)
{
    return 1;
}

static int uninit(priv_t *priv)
{
    return 1;
}

static int control(priv_t *priv, int cmd, void *arg)
{
    switch(cmd)
    {
	case TVI_CONTROL_IS_VIDEO:
	    return TVI_CONTROL_TRUE;
	case TVI_CONTROL_VID_GET_FORMAT:
//	    *(int *)arg = IMGFMT_YV12;
	    *(int *)arg = IMGFMT_YV12;
	    return TVI_CONTROL_TRUE;
	case TVI_CONTROL_VID_SET_FORMAT:
	{
//	    int req_fmt = *(int *)arg;
	    int req_fmt = *(int *)arg;
	    if (req_fmt != IMGFMT_YV12)
		return TVI_CONTROL_FALSE;
	    return TVI_CONTROL_TRUE;
	}
	case TVI_CONTROL_VID_SET_WIDTH:
	    priv->width = *(int *)arg;
	    return TVI_CONTROL_TRUE;
	case TVI_CONTROL_VID_GET_WIDTH:
	    *(int *)arg = priv->width;
	    return TVI_CONTROL_TRUE;
	case TVI_CONTROL_VID_SET_HEIGHT:
	    priv->height = *(int *)arg;
	    return TVI_CONTROL_TRUE;
	case TVI_CONTROL_VID_GET_HEIGHT:
	    *(int *)arg = priv->height;
	    return TVI_CONTROL_TRUE;
	case TVI_CONTROL_VID_CHK_WIDTH:
	case TVI_CONTROL_VID_CHK_HEIGHT:
	    return TVI_CONTROL_TRUE;
	case TVI_CONTROL_TUN_SET_NORM:
	    return TVI_CONTROL_TRUE;
    }
    return TVI_CONTROL_UNKNOWN;
}

static double grab_video_frame(priv_t *priv, char *buffer, int len)
{
    memset(buffer, 0x42, len);
    return 1;
}

static int get_video_framesize(priv_t *priv)
{
    /* YV12 */
    return priv->width * priv->height * 12 / 8;
}

static double grab_audio_frame(priv_t *priv, char *buffer, int len)
{
    memset(buffer, 0x42, len);
    return 1;
}

static int get_audio_framesize(priv_t *priv)
{
    return 1;
}