Mercurial > mplayer.hg
annotate libmpdemux/stream_vcd.c @ 14110:9d242e613fd8
Some other fixes. Better wordings and better translations of tech stuff
author | gpoirier |
---|---|
date | Sun, 05 Dec 2004 21:51:39 +0000 |
parents | e52daf7f3bcc |
children | 719883aa0adf |
rev | line source |
---|---|
9886 | 1 |
2 #include "config.h" | |
3 | |
4 #ifdef HAVE_VCD | |
5 #include "mp_msg.h" | |
6 #include "stream.h" | |
7 #include "help_mp.h" | |
8 #include "../m_option.h" | |
9 #include "../m_struct.h" | |
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 | 12 #include <stdlib.h> |
13 #include <unistd.h> | |
14 #include <sys/ioctl.h> | |
15 #include <errno.h> | |
16 | |
17 #ifdef __FreeBSD__ | |
18 #include <sys/cdrio.h> | |
19 #include "vcd_read_fbsd.h" | |
12797
b2419eef04da
OpenBSD portability patches from the OpenBSD ports tree
diego
parents:
10591
diff
changeset
|
20 #elif defined(__NetBSD__) || defined (__OpenBSD__) |
13678 | 21 #include "vcd_read_nbsd.h" |
13681
e52daf7f3bcc
enable vcd for all darwin based sys not only mac osx
nplourde
parents:
13678
diff
changeset
|
22 #elif defined(SYS_DARWIN) |
e52daf7f3bcc
enable vcd for all darwin based sys not only mac osx
nplourde
parents:
13678
diff
changeset
|
23 #include "vcd_read_darwin.h" |
9886 | 24 #else |
25 #include "vcd_read.h" | |
26 #endif | |
27 | |
10591 | 28 extern char *cdrom_device; |
29 | |
9886 | 30 static struct stream_priv_s { |
31 int track; | |
32 char* device; | |
33 } stream_priv_dflts = { | |
34 1, | |
10591 | 35 NULL |
9886 | 36 }; |
37 | |
38 #define ST_OFF(f) M_ST_OFF(struct stream_priv_s,f) | |
39 /// URL definition | |
40 static m_option_t stream_opts_fields[] = { | |
41 { "track", ST_OFF(track), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL }, | |
42 { "device", ST_OFF(device), CONF_TYPE_STRING, 0, 0 ,0, NULL}, | |
43 /// For url parsing | |
44 { "hostname", ST_OFF(track), CONF_TYPE_INT, M_OPT_MIN, 1, 0, NULL }, | |
45 { "filename", ST_OFF(device), CONF_TYPE_STRING, 0, 0 ,0, NULL}, | |
46 { NULL, NULL, 0, 0, 0, 0, NULL } | |
47 }; | |
48 static struct m_struct_st stream_opts = { | |
49 "vcd", | |
50 sizeof(struct stream_priv_s), | |
51 &stream_priv_dflts, | |
52 stream_opts_fields | |
53 }; | |
54 | |
55 static int fill_buffer(stream_t *s, char* buffer, int max_len){ | |
56 return vcd_read(s->priv,buffer); | |
57 } | |
58 | |
59 static int seek(stream_t *s,off_t newpos) { | |
60 s->pos = newpos; | |
61 vcd_set_msf(s->priv,s->pos/VCD_SECTOR_DATA); | |
62 return 1; | |
63 } | |
64 | |
65 static void close_s(stream_t *stream) { | |
66 free(stream->priv); | |
67 } | |
68 | |
69 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { | |
70 struct stream_priv_s* p = (struct stream_priv_s*)opts; | |
71 int ret,ret2,f; | |
72 mp_vcd_priv_t* vcd; | |
73 #ifdef __FreeBSD__ | |
74 int bsize = VCD_SECTOR_SIZE; | |
75 #endif | |
76 | |
77 if(mode != STREAM_READ) { | |
78 m_struct_free(&stream_opts,opts); | |
79 return STREAM_UNSUPORTED; | |
80 } | |
81 | |
10591 | 82 if (!p->device) { |
83 if(cdrom_device) | |
84 p->device = strdup(cdrom_device); | |
85 else | |
86 p->device = strdup(DEFAULT_CDROM_DEVICE); | |
87 } | |
88 | |
9886 | 89 f=open(p->device,O_RDONLY); |
90 if(f<0){ | |
91 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CdDevNotfound,p->device); | |
92 close(f); | |
93 m_struct_free(&stream_opts,opts); | |
94 return STREAM_ERROR; | |
95 } | |
96 | |
97 vcd = vcd_read_toc(f); | |
98 if(!vcd) { | |
99 mp_msg(MSGT_OPEN,MSGL_ERR,"Failed to get cd toc\n"); | |
100 close(f); | |
101 m_struct_free(&stream_opts,opts); | |
102 return STREAM_ERROR; | |
103 } | |
104 ret2=vcd_get_track_end(vcd,p->track); | |
105 if(ret2<0){ | |
106 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (get)\n"); | |
107 close(f); | |
108 free(vcd); | |
109 m_struct_free(&stream_opts,opts); | |
110 return STREAM_ERROR; | |
111 } | |
112 ret=vcd_seek_to_track(vcd,p->track); | |
113 if(ret<0){ | |
114 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n"); | |
115 close(f); | |
116 free(vcd); | |
117 m_struct_free(&stream_opts,opts); | |
118 return STREAM_ERROR; | |
119 } | |
120 mp_msg(MSGT_OPEN,MSGL_V,"VCD start byte position: 0x%X end: 0x%X\n",ret,ret2); | |
121 | |
122 #ifdef __FreeBSD__ | |
123 if (ioctl (f, CDRIOCSETBLOCKSIZE, &bsize) == -1) { | |
124 mp_msg(MSGT_OPEN,MSGL_WARN,"Error in CDRIOCSETBLOCKSIZE"); | |
125 } | |
126 #endif | |
127 | |
128 stream->fd = f; | |
129 stream->type = STREAMTYPE_VCD; | |
130 stream->sector_size = VCD_SECTOR_DATA; | |
131 stream->start_pos=ret; | |
132 stream->end_pos=ret2; | |
133 stream->priv = vcd; | |
134 | |
135 stream->fill_buffer = fill_buffer; | |
136 stream->seek = seek; | |
137 stream->close = close_s; | |
138 | |
139 m_struct_free(&stream_opts,opts); | |
140 return STREAM_OK; | |
141 } | |
142 | |
143 stream_info_t stream_info_vcd = { | |
144 "Video CD", | |
145 "vcd", | |
146 "Albeu", | |
147 "based on the code from ???", | |
148 open_s, | |
149 { "vcd", NULL }, | |
150 &stream_opts, | |
151 1 // Urls are an option string | |
152 }; | |
153 | |
154 #endif |