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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
#include "config.h"
#ifdef HAVE_VCD
#include "mp_msg.h"
#include "stream.h"
#include "help_mp.h"
#include "../m_option.h"
#include "../m_struct.h"
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <errno.h>
#ifdef __FreeBSD__
#include <sys/cdrio.h>
#include "vcd_read_fbsd.h"
#elif defined(__NetBSD__) || defined (__OpenBSD__)
#include "vcd_read_nbsd.h"
#elif defined(MACOSX)
#include "vcd_read_macosx.h"
#else
#include "vcd_read.h"
#endif
extern char *cdrom_device;
static struct stream_priv_s {
int track;
char* device;
} stream_priv_dflts = {
1,
NULL
};
#define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f)
/// URL definition
static m_option_t stream_opts_fields[] = {
{ "track", ST_OFF(track), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL },
{ "device", ST_OFF(device), CONF_TYPE_STRING, 0, 0 ,0, NULL},
/// For url parsing
{ "hostname", ST_OFF(track), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL },
{ "filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0 ,0, NULL},
{ NULL, NULL, 0, 0, 0, 0, NULL }
};
static struct m_struct_st stream_opts = {
"vcd",
sizeof(struct stream_priv_s),
&stream_priv_dflts,
stream_opts_fields
};
static int fill_buffer(stream_t *s, char* buffer, int max_len){
return vcd_read(s->priv,buffer);
}
static int seek(stream_t *s,off_t newpos) {
s->pos = newpos;
vcd_set_msf(s->priv,s->pos/VCD_SECTOR_DATA);
return 1;
}
static void close_s(stream_t *stream) {
free(stream->priv);
}
static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
struct stream_priv_s* p = (struct stream_priv_s*)opts;
int ret,ret2,f;
mp_vcd_priv_t* vcd;
#ifdef __FreeBSD__
int bsize = VCD_SECTOR_SIZE;
#endif
if(mode != STREAM_READ) {
m_struct_free(&stream_opts,opts);
return STREAM_UNSUPORTED;
}
if (!p->device) {
if(cdrom_device)
p->device = strdup(cdrom_device);
else
p->device = strdup(DEFAULT_CDROM_DEVICE);
}
f=open(p->device,O_RDONLY);
if(f<0){
mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CdDevNotfound,p->device);
close(f);
m_struct_free(&stream_opts,opts);
return STREAM_ERROR;
}
vcd = vcd_read_toc(f);
if(!vcd) {
mp_msg(MSGT_OPEN,MSGL_ERR,"Failed to get cd toc\n");
close(f);
m_struct_free(&stream_opts,opts);
return STREAM_ERROR;
}
ret2=vcd_get_track_end(vcd,p->track);
if(ret2<0){
mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (get)\n");
close(f);
free(vcd);
m_struct_free(&stream_opts,opts);
return STREAM_ERROR;
}
ret=vcd_seek_to_track(vcd,p->track);
if(ret<0){
mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n");
close(f);
free(vcd);
m_struct_free(&stream_opts,opts);
return STREAM_ERROR;
}
mp_msg(MSGT_OPEN,MSGL_V,"VCD start byte position: 0x%X end: 0x%X\n",ret,ret2);
#ifdef __FreeBSD__
if (ioctl (f, CDRIOCSETBLOCKSIZE, &bsize) == -1) {
mp_msg(MSGT_OPEN,MSGL_WARN,"Error in CDRIOCSETBLOCKSIZE");
}
#endif
stream->fd = f;
stream->type = STREAMTYPE_VCD;
stream->sector_size = VCD_SECTOR_DATA;
stream->start_pos=ret;
stream->end_pos=ret2;
stream->priv = vcd;
stream->fill_buffer = fill_buffer;
stream->seek = seek;
stream->close = close_s;
m_struct_free(&stream_opts,opts);
return STREAM_OK;
}
stream_info_t stream_info_vcd = {
"Video CD",
"vcd",
"Albeu",
"based on the code from ???",
open_s,
{ "vcd", NULL },
&stream_opts,
1 // Urls are an option string
};
#endif
|