comparison remap.c @ 114:b6834e6359cf src

big libdvdnav cleanup, quoting the ChangeLog: * some bugfixes * code cleanup * build process polishing * more sensible event order in get_next_block to ensure useful event delivery * VOBU level resume * fixed: seeking in a multiangle feature briefly showed the wrong angle
author mroi
date Thu, 20 Feb 2003 15:32:21 +0000
parents 2fcb4f228308
children 4e099155c968
comparison
equal deleted inserted replaced
113:ec2df154be56 114:b6834e6359cf
1 /*
2 * This file is part of libdvdnav, a DVD navigation library.
3 *
4 * libdvdnav is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * libdvdnav is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
17 *
18 * $Id$
19 */
20
1 #include <stdlib.h> 21 #include <stdlib.h>
2 #include <string.h> 22 #include <string.h>
3 #include <stdio.h> 23 #include <stdio.h>
4 #include <sys/param.h> 24 #include <sys/param.h>
5 #include <sys/fcntl.h> 25 #include <sys/fcntl.h>
6 #include <assert.h> 26 #include <assert.h>
7 #include "remap.h" 27 #include "remap.h"
28 #include "dvdnav_internal.h"
8 29
9 struct block_s { 30 struct block_s {
10 int domain; 31 int domain;
11 int title; 32 int title;
12 int program; 33 int program;
162 remap_t *map; 183 remap_t *map;
163 184
164 /* Build the map filename */ 185 /* Build the map filename */
165 home = getenv("HOME"); assert(home); 186 home = getenv("HOME"); assert(home);
166 strncpy(fname, home, sizeof(fname)); 187 strncpy(fname, home, sizeof(fname));
167 strncat(fname, "/.xine/", sizeof(fname)); 188 strncat(fname, "/.dvdnav/", sizeof(fname));
168 strncat(fname, title, sizeof(fname)); 189 strncat(fname, title, sizeof(fname));
169 strncat(fname, ".map", sizeof(fname)); 190 strncat(fname, ".map", sizeof(fname));
170 191
171 printf("Loading %s.\n", fname);
172 /* Open the map file */ 192 /* Open the map file */
173 fp = fopen( fname, "r"); 193 fp = fopen( fname, "r");
174 if (!fp) { 194 if (!fp) {
175 printf("Unable to find map file '%s'\n", fname); 195 fprintf(MSG_OUT, "libdvdnav: Unable to find map file '%s'\n", fname);
176 return NULL; 196 return NULL;
177 } 197 }
178 198
179 /* Load the map file */ 199 /* Load the map file */
180 map = remap_new( title); 200 map = remap_new( title);
184 map->debug = 1; 204 map->debug = 1;
185 } else { 205 } else {
186 res = parseblock( buf, 206 res = parseblock( buf,
187 &tmp.domain, &tmp.title, &tmp.program, &tmp.start_block, &tmp.end_block); 207 &tmp.domain, &tmp.title, &tmp.program, &tmp.start_block, &tmp.end_block);
188 if (res != 5) { 208 if (res != 5) {
189 printf("Ignoring map line (%d): %s\n", res, buf); 209 fprintf(MSG_OUT, "libdvdnav: Ignoring map line (%d): %s\n", res, buf);
190 continue; 210 continue;
191 } 211 }
192 remap_add_node( map, tmp); 212 remap_add_node( map, tmp);
193 } 213 }
194 } 214 }
203 { 223 {
204 block_t key; 224 block_t key;
205 block_t *b; 225 block_t *b;
206 226
207 if (map->debug) { 227 if (map->debug) {
208 printf("%s: domain %d, title %d, program %d, start %lx, next %lx\n", 228 fprintf(MSG_OUT, "libdvdnav: %s: domain %d, title %d, program %d, start %lx, next %lx\n",
209 map->title, domain, title, program, cblock, cblock+offset); 229 map->title, domain, title, program, cblock, cblock+offset);
210 } 230 }
211 231
212 key.domain = domain; 232 key.domain = domain;
213 key.title = title; 233 key.title = title;
215 key.start_block = key.end_block = cblock + offset; 235 key.start_block = key.end_block = cblock + offset;
216 b = findblock( map, &key); 236 b = findblock( map, &key);
217 237
218 if (b) { 238 if (b) {
219 if (map->debug) { 239 if (map->debug) {
220 printf("Redirected to %lx\n", b->end_block); 240 fprintf(MSG_OUT, "libdvdnav: Redirected to %lx\n", b->end_block);
221 } 241 }
222 return b->end_block - cblock; 242 return b->end_block - cblock;
223 } 243 }
224 return offset; 244 return offset;
225 } 245 }