Mercurial > mplayer.hg
annotate libmpdemux/stream_vcd.c @ 16403:a90d07677f2d
Obsoleted...
author | ods15 |
---|---|
date | Tue, 06 Sep 2005 05:33:14 +0000 |
parents | 25feca1387e7 |
children | 6ff3379a0862 |
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 | |
15566 | 17 #if defined(__FreeBSD__) || defined(__DragonFly__) |
9886 | 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){ | |
15912 | 56 if(s->pos > s->end_pos) /// don't past end of current track |
57 return 0; | |
9886 | 58 return vcd_read(s->priv,buffer); |
59 } | |
60 | |
61 static int seek(stream_t *s,off_t newpos) { | |
62 s->pos = newpos; | |
63 vcd_set_msf(s->priv,s->pos/VCD_SECTOR_DATA); | |
64 return 1; | |
65 } | |
66 | |
67 static void close_s(stream_t *stream) { | |
68 free(stream->priv); | |
69 } | |
70 | |
71 static int open_s(stream_t *stream,int mode, void* opts, int* file_format) { | |
72 struct stream_priv_s* p = (struct stream_priv_s*)opts; | |
73 int ret,ret2,f; | |
74 mp_vcd_priv_t* vcd; | |
75 #ifdef __FreeBSD__ | |
76 int bsize = VCD_SECTOR_SIZE; | |
77 #endif | |
78 | |
79 if(mode != STREAM_READ) { | |
80 m_struct_free(&stream_opts,opts); | |
81 return STREAM_UNSUPORTED; | |
82 } | |
83 | |
10591 | 84 if (!p->device) { |
85 if(cdrom_device) | |
86 p->device = strdup(cdrom_device); | |
87 else | |
88 p->device = strdup(DEFAULT_CDROM_DEVICE); | |
89 } | |
90 | |
9886 | 91 f=open(p->device,O_RDONLY); |
92 if(f<0){ | |
93 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_CdDevNotfound,p->device); | |
94 m_struct_free(&stream_opts,opts); | |
95 return STREAM_ERROR; | |
96 } | |
97 | |
98 vcd = vcd_read_toc(f); | |
99 if(!vcd) { | |
100 mp_msg(MSGT_OPEN,MSGL_ERR,"Failed to get cd toc\n"); | |
101 close(f); | |
102 m_struct_free(&stream_opts,opts); | |
103 return STREAM_ERROR; | |
104 } | |
105 ret2=vcd_get_track_end(vcd,p->track); | |
106 if(ret2<0){ | |
107 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (get)\n"); | |
108 close(f); | |
109 free(vcd); | |
110 m_struct_free(&stream_opts,opts); | |
111 return STREAM_ERROR; | |
112 } | |
113 ret=vcd_seek_to_track(vcd,p->track); | |
114 if(ret<0){ | |
115 mp_msg(MSGT_OPEN,MSGL_ERR,MSGTR_ErrTrackSelect " (seek)\n"); | |
116 close(f); | |
117 free(vcd); | |
118 m_struct_free(&stream_opts,opts); | |
119 return STREAM_ERROR; | |
120 } | |
121 mp_msg(MSGT_OPEN,MSGL_V,"VCD start byte position: 0x%X end: 0x%X\n",ret,ret2); | |
122 | |
123 #ifdef __FreeBSD__ | |
124 if (ioctl (f, CDRIOCSETBLOCKSIZE, &bsize) == -1) { | |
125 mp_msg(MSGT_OPEN,MSGL_WARN,"Error in CDRIOCSETBLOCKSIZE"); | |
126 } | |
127 #endif | |
128 | |
129 stream->fd = f; | |
130 stream->type = STREAMTYPE_VCD; | |
131 stream->sector_size = VCD_SECTOR_DATA; | |
132 stream->start_pos=ret; | |
133 stream->end_pos=ret2; | |
134 stream->priv = vcd; | |
135 | |
136 stream->fill_buffer = fill_buffer; | |
137 stream->seek = seek; | |
138 stream->close = close_s; | |
139 | |
140 m_struct_free(&stream_opts,opts); | |
141 return STREAM_OK; | |
142 } | |
143 | |
144 stream_info_t stream_info_vcd = { | |
145 "Video CD", | |
146 "vcd", | |
147 "Albeu", | |
148 "based on the code from ???", | |
149 open_s, | |
150 { "vcd", NULL }, | |
151 &stream_opts, | |
152 1 // Urls are an option string | |
153 }; | |
154 | |
155 #endif |