Mercurial > libdvdread4.hg
annotate libdvdread/dvd_input.c @ 0:427b7da5cbdb src
first split of dvdread; it's just a copy of dvdnav still to be cleaned
author | nicodvb |
---|---|
date | Sun, 01 Jun 2008 08:39:07 +0000 |
parents | |
children |
rev | line source |
---|---|
0
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
1 /* |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
2 * Copyright (C) 2002 Samuel Hocevar <sam@zoy.org>, |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
3 * Håkan Hjort <d95hjort@dtek.chalmers.se> |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
4 * |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
7 * the Free Software Foundation; either version 2 of the License, or |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
8 * (at your option) any later version. |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
9 * |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
13 * GNU General Public License for more details. |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
14 * |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
16 * along with this program; if not, write to the Free Software |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
18 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
19 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
20 #include "config.h" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
21 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
22 #include <stdio.h> |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
23 #include <stdlib.h> |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
24 #include <fcntl.h> |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
25 #include <unistd.h> |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
26 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
27 #include "dvd_reader.h" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
28 #include "dvd_input.h" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
29 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
30 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
31 /* The function pointers that is the exported interface of this file. */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
32 dvd_input_t (*dvdinput_open) (const char *); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
33 int (*dvdinput_close) (dvd_input_t); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
34 int (*dvdinput_seek) (dvd_input_t, int); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
35 int (*dvdinput_title) (dvd_input_t, int); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
36 int (*dvdinput_read) (dvd_input_t, void *, int, int); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
37 char * (*dvdinput_error) (dvd_input_t); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
38 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
39 #ifdef HAVE_DVDCSS_DVDCSS_H |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
40 /* linking to libdvdcss */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
41 #include <dvdcss/dvdcss.h> |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
42 #define DVDcss_open(a) dvdcss_open((char*)(a)) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
43 #define DVDcss_close dvdcss_close |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
44 #define DVDcss_seek dvdcss_seek |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
45 #define DVDcss_title dvdcss_title |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
46 #define DVDcss_read dvdcss_read |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
47 #define DVDcss_error dvdcss_error |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
48 #else |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
49 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
50 /* dlopening libdvdcss */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
51 #ifdef HAVE_DLFCN_H |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
52 #include <dlfcn.h> |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
53 #else |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
54 /* Only needed on MINGW at the moment */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
55 #include "../../msvc/contrib/dlfcn.c" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
56 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
57 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
58 typedef struct dvdcss_s *dvdcss_handle; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
59 static dvdcss_handle (*DVDcss_open) (const char *); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
60 static int (*DVDcss_close) (dvdcss_handle); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
61 static int (*DVDcss_seek) (dvdcss_handle, int, int); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
62 static int (*DVDcss_title) (dvdcss_handle, int); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
63 static int (*DVDcss_read) (dvdcss_handle, void *, int, int); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
64 static char * (*DVDcss_error) (dvdcss_handle); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
65 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
66 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
67 /* The DVDinput handle, add stuff here for new input methods. */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
68 struct dvd_input_s { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
69 /* libdvdcss handle */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
70 dvdcss_handle dvdcss; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
71 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
72 /* dummy file input */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
73 int fd; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
74 }; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
75 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
76 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
77 /** |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
78 * initialize and open a DVD device or file. |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
79 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
80 static dvd_input_t css_open(const char *target) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
81 { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
82 dvd_input_t dev; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
83 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
84 /* Allocate the handle structure */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
85 dev = (dvd_input_t) malloc(sizeof(*dev)); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
86 if(dev == NULL) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
87 fprintf(stderr, "libdvdread: Could not allocate memory.\n"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
88 return NULL; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
89 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
90 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
91 /* Really open it with libdvdcss */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
92 dev->dvdcss = DVDcss_open(target); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
93 if(dev->dvdcss == 0) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
94 fprintf(stderr, "libdvdread: Could not open %s with libdvdcss.\n", target); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
95 free(dev); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
96 return NULL; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
97 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
98 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
99 return dev; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
100 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
101 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
102 /** |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
103 * return the last error message |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
104 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
105 static char *css_error(dvd_input_t dev) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
106 { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
107 return DVDcss_error(dev->dvdcss); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
108 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
109 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
110 /** |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
111 * seek into the device. |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
112 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
113 static int css_seek(dvd_input_t dev, int blocks) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
114 { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
115 /* DVDINPUT_NOFLAGS should match the DVDCSS_NOFLAGS value. */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
116 return DVDcss_seek(dev->dvdcss, blocks, DVDINPUT_NOFLAGS); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
117 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
118 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
119 /** |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
120 * set the block for the begining of a new title (key). |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
121 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
122 static int css_title(dvd_input_t dev, int block) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
123 { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
124 return DVDcss_title(dev->dvdcss, block); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
125 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
126 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
127 /** |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
128 * read data from the device. |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
129 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
130 static int css_read(dvd_input_t dev, void *buffer, int blocks, int flags) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
131 { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
132 return DVDcss_read(dev->dvdcss, buffer, blocks, flags); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
133 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
134 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
135 /** |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
136 * close the DVD device and clean up the library. |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
137 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
138 static int css_close(dvd_input_t dev) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
139 { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
140 int ret; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
141 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
142 ret = DVDcss_close(dev->dvdcss); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
143 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
144 if(ret < 0) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
145 return ret; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
146 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
147 free(dev); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
148 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
149 return 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
150 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
151 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
152 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
153 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
154 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
155 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
156 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
157 /** |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
158 * initialize and open a DVD device or file. |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
159 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
160 static dvd_input_t file_open(const char *target) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
161 { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
162 dvd_input_t dev; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
163 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
164 /* Allocate the library structure */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
165 dev = (dvd_input_t) malloc(sizeof(*dev)); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
166 if(dev == NULL) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
167 fprintf(stderr, "libdvdread: Could not allocate memory.\n"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
168 return NULL; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
169 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
170 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
171 /* Open the device */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
172 #ifndef WIN32 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
173 dev->fd = open(target, O_RDONLY); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
174 #else |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
175 dev->fd = open(target, O_RDONLY | O_BINARY); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
176 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
177 if(dev->fd < 0) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
178 perror("libdvdread: Could not open input"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
179 free(dev); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
180 return NULL; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
181 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
182 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
183 return dev; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
184 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
185 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
186 /** |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
187 * return the last error message |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
188 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
189 static char *file_error(dvd_input_t dev) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
190 { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
191 /* use strerror(errno)? */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
192 return (char *)"unknown error"; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
193 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
194 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
195 /** |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
196 * seek into the device. |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
197 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
198 static int file_seek(dvd_input_t dev, int blocks) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
199 { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
200 off_t pos; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
201 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
202 pos = lseek(dev->fd, (off_t)blocks * (off_t)DVD_VIDEO_LB_LEN, SEEK_SET); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
203 if(pos < 0) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
204 return pos; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
205 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
206 /* assert pos % DVD_VIDEO_LB_LEN == 0 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
207 return (int) (pos / DVD_VIDEO_LB_LEN); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
208 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
209 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
210 /** |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
211 * set the block for the begining of a new title (key). |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
212 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
213 static int file_title(dvd_input_t dev, int block) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
214 { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
215 return -1; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
216 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
217 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
218 /** |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
219 * read data from the device. |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
220 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
221 static int file_read(dvd_input_t dev, void *buffer, int blocks, int flags) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
222 { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
223 size_t len; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
224 ssize_t ret; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
225 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
226 len = (size_t)blocks * DVD_VIDEO_LB_LEN; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
227 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
228 while(len > 0) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
229 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
230 ret = read(dev->fd, buffer, len); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
231 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
232 if(ret < 0) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
233 /* One of the reads failed, too bad. We won't even bother |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
234 * returning the reads that went ok, and as in the posix spec |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
235 * the file postition is left unspecified after a failure. */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
236 return ret; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
237 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
238 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
239 if(ret == 0) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
240 /* Nothing more to read. Return the whole blocks, if any, that we got. |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
241 and adjust the file possition back to the previous block boundary. */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
242 size_t bytes = (size_t)blocks * DVD_VIDEO_LB_LEN - len; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
243 off_t over_read = -(bytes % DVD_VIDEO_LB_LEN); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
244 /*off_t pos =*/ lseek(dev->fd, over_read, SEEK_CUR); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
245 /* should have pos % 2048 == 0 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
246 return (int) (bytes / DVD_VIDEO_LB_LEN); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
247 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
248 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
249 len -= ret; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
250 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
251 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
252 return blocks; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
253 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
254 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
255 /** |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
256 * close the DVD device and clean up. |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
257 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
258 static int file_close(dvd_input_t dev) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
259 { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
260 int ret; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
261 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
262 ret = close(dev->fd); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
263 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
264 if(ret < 0) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
265 return ret; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
266 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
267 free(dev); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
268 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
269 return 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
270 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
271 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
272 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
273 /** |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
274 * Setup read functions with either libdvdcss or minimal DVD access. |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
275 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
276 int dvdinput_setup(void) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
277 { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
278 void *dvdcss_library = NULL; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
279 char **dvdcss_version = NULL; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
280 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
281 #ifdef HAVE_DVDCSS_DVDCSS_H |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
282 /* linking to libdvdcss */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
283 dvdcss_library = &dvdcss_library; /* Give it some value != NULL */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
284 /* the DVDcss_* functions have been #defined at the top */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
285 dvdcss_version = &dvdcss_interface_2; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
286 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
287 #else |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
288 /* dlopening libdvdcss */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
289 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
290 #ifdef __APPLE__ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
291 #define CSS_LIB "libdvdcss.2.dylib" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
292 #elif defined(WIN32) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
293 #define CSS_LIB "libdvdcss.dll" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
294 #else |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
295 #define CSS_LIB "libdvdcss.so.2" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
296 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
297 dvdcss_library = dlopen(CSS_LIB, RTLD_LAZY); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
298 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
299 if(dvdcss_library != NULL) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
300 #if defined(__OpenBSD__) && !defined(__ELF__) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
301 #define U_S "_" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
302 #else |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
303 #define U_S |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
304 #endif |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
305 DVDcss_open = (dvdcss_handle (*)(const char*)) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
306 dlsym(dvdcss_library, U_S "dvdcss_open"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
307 DVDcss_close = (int (*)(dvdcss_handle)) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
308 dlsym(dvdcss_library, U_S "dvdcss_close"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
309 DVDcss_title = (int (*)(dvdcss_handle, int)) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
310 dlsym(dvdcss_library, U_S "dvdcss_title"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
311 DVDcss_seek = (int (*)(dvdcss_handle, int, int)) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
312 dlsym(dvdcss_library, U_S "dvdcss_seek"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
313 DVDcss_read = (int (*)(dvdcss_handle, void*, int, int)) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
314 dlsym(dvdcss_library, U_S "dvdcss_read"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
315 DVDcss_error = (char* (*)(dvdcss_handle)) |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
316 dlsym(dvdcss_library, U_S "dvdcss_error"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
317 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
318 dvdcss_version = (char **)dlsym(dvdcss_library, U_S "dvdcss_interface_2"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
319 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
320 if(dlsym(dvdcss_library, U_S "dvdcss_crack")) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
321 fprintf(stderr, |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
322 "libdvdread: Old (pre-0.0.2) version of libdvdcss found.\n" |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
323 "libdvdread: You should get the latest version from " |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
324 "http://www.videolan.org/\n" ); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
325 dlclose(dvdcss_library); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
326 dvdcss_library = NULL; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
327 } else if(!DVDcss_open || !DVDcss_close || !DVDcss_title || !DVDcss_seek |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
328 || !DVDcss_read || !DVDcss_error || !dvdcss_version) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
329 fprintf(stderr, "libdvdread: Missing symbols in %s, " |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
330 "this shouldn't happen !\n", CSS_LIB); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
331 dlclose(dvdcss_library); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
332 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
333 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
334 #endif /* HAVE_DVDCSS_DVDCSS_H */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
335 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
336 if(dvdcss_library != NULL) { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
337 /* |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
338 char *psz_method = getenv( "DVDCSS_METHOD" ); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
339 char *psz_verbose = getenv( "DVDCSS_VERBOSE" ); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
340 fprintf(stderr, "DVDCSS_METHOD %s\n", psz_method); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
341 fprintf(stderr, "DVDCSS_VERBOSE %s\n", psz_verbose); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
342 */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
343 fprintf(stderr, "libdvdread: Using libdvdcss version %s for DVD access\n", |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
344 dvdcss_version ? *dvdcss_version : ""); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
345 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
346 /* libdvdcss wrapper functions */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
347 dvdinput_open = css_open; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
348 dvdinput_close = css_close; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
349 dvdinput_seek = css_seek; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
350 dvdinput_title = css_title; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
351 dvdinput_read = css_read; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
352 dvdinput_error = css_error; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
353 return 1; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
354 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
355 } else { |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
356 fprintf(stderr, "libdvdread: Encrypted DVD support unavailable.\n"); |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
357 |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
358 /* libdvdcss replacement functions */ |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
359 dvdinput_open = file_open; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
360 dvdinput_close = file_close; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
361 dvdinput_seek = file_seek; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
362 dvdinput_title = file_title; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
363 dvdinput_read = file_read; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
364 dvdinput_error = file_error; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
365 return 0; |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
366 } |
427b7da5cbdb
first split of dvdread; it's just a copy of dvdnav still to be cleaned
nicodvb
parents:
diff
changeset
|
367 } |