8 #include "../m_option.h"
9 #include "../m_struct.h"
14 #include <sys/ioctl.h>
18 #include <sys/cdrio.h>
19 #include "vcd_read_fbsd.h"
20 #elif defined(__NetBSD__)
21 #include "vcd_read_nbsd.h"
26 extern char *cdrom_device
;
28 static struct stream_priv_s
{
31 } stream_priv_dflts
= {
36 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f)
38 static m_option_t stream_opts_fields
[] = {
39 { "track", ST_OFF(track
), CONF_TYPE_INT
, M_OPT_MIN
, 1, 0, NULL
},
40 { "device", ST_OFF(device
), CONF_TYPE_STRING
, 0, 0 ,0, NULL
},
42 { "hostname", ST_OFF(track
), CONF_TYPE_INT
, M_OPT_MIN
, 1, 0, NULL
},
43 { "filename", ST_OFF(device
), CONF_TYPE_STRING
, 0, 0 ,0, NULL
},
44 { NULL
, NULL
, 0, 0, 0, 0, NULL
}
46 static struct m_struct_st stream_opts
= {
48 sizeof(struct stream_priv_s
),
53 static int fill_buffer(stream_t
*s
, char* buffer
, int max_len
){
54 return vcd_read(s
->priv
,buffer
);
57 static int seek(stream_t
*s
,off_t newpos
) {
59 vcd_set_msf(s
->priv
,s
->pos
/VCD_SECTOR_DATA
);
63 static void close_s(stream_t
*stream
) {
67 static int open_s(stream_t
*stream
,int mode
, void* opts
, int* file_format
) {
68 struct stream_priv_s
* p
= (struct stream_priv_s
*)opts
;
72 int bsize
= VCD_SECTOR_SIZE
;
75 if(mode
!= STREAM_READ
) {
76 m_struct_free(&stream_opts
,opts
);
77 return STREAM_UNSUPORTED
;
82 p
->device
= strdup(cdrom_device
);
84 p
->device
= strdup(DEFAULT_CDROM_DEVICE
);
87 f
=open(p
->device
,O_RDONLY
);
89 mp_msg(MSGT_OPEN
,MSGL_ERR
,MSGTR_CdDevNotfound
,p
->device
);
91 m_struct_free(&stream_opts
,opts
);
95 vcd
= vcd_read_toc(f
);
97 mp_msg(MSGT_OPEN
,MSGL_ERR
,"Failed to get cd toc\n");
99 m_struct_free(&stream_opts
,opts
);
102 ret2
=vcd_get_track_end(vcd
,p
->track
);
104 mp_msg(MSGT_OPEN
,MSGL_ERR
,MSGTR_ErrTrackSelect
" (get)\n");
107 m_struct_free(&stream_opts
,opts
);
110 ret
=vcd_seek_to_track(vcd
,p
->track
);
112 mp_msg(MSGT_OPEN
,MSGL_ERR
,MSGTR_ErrTrackSelect
" (seek)\n");
115 m_struct_free(&stream_opts
,opts
);
118 mp_msg(MSGT_OPEN
,MSGL_V
,"VCD start byte position: 0x%X end: 0x%X\n",ret
,ret2
);
121 if (ioctl (f
, CDRIOCSETBLOCKSIZE
, &bsize
) == -1) {
122 mp_msg(MSGT_OPEN
,MSGL_WARN
,"Error in CDRIOCSETBLOCKSIZE");
127 stream
->type
= STREAMTYPE_VCD
;
128 stream
->sector_size
= VCD_SECTOR_DATA
;
129 stream
->start_pos
=ret
;
130 stream
->end_pos
=ret2
;
133 stream
->fill_buffer
= fill_buffer
;
135 stream
->close
= close_s
;
137 m_struct_free(&stream_opts
,opts
);
141 stream_info_t stream_info_vcd
= {
145 "based on the code from ???",
149 1 // Urls are an option string