annotate libmpdemux/stream_vcd.c @ 12006:f4537eee7c33

xvmc use get_format for IDCT/MC recognition
author iive
date Mon, 01 Mar 2004 14:58:20 +0000
parents 0d381b648b51
children b2419eef04da
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
1
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
2 #include "config.h"
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
3
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
4 #ifdef HAVE_VCD
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
5 #include "mp_msg.h"
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
6 #include "stream.h"
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
7 #include "help_mp.h"
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
8 #include "../m_option.h"
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
9 #include "../m_struct.h"
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
10
10121
d42177a0da2a Changed the STREAMING defines to MPLAYER_NETWORK to avoid name definition clash.
bertrand
parents: 9886
diff changeset
11 #include <fcntl.h>
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
12 #include <stdlib.h>
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
13 #include <unistd.h>
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
14 #include <sys/ioctl.h>
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
15 #include <errno.h>
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
16
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
17 #ifdef __FreeBSD__
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
18 #include <sys/cdrio.h>
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
19 #include "vcd_read_fbsd.h"
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
20 #elif defined(__NetBSD__)
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
21 #include "vcd_read_nbsd.h"
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
22 #else
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
23 #include "vcd_read.h"
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
24 #endif
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
25
10591
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
26 extern char *cdrom_device;
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
27
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
28 static struct stream_priv_s {
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
29 int track;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
30 char* device;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
31 } stream_priv_dflts = {
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
32 1,
10591
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
33 NULL
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
34 };
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
35
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
36 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f)
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
37 /// URL definition
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
38 static m_option_t stream_opts_fields[] = {
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
39 { "track", ST_OFF(track), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL },
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
40 { "device", ST_OFF(device), CONF_TYPE_STRING, 0, 0 ,0, NULL},
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
41 /// For url parsing
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
42 { "hostname", ST_OFF(track), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL },
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
43 { "filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0 ,0, NULL},
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
44 { NULL, NULL, 0, 0, 0, 0, NULL }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
45 };
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
46 static struct m_struct_st stream_opts = {
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
47 "vcd",
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
48 sizeof(struct stream_priv_s),
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
49 &stream_priv_dflts,
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
50 stream_opts_fields
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
51 };
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
52
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
53 static int fill_buffer(stream_t *s, char* buffer, int max_len){
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
54 return vcd_read(s->priv,buffer);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
55 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
56
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
57 static int seek(stream_t *s,off_t newpos) {
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
58 s->pos = newpos;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
59 vcd_set_msf(s->priv,s->pos/VCD_SECTOR_DATA);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
60 return 1;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
61 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
62
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
63 static void close_s(stream_t *stream) {
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
64 free(stream->priv);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
65 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
66
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
67 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
68 struct stream_priv_s* p = (struct stream_priv_s*)opts;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
69 int ret,ret2,f;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
70 mp_vcd_priv_t* vcd;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
71 #ifdef __FreeBSD__
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
72 int bsize = VCD_SECTOR_SIZE;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
73 #endif
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
74
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
75 if(mode != STREAM_READ) {
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
76 m_struct_free(&stream_opts,opts);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
77 return STREAM_UNSUPORTED;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
78 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
79
10591
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
80 if (!p->device) {
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
81 if(cdrom_device)
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
82 p->device = strdup(cdrom_device);
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
83 else
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
84 p->device = strdup(DEFAULT_CDROM_DEVICE);
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
85 }
0d381b648b51 Fix -cdrom-device to work again with cdda and vcd.
albeu
parents: 10121
diff changeset
86
9886
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
87 f=open(p->device,O_RDONLY);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
88 if(f<0){
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
89 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CdDevNotfound,p->device);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
90 close(f);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
91 m_struct_free(&stream_opts,opts);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
92 return STREAM_ERROR;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
93 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
94
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
95 vcd = vcd_read_toc(f);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
96 if(!vcd) {
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
97 mp_msg(MSGT_OPEN,MSGL_ERR,"Failed to get cd toc\n");
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
98 close(f);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
99 m_struct_free(&stream_opts,opts);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
100 return STREAM_ERROR;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
101 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
102 ret2=vcd_get_track_end(vcd,p->track);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
103 if(ret2<0){
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
104 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (get)\n");
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
105 close(f);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
106 free(vcd);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
107 m_struct_free(&stream_opts,opts);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
108 return STREAM_ERROR;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
109 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
110 ret=vcd_seek_to_track(vcd,p->track);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
111 if(ret<0){
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
112 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n");
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
113 close(f);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
114 free(vcd);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
115 m_struct_free(&stream_opts,opts);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
116 return STREAM_ERROR;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
117 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
118 mp_msg(MSGT_OPEN,MSGL_V,"VCD start byte position: 0x%X end: 0x%X\n",ret,ret2);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
119
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
120 #ifdef __FreeBSD__
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
121 if (ioctl (f, CDRIOCSETBLOCKSIZE, &bsize) == -1) {
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
122 mp_msg(MSGT_OPEN,MSGL_WARN,"Error in CDRIOCSETBLOCKSIZE");
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
123 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
124 #endif
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
125
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
126 stream->fd = f;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
127 stream->type = STREAMTYPE_VCD;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
128 stream->sector_size = VCD_SECTOR_DATA;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
129 stream->start_pos=ret;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
130 stream->end_pos=ret2;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
131 stream->priv = vcd;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
132
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
133 stream->fill_buffer = fill_buffer;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
134 stream->seek = seek;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
135 stream->close = close_s;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
136
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
137 m_struct_free(&stream_opts,opts);
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
138 return STREAM_OK;
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
139 }
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
140
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
141 stream_info_t stream_info_vcd = {
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
142 "Video CD",
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
143 "vcd",
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
144 "Albeu",
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
145 "based on the code from ???",
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
146 open_s,
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
147 { "vcd", NULL },
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
148 &stream_opts,
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
149 1 // Urls are an option string
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
150 };
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
151
e578e4375434 Port vcd to the new API
albeu
parents:
diff changeset
152 #endif