1 /* !! DO NO EDIT THIS FILE, it is automatically generated */
2 /*
3  * Copyright (C) 2001 Rich Wareham <richwareham@users.sourceforge.net>
4  *
5  * This file is part of libdvdnav, a DVD navigation library.
6  *
7  * libdvdnav is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * libdvdnav is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with libdvdnav; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21 
22 #ifndef LIBDVDNAV_DVDNAV_INTERNAL_H
23 #define LIBDVDNAV_DVDNAV_INTERNAL_H
24 
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
28 
29 #include <stdlib.h>
30 #include <stdio.h>
31 #include <unistd.h>
32 #include <limits.h>
33 #include <string.h>
34 #include <pthread.h>
35 
36 #undef WORDS_BIGENDIAN
37 
38 #include "dvd_reader.h"
39 #include "ifo_read.h"
40 #include "ifo_types.h"
41 
42 /* Uncomment for VM command tracing */
43 /* #define TRACE */
44 
45 #include "decoder.h"
46 #include "dvdnav.h"
47 #include "vm.h"
48 #include "vmcmd.h"
49 
50 /* where should libdvdnav write its messages (stdout/stderr) */
51 #define MSG_OUT stdout
52 
53 /* Maximum length of an error string */
54 #define MAX_ERR_LEN 255
55 
56 /* Use the POSIX PATH_MAX if available */
57 #ifdef PATH_MAX
58 #define MAX_PATH_LEN PATH_MAX
59 #else
60 #define MAX_PATH_LEN 255 /* Arbitrary */
61 #endif
62 
63 #ifndef DVD_VIDEO_LB_LEN
64 #define DVD_VIDEO_LB_LEN 2048
65 #endif
66 
67 typedef struct read_cache_s read_cache_t;
68 
69 /*
70  * These are defined here because they are
71  * not in ifo_types.h, they maybe one day
72  */
73 
74 #ifndef audio_status_t
75 typedef struct {
76 #ifdef WORDS_BIGENDIAN
77   unsigned int available     : 1;
78   unsigned int zero1         : 4;
79   unsigned int stream_number : 3;
80   uint8_t zero2;
81 #else
82   uint8_t zero2;
83   unsigned int stream_number : 3;
84   unsigned int zero1         : 4;
85   unsigned int available     : 1;
86 #endif
87 } ATTRIBUTE_PACKED audio_status_t;
88 #endif
89 
90 #ifndef spu_status_t
91 typedef struct {
92 #ifdef WORDS_BIGENDIAN
93   unsigned int available               : 1;
94   unsigned int zero1                   : 2;
95   unsigned int stream_number_4_3       : 5;
96   unsigned int zero2                   : 3;
97   unsigned int stream_number_wide      : 5;
98   unsigned int zero3                   : 3;
99   unsigned int stream_number_letterbox : 5;
100   unsigned int zero4                   : 3;
101   unsigned int stream_number_pan_scan  : 5;
102 #else
103   unsigned int stream_number_pan_scan  : 5;
104   unsigned int zero4                   : 3;
105   unsigned int stream_number_letterbox : 5;
106   unsigned int zero3                   : 3;
107   unsigned int stream_number_wide      : 5;
108   unsigned int zero2                   : 3;
109   unsigned int stream_number_4_3       : 5;
110   unsigned int zero1                   : 2;
111   unsigned int available               : 1;
112 #endif
113 } ATTRIBUTE_PACKED spu_status_t;
114 #endif
115 
116 typedef struct dvdnav_vobu_s {
117   int32_t vobu_start;  /* Logical Absolute. MAX needed is 0x300000 */
118   int32_t vobu_length;
119   int32_t blockN;      /* Relative offset */
120   int32_t vobu_next;   /* Relative offset */
121 } dvdnav_vobu_t;
122 
123 /** The main DVDNAV type **/
124 
125 struct dvdnav_s {
126   /* General data */
127   char        path[MAX_PATH_LEN]; /* Path to DVD device/dir */
128   dvd_file_t *file;               /* Currently opened file */
129   int         open_vtsN;          /* The domain and number of the... */
130   int         open_domain;        /* ..currently opened VOB */
131 
132   /* Position data */
133   vm_position_t position_next;
134   vm_position_t position_current;
135   dvdnav_vobu_t vobu;
136 
137   /* NAV data */
138   pci_t pci;
139   dsi_t dsi;
140   uint32_t last_cmd_nav_lbn;      /* detects when a command is issued on an already left NAV */
141 
142   /* Flags */
143   int skip_still;                 /* Set when skipping a still */
144   int sync_wait;                  /* applications should wait till they are in sync with us */
145   int sync_wait_skip;             /* Set when skipping wait state */
146   int spu_clut_changed;           /* The SPU CLUT changed */
147   int started;                    /* vm_start has been called? */
148   int use_read_ahead;             /* 1 - use read-ahead cache, 0 - don't */
149   int pgc_based;                  /* positioning works PGC based instead of PG based */
150 
151   /* VM */
152   vm_t *vm;
153   pthread_mutex_t vm_lock;
154 
155   /* Read-ahead cache */
156   read_cache_t *cache;
157 
158   /* Errors */
159   char err_str[MAX_ERR_LEN];
160 };
161 
162 /** USEFUL MACROS **/
163 
164 #ifdef __GNUC__
165 #define printerrf(format, args...) snprintf(this->err_str, MAX_ERR_LEN, format, ## args);
166 #else
167 #ifdef _MSC_VER
168 #define printerrf(str) snprintf(this->err_str, MAX_ERR_LEN, str);
169 #else
170 #define printerrf(...) snprintf(this->err_str, MAX_ERR_LEN, __VA_ARGS__);
171 #endif /* WIN32 */
172 #endif
173 #define printerr(str) strncpy(this->err_str, str, MAX_ERR_LEN);
174 
175 /* Save my typing */
176 #define S_ERR DVDNAV_STATUS_ERR
177 
178 #ifndef _MSC_VER
179 #define S_OK  DVDNAV_STATUS_OK
180 #endif /* MSC_VER */
181 
182 #endif /* LIBDVDNAV_DVDNAV_INTERNAL_H */
183