Skip to content
This repository
Browse code

Added diffs for XBMC changes to libdvd libs

cores.diff is the differences between include files in lib/libdvd
and xbmc/cores/dvdplayer/dvdinputstreams/dvdnav
  • Loading branch information...
commit 57e27aff0a152ef53d29c80ff07136cd065e77ff 1 parent 421d9fd
Paxxi authored February 08, 2013
545  lib/libdvd/patches/cores.diff
... ...
@@ -0,0 +1,545 @@
  1
+diff -uw dvdnav_diff/config.h xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/config.h
  2
+--- dvdnav_diff/config.h	2013-02-07 14:42:34 +0100
  3
++++ xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/config.h	2013-01-26 23:33:20 +0100
  4
+@@ -1,56 +1,95 @@
  5
+-/* config.h.  Generated by hand.  */
  6
++#pragma once
  7
+ 
  8
+-#ifndef LIBDVDREAD_CONFIG_H
  9
+-#define LIBDVDREAD_CONFIG_H
  10
++/*
  11
++ *      Copyright (C) 2005-2012 Team XBMC
  12
++ *      http://www.xbmc.org
  13
++ *
  14
++ *  This Program is free software; you can redistribute it and/or modify
  15
++ *  it under the terms of the GNU General Public License as published by
  16
++ *  the Free Software Foundation; either version 2, or (at your option)
  17
++ *  any later version.
  18
++ *
  19
++ *  This Program is distributed in the hope that it will be useful,
  20
++ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  21
++ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22
++ *  GNU General Public License for more details.
  23
++ *
  24
++ *  You should have received a copy of the GNU General Public License
  25
++ *  along with XBMC; see the file COPYING.  If not, see
  26
++ *  <http://www.gnu.org/licenses/>.
  27
++ *
  28
++ */
  29
+ 
  30
+-#define HAVE_DLFCN_H 1
  31
++/* config.h.  Generated by hand.  */
  32
++#if defined(_LINUX)
  33
++#include "PlatformInclude.h"
  34
++#else
  35
++#include <windows.h>
  36
++#endif
  37
++#include <stdio.h>
  38
++
  39
++//#define HAVE_DLFCN_H 1
  40
++#define HAVE_DVDCSS_DVDCSS_H 1
  41
+ /* #undef HAVE_DVDCSS_DVDCSS_H*/
  42
+ /* #undef HAVE_INTTYPES_H */
  43
+ #define HAVE_MEMORY_H 1
  44
+-/* #undef HAVE_STDINT_H */
  45
++#define HAVE_STDINT_H 1
  46
+ #define HAVE_STDLIB_H 1
  47
+ #define HAVE_STRINGS_H 1
  48
+ #define HAVE_STRING_H 1
  49
+ #define HAVE_SYS_STAT_H 1
  50
+ #define HAVE_SYS_TYPES_H 1
  51
+ /* #undef HAVE_UNISTD_H */
  52
++#ifndef PACKAGE
  53
+ #define PACKAGE "libdvdread"
  54
++#endif
  55
++#ifndef PACKAGE_BUGREPORT
  56
+ #define PACKAGE_BUGREPORT ""
  57
++#endif
  58
++#ifndef PACKAGE_NAME
  59
+ #define PACKAGE_NAME ""
  60
++#endif
  61
++#ifndef PACKAGE_STRING
  62
+ #define PACKAGE_STRING ""
  63
++#endif
  64
++#ifndef PACKAGE_TARNAME
  65
+ #define PACKAGE_TARNAME ""
  66
++#endif
  67
++#ifndef PACKAGE_VERSION
  68
+ #define PACKAGE_VERSION ""
  69
++#endif
  70
+ #define STDC_HEADERS 1
  71
++#ifndef VERSION
  72
+ #define VERSION "1.2.6"
  73
++#endif
  74
+ /* #undef WORDS_BIGENDIAN */
  75
+ /* #undef __DARWIN__ */
  76
+ /* #undef const */
  77
+ #define inline __inline
  78
+ /* #undef size_t */
  79
+ 
  80
+-#define ssize_t __int64
  81
++#define ssize_t int
  82
+ 
  83
+ #ifndef PATH_MAX
  84
+ #define PATH_MAX MAX_PATH
  85
+ #endif
  86
+ 
  87
++#ifndef strcasecmp
  88
+ #define strcasecmp stricmp
  89
++#endif
  90
++#ifndef strncasecmp
  91
+ #define strncasecmp strnicmp
  92
++#endif
  93
+ 
  94
++#ifndef S_ISDIR
  95
+ #define S_ISDIR(m) ((m) & _S_IFDIR)
  96
++#endif
  97
++#ifndef S_ISREG
  98
+ #define S_ISREG(m) ((m) & _S_IFREG)
  99
++#endif
  100
++#ifndef S_ISBLK
  101
+ #define S_ISBLK(m) 0
  102
++#endif
  103
++#ifndef S_ISCHR
  104
+ #define S_ISCHR(m) 0
  105
+-
  106
+-/* Fallback types (very x86-centric, sorry) */
  107
+-typedef unsigned char       uint8_t;
  108
+-typedef signed char         int8_t;
  109
+-typedef unsigned short      uint16_t;
  110
+-typedef signed short        int16_t;
  111
+-typedef unsigned int        uint32_t;
  112
+-typedef signed int          int32_t;
  113
+-typedef unsigned __int64    uint64_t;
  114
+-typedef signed __int64      int64_t;
  115
+-typedef unsigned int        uintptr_t;
  116
+-
  117
+-#endif /* LIBDVDREAD_CONFIG_H */
  118
++#endif
  119
+diff -uw dvdnav_diff/decoder.h xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/decoder.h
  120
+--- dvdnav_diff/decoder.h	2013-02-07 14:42:34 +0100
  121
++++ xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/decoder.h	2013-02-04 14:58:00 +0100
  122
+@@ -22,6 +22,12 @@
  123
+ #ifndef LIBDVDNAV_DECODER_H
  124
+ #define LIBDVDNAV_DECODER_H
  125
+ 
  126
++//#include <inttypes.h>
  127
++//#include <sys/time.h>
  128
++
  129
++#include "ifo_types.h" /*  vm_cmd_t */
  130
++#include "dvdnav_internal.h"
  131
++
  132
+ /* link command types */
  133
+ typedef enum {
  134
+   LinkNoLink  = 0,
  135
+diff -uw dvdnav_diff/dvd_reader.h xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/dvd_reader.h
  136
+--- dvdnav_diff/dvd_reader.h	2013-02-07 14:42:34 +0100
  137
++++ xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/dvd_reader.h	2013-02-04 14:58:00 +0100
  138
+@@ -24,14 +24,14 @@
  139
+ #define LIBDVDREAD_DVD_READER_H
  140
+ 
  141
+ #ifdef _MSC_VER
  142
+-#include <config.h>
  143
++#include "config.h"
  144
+ 
  145
+ #include <stdio.h>
  146
+ #include <stdlib.h>
  147
+ #endif
  148
+ 
  149
+ #include <sys/types.h>
  150
+-#include <inttypes.h>
  151
++//#include <inttypes.h>
  152
+ 
  153
+ /**
  154
+  * The DVD access interface.
  155
+diff -uw dvdnav_diff/dvd_types.h xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/dvd_types.h
  156
+--- dvdnav_diff/dvd_types.h	2013-02-07 14:42:34 +0100
  157
++++ xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/dvd_types.h	2013-02-04 14:58:00 +0100
  158
+@@ -26,6 +26,8 @@
  159
+ #ifndef LIBDVDNAV_DVD_TYPES_H
  160
+ #define LIBDVDNAV_DVD_TYPES_H
  161
+ 
  162
++//#include <inttypes.h>
  163
++
  164
+ /*
  165
+  * DVD Menu ID
  166
+  * (see dvdnav_menu_call())
  167
+@@ -60,7 +62,8 @@
  168
+ 
  169
+ /* the following types are currently unused */
  170
+ 
  171
+-#if 0
  172
++//XBMC Needs some of these
  173
++#if 1
  174
+ 
  175
+ /* Domain */
  176
+ typedef enum {
  177
+@@ -222,6 +225,10 @@
  178
+   DVD_DISPLAY_MODE_4x3Letterboxed = 3
  179
+ } DVDDisplayMode_t;
  180
+ 
  181
++typedef int DVDAudioSampleFreq_t;
  182
++typedef int DVDAudioSampleQuant_t;
  183
++typedef int DVDChannelNumber_t;
  184
++
  185
+ /* Audio attributes */
  186
+ typedef struct {
  187
+   DVDAudioAppMode_t     AppMode;
  188
+@@ -233,9 +240,6 @@
  189
+   DVDAudioSampleQuant_t SampleQuantization;
  190
+   DVDChannelNumber_t    NumberOfChannels;
  191
+ } DVDAudioAttributes_t;
  192
+-typedef int DVDAudioSampleFreq_t;
  193
+-typedef int DVDAudioSampleQuant_t;
  194
+-typedef int DVDChannelNumber_t;
  195
+ 
  196
+ /* Subpicture attributes */
  197
+ typedef enum {
  198
+@@ -255,6 +259,8 @@
  199
+   DVDSubpictureLangExt_t LanguageExtension;
  200
+ } DVDSubpictureAttributes_t;
  201
+ 
  202
++typedef int DVDVideoCompression_t;
  203
++
  204
+ /* Video attributes */
  205
+ typedef struct {
  206
+   DVDBool_t PanscanPermitted;
  207
+@@ -268,7 +274,6 @@
  208
+   DVDBool_t Line21Field2InGop;
  209
+   int more_to_come;
  210
+ } DVDVideoAttributes_t;
  211
+-typedef int DVDVideoCompression_t;
  212
+ 
  213
+ #endif
  214
+ 
  215
+diff -uw dvdnav_diff/dvdnav.h xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/dvdnav.h
  216
+--- dvdnav_diff/dvdnav.h	2013-02-07 14:42:34 +0100
  217
++++ xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/dvdnav.h	2013-02-04 14:58:00 +0100
  218
+@@ -32,11 +32,14 @@
  219
+ extern "C" {
  220
+ #endif
  221
+ 
  222
+-#  include <dvdnav/dvd_types.h>
  223
+-#  include <dvdread/dvd_reader.h>
  224
+-#  include <dvdread/nav_types.h>
  225
+-#  include <dvdread/ifo_types.h> /* For vm_cmd_t */
  226
+-#  include <dvdnav/dvdnav_events.h>
  227
++#  include "dvd_types.h"
  228
++#  include "dvd_reader.h"
  229
++#  include "nav_types.h"
  230
++#  include "ifo_types.h" /* For vm_cmd_t */
  231
++#  include "dvdnav_events.h"
  232
++#  include "dvd_types.h"
  233
++#  include "dvd_reader.h"
  234
++#  include "ifo_types.h" /* For vm_cmd_t */
  235
+ 
  236
+ 
  237
+ 
  238
+@@ -63,11 +66,6 @@
  239
+ #define DVDNAV_STATUS_ERR 0
  240
+ #define DVDNAV_STATUS_OK  1
  241
+ 
  242
+-#define DVDNAV_FORMAT_AC3 0
  243
+-#define DVDNAV_FORMAT_MPEGAUDIO 3
  244
+-#define DVDNAV_FORMAT_LPCM 4
  245
+-#define DVDNAV_FORMAT_DTS 5
  246
+-#define DVDNAV_FORMAT_SDDS 6
  247
+ 
  248
+ /*********************************************************************
  249
+  * initialisation & housekeeping functions                           *
  250
+@@ -281,7 +279,7 @@
  251
+ /*
  252
+  * Plays the specified title, starting from the specified program
  253
+  */
  254
+-dvdnav_status_t dvdnav_program_play(dvdnav_t *this, int32_t title, int32_t pgcn, int32_t pgn);
  255
++dvdnav_status_t dvdnav_program_play(dvdnav_t *self, int32_t title, int32_t pgcn, int32_t pgn);
  256
+ 
  257
+ /*
  258
+  * Stores in *times an array (that the application *must* free) of
  259
+@@ -695,6 +693,15 @@
  260
+  */
  261
+ int8_t dvdnav_is_domain_vts(dvdnav_t *self);
  262
+ 
  263
++/* XBMC added functions */
  264
++int dvdnav_get_nr_of_subtitle_streams(dvdnav_t *self);
  265
++
  266
++int dvdnav_get_nr_of_audio_streams(dvdnav_t *self);
  267
++
  268
++int dvdnav_get_button_info(dvdnav_t* self, int alpha[2][4], int color[2][4]);
  269
++
  270
++int64_t dvdnav_convert_time(dvd_time_t *time);
  271
++
  272
+ ////////// RATDVD stuff ///////////////
  273
+ 
  274
+ /*
  275
+diff -uw dvdnav_diff/dvdnav_events.h xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/dvdnav_events.h
  276
+--- dvdnav_diff/dvdnav_events.h	2013-02-07 14:42:34 +0100
  277
++++ xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/dvdnav_events.h	2013-02-04 14:58:00 +0100
  278
+@@ -25,6 +25,10 @@
  279
+ #ifndef LIBDVDNAV_DVDNAV_EVENTS_H
  280
+ #define LIBDVDNAV_DVDNAV_EVENTS_H
  281
+ 
  282
++#include "ifo_types.h"
  283
++#include "dvd_reader.h"
  284
++#include "nav_types.h"
  285
++
  286
+ /*
  287
+  * DVDNAV_BLOCK_OK
  288
+  *
  289
+diff -uw dvdnav_diff/dvdnav_internal.h xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/dvdnav_internal.h
  290
+--- dvdnav_diff/dvdnav_internal.h	2013-02-07 14:42:34 +0100
  291
++++ xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/dvdnav_internal.h	2013-02-07 14:33:08 +0100
  292
+@@ -1,6 +1,5 @@
  293
+-/* !! DO NO EDIT THIS FILE, it is automatically generated */
  294
+ /*
  295
+- * Copyright (C) 2001 Rich Wareham <richwareham@users.sourceforge.net>
  296
++ * Copyright (C) 2001-2004 Rich Wareham <richwareham@users.sourceforge.net>
  297
+  *
  298
+  * This file is part of libdvdnav, a DVD navigation library.
  299
+  *
  300
+@@ -19,8 +18,8 @@
  301
+  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  302
+  */
  303
+ 
  304
+-#ifndef LIBDVDREAD_DVDNAV_INTERNAL_H
  305
+-#define LIBDVDREAD_DVDNAV_INTERNAL_H
  306
++#ifndef LIBDVDNAV_DVDNAV_INTERNAL_H
  307
++#define LIBDVDNAV_DVDNAV_INTERNAL_H
  308
+ 
  309
+ #ifdef HAVE_CONFIG_H
  310
+ #include "config.h"
  311
+@@ -28,16 +27,47 @@
  312
+ 
  313
+ #include <stdlib.h>
  314
+ #include <stdio.h>
  315
+-#include <unistd.h>
  316
++//#include <unistd.h>
  317
+ #include <limits.h>
  318
+ #include <string.h>
  319
+-#include <pthread.h>
  320
+ 
  321
+-#undef WORDS_BIGENDIAN
  322
++#ifdef WIN32
  323
++
  324
++/* pthread_mutex_* wrapper for win32 */
  325
++#ifndef _LINUX
  326
++#include <windows.h>
  327
++#include <process.h>
  328
++typedef CRITICAL_SECTION pthread_mutex_t;
  329
++#define pthread_mutex_init(a, b) InitializeCriticalSection(a)
  330
++#define pthread_mutex_lock(a)    EnterCriticalSection(a)
  331
++#define pthread_mutex_unlock(a)  LeaveCriticalSection(a)
  332
++#define pthread_mutex_destroy(a) DeleteCriticalSection(a)
  333
++#endif // !_LINUX
  334
++
  335
++#ifndef HAVE_GETTIMEOFDAY
  336
++/* replacement gettimeofday implementation */
  337
++#include <sys/timeb.h>
  338
++static inline int _private_gettimeofday( struct timeval *tv, void *tz )
  339
++{
  340
++  struct timeb t;
  341
++  ftime( &t );
  342
++  tv->tv_sec = t.time;
  343
++  tv->tv_usec = t.millitm * 1000;
  344
++  return 0;
  345
++}
  346
++#define gettimeofday(TV, TZ) _private_gettimeofday((TV), (TZ))
  347
++#endif
  348
++
  349
++#ifndef _LINUX
  350
++#include <io.h> /* read() */
  351
++#define lseek64 _lseeki64
  352
++#endif // !_LINUX
  353
+ 
  354
+-#include "dvd_reader.h"
  355
+-#include "ifo_read.h"
  356
+-#include "ifo_types.h"
  357
++#else
  358
++
  359
++#include <pthread.h>
  360
++
  361
++#endif /* WIN32 */
  362
+ 
  363
+ /* Uncomment for VM command tracing */
  364
+ /* #define TRACE */
  365
+@@ -48,7 +78,7 @@
  366
+ #include "vmcmd.h"
  367
+ 
  368
+ /* where should libdvdnav write its messages (stdout/stderr) */
  369
+-#define MSG_OUT stdout
  370
++#define MSG_OUT stderr
  371
+ 
  372
+ /* Maximum length of an error string */
  373
+ #define MAX_ERR_LEN 255
  374
+@@ -126,8 +156,6 @@
  375
+   /* General data */
  376
+   char        path[MAX_PATH_LEN]; /* Path to DVD device/dir */
  377
+   dvd_file_t *file;               /* Currently opened file */
  378
+-  int         open_vtsN;          /* The domain and number of the... */
  379
+-  int         open_domain;        /* ..currently opened VOB */
  380
+ 
  381
+   /* Position data */
  382
+   vm_position_t position_next;
  383
+@@ -147,6 +175,7 @@
  384
+   int started;                    /* vm_start has been called? */
  385
+   int use_read_ahead;             /* 1 - use read-ahead cache, 0 - don't */
  386
+   int pgc_based;                  /* positioning works PGC based instead of PG based */
  387
++  int cur_cell_time;              /* time expired since the beginning of the current cell, read from the dsi */
  388
+ 
  389
+   /* VM */
  390
+   vm_t *vm;
  391
+@@ -159,24 +188,38 @@
  392
+   char err_str[MAX_ERR_LEN];
  393
+ };
  394
+ 
  395
++/** HELPER FUNCTIONS **/
  396
++
  397
++/* converts a dvd_time_t to PTS ticks */
  398
++int64_t dvdnav_convert_time(dvd_time_t *time);
  399
++
  400
++/* XBMC added functions */
  401
++/*
  402
++ * Get current playback state
  403
++ */
  404
++dvdnav_status_t dvdnav_get_state(dvdnav_t *self, dvd_state_t *save_state);
  405
++
  406
++/*
  407
++ * Resume playback state
  408
++ */
  409
++dvdnav_status_t dvdnav_set_state(dvdnav_t *self, dvd_state_t *save_state);
  410
++/* end XBMC */
  411
++
  412
+ /** USEFUL MACROS **/
  413
+ 
  414
+ #ifdef __GNUC__
  415
+-#define printerrf(format, args...) snprintf(this->err_str, MAX_ERR_LEN, format, ## args);
  416
++#define printerrf(format, args...) \
  417
++	do { if (this) snprintf(this->err_str, MAX_ERR_LEN, format, ## args); } while (0)
  418
+ #else
  419
+ #ifdef _MSC_VER
  420
+-#define printerrf(str) snprintf(this->err_str, MAX_ERR_LEN, str);
  421
++#define printerrf(str) \
  422
++	do { if (this) snprintf(this->err_str, MAX_ERR_LEN, str); } while (0)
  423
+ #else
  424
+-#define printerrf(...) snprintf(this->err_str, MAX_ERR_LEN, __VA_ARGS__);
  425
++#define printerrf(...) \
  426
++	do { if (this) snprintf(this->err_str, MAX_ERR_LEN, __VA_ARGS__); } while (0)
  427
+ #endif /* WIN32 */
  428
+ #endif
  429
+-#define printerr(str) strncpy(this->err_str, str, MAX_ERR_LEN);
  430
+-
  431
+-/* Save my typing */
  432
+-#define S_ERR DVDNAV_STATUS_ERR
  433
+-
  434
+-#ifndef _MSC_VER
  435
+-#define S_OK  DVDNAV_STATUS_OK
  436
+-#endif /* MSC_VER */
  437
++#define printerr(str) \
  438
++	do { if (this) strncpy(this->err_str, str, MAX_ERR_LEN - 1); } while (0)
  439
+ 
  440
+-#endif /* LIBDVDREAD_DVDNAV_INTERNAL_H */
  441
++#endif /* LIBDVDNAV_DVDNAV_INTERNAL_H */
  442
+diff -uw dvdnav_diff/ifo_types.h xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/ifo_types.h
  443
+--- dvdnav_diff/ifo_types.h	2013-02-07 14:42:34 +0100
  444
++++ xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/ifo_types.h	2013-02-04 14:58:00 +0100
  445
+@@ -22,8 +22,8 @@
  446
+ #ifndef LIBDVDREAD_IFO_TYPES_H
  447
+ #define LIBDVDREAD_IFO_TYPES_H
  448
+ 
  449
+-#include <inttypes.h>
  450
+-#include "dvdread/dvd_reader.h"
  451
++//#include <inttypes.h>
  452
++#include "dvd_reader.h"
  453
+ 
  454
+ 
  455
+ #undef ATTRIBUTE_PACKED
  456
+diff -uw dvdnav_diff/nav_types.h xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/nav_types.h
  457
+--- dvdnav_diff/nav_types.h	2013-02-07 14:42:34 +0100
  458
++++ xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/nav_types.h	2013-02-04 14:58:00 +0100
  459
+@@ -28,9 +28,27 @@
  460
+ #ifndef LIBDVDREAD_NAV_TYPES_H
  461
+ #define LIBDVDREAD_NAV_TYPES_H
  462
+ 
  463
+-#include <inttypes.h>
  464
++//#include <inttypes.h>
  465
+ #include "ifo_types.h" /* only dvd_time_t, vm_cmd_t and user_ops_t */
  466
+ 
  467
++
  468
++#undef ATTRIBUTE_PACKED
  469
++#undef PRAGMA_PACK_BEGIN 
  470
++#undef PRAGMA_PACK_END
  471
++
  472
++#if defined(__GNUC__)
  473
++#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
  474
++#define ATTRIBUTE_PACKED __attribute__ ((packed))
  475
++#define PRAGMA_PACK 0
  476
++#endif
  477
++#endif
  478
++
  479
++#if !defined(ATTRIBUTE_PACKED)
  480
++#define ATTRIBUTE_PACKED
  481
++#define PRAGMA_PACK 1
  482
++#endif
  483
++
  484
++
  485
+ /* The length including the substream id byte. */
  486
+ #define PCI_BYTES 0x3d4
  487
+ #define DSI_BYTES 0x3fa
  488
+@@ -41,6 +59,12 @@
  489
+ /* Remove this */
  490
+ #define DSI_START_BYTE 1031
  491
+ 
  492
++
  493
++#if PRAGMA_PACK
  494
++#pragma pack(1)
  495
++#endif
  496
++
  497
++
  498
+ /**
  499
+  * PCI General Information
  500
+  */
  501
+diff -uw dvdnav_diff/vm.h xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/vm.h
  502
+--- dvdnav_diff/vm.h	2013-02-07 14:42:34 +0100
  503
++++ xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/vm.h	2013-02-07 14:33:08 +0100
  504
+@@ -23,6 +23,9 @@
  505
+ #ifndef LIBDVDNAV_VM_H
  506
+ #define LIBDVDNAV_VM_H
  507
+ 
  508
++#include "remap.h"
  509
++#include "dvdnav_internal.h"
  510
++
  511
+ /* DOMAIN enum */
  512
+ 
  513
+ typedef enum {
  514
+@@ -156,11 +159,8 @@
  515
+ int vm_get_audio_active_stream(vm_t *vm);
  516
+ int vm_get_subp_active_stream(vm_t *vm, int mode);
  517
+ void vm_get_angle_info(vm_t *vm, int *current, int *num_avail);
  518
+-// _XBMC #if 0
  519
+-/* currently unused */
  520
+ void vm_get_audio_info(vm_t *vm, int *current, int *num_avail);
  521
+ void vm_get_subp_info(vm_t *vm, int *current, int *num_avail);
  522
+-// _XBMC #endif
  523
+ void vm_get_video_res(vm_t *vm, int *width, int *height);
  524
+ int  vm_get_video_aspect(vm_t *vm);
  525
+ int  vm_get_video_scale_permission(vm_t *vm);
  526
+@@ -180,5 +180,7 @@
  527
+ void vm_position_print(vm_t *vm, vm_position_t *position);
  528
+ #endif
  529
+ 
  530
++/* XBMC added functions */
  531
++vm_t* dvdnav_get_vm(dvdnav_t *self);
  532
+ 
  533
+ #endif /* LIBDVDNAV_VM_H */
  534
+diff -uw dvdnav_diff/vmcmd.h xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/vmcmd.h
  535
+--- dvdnav_diff/vmcmd.h	2013-02-07 14:42:34 +0100
  536
++++ xbmc/xbmc/cores/dvdplayer/DVDInputStreams/dvdnav/vmcmd.h	2013-02-04 14:58:00 +0100
  537
+@@ -22,6 +22,8 @@
  538
+ #ifndef LIBDVDNAV_VMCMD_H
  539
+ #define LIBDVDNAV_VMCMD_H
  540
+ 
  541
++//#include <inttypes.h>
  542
++
  543
+ void vm_print_mnemonic(vm_cmd_t *command);
  544
+ void vm_print_cmd(int row, vm_cmd_t *command);
  545
+ 
365  lib/libdvd/patches/libdvdcss.diff
... ...
@@ -0,0 +1,365 @@
  1
+diff -uwr libdvdcss-1.2.12/src/device.c xbmc/lib/libdvd/libdvdcss/src/device.c
  2
+--- libdvdcss-1.2.12/src/device.c	2012-03-12 00:07:48 +0100
  3
++++ xbmc/lib/libdvd/libdvdcss/src/device.c	2013-02-07 14:42:34 +0100
  4
+@@ -23,6 +23,10 @@
  5
+  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  6
+  *****************************************************************************/
  7
+ 
  8
++/*
  9
++	Modifications for XBMC are all contained within _XBOX (real xbox hardware) or WITH_CACHE
  10
++*/
  11
++
  12
+ /*****************************************************************************
  13
+  * Preamble
  14
+  *****************************************************************************/
  15
+@@ -368,11 +372,20 @@
  16
+ 
  17
+ #if defined( WIN32 )
  18
+     dvdcss->b_file = 1;
  19
++#if defined( _XBOX )
  20
++	// If we've passed over the device string make sure we don't try
  21
++	// to use file based handling (libc) - we want Win2k routines ...
  22
++	if (!stricmp(psz_device, "\\Device\\Cdrom0"))
  23
++		dvdcss->b_file = 0;
  24
++	else
  25
++		dvdcss->b_file = stricmp(psz_device, "D:");
  26
++#else
  27
+     /* If device is "X:" or "X:\", we are not actually opening a file. */
  28
+     if (psz_device[0] && psz_device[1] == ':' &&
  29
+        (!psz_device[2] || (psz_device[2] == '\\' && !psz_device[3])))
  30
+         dvdcss->b_file = 0;
  31
+ 
  32
++#endif	// _XBOX
  33
+     /* Initialize readv temporary buffer */
  34
+     dvdcss->p_readv_buffer   = NULL;
  35
+     dvdcss->i_readv_buf_size = 0;
  36
+@@ -450,11 +463,13 @@
  37
+     }
  38
+     else /* ASPI */
  39
+     {
  40
++#if !defined(_XBOX)
  41
+         struct w32_aspidev *fd = (struct w32_aspidev *) dvdcss->i_fd;
  42
+ 
  43
+         /* Unload aspi and free w32_aspidev structure */
  44
+         FreeLibrary( (HMODULE) fd->hASPI );
  45
+         free( (void*) dvdcss->i_fd );
  46
++#endif	// !_XBOX
  47
+     }
  48
+ 
  49
+     /* Free readv temporary buffer */
  50
+@@ -510,9 +525,14 @@
  51
+ #if defined( WIN32 )
  52
+ static int win2k_open ( dvdcss_t dvdcss, char const *psz_device )
  53
+ {
  54
++#ifdef _XBOX
  55
++    char psz_dvd[70];
  56
++    strcpy(psz_dvd, "cdrom0:");
  57
++#else
  58
+     char psz_dvd[7];
  59
+     snprintf( psz_dvd, 7, "\\\\.\\%c:", psz_device[0] );
  60
+ 
  61
++#endif
  62
+     /* To work around an M$ bug in IOCTL_DVD_READ_STRUCTURE, we need read
  63
+      * _and_ write access to the device (so we can make SCSI Pass Through
  64
+      * Requests). Unfortunately this is only allowed if you have
  65
+@@ -521,17 +541,24 @@
  66
+      * won't send back the right result).
  67
+      * (See Microsoft Q241374: Read and Write Access Required for SCSI
  68
+      * Pass Through Requests) */
  69
++
  70
++#ifdef WITH_CACHE
  71
++    DWORD flags = FILE_FLAG_NO_BUFFERING; /* we handle buffering ourself */
  72
++#else
  73
++    DWORD flags = FILE_FLAG_RANDOM_ACCESS;
  74
++#endif //!_XBOX
  75
++
  76
+     dvdcss->i_fd = (int)
  77
+                 CreateFile( psz_dvd, GENERIC_READ | GENERIC_WRITE,
  78
+                             FILE_SHARE_READ | FILE_SHARE_WRITE,
  79
+                             NULL, OPEN_EXISTING,
  80
+-                            FILE_FLAG_RANDOM_ACCESS, NULL );
  81
++                            flags, NULL );
  82
+ 
  83
+     if( (HANDLE) dvdcss->i_fd == INVALID_HANDLE_VALUE )
  84
+         dvdcss->i_fd = (int)
  85
+                     CreateFile( psz_dvd, GENERIC_READ, FILE_SHARE_READ,
  86
+                                 NULL, OPEN_EXISTING,
  87
+-                                FILE_FLAG_RANDOM_ACCESS, NULL );
  88
++                                flags, NULL );
  89
+ 
  90
+     if( (HANDLE) dvdcss->i_fd == INVALID_HANDLE_VALUE )
  91
+     {
  92
+@@ -727,6 +754,9 @@
  93
+ static int win2k_seek( dvdcss_t dvdcss, int i_blocks )
  94
+ {
  95
+     LARGE_INTEGER li_seek;
  96
++#ifdef WITH_CACHE
  97
++    int iBytesToSkip;
  98
++#endif
  99
+ 
  100
+ #ifndef INVALID_SET_FILE_POINTER
  101
+ #   define INVALID_SET_FILE_POINTER ((DWORD)-1)
  102
+@@ -738,6 +768,28 @@
  103
+         return i_blocks;
  104
+     }
  105
+ 
  106
++#ifdef WITH_CACHE
  107
++
  108
++    // if our buffer contains the position which we want to seek too, we can
  109
++    // just decrease dwCacheBufferSize
  110
++    iBytesToSkip = (i_blocks - dvdcss->i_pos) * DVDCSS_BLOCK_SIZE;
  111
++    if (iBytesToSkip > 0 && iBytesToSkip < dvdcss->buffer_size)
  112
++    {
  113
++      dvdcss->buffer_size -= iBytesToSkip;
  114
++      dvdcss->i_pos = i_blocks;
  115
++      return dvdcss->i_pos;
  116
++    }
  117
++    else if (iBytesToSkip < 0 && (DISC_CACHE_SIZE - dvdcss->buffer_size) >= -iBytesToSkip)
  118
++    {
  119
++      // we want to seek backwards, and we have enough old data in our buffer
  120
++      dvdcss->buffer_size -= iBytesToSkip; // since iBytesToSkip is negative, dwCacheBufferSize will get bigger
  121
++      dvdcss->i_pos = i_blocks;
  122
++      return dvdcss->i_pos;
  123
++    }
  124
++    else dvdcss->buffer_size = 0;
  125
++    
  126
++#endif
  127
++
  128
+     li_seek.QuadPart = (LONGLONG)i_blocks * DVDCSS_BLOCK_SIZE;
  129
+ 
  130
+     li_seek.LowPart = SetFilePointer( (HANDLE) dvdcss->i_fd,
  131
+@@ -827,6 +879,66 @@
  132
+ {
  133
+     int i_bytes;
  134
+ 
  135
++#ifdef WITH_CACHE
  136
++
  137
++  if (dvdcss->buffer_size < i_blocks * DVDCSS_BLOCK_SIZE)
  138
++  {
  139
++    // we don't have enough data in our buffer
  140
++    int iRemaining = i_blocks * DVDCSS_BLOCK_SIZE;
  141
++    int iCopied = 0;
  142
++    // copy data we already have and read again into the cache
  143
++	if (dvdcss->buffer_size > 0) memcpy(p_buffer, dvdcss->buffer + (DISC_CACHE_SIZE - dvdcss->buffer_size), dvdcss->buffer_size);
  144
++    iCopied = dvdcss->buffer_size;
  145
++    iRemaining -= dvdcss->buffer_size;
  146
++    (BYTE*)p_buffer += iCopied;
  147
++    dvdcss->buffer_size = 0;
  148
++    
  149
++    // if remaining size is bigger >= DISC_CACHE_SIZE, don't cache it. Just read
  150
++    if (iRemaining >= DISC_CACHE_SIZE)
  151
++    {
  152
++      if (!ReadFile((HANDLE)dvdcss->i_fd, p_buffer, iRemaining, (LPDWORD)&i_bytes, NULL))
  153
++      {
  154
++        dvdcss->i_pos = -1;
  155
++        return -1;
  156
++      }
  157
++      dvdcss->i_pos += (i_bytes + iCopied) / DVDCSS_BLOCK_SIZE;
  158
++      return (i_bytes + iCopied) / DVDCSS_BLOCK_SIZE;
  159
++    }
  160
++    else
  161
++    {
  162
++      // read a chunk into the cache and copy the needed bytes into p_buffer
  163
++      if (!ReadFile((HANDLE)dvdcss->i_fd, dvdcss->buffer, DISC_CACHE_SIZE, &dvdcss->buffer_size, NULL))
  164
++      {
  165
++         // read error, maybe we tried to read to much. Try again but now without cache
  166
++        if (!ReadFile((HANDLE)dvdcss->i_fd, p_buffer, iRemaining, (LPDWORD)&i_bytes, NULL))
  167
++        {
  168
++          dvdcss->i_pos = -1;
  169
++          return -1;
  170
++        }
  171
++        dvdcss->i_pos += (i_bytes + iCopied) / DVDCSS_BLOCK_SIZE;
  172
++        return (i_bytes + iCopied) / DVDCSS_BLOCK_SIZE;
  173
++      }
  174
++      // copy bytes into the buffer
  175
++      memcpy(p_buffer, dvdcss->buffer, iRemaining);
  176
++      dvdcss->buffer_size -= iRemaining;
  177
++      dvdcss->i_pos += (iRemaining + iCopied) / DVDCSS_BLOCK_SIZE;
  178
++      return (iRemaining + iCopied) / DVDCSS_BLOCK_SIZE;
  179
++    } 
  180
++  }
  181
++  else
  182
++  {
  183
++    // we have enough data in our cache, just copy it
  184
++    memcpy(p_buffer, dvdcss->buffer + (DISC_CACHE_SIZE - dvdcss->buffer_size), i_blocks * DVDCSS_BLOCK_SIZE);
  185
++    dvdcss->buffer_size -= i_blocks * DVDCSS_BLOCK_SIZE;
  186
++    dvdcss->i_pos += i_blocks;
  187
++    return i_blocks;
  188
++  }
  189
++
  190
++  dvdcss->i_pos = -1;
  191
++  return -1;
  192
++  
  193
++#else // WITH_CACHE
  194
++
  195
+     if( !ReadFile( (HANDLE) dvdcss->i_fd, p_buffer,
  196
+               i_blocks * DVDCSS_BLOCK_SIZE,
  197
+               (LPDWORD)&i_bytes, NULL ) )
  198
+@@ -837,6 +949,7 @@
  199
+ 
  200
+     dvdcss->i_pos += i_bytes / DVDCSS_BLOCK_SIZE;
  201
+     return i_bytes / DVDCSS_BLOCK_SIZE;
  202
++#endif // WITH_CACHE
  203
+ }
  204
+ 
  205
+ static int aspi_read ( dvdcss_t dvdcss, void *p_buffer, int i_blocks )
  206
+diff -uwr libdvdcss-1.2.12/src/ioctl.c xbmc/lib/libdvd/libdvdcss/src/ioctl.c
  207
+--- libdvdcss-1.2.12/src/ioctl.c	2012-03-12 00:07:48 +0100
  208
++++ xbmc/lib/libdvd/libdvdcss/src/ioctl.c	2013-02-07 14:42:34 +0100
  209
+@@ -373,6 +373,37 @@
  210
+ 
  211
+     memcpy( p_key, dvdbs.discKeyStructures, DVD_DISCKEY_SIZE );
  212
+ 
  213
++#elif defined( _XBOX )
  214
++    // the next piece of code will read the disc key on the xbox for all drives (samsung included)
  215
++    // but for some reason it takes 15 - 20 seconds longer to load a dvd if mplayer has the dvd key
  216
++    // so we let this part fail and will only use the modified ioctl_ReadTitleKey code.
  217
++    // don't get this delay, and i'm surprised it worked as the ReadTitleKey function didn't work.
  218
++
  219
++    DWORD dwBytesRead;
  220
++	DVD_READ_STRUCTURE st;
  221
++    char buffer[DVD_DISCKEY_SIZE];
  222
++    
  223
++    memset( &buffer, 0, sizeof( buffer ) );
  224
++	memset( &st, 0, sizeof( st ) );
  225
++
  226
++    st.BlockByteOffset.QuadPart = 0;
  227
++    st.SessionId = *pi_agid;
  228
++    st.Format = DvdDiskKeyDescriptor;
  229
++
  230
++    i_ret = DeviceIoControl((HANDLE) i_fd, IOCTL_DVD_READ_STRUCTURE, &st,
  231
++				sizeof(st), buffer, DVD_DISCKEY_SIZE, &dwBytesRead, NULL ) ? 0 : -1;
  232
++
  233
++	if (i_ret < 0)	// didn't work
  234
++	{
  235
++		printf("Failed to read disc key\n");
  236
++		return i_ret;
  237
++	}
  238
++    
  239
++	// copy the returned key into our key buffer
  240
++	int i;
  241
++    for (i = 0; i < DVD_DISCKEY_SIZE; i++)
  242
++		p_key[i] = buffer[i+4];
  243
++
  244
+ #elif defined( WIN32 )
  245
+     if( WIN2K ) /* NT/2k/XP */
  246
+     {
  247
+@@ -541,6 +572,25 @@
  248
+ 
  249
+     memcpy( p_key, dvdbs.titleKeyValue, DVD_KEY_SIZE );
  250
+ 
  251
++#elif defined( _XBOX ) && 0 //Faulty wrong key returned, original for WIN32 works thou so use it instead
  252
++    DWORD dwBytesRead;
  253
++    DVD_READ_STRUCTURE st;
  254
++    char buffer[2048+4];
  255
++
  256
++    memset( &buffer, 0, sizeof( buffer ) );
  257
++		
  258
++    st.BlockByteOffset.QuadPart = (LONGLONG) i_pos * 2048 /*DVDCSS_BLOCK_SIZE*/;
  259
++    st.SessionId = *pi_agid;
  260
++    st.Format = DvdDiskKeyDescriptor;
  261
++		
  262
++    i_ret = DeviceIoControl((HANDLE) i_fd, IOCTL_DVD_READ_STRUCTURE, &st, sizeof(st), buffer, 2048+4, &dwBytesRead, NULL ) ? 0 : -1;
  263
++    if( i_ret < 0 )
  264
++    {
  265
++      return i_ret;
  266
++    }
  267
++
  268
++    memcpy( p_key, &(buffer[4]), 2048);
  269
++
  270
+ #elif defined( WIN32 )
  271
+     if( WIN2K ) /* NT/2k/XP */
  272
+     {
  273
+@@ -693,8 +743,13 @@
  274
+         ULONG id;
  275
+         DWORD tmp;
  276
+ 
  277
++#if defined( _XBOX)
  278
++        i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_START_SESSION,
  279
++						NULL, 0, &id, sizeof(id), &tmp, NULL ) ? 0 : -1;
  280
++#else
  281
+         i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_START_SESSION,
  282
+                         &tmp, 4, &id, sizeof( id ), &tmp, NULL ) ? 0 : -1;
  283
++#endif
  284
+ 
  285
+         *pi_agid = id;
  286
+     }
  287
+@@ -1336,8 +1391,13 @@
  288
+ 
  289
+         memcpy( key->KeyData, p_challenge, DVD_CHALLENGE_SIZE );
  290
+ 
  291
++#if defined(_XBOX)
  292
++        i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key,
  293
++                 key->KeyLength, NULL, 0, &tmp, NULL ) ? 0 : -1;
  294
++#else
  295
+         i_ret = DeviceIoControl( (HANDLE) i_fd, IOCTL_DVD_SEND_KEY, key,
  296
+                  key->KeyLength, key, key->KeyLength, &tmp, NULL ) ? 0 : -1;
  297
++#endif
  298
+     }
  299
+     else
  300
+     {
  301
+diff -uwr libdvdcss-1.2.12/src/ioctl.h xbmc/lib/libdvd/libdvdcss/src/ioctl.h
  302
+--- libdvdcss-1.2.12/src/ioctl.h	2012-03-12 00:07:48 +0100
  303
++++ xbmc/lib/libdvd/libdvdcss/src/ioctl.h	2013-02-07 14:42:34 +0100
  304
+@@ -324,7 +324,11 @@
  305
+ typedef DWORD (CALLBACK *GETASPI32SUPPORTINFO)(VOID);
  306
+ typedef DWORD (CALLBACK *SENDASPI32COMMAND)(LPVOID);
  307
+ 
  308
++#if defined(_XBOX)
  309
++#define WIN2K	1
  310
++#else
  311
+ #define WIN2K               ( GetVersion() < 0x80000000 )
  312
++#endif	// _XBOX
  313
+ #define ASPI_HAID           0
  314
+ #define ASPI_TARGET         0
  315
+ #define DTYPE_CDROM         0x05
  316
+diff -uwr libdvdcss-1.2.12/src/libdvdcss.c xbmc/lib/libdvd/libdvdcss/src/libdvdcss.c
  317
+--- libdvdcss-1.2.12/src/libdvdcss.c	2012-03-12 00:07:48 +0100
  318
++++ xbmc/lib/libdvd/libdvdcss/src/libdvdcss.c	2013-02-07 14:42:34 +0100
  319
+@@ -195,6 +195,10 @@
  320
+     dvdcss->b_debug = 0;
  321
+     dvdcss->b_errors = 0;
  322
+ 
  323
++#ifdef WITH_CACHE
  324
++    dvdcss->buffer_size = 0;
  325
++#endif
  326
++
  327
+     /*
  328
+      *  Find verbosity from DVDCSS_VERBOSE environment variable
  329
+      */
  330
+@@ -388,7 +392,7 @@
  331
+             dvdcss->b_scrambled = i_ret;
  332
+         }
  333
+     }
  334
+-
  335
++    /* if wo don't have b_ioctls, we don't have a disk key, make sure area is nulled */
  336
+     memset( dvdcss->css.p_disc_key, 0, KEY_SIZE );
  337
+     /* If disc is CSS protected and the ioctls work, authenticate the drive */
  338
+     if( dvdcss->b_scrambled && dvdcss->b_ioctls )
  339
+@@ -533,8 +537,26 @@
  340
+             goto nocache;
  341
+         }
  342
+ 
  343
++#ifdef _XBOX
  344
++        //due to xbox file system having a limited length on folders/files, 
  345
++        //make separate folder for disk name first
  346
++        if(psz_title[0] == '\0')
  347
++          strcat(psz_title, "NONAME");
  348
++
  349
++        i += sprintf( dvdcss->psz_cachefile + i, "/%s", psz_title);
  350
++        
  351
++        i_ret = mkdir( dvdcss->psz_cachefile );
  352
++        if( i_ret < 0 && errno != EEXIST )
  353
++        {
  354
++            print_error( dvdcss, "failed creating cache titledirectory" );
  355
++            dvdcss->psz_cachefile[0] = '\0';
  356
++            goto nocache;
  357
++        }
  358
++        i += sprintf( dvdcss->psz_cachefile + i, "/%s%s", psz_serial, psz_key );
  359
++#else
  360
+         i += sprintf( dvdcss->psz_cachefile + i, "/%s-%s%s", psz_title,
  361
+                       psz_serial, psz_key );
  362
++#endif
  363
+ #if !defined( WIN32 ) || defined( SYS_CYGWIN )
  364
+         i_ret = mkdir( dvdcss->psz_cachefile, 0755 );
  365
+ #else
766  lib/libdvd/patches/libdvdnav.diff
... ...
@@ -0,0 +1,766 @@
  1
+diff -uwr libdvdnav-4.2.0/Makefile xbmc/lib/libdvd/libdvdnav/Makefile
  2
+--- libdvdnav-4.2.0/Makefile	2008-12-30 15:48:46 +0100
  3
++++ xbmc/lib/libdvd/libdvdnav/Makefile	2013-02-07 14:42:34 +0100
  4
+@@ -112,7 +112,7 @@
  5
+ # Clean targets
  6
+ 
  7
+ clean:
  8
+-	rm -rf  *~ $(.OBJDIR)/* version.h
  9
++	rm -rf  *~ $(.OBJDIR)/* 
  10
+ 
  11
+ pcedit = sed \
  12
+ 	-e 's,@prefix@,$(PREFIX),' \
  13
+diff -uwr libdvdnav-4.2.0/src/dvdnav/dvdnav.h xbmc/lib/libdvd/libdvdnav/src/dvdnav/dvdnav.h
  14
+--- libdvdnav-4.2.0/src/dvdnav/dvdnav.h	2011-02-26 21:32:32 +0100
  15
++++ xbmc/lib/libdvd/libdvdnav/src/dvdnav/dvdnav.h	2013-02-07 14:42:34 +0100
  16
+@@ -695,6 +695,42 @@
  17
+  */
  18
+ int8_t dvdnav_is_domain_vts(dvdnav_t *self);
  19
+ 
  20
++////////// RATDVD stuff ///////////////
  21
++
  22
++/*
  23
++ * Get the number of audio streams.
  24
++ */
  25
++int32_t dvdnav_get_audio_stream_count(dvdnav_t * self);
  26
++
  27
++/*
  28
++ * Get the number of subpicture streams.
  29
++ */
  30
++int32_t dvdnav_get_subpicture_stream_count(dvdnav_t * self);
  31
++
  32
++/*
  33
++ * Get attributes of the current audio stream.
  34
++ */
  35
++dvdnav_status_t dvdnav_get_audio_info(dvdnav_t * self, int32_t streamid, audio_attr_t* audio_attributes);
  36
++
  37
++/*
  38
++ * Get attributes of the current subpicture stream.
  39
++ */
  40
++dvdnav_status_t dvdnav_get_stitle_info(dvdnav_t * self, int32_t streamid, subp_attr_t* stitle_attributes);
  41
++
  42
++/*
  43
++ * Get information about the current video stream
  44
++ */
  45
++dvdnav_status_t dvdnav_get_video_info(dvdnav_t * self, video_attr_t* video_attributes);
  46
++
  47
++/*
  48
++ * Select the audio stream to be played
  49
++ */
  50
++dvdnav_status_t dvdnav_audio_change(dvdnav_t *self, int32_t audio);
  51
++
  52
++/*
  53
++ * Select the spu stream to be displayed
  54
++ */
  55
++dvdnav_status_t dvdnav_subpicture_change(dvdnav_t *self, int32_t subpicture);
  56
+ 
  57
+ #ifdef __cplusplus
  58
+ }
  59
+diff -uwr libdvdnav-4.2.0/src/dvdnav.c xbmc/lib/libdvd/libdvdnav/src/dvdnav.c
  60
+--- libdvdnav-4.2.0/src/dvdnav.c	2010-07-31 01:34:12 +0200
  61
++++ xbmc/lib/libdvd/libdvdnav/src/dvdnav.c	2013-02-07 14:42:34 +0100
  62
+@@ -337,7 +337,9 @@
  63
+   }
  64
+ #endif
  65
+ 
  66
+-  if(num_angle != 0) {
  67
++  /* only use ILVU information if we are at the last vobunit in ILVU */
  68
++  /* otherwise we will miss nav packets from vobunits inbetween */
  69
++  if(num_angle != 0 && (nav_dsi->sml_pbi.category & 0x5000) == 0x5000 ) {
  70
+ 
  71
+     if((next = nav_pci->nsml_agli.nsml_agl_dsta[angle-1]) != 0) {
  72
+       if((next & 0x3fffffff) != 0) {
  73
+@@ -466,6 +468,10 @@
  74
+ 	/* Decode nav into pci and dsi. Then get next VOBU info. */
  75
+ 	if(!dvdnav_decode_packet(this, *buf, &this->dsi, &this->pci)) {
  76
+ 	  printerr("Expected NAV packet but none found.");
  77
++#ifdef _XBMC
  78
++    /* skip this cell as we won't recover from this*/
  79
++    vm_get_next_cell(this->vm);
  80
++#endif
  81
+ 	  pthread_mutex_unlock(&this->vm_lock);
  82
+ 	  return DVDNAV_STATUS_ERR;
  83
+ 	}
  84
+@@ -618,9 +624,17 @@
  85
+     cell_event->pgc_length = dvdnav_convert_time(&state->pgc->playback_time);
  86
+ 
  87
+     cell_event->cell_start = 0;
  88
+-    for (i = 1; i < state->cellN; i++)
  89
++    for (i = 0; i < state->cellN; i++)
  90
++    {
  91
++      /* only count the first angle cell */
  92
++      if(  state->pgc->cell_playback[i].block_type == BLOCK_TYPE_ANGLE_BLOCK 
  93
++        && state->pgc->cell_playback[i].block_mode != BLOCK_MODE_FIRST_CELL )
  94
++        continue;
  95
++
  96
+       cell_event->cell_start +=
  97
+-        dvdnav_convert_time(&state->pgc->cell_playback[i - 1].playback_time);
  98
++          dvdnav_convert_time(&state->pgc->cell_playback[i].playback_time);
  99
++    }    
  100
++    cell_event->cell_start-= dvdnav_convert_time(&state->pgc->cell_playback[state->cellN-1].playback_time);
  101
+ 
  102
+     cell_event->pg_start = 0;
  103
+     for (i = 1; i < state->pgc->program_map[state->pgN-1]; i++)
  104
+@@ -769,6 +783,10 @@
  105
+     /* Decode nav into pci and dsi. Then get next VOBU info. */
  106
+     if(!dvdnav_decode_packet(this, *buf, &this->dsi, &this->pci)) {
  107
+       printerr("Expected NAV packet but none found.");
  108
++#ifdef _XBMC
  109
++      /* skip this cell as we won't recover from this */
  110
++      vm_get_next_cell(this->vm);
  111
++#endif
  112
+       pthread_mutex_unlock(&this->vm_lock);
  113
+       return DVDNAV_STATUS_ERR;
  114
+     }
  115
+@@ -1166,6 +1184,10 @@
  116
+ 
  117
+   ops.ops_int = 0;
  118
+ 
  119
++  if(!this) {
  120
++    printerr("Passed a NULL pointer.");
  121
++    return ops.ops_struct;
  122
++  }
  123
+   if(!this->started) {
  124
+     printerr("Virtual DVD machine not started.");
  125
+     return ops.ops_struct;
  126
+@@ -1180,3 +1202,263 @@
  127
+ 
  128
+   return ops.ops_struct;
  129
+ }
  130
++
  131
++#ifdef _XBMC
  132
++
  133
++vm_t* dvdnav_get_vm(dvdnav_t *this) {
  134
++  if(!this) return 0;
  135
++  return this->vm;
  136
++}
  137
++
  138
++int dvdnav_get_nr_of_subtitle_streams(dvdnav_t *this)
  139
++{
  140
++  int i;
  141
++  int count = 0;
  142
++  
  143
++  if (this && this->vm && this->vm->state.pgc)
  144
++  {
  145
++    for (i = 0; i < 32; i++)
  146
++    {
  147
++      if (this->vm->state.pgc->subp_control[i] & (1<<31)) count++;
  148
++    }
  149
++  }
  150
++  return count;
  151
++  
  152
++  /* old code
  153
++  if(!this || !this->vm || !this->vm->vtsi || !this->vm->vtsi->vtsi_mat) return 0;
  154
++  
  155
++  switch ((this->vm->state).domain) {
  156
++  case VTS_DOMAIN:
  157
++    return this->vm->vtsi->vtsi_mat->nr_of_vts_subp_streams;
  158
++  case VTSM_DOMAIN:
  159
++    return this->vm->vtsi->vtsi_mat->nr_of_vtsm_subp_streams; // 1
  160
++  case VMGM_DOMAIN:
  161
++  case FP_DOMAIN:
  162
++    return this->vm->vmgi->vmgi_mat->nr_of_vmgm_subp_streams; // 1
  163
++  }
  164
++
  165
++  return 0;
  166
++  */
  167
++}
  168
++
  169
++int dvdnav_get_nr_of_audio_streams(dvdnav_t *this)
  170
++{
  171
++  int i;
  172
++  int count = 0;
  173
++  
  174
++  if (this && this->vm && this->vm->state.pgc)
  175
++  {
  176
++    for (i = 0; i < 8; i++)
  177
++    {
  178
++      if (this->vm->state.pgc->audio_control[i] & (1<<15)) count++;
  179
++    }
  180
++  }
  181
++  return count;
  182
++  
  183
++  /* old code
  184
++  if(!this || !this->vm || !this->vm->vtsi || !this->vm->vtsi->vtsi_mat) return 0;
  185
++   
  186
++  switch ((this->vm->state).domain) {
  187
++  case VTS_DOMAIN:
  188
++    return this->vm->vtsi->vtsi_mat->nr_of_vts_audio_streams;
  189
++  case VTSM_DOMAIN:
  190
++    return this->vm->vtsi->vtsi_mat->nr_of_vtsm_audio_streams; // 1
  191
++  case VMGM_DOMAIN:
  192
++  case FP_DOMAIN:
  193
++    return this->vm->vmgi->vmgi_mat->nr_of_vmgm_audio_streams; // 1
  194
++  }
  195
++