2 * Copyright (C) 2001-2004 Rich Wareham <richwareham@users.sourceforge.net>
4 * This file is part of libdvdnav, a DVD navigation library.
6 * libdvdnav is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * libdvdnav is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with libdvdnav; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #ifndef LIBDVDNAV_DVDNAV_INTERNAL_H
22 #define LIBDVDNAV_DVDNAV_INTERNAL_H
30 /* pthread_mutex_* wrapper for win32 */
33 typedef CRITICAL_SECTION pthread_mutex_t
;
34 #define pthread_mutex_init(a, b) InitializeCriticalSection(a)
35 #define pthread_mutex_lock(a) EnterCriticalSection(a)
36 #define pthread_mutex_unlock(a) LeaveCriticalSection(a)
37 #define pthread_mutex_destroy(a)
39 #ifndef HAVE_GETTIMEOFDAY
40 /* replacement gettimeofday implementation */
41 #include <sys/timeb.h>
42 static inline int _private_gettimeofday( struct timeval
*tv
, void *tz
)
47 tv
->tv_usec
= t
.millitm
* 1000;
50 #define gettimeofday(TV, TZ) _private_gettimeofday((TV), (TZ))
53 #include <io.h> /* read() */
54 #define lseek64 _lseeki64
62 /* where should libdvdnav write its messages (stdout/stderr) */
63 #define MSG_OUT stdout
65 /* Maximum length of an error string */
66 #define MAX_ERR_LEN 255
68 /* Use the POSIX PATH_MAX if available */
70 #define MAX_PATH_LEN PATH_MAX
72 #define MAX_PATH_LEN 255 /* Arbitrary */
75 #ifndef DVD_VIDEO_LB_LEN
76 #define DVD_VIDEO_LB_LEN 2048
79 typedef struct read_cache_s read_cache_t
;
82 * These are defined here because they are
83 * not in ifo_types.h, they maybe one day
86 #ifndef audio_status_t
88 #ifdef WORDS_BIGENDIAN
89 unsigned int available
: 1;
90 unsigned int zero1
: 4;
91 unsigned int stream_number
: 3;
95 unsigned int stream_number
: 3;
96 unsigned int zero1
: 4;
97 unsigned int available
: 1;
99 } ATTRIBUTE_PACKED audio_status_t
;
104 #ifdef WORDS_BIGENDIAN
105 unsigned int available
: 1;
106 unsigned int zero1
: 2;
107 unsigned int stream_number_4_3
: 5;
108 unsigned int zero2
: 3;
109 unsigned int stream_number_wide
: 5;
110 unsigned int zero3
: 3;
111 unsigned int stream_number_letterbox
: 5;
112 unsigned int zero4
: 3;
113 unsigned int stream_number_pan_scan
: 5;
115 unsigned int stream_number_pan_scan
: 5;
116 unsigned int zero4
: 3;
117 unsigned int stream_number_letterbox
: 5;
118 unsigned int zero3
: 3;
119 unsigned int stream_number_wide
: 5;
120 unsigned int zero2
: 3;
121 unsigned int stream_number_4_3
: 5;
122 unsigned int zero1
: 2;
123 unsigned int available
: 1;
125 } ATTRIBUTE_PACKED spu_status_t
;
128 typedef struct dvdnav_vobu_s
{
129 int32_t vobu_start
; /* Logical Absolute. MAX needed is 0x300000 */
131 int32_t blockN
; /* Relative offset */
132 int32_t vobu_next
; /* Relative offset */
135 /** The main DVDNAV type **/
139 char path
[MAX_PATH_LEN
]; /* Path to DVD device/dir */
140 dvd_file_t
*file
; /* Currently opened file */
143 vm_position_t position_next
;
144 vm_position_t position_current
;
150 uint32_t last_cmd_nav_lbn
; /* detects when a command is issued on an already left NAV */
153 int skip_still
; /* Set when skipping a still */
154 int sync_wait
; /* applications should wait till they are in sync with us */
155 int sync_wait_skip
; /* Set when skipping wait state */
156 int spu_clut_changed
; /* The SPU CLUT changed */
157 int started
; /* vm_start has been called? */
158 int use_read_ahead
; /* 1 - use read-ahead cache, 0 - don't */
159 int pgc_based
; /* positioning works PGC based instead of PG based */
160 int cur_cell_time
; /* time expired since the beginning of the current cell, read from the dsi */
164 pthread_mutex_t vm_lock
;
166 /* Read-ahead cache */
170 char err_str
[MAX_ERR_LEN
];
173 /** HELPER FUNCTIONS **/
175 /* converts a dvd_time_t to PTS ticks */
176 int64_t dvdnav_convert_time(dvd_time_t
*time
);
178 /** USEFUL MACROS **/
181 #define printerrf(format, args...) \
182 do { if (this) snprintf(this->err_str, MAX_ERR_LEN, format, ## args); } while (0)
185 #define printerrf(str) \
186 do { if (this) snprintf(this->err_str, MAX_ERR_LEN, str); } while (0)
188 #define printerrf(...) \
189 do { if (this) snprintf(this->err_str, MAX_ERR_LEN, __VA_ARGS__); } while (0)
192 #define printerr(str) \
193 do { if (this) strncpy(this->err_str, str, MAX_ERR_LEN - 1); } while (0)
195 #endif /* LIBDVDNAV_DVDNAV_INTERNAL_H */