PageRenderTime 49ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 1ms

/packages/multimedia/libbluray/patches/libbluray-02-add-mvc-support.patch

http://github.com/OpenELEC/OpenELEC.tv
Patch | 6409 lines | 6292 code | 117 blank | 0 comment | 0 complexity | 55a24966b92c556ea67aecad7826064c MD5 | raw file
Possible License(s): CC0-1.0
  1. diff --git a/Makefile.am b/Makefile.am
  2. index 300deec..5c77a05 100644
  3. --- a/Makefile.am
  4. +++ b/Makefile.am
  5. @@ -186,10 +186,12 @@ endif
  6. if USING_BDJAVA
  7. +if USING_BDJAVA_BUILD_JAR
  8. jardir=$(datadir)/java/
  9. jar_DATA=$(top_builddir)/.libs/libbluray-$(BDJ_TYPE)-$(VERSION).jar
  10. $(top_builddir)/.libs/libbluray-$(BDJ_TYPE)-$(VERSION).jar: all-local
  11. +endif
  12. libbluray_la_SOURCES += \
  13. src/libbluray/bdj/bdj.h \
  14. @@ -214,6 +216,7 @@ libbluray_la_SOURCES += \
  15. AM_CFLAGS += $(BDJAVA_CFLAGS)
  16. +if USING_BDJAVA_BUILD_JAR
  17. all-local:
  18. ant -f $(top_srcdir)/src/libbluray/bdj/build.xml \
  19. -Dbuild='$(abs_builddir)/src/libbluray/bdj/build' \
  20. @@ -229,6 +232,7 @@ clean-local:
  21. -Dversion='$(BDJ_TYPE)-$(VERSION)' \
  22. clean
  23. endif
  24. +endif
  25. pkgconfigdir = $(libdir)/pkgconfig
  26. pkgconfig_DATA = src/libbluray.pc
  27. @@ -266,20 +270,20 @@ bd_info_LDADD = libbluray.la
  28. bdsplice_SOURCES = src/examples/bdsplice.c
  29. bdsplice_LDADD = libbluray.la
  30. -bdj_test_SOURCES = src/examples/bdj_test.c
  31. +bdj_test_SOURCES = src/devtools/bdj_test.c
  32. bdj_test_LDADD = libbluray.la
  33. -bdjo_dump_SOURCES = src/examples/bdjo_dump.c
  34. +bdjo_dump_SOURCES = src/devtools/bdjo_dump.c
  35. bdjo_dump_LDADD = libbluray.la
  36. clpi_dump_CFLAGS = $(AM_CFLAGS)
  37. clpi_dump_SOURCES = \
  38. - src/examples/clpi_dump.c \
  39. - src/examples/util.c \
  40. - src/examples/util.h
  41. + src/devtools/clpi_dump.c \
  42. + src/devtools/util.c \
  43. + src/devtools/util.h
  44. clpi_dump_LDADD = libbluray.la
  45. -hdmv_test_SOURCES = src/examples/hdmv_test.c
  46. +hdmv_test_SOURCES = src/devtools/hdmv_test.c
  47. hdmv_test_LDADD = libbluray.la
  48. index_dump_SOURCES = src/examples/index_dump.c
  49. @@ -292,15 +296,15 @@ list_titles_SOURCES = src/examples/list_titles.c
  50. list_titles_LDADD = libbluray.la
  51. mobj_dump_CFLAGS = $(AM_CFLAGS)
  52. -mobj_dump_SOURCES = src/examples/mobj_dump.c \
  53. +mobj_dump_SOURCES = src/devtools/mobj_dump.c \
  54. src/libbluray/hdmv/mobj_print.c
  55. mobj_dump_LDADD = libbluray.la
  56. mpls_dump_CFLAGS = $(AM_CFLAGS)
  57. mpls_dump_SOURCES = \
  58. - src/examples/mpls_dump.c \
  59. - src/examples/util.c \
  60. - src/examples/util.h
  61. + src/devtools/mpls_dump.c \
  62. + src/devtools/util.c \
  63. + src/devtools/util.h
  64. mpls_dump_LDADD = libbluray.la
  65. sound_dump_SOURCES = src/examples/sound_dump.c
  66. diff --git a/config.h b/config.h
  67. new file mode 100644
  68. index 0000000..6764704
  69. --- /dev/null
  70. +++ b/config.h
  71. @@ -0,0 +1,157 @@
  72. +/* config.h. Generated from config.h.in by configure. */
  73. +/* config.h.in. Generated from configure.ac by autoheader. */
  74. +
  75. +/* Define to 1 if libudfread is to be used for disc image access */
  76. +/* #undef ENABLE_UDF */
  77. +
  78. +/* Define to 1 if using libbluray J2ME stack */
  79. +/* #undef HAVE_BDJ_J2ME */
  80. +
  81. +/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
  82. + */
  83. +/* #undef HAVE_DIRENT_H */
  84. +
  85. +/* Define to 1 if you have the <dlfcn.h> header file. */
  86. +/* #undef HAVE_DLFCN_H */
  87. +
  88. +/* Define to 1 if you have the <errno.h> header file. */
  89. +#define HAVE_ERRNO_H 1
  90. +
  91. +/* Define to 1 if you have the <fcntl.h> header file. */
  92. +/* #undef HAVE_FCNTL_H */
  93. +
  94. +/* Define this if you have fontconfig library */
  95. +/* #undef HAVE_FONTCONFIG */
  96. +
  97. +/* Define this if you have FreeType2 library */
  98. +/* #undef HAVE_FT2 */
  99. +
  100. +/* Define to 1 if you have the <inttypes.h> header file. */
  101. +#define HAVE_INTTYPES_H 1
  102. +
  103. +/* Define to 1 if you have the <jni.h> header file. */
  104. +/* #undef HAVE_JNI_H */
  105. +
  106. +/* Define to 1 if you have the <libgen.h> header file. */
  107. +#define HAVE_LIBGEN_H 1
  108. +
  109. +/* Define to 1 if libxml2 is to be used for metadata parsing */
  110. +/* #undef HAVE_LIBXML2 */
  111. +
  112. +/* Define to 1 if you have the <linux/cdrom.h> header file. */
  113. +/* #undef HAVE_LINUX_CDROM_H */
  114. +
  115. +/* Define to 1 if you have the <malloc.h> header file. */
  116. +#define HAVE_MALLOC_H 1
  117. +
  118. +/* Define to 1 if you have the <memory.h> header file. */
  119. +#define HAVE_MEMORY_H 1
  120. +
  121. +/* Define to 1 if you have the <mntent.h> header file. */
  122. +/* #undef HAVE_MNTENT_H */
  123. +
  124. +/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
  125. +/* #undef HAVE_NDIR_H */
  126. +
  127. +/* Define to 1 if you have the <pthread.h> header file. */
  128. +/* #undef HAVE_PTHREAD_H */
  129. +
  130. +/* Define to 1 if you have the <stdarg.h> header file. */
  131. +#define HAVE_STDARG_H 1
  132. +
  133. +/* Define to 1 if you have the <stdint.h> header file. */
  134. +#define HAVE_STDINT_H 1
  135. +
  136. +/* Define to 1 if you have the <stdlib.h> header file. */
  137. +#define HAVE_STDLIB_H 1
  138. +
  139. +/* Define to 1 if you have the <strings.h> header file. */
  140. +/* #undef HAVE_STRINGS_H */
  141. +
  142. +/* Define to 1 if you have the <string.h> header file. */
  143. +#define HAVE_STRING_H 1
  144. +
  145. +/* Define to 1 if `d_type' is a member of `struct dirent'. */
  146. +/* #undef HAVE_STRUCT_DIRENT_D_TYPE */
  147. +
  148. +/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
  149. + */
  150. +/* #undef HAVE_SYS_DIR_H */
  151. +
  152. +/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
  153. + */
  154. +/* #undef HAVE_SYS_NDIR_H */
  155. +
  156. +/* Define to 1 if you have the <sys/stat.h> header file. */
  157. +#define HAVE_SYS_STAT_H 1
  158. +
  159. +/* Define to 1 if you have the <sys/time.h> header file. */
  160. +#define HAVE_SYS_TIME_H 1
  161. +
  162. +/* Define to 1 if you have the <sys/types.h> header file. */
  163. +#define HAVE_SYS_TYPES_H 1
  164. +
  165. +/* Define to 1 if you have the <time.h> header file. */
  166. +#define HAVE_TIME_H 1
  167. +
  168. +/* Define to 1 if you have the <unistd.h> header file. */
  169. +/* #undef HAVE_UNISTD_H */
  170. +
  171. +/* "Defines the architecture of the java vm." */
  172. +/* #undef JAVA_ARCH */
  173. +
  174. +/* "" */
  175. +/* #undef JDK_HOME */
  176. +
  177. +/* Define to the sub-directory where libtool stores uninstalled libraries. */
  178. +#define LT_OBJDIR ".libs/"
  179. +
  180. +/* Name of package */
  181. +#define PACKAGE "libbluray"
  182. +
  183. +/* Define to the address where bug reports for this package should be sent. */
  184. +#define PACKAGE_BUGREPORT "http://www.videolan.org/developers/libbluray.html"
  185. +
  186. +/* Define to the full name of this package. */
  187. +#define PACKAGE_NAME "libbluray"
  188. +
  189. +/* Define to the full name and version of this package. */
  190. +#define PACKAGE_STRING "libbluray 0.9.2"
  191. +
  192. +/* Define to the one symbol short name of this package. */
  193. +#define PACKAGE_TARNAME "libbluray"
  194. +
  195. +/* Define to the home page for this package. */
  196. +#define PACKAGE_URL ""
  197. +
  198. +/* Define to the version of this package. */
  199. +#define PACKAGE_VERSION "0.9.2"
  200. +
  201. +/* Define as the return type of signal handlers (`int' or `void'). */
  202. +#define RETSIGTYPE void
  203. +
  204. +/* Define to 1 if you have the ANSI C header files. */
  205. +#define STDC_HEADERS 1
  206. +
  207. +/* "Define to 1 if using BD-Java" */
  208. +/* #undef USING_BDJAVA */
  209. +
  210. +/* Version number of package */
  211. +#define VERSION "0.9.2"
  212. +
  213. +/* Enable large inode numbers on Mac OS X 10.5. */
  214. +#ifndef _DARWIN_USE_64_BIT_INODE
  215. +# define _DARWIN_USE_64_BIT_INODE 1
  216. +#endif
  217. +
  218. +/* Number of bits in a file offset, on hosts where this is settable. */
  219. +#define _FILE_OFFSET_BITS 64
  220. +
  221. +/* Define for large files, on AIX-style hosts. */
  222. +/* #undef _LARGE_FILES */
  223. +
  224. +/* Define to '0x0501' for IE 5.01. */
  225. +#define _WIN32_IE 0x0501
  226. +
  227. +/* Define to '0x0502' for Windows XP SP2 APIs. */
  228. +#define _WIN32_WINNT 0x0502
  229. diff --git a/configure.ac b/configure.ac
  230. index e0da375..ed08c96 100644
  231. --- a/configure.ac
  232. +++ b/configure.ac
  233. @@ -87,7 +87,15 @@ AC_ARG_ENABLE([bdjava],
  234. [use_bdjava=yes])
  235. AC_ARG_ENABLE([udf],
  236. - [AS_HELP_STRING([--enable-udf], [enable UDF support @<:@default=disabled@:>@])])
  237. + [AS_HELP_STRING([--disable-udf], [disable UDF support @<:@default=enabled@:>@])],
  238. + [enable_udf=$enableval],
  239. + [enable_udf=yes])
  240. +
  241. +AC_ARG_ENABLE([bdjava-jar],
  242. + [AS_HELP_STRING([--disable-bdjava-jar],
  243. + [disable building of BD-Java JAR file @<:@default=enabled@:>@])],
  244. + [use_bdjava_jar=$enableval],
  245. + [use_bdjava_jar=yes])
  246. AC_ARG_WITH([libxml2],
  247. [AS_HELP_STRING([--without-libxml2], [build without libxml2 support @<:@default=with@:>@])])
  248. @@ -224,7 +232,7 @@ if [[ $use_bdjava = "yes" ]]; then
  249. ])
  250. AC_CHECK_PROG(HAVE_ANT, [ant], yes, no)
  251. - if test "x$HAVE_ANT" = "xno"; then
  252. + if test "x$use_bdjava_jar" = "xyes" && test "x$HAVE_ANT" = "xno"; then
  253. AC_MSG_ERROR([BD-J requires ANT, but ant was not found. Please install it.])
  254. fi
  255. @@ -233,6 +241,7 @@ if [[ $use_bdjava = "yes" ]]; then
  256. AC_DEFINE_UNQUOTED([JDK_HOME], ["$JDK_HOME"], [""])
  257. fi
  258. AM_CONDITIONAL([USING_BDJAVA], [ test $use_bdjava = "yes" ])
  259. +AM_CONDITIONAL([USING_BDJAVA_BUILD_JAR], [ test $use_bdjava_jar = "yes" ])
  260. dnl BD-J type
  261. if test "$BDJ_TYPE" = "j2me"; then
  262. @@ -292,6 +301,7 @@ echo " --------"
  263. echo " BD-J support: $use_bdjava"
  264. if [[ $use_bdjava = "yes" ]]; then
  265. echo " BD-J type: $BDJ_TYPE"
  266. +echo " build JAR: $use_bdjava_jar"
  267. if test x"$BDJ_BOOTCLASSPATH" != x""; then
  268. echo " BD-J bootclasspath: $BDJ_BOOTCLASSPATH"
  269. fi
  270. diff --git a/includes/inttypes.h b/includes/inttypes.h
  271. new file mode 100644
  272. index 0000000..ead903f
  273. --- /dev/null
  274. +++ b/includes/inttypes.h
  275. @@ -0,0 +1,305 @@
  276. +// ISO C9x compliant inttypes.h for Microsoft Visual Studio
  277. +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
  278. +//
  279. +// Copyright (c) 2006 Alexander Chemeris
  280. +//
  281. +// Redistribution and use in source and binary forms, with or without
  282. +// modification, are permitted provided that the following conditions are met:
  283. +//
  284. +// 1. Redistributions of source code must retain the above copyright notice,
  285. +// this list of conditions and the following disclaimer.
  286. +//
  287. +// 2. Redistributions in binary form must reproduce the above copyright
  288. +// notice, this list of conditions and the following disclaimer in the
  289. +// documentation and/or other materials provided with the distribution.
  290. +//
  291. +// 3. The name of the author may be used to endorse or promote products
  292. +// derived from this software without specific prior written permission.
  293. +//
  294. +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  295. +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  296. +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  297. +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  298. +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  299. +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  300. +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  301. +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  302. +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  303. +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  304. +//
  305. +///////////////////////////////////////////////////////////////////////////////
  306. +
  307. +#ifndef _MSC_VER // [
  308. +#error "Use this header only with Microsoft Visual C++ compilers!"
  309. +#endif // _MSC_VER ]
  310. +
  311. +#ifndef _MSC_INTTYPES_H_ // [
  312. +#define _MSC_INTTYPES_H_
  313. +
  314. +#if _MSC_VER > 1000
  315. +#pragma once
  316. +#endif
  317. +
  318. +#include "stdint.h"
  319. +
  320. +// 7.8 Format conversion of integer types
  321. +
  322. +typedef struct {
  323. + intmax_t quot;
  324. + intmax_t rem;
  325. +} imaxdiv_t;
  326. +
  327. +// 7.8.1 Macros for format specifiers
  328. +
  329. +#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) // [ See footnote 185 at page 198
  330. +
  331. +// The fprintf macros for signed integers are:
  332. +#define PRId8 "d"
  333. +#define PRIi8 "i"
  334. +#define PRIdLEAST8 "d"
  335. +#define PRIiLEAST8 "i"
  336. +#define PRIdFAST8 "d"
  337. +#define PRIiFAST8 "i"
  338. +
  339. +#define PRId16 "hd"
  340. +#define PRIi16 "hi"
  341. +#define PRIdLEAST16 "hd"
  342. +#define PRIiLEAST16 "hi"
  343. +#define PRIdFAST16 "hd"
  344. +#define PRIiFAST16 "hi"
  345. +
  346. +#define PRId32 "I32d"
  347. +#define PRIi32 "I32i"
  348. +#define PRIdLEAST32 "I32d"
  349. +#define PRIiLEAST32 "I32i"
  350. +#define PRIdFAST32 "I32d"
  351. +#define PRIiFAST32 "I32i"
  352. +
  353. +#define PRId64 "I64d"
  354. +#define PRIi64 "I64i"
  355. +#define PRIdLEAST64 "I64d"
  356. +#define PRIiLEAST64 "I64i"
  357. +#define PRIdFAST64 "I64d"
  358. +#define PRIiFAST64 "I64i"
  359. +
  360. +#define PRIdMAX "I64d"
  361. +#define PRIiMAX "I64i"
  362. +
  363. +#define PRIdPTR "Id"
  364. +#define PRIiPTR "Ii"
  365. +
  366. +// The fprintf macros for unsigned integers are:
  367. +#define PRIo8 "o"
  368. +#define PRIu8 "u"
  369. +#define PRIx8 "x"
  370. +#define PRIX8 "X"
  371. +#define PRIoLEAST8 "o"
  372. +#define PRIuLEAST8 "u"
  373. +#define PRIxLEAST8 "x"
  374. +#define PRIXLEAST8 "X"
  375. +#define PRIoFAST8 "o"
  376. +#define PRIuFAST8 "u"
  377. +#define PRIxFAST8 "x"
  378. +#define PRIXFAST8 "X"
  379. +
  380. +#define PRIo16 "ho"
  381. +#define PRIu16 "hu"
  382. +#define PRIx16 "hx"
  383. +#define PRIX16 "hX"
  384. +#define PRIoLEAST16 "ho"
  385. +#define PRIuLEAST16 "hu"
  386. +#define PRIxLEAST16 "hx"
  387. +#define PRIXLEAST16 "hX"
  388. +#define PRIoFAST16 "ho"
  389. +#define PRIuFAST16 "hu"
  390. +#define PRIxFAST16 "hx"
  391. +#define PRIXFAST16 "hX"
  392. +
  393. +#define PRIo32 "I32o"
  394. +#define PRIu32 "I32u"
  395. +#define PRIx32 "I32x"
  396. +#define PRIX32 "I32X"
  397. +#define PRIoLEAST32 "I32o"
  398. +#define PRIuLEAST32 "I32u"
  399. +#define PRIxLEAST32 "I32x"
  400. +#define PRIXLEAST32 "I32X"
  401. +#define PRIoFAST32 "I32o"
  402. +#define PRIuFAST32 "I32u"
  403. +#define PRIxFAST32 "I32x"
  404. +#define PRIXFAST32 "I32X"
  405. +
  406. +#define PRIo64 "I64o"
  407. +#define PRIu64 "I64u"
  408. +#define PRIx64 "I64x"
  409. +#define PRIX64 "I64X"
  410. +#define PRIoLEAST64 "I64o"
  411. +#define PRIuLEAST64 "I64u"
  412. +#define PRIxLEAST64 "I64x"
  413. +#define PRIXLEAST64 "I64X"
  414. +#define PRIoFAST64 "I64o"
  415. +#define PRIuFAST64 "I64u"
  416. +#define PRIxFAST64 "I64x"
  417. +#define PRIXFAST64 "I64X"
  418. +
  419. +#define PRIoMAX "I64o"
  420. +#define PRIuMAX "I64u"
  421. +#define PRIxMAX "I64x"
  422. +#define PRIXMAX "I64X"
  423. +
  424. +#define PRIoPTR "Io"
  425. +#define PRIuPTR "Iu"
  426. +#define PRIxPTR "Ix"
  427. +#define PRIXPTR "IX"
  428. +
  429. +// The fscanf macros for signed integers are:
  430. +#define SCNd8 "d"
  431. +#define SCNi8 "i"
  432. +#define SCNdLEAST8 "d"
  433. +#define SCNiLEAST8 "i"
  434. +#define SCNdFAST8 "d"
  435. +#define SCNiFAST8 "i"
  436. +
  437. +#define SCNd16 "hd"
  438. +#define SCNi16 "hi"
  439. +#define SCNdLEAST16 "hd"
  440. +#define SCNiLEAST16 "hi"
  441. +#define SCNdFAST16 "hd"
  442. +#define SCNiFAST16 "hi"
  443. +
  444. +#define SCNd32 "ld"
  445. +#define SCNi32 "li"
  446. +#define SCNdLEAST32 "ld"
  447. +#define SCNiLEAST32 "li"
  448. +#define SCNdFAST32 "ld"
  449. +#define SCNiFAST32 "li"
  450. +
  451. +#define SCNd64 "I64d"
  452. +#define SCNi64 "I64i"
  453. +#define SCNdLEAST64 "I64d"
  454. +#define SCNiLEAST64 "I64i"
  455. +#define SCNdFAST64 "I64d"
  456. +#define SCNiFAST64 "I64i"
  457. +
  458. +#define SCNdMAX "I64d"
  459. +#define SCNiMAX "I64i"
  460. +
  461. +#ifdef _WIN64 // [
  462. +# define SCNdPTR "I64d"
  463. +# define SCNiPTR "I64i"
  464. +#else // _WIN64 ][
  465. +# define SCNdPTR "ld"
  466. +# define SCNiPTR "li"
  467. +#endif // _WIN64 ]
  468. +
  469. +// The fscanf macros for unsigned integers are:
  470. +#define SCNo8 "o"
  471. +#define SCNu8 "u"
  472. +#define SCNx8 "x"
  473. +#define SCNX8 "X"
  474. +#define SCNoLEAST8 "o"
  475. +#define SCNuLEAST8 "u"
  476. +#define SCNxLEAST8 "x"
  477. +#define SCNXLEAST8 "X"
  478. +#define SCNoFAST8 "o"
  479. +#define SCNuFAST8 "u"
  480. +#define SCNxFAST8 "x"
  481. +#define SCNXFAST8 "X"
  482. +
  483. +#define SCNo16 "ho"
  484. +#define SCNu16 "hu"
  485. +#define SCNx16 "hx"
  486. +#define SCNX16 "hX"
  487. +#define SCNoLEAST16 "ho"
  488. +#define SCNuLEAST16 "hu"
  489. +#define SCNxLEAST16 "hx"
  490. +#define SCNXLEAST16 "hX"
  491. +#define SCNoFAST16 "ho"
  492. +#define SCNuFAST16 "hu"
  493. +#define SCNxFAST16 "hx"
  494. +#define SCNXFAST16 "hX"
  495. +
  496. +#define SCNo32 "lo"
  497. +#define SCNu32 "lu"
  498. +#define SCNx32 "lx"
  499. +#define SCNX32 "lX"
  500. +#define SCNoLEAST32 "lo"
  501. +#define SCNuLEAST32 "lu"
  502. +#define SCNxLEAST32 "lx"
  503. +#define SCNXLEAST32 "lX"
  504. +#define SCNoFAST32 "lo"
  505. +#define SCNuFAST32 "lu"
  506. +#define SCNxFAST32 "lx"
  507. +#define SCNXFAST32 "lX"
  508. +
  509. +#define SCNo64 "I64o"
  510. +#define SCNu64 "I64u"
  511. +#define SCNx64 "I64x"
  512. +#define SCNX64 "I64X"
  513. +#define SCNoLEAST64 "I64o"
  514. +#define SCNuLEAST64 "I64u"
  515. +#define SCNxLEAST64 "I64x"
  516. +#define SCNXLEAST64 "I64X"
  517. +#define SCNoFAST64 "I64o"
  518. +#define SCNuFAST64 "I64u"
  519. +#define SCNxFAST64 "I64x"
  520. +#define SCNXFAST64 "I64X"
  521. +
  522. +#define SCNoMAX "I64o"
  523. +#define SCNuMAX "I64u"
  524. +#define SCNxMAX "I64x"
  525. +#define SCNXMAX "I64X"
  526. +
  527. +#ifdef _WIN64 // [
  528. +# define SCNoPTR "I64o"
  529. +# define SCNuPTR "I64u"
  530. +# define SCNxPTR "I64x"
  531. +# define SCNXPTR "I64X"
  532. +#else // _WIN64 ][
  533. +# define SCNoPTR "lo"
  534. +# define SCNuPTR "lu"
  535. +# define SCNxPTR "lx"
  536. +# define SCNXPTR "lX"
  537. +#endif // _WIN64 ]
  538. +
  539. +#endif // __STDC_FORMAT_MACROS ]
  540. +
  541. +// 7.8.2 Functions for greatest-width integer types
  542. +
  543. +// 7.8.2.1 The imaxabs function
  544. +#define imaxabs _abs64
  545. +
  546. +// 7.8.2.2 The imaxdiv function
  547. +
  548. +// This is modified version of div() function from Microsoft's div.c found
  549. +// in %MSVC.NET%\crt\src\div.c
  550. +#ifdef STATIC_IMAXDIV // [
  551. +static
  552. +#else // STATIC_IMAXDIV ][
  553. +_inline
  554. +#endif // STATIC_IMAXDIV ]
  555. +imaxdiv_t __cdecl imaxdiv(intmax_t numer, intmax_t denom)
  556. +{
  557. + imaxdiv_t result;
  558. +
  559. + result.quot = numer / denom;
  560. + result.rem = numer % denom;
  561. +
  562. + if (numer < 0 && result.rem > 0) {
  563. + // did division wrong; must fix up
  564. + ++result.quot;
  565. + result.rem -= denom;
  566. + }
  567. +
  568. + return result;
  569. +}
  570. +
  571. +// 7.8.2.3 The strtoimax and strtoumax functions
  572. +#define strtoimax _strtoi64
  573. +#define strtoumax _strtoui64
  574. +
  575. +// 7.8.2.4 The wcstoimax and wcstoumax functions
  576. +#define wcstoimax _wcstoi64
  577. +#define wcstoumax _wcstoui64
  578. +
  579. +
  580. +#endif // _MSC_INTTYPES_H_ ]
  581. diff --git a/libbluray.def b/libbluray.def
  582. new file mode 100644
  583. index 0000000..d4c93cb
  584. --- /dev/null
  585. +++ b/libbluray.def
  586. @@ -0,0 +1,63 @@
  587. +; libbluray.def ; declares the exports
  588. +
  589. +LIBRARY "libbluray.dll"
  590. +
  591. +EXPORTS
  592. + ; bluray.h
  593. + bd_get_version
  594. + bd_get_titles
  595. + bd_get_title_info
  596. + bd_get_playlist_info
  597. + bd_free_title_info
  598. + bd_open
  599. + bd_close
  600. + bd_seek
  601. + bd_seek_time
  602. + bd_find_seek_point
  603. + bd_read
  604. + bd_read_skip_still
  605. + bd_seek_chapter
  606. + bd_chapter_pos
  607. + bd_get_current_chapter
  608. + bd_seek_mark
  609. + bd_seek_playitem
  610. + bd_select_playlist
  611. + bd_select_title
  612. + bd_select_angle
  613. + bd_seamless_angle_change
  614. + bd_get_title_size
  615. + bd_get_current_title
  616. + bd_get_current_angle
  617. + bd_tell
  618. + bd_tell_time
  619. + bd_get_disc_info
  620. + bd_set_player_setting
  621. + bd_set_player_setting_str
  622. + bd_start_bdj
  623. + bd_stop_bdj
  624. + bd_get_event
  625. + bd_play
  626. + bd_read_ext
  627. + bd_play_title
  628. + bd_menu_call
  629. + bd_register_overlay_proc
  630. + bd_register_argb_overlay_proc
  631. + bd_set_scr
  632. + bd_user_input
  633. + bd_mouse_select
  634. + bd_get_sound_effect
  635. + bd_get_meta
  636. + bd_get_clpi
  637. + bd_read_clpi
  638. + bd_free_clpi
  639. + bd_read_mpls
  640. + bd_free_mpls
  641. + bd_read_mobj
  642. + bd_free_mobj
  643. + bd_get_clip_infos
  644. + bd_get_title_mpls
  645. +
  646. + ; additional functions
  647. + bd_set_debug_handler
  648. + bd_set_debug_mask
  649. + bd_get_debug_mask
  650. diff --git a/libbluray.vcxproj b/libbluray.vcxproj
  651. new file mode 100644
  652. index 0000000..c778955
  653. --- /dev/null
  654. +++ b/libbluray.vcxproj
  655. @@ -0,0 +1,231 @@
  656. +<?xml version="1.0" encoding="utf-8"?>
  657. +<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  658. + <ItemGroup Label="ProjectConfigurations">
  659. + <ProjectConfiguration Include="DebugRelease|Win32">
  660. + <Configuration>DebugRelease</Configuration>
  661. + <Platform>Win32</Platform>
  662. + </ProjectConfiguration>
  663. + <ProjectConfiguration Include="DebugRelease|x64">
  664. + <Configuration>DebugRelease</Configuration>
  665. + <Platform>x64</Platform>
  666. + </ProjectConfiguration>
  667. + <ProjectConfiguration Include="Debug|Win32">
  668. + <Configuration>Debug</Configuration>
  669. + <Platform>Win32</Platform>
  670. + </ProjectConfiguration>
  671. + <ProjectConfiguration Include="Debug|x64">
  672. + <Configuration>Debug</Configuration>
  673. + <Platform>x64</Platform>
  674. + </ProjectConfiguration>
  675. + <ProjectConfiguration Include="Release|Win32">
  676. + <Configuration>Release</Configuration>
  677. + <Platform>Win32</Platform>
  678. + </ProjectConfiguration>
  679. + <ProjectConfiguration Include="Release|x64">
  680. + <Configuration>Release</Configuration>
  681. + <Platform>x64</Platform>
  682. + </ProjectConfiguration>
  683. + </ItemGroup>
  684. + <ItemGroup>
  685. + <ClInclude Include="src\file\dirs.h" />
  686. + <ClInclude Include="src\file\dl.h" />
  687. + <ClInclude Include="src\file\file.h" />
  688. + <ClInclude Include="src\file\filesystem.h" />
  689. + <ClInclude Include="src\file\mount.h" />
  690. + <ClInclude Include="src\libbluray\bdnav\bdid_parse.h" />
  691. + <ClInclude Include="src\libbluray\bdnav\bdparse.h" />
  692. + <ClInclude Include="src\libbluray\bdnav\clpi_data.h" />
  693. + <ClInclude Include="src\libbluray\bdnav\clpi_parse.h" />
  694. + <ClInclude Include="src\libbluray\bdnav\extdata_parse.h" />
  695. + <ClInclude Include="src\libbluray\bdnav\index_parse.h" />
  696. + <ClInclude Include="src\libbluray\bdnav\meta_data.h" />
  697. + <ClInclude Include="src\libbluray\bdnav\meta_parse.h" />
  698. + <ClInclude Include="src\libbluray\bdnav\mpls_parse.h" />
  699. + <ClInclude Include="src\libbluray\bdnav\navigation.h" />
  700. + <ClInclude Include="src\libbluray\bdnav\sound_parse.h" />
  701. + <ClInclude Include="src\libbluray\bdnav\uo_mask_table.h" />
  702. + <ClInclude Include="src\libbluray\bluray-version.h" />
  703. + <ClInclude Include="src\libbluray\bluray.h" />
  704. + <ClInclude Include="src\libbluray\bluray_internal.h" />
  705. + <ClInclude Include="src\libbluray\decoders\graphics_controller.h" />
  706. + <ClInclude Include="src\libbluray\decoders\graphics_processor.h" />
  707. + <ClInclude Include="src\libbluray\decoders\ig.h" />
  708. + <ClInclude Include="src\libbluray\decoders\ig_decode.h" />
  709. + <ClInclude Include="src\libbluray\decoders\m2ts_demux.h" />
  710. + <ClInclude Include="src\libbluray\decoders\m2ts_filter.h" />
  711. + <ClInclude Include="src\libbluray\decoders\overlay.h" />
  712. + <ClInclude Include="src\libbluray\decoders\pes_buffer.h" />
  713. + <ClInclude Include="src\libbluray\decoders\pg.h" />
  714. + <ClInclude Include="src\libbluray\decoders\pg_decode.h" />
  715. + <ClInclude Include="src\libbluray\decoders\rle.h" />
  716. + <ClInclude Include="src\libbluray\decoders\textst.h" />
  717. + <ClInclude Include="src\libbluray\decoders\textst_decode.h" />
  718. + <ClInclude Include="src\libbluray\decoders\textst_render.h" />
  719. + <ClInclude Include="src\libbluray\disc\aacs.h" />
  720. + <ClInclude Include="src\libbluray\disc\bdplus.h" />
  721. + <ClInclude Include="src\libbluray\disc\dec.h" />
  722. + <ClInclude Include="src\libbluray\disc\disc.h" />
  723. + <ClInclude Include="src\libbluray\disc\enc_info.h" />
  724. + <ClInclude Include="src\libbluray\hdmv\hdmv_insn.h" />
  725. + <ClInclude Include="src\libbluray\hdmv\hdmv_vm.h" />
  726. + <ClInclude Include="src\libbluray\hdmv\mobj_parse.h" />
  727. + <ClInclude Include="src\libbluray\keys.h" />
  728. + <ClInclude Include="src\libbluray\register.h" />
  729. + <ClInclude Include="src\util\array.h" />
  730. + <ClInclude Include="src\util\attributes.h" />
  731. + <ClInclude Include="src\util\bits.h" />
  732. + <ClInclude Include="src\util\logging.h" />
  733. + <ClInclude Include="src\util\log_control.h" />
  734. + <ClInclude Include="src\util\macro.h" />
  735. + <ClInclude Include="src\util\mutex.h" />
  736. + <ClInclude Include="src\util\refcnt.h" />
  737. + <ClInclude Include="src\util\strutl.h" />
  738. + <ClInclude Include="src\util\time.h" />
  739. + </ItemGroup>
  740. + <ItemGroup>
  741. + <ClCompile Include="src\file\dirs_win32.c" />
  742. + <ClCompile Include="src\file\dir_win32.c" />
  743. + <ClCompile Include="src\file\dl_win32.c" />
  744. + <ClCompile Include="src\file\file.c" />
  745. + <ClCompile Include="src\file\filesystem.c" />
  746. + <ClCompile Include="src\file\file_win32.c" />
  747. + <ClCompile Include="src\file\mount.c" />
  748. + <ClCompile Include="src\libbluray\bdnav\bdid_parse.c" />
  749. + <ClCompile Include="src\libbluray\bdnav\clpi_parse.c" />
  750. + <ClCompile Include="src\libbluray\bdnav\extdata_parse.c" />
  751. + <ClCompile Include="src\libbluray\bdnav\index_parse.c" />
  752. + <ClCompile Include="src\libbluray\bdnav\meta_parse.c" />
  753. + <ClCompile Include="src\libbluray\bdnav\mpls_parse.c" />
  754. + <ClCompile Include="src\libbluray\bdnav\navigation.c" />
  755. + <ClCompile Include="src\libbluray\bdnav\sound_parse.c" />
  756. + <ClCompile Include="src\libbluray\bluray.c" />
  757. + <ClCompile Include="src\libbluray\decoders\graphics_controller.c" />
  758. + <ClCompile Include="src\libbluray\decoders\graphics_processor.c" />
  759. + <ClCompile Include="src\libbluray\decoders\ig_decode.c" />
  760. + <ClCompile Include="src\libbluray\decoders\m2ts_demux.c" />
  761. + <ClCompile Include="src\libbluray\decoders\m2ts_filter.c" />
  762. + <ClCompile Include="src\libbluray\decoders\pes_buffer.c" />
  763. + <ClCompile Include="src\libbluray\decoders\pg_decode.c" />
  764. + <ClCompile Include="src\libbluray\decoders\rle.c" />
  765. + <ClCompile Include="src\libbluray\decoders\textst_decode.c" />
  766. + <ClCompile Include="src\libbluray\decoders\textst_render.c" />
  767. + <ClCompile Include="src\libbluray\disc\aacs.c" />
  768. + <ClCompile Include="src\libbluray\disc\bdplus.c" />
  769. + <ClCompile Include="src\libbluray\disc\dec.c" />
  770. + <ClCompile Include="src\libbluray\disc\disc.c" />
  771. + <ClCompile Include="src\libbluray\hdmv\hdmv_vm.c" />
  772. + <ClCompile Include="src\libbluray\hdmv\mobj_parse.c" />
  773. + <ClCompile Include="src\libbluray\hdmv\mobj_print.c" />
  774. + <ClCompile Include="src\libbluray\register.c" />
  775. + <ClCompile Include="src\util\array.c" />
  776. + <ClCompile Include="src\util\bits.c" />
  777. + <ClCompile Include="src\util\logging.c" />
  778. + <ClCompile Include="src\util\mutex.c" />
  779. + <ClCompile Include="src\util\refcnt.c" />
  780. + <ClCompile Include="src\util\strutl.c" />
  781. + <ClCompile Include="src\util\time.c" />
  782. + </ItemGroup>
  783. + <ItemGroup>
  784. + <None Include="libbluray.def" />
  785. + </ItemGroup>
  786. + <PropertyGroup Label="Globals">
  787. + <ProjectGuid>{E1DA1B95-71F1-4C21-A271-121176925062}</ProjectGuid>
  788. + <Keyword>Win32Proj</Keyword>
  789. + <RootNamespace>libbluray</RootNamespace>
  790. + </PropertyGroup>
  791. + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
  792. + <PropertyGroup Label="Configuration" Condition="'$(VisualStudioVersion)' == '11.0'">
  793. + <PlatformToolset>v110_xp</PlatformToolset>
  794. + </PropertyGroup>
  795. + <PropertyGroup Label="Configuration" Condition="'$(VisualStudioVersion)' == '12.0'">
  796. + <PlatformToolset>v120_xp</PlatformToolset>
  797. + </PropertyGroup>
  798. + <PropertyGroup Label="Configuration" Condition="'$(VisualStudioVersion)' == '14.0'">
  799. + <PlatformToolset>v140_xp</PlatformToolset>
  800. + </PropertyGroup>
  801. + <PropertyGroup Condition="'$(Configuration)'=='Debug' Or '$(Configuration)'=='DebugRelease'" Label="Configuration">
  802. + <ConfigurationType>DynamicLibrary</ConfigurationType>
  803. + <UseDebugLibraries>true</UseDebugLibraries>
  804. + <CharacterSet>Unicode</CharacterSet>
  805. + </PropertyGroup>
  806. + <PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
  807. + <ConfigurationType>DynamicLibrary</ConfigurationType>
  808. + <UseDebugLibraries>false</UseDebugLibraries>
  809. + <WholeProgramOptimization>true</WholeProgramOptimization>
  810. + <CharacterSet>Unicode</CharacterSet>
  811. + </PropertyGroup>
  812. + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
  813. + <ImportGroup Label="ExtensionSettings">
  814. + </ImportGroup>
  815. + <ImportGroup Label="PropertySheets">
  816. + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
  817. + </ImportGroup>
  818. + <PropertyGroup Label="UserMacros" />
  819. + <PropertyGroup Condition="'$(Configuration)'=='Debug' Or '$(Configuration)'=='DebugRelease'">
  820. + <LinkIncremental>true</LinkIncremental>
  821. + <OutDir>$(SolutionDir)bin_$(PlatformName)d\</OutDir>
  822. + <IntDir>$(SolutionDir)bin_$(PlatformName)d\$(ProjectName)\</IntDir>
  823. + </PropertyGroup>
  824. + <PropertyGroup Condition="'$(Configuration)'=='Release'">
  825. + <LinkIncremental>false</LinkIncremental>
  826. + <OutDir>$(SolutionDir)bin_$(PlatformName)\$(ProjectName)\</OutDir>
  827. + <IntDir>$(SolutionDir)bin_$(PlatformName)\$(ProjectName)\</IntDir>
  828. + </PropertyGroup>
  829. + <ItemDefinitionGroup Condition="'$(Configuration)'=='Debug' Or '$(Configuration)'=='DebugRelease'">
  830. + <ClCompile>
  831. + <PrecompiledHeader>
  832. + </PrecompiledHeader>
  833. + <WarningLevel>Level3</WarningLevel>
  834. + <Optimization>Disabled</Optimization>
  835. + <PreprocessorDefinitions>HAVE_CONFIG_H;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBBLURAY_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  836. + <PreprocessorDefinitions Condition="'$(VisualStudioVersion)' == '12.0'">__STDC_FORMAT_MACROS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  837. + <AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)includes;$(ProjectDir)src;$(ProjectDir)src\libbluray;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  838. + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
  839. + <CompileAs Condition="'$(VisualStudioVersion)' == '12.0'">CompileAsCpp</CompileAs>
  840. + </ClCompile>
  841. + <Link>
  842. + <SubSystem>Windows</SubSystem>
  843. + <GenerateDebugInformation>true</GenerateDebugInformation>
  844. + <ModuleDefinitionFile>libbluray.def</ModuleDefinitionFile>
  845. + </Link>
  846. + <PostBuildEvent>
  847. + <Command>xcopy /I /Y "$(OutDir)$(TargetName).lib" "$(OutDir)lib\"</Command>
  848. + <Message>Copy .lib into library path</Message>
  849. + </PostBuildEvent>
  850. + </ItemDefinitionGroup>
  851. + <ItemDefinitionGroup Condition="'$(Configuration)'=='DebugRelease'">
  852. + <ClCompile>
  853. + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
  854. + </ClCompile>
  855. + </ItemDefinitionGroup>
  856. + <ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
  857. + <ClCompile>
  858. + <WarningLevel>Level3</WarningLevel>
  859. + <Optimization>MaxSpeed</Optimization>
  860. + <FunctionLevelLinking>true</FunctionLevelLinking>
  861. + <IntrinsicFunctions>true</IntrinsicFunctions>
  862. + <PreprocessorDefinitions>HAVE_CONFIG_H;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBBLURAY_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  863. + <PreprocessorDefinitions Condition="'$(VisualStudioVersion)' == '12.0'">__STDC_FORMAT_MACROS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
  864. + <AdditionalIncludeDirectories>$(ProjectDir);$(ProjectDir)includes;$(ProjectDir)src;$(ProjectDir)src\libbluray;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
  865. + <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
  866. + <EnableEnhancedInstructionSet Condition="'$(Platform)'=='Win32'">StreamingSIMDExtensions</EnableEnhancedInstructionSet>
  867. + <CompileAs Condition="'$(VisualStudioVersion)' == '12.0'">CompileAsCpp</CompileAs>
  868. + </ClCompile>
  869. + <Link>
  870. + <SubSystem>Windows</SubSystem>
  871. + <GenerateDebugInformation>true</GenerateDebugInformation>
  872. + <EnableCOMDATFolding>true</EnableCOMDATFolding>
  873. + <OptimizeReferences>true</OptimizeReferences>
  874. + <ModuleDefinitionFile>libbluray.def</ModuleDefinitionFile>
  875. + <SetChecksum>true</SetChecksum>
  876. + </Link>
  877. + <PostBuildEvent>
  878. + <Command>xcopy /I /Y "$(TargetDir)$(TargetName)$(TargetExt)" "$(OutDir)..\"
  879. +xcopy /I /Y "$(TargetDir)$(TargetName).lib" "$(OutDir)..\lib\"</Command>
  880. + <Message>Copy .dll/.lib into library path</Message>
  881. + </PostBuildEvent>
  882. + </ItemDefinitionGroup>
  883. + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
  884. + <ImportGroup Label="ExtensionTargets">
  885. + </ImportGroup>
  886. +</Project>
  887. \ No newline at end of file
  888. diff --git a/libbluray.vcxproj.filters b/libbluray.vcxproj.filters
  889. new file mode 100644
  890. index 0000000..57ff16c
  891. --- /dev/null
  892. +++ b/libbluray.vcxproj.filters
  893. @@ -0,0 +1,353 @@
  894. +<?xml version="1.0" encoding="utf-8"?>
  895. +<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  896. + <ItemGroup>
  897. + <Filter Include="Source Files">
  898. + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
  899. + <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
  900. + </Filter>
  901. + <Filter Include="Header Files">
  902. + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
  903. + <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
  904. + </Filter>
  905. + <Filter Include="Resource Files">
  906. + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
  907. + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
  908. + </Filter>
  909. + <Filter Include="Source Files\util">
  910. + <UniqueIdentifier>{1ab0e905-7c04-4090-b385-6363dd1c961c}</UniqueIdentifier>
  911. + </Filter>
  912. + <Filter Include="Header Files\util">
  913. + <UniqueIdentifier>{b8fa3348-a089-461f-9ef5-3d9df997b8e5}</UniqueIdentifier>
  914. + </Filter>
  915. + <Filter Include="Header Files\file">
  916. + <UniqueIdentifier>{125333e9-0b5e-45f9-a444-f0aaaf547d9b}</UniqueIdentifier>
  917. + </Filter>
  918. + <Filter Include="Source Files\file">
  919. + <UniqueIdentifier>{a743058f-f07a-4d0f-bab6-02dc57defda9}</UniqueIdentifier>
  920. + </Filter>
  921. + <Filter Include="Source Files\libbluray">
  922. + <UniqueIdentifier>{7dacc7c4-ef59-452b-9e5b-392c9df07c98}</UniqueIdentifier>
  923. + </Filter>
  924. + <Filter Include="Header Files\libbluray">
  925. + <UniqueIdentifier>{c7895c81-c186-4d5e-a8ff-645c6d55a731}</UniqueIdentifier>
  926. + </Filter>
  927. + <Filter Include="Header Files\libbluray\bdnav">
  928. + <UniqueIdentifier>{c8619466-211b-4c85-9d30-d1b1a822d32e}</UniqueIdentifier>
  929. + </Filter>
  930. + <Filter Include="Source Files\libbluray\bdnav">
  931. + <UniqueIdentifier>{8afb6919-994f-4d1f-9638-ce4a06d0b473}</UniqueIdentifier>
  932. + </Filter>
  933. + <Filter Include="Source Files\libbluray\decoders">
  934. + <UniqueIdentifier>{0e9086a7-eebf-4b8e-a4fe-b1724d148877}</UniqueIdentifier>
  935. + </Filter>
  936. + <Filter Include="Header Files\libbluray\decoders">
  937. + <UniqueIdentifier>{fc5e776b-0f32-493a-b823-240288288502}</UniqueIdentifier>
  938. + </Filter>
  939. + <Filter Include="Header Files\libbluray\hdmv">
  940. + <UniqueIdentifier>{96d2d786-cd45-4856-937d-9e6f85ced241}</UniqueIdentifier>
  941. + </Filter>
  942. + <Filter Include="Source Files\libbluray\hdmv">
  943. + <UniqueIdentifier>{9f4ea4ae-217a-4d97-a5f3-e561ce1e49cd}</UniqueIdentifier>
  944. + </Filter>
  945. + <Filter Include="Source Files\libbluray\disc">
  946. + <UniqueIdentifier>{09e1b1b8-3aa3-4918-b157-3dfc0554ccbb}</UniqueIdentifier>
  947. + </Filter>
  948. + <Filter Include="Header Files\libbluray\disc">
  949. + <UniqueIdentifier>{1e02e503-752e-4765-9dfb-8cc67a7b79f8}</UniqueIdentifier>
  950. + </Filter>
  951. + </ItemGroup>
  952. + <ItemGroup>
  953. + <ClInclude Include="src\util\attributes.h">
  954. + <Filter>Header Files\util</Filter>
  955. + </ClInclude>
  956. + <ClInclude Include="src\util\strutl.h">
  957. + <Filter>Header Files\util</Filter>
  958. + </ClInclude>
  959. + <ClInclude Include="src\util\bits.h">
  960. + <Filter>Header Files\util</Filter>
  961. + </ClInclude>
  962. + <ClInclude Include="src\util\log_control.h">
  963. + <Filter>Header Files\util</Filter>
  964. + </ClInclude>
  965. + <ClInclude Include="src\util\logging.h">
  966. + <Filter>Header Files\util</Filter>
  967. + </ClInclude>
  968. + <ClInclude Include="src\util\macro.h">
  969. + <Filter>Header Files\util</Filter>
  970. + </ClInclude>
  971. + <ClInclude Include="src\util\mutex.h">
  972. + <Filter>Header Files\util</Filter>
  973. + </ClInclude>
  974. + <ClInclude Include="src\file\dl.h">
  975. + <Filter>Header Files\file</Filter>
  976. + </ClInclude>
  977. + <ClInclude Include="src\file\filesystem.h">
  978. + <Filter>Header Files\file</Filter>
  979. + </ClInclude>
  980. + <ClInclude Include="src\file\file.h">
  981. + <Filter>Header Files\file</Filter>
  982. + </ClInclude>
  983. + <ClInclude Include="src\libbluray\bluray.h">
  984. + <Filter>Header Files\libbluray</Filter>
  985. + </ClInclude>
  986. + <ClInclude Include="src\libbluray\register.h">
  987. + <Filter>Header Files\libbluray</Filter>
  988. + </ClInclude>
  989. + <ClInclude Include="src\libbluray\keys.h">
  990. + <Filter>Header Files\libbluray</Filter>
  991. + </ClInclude>
  992. + <ClInclude Include="src\libbluray\bdnav\bdparse.h">
  993. + <Filter>Header Files\libbluray\bdnav</Filter>
  994. + </ClInclude>
  995. + <ClInclude Include="src\libbluray\bdnav\uo_mask_table.h">
  996. + <Filter>Header Files\libbluray\bdnav</Filter>
  997. + </ClInclude>
  998. + <ClInclude Include="src\libbluray\bdnav\clpi_parse.h">
  999. + <Filter>Header Files\libbluray\bdnav</Filter>
  1000. + </ClInclude>
  1001. + <ClInclude Include="src\libbluray\bdnav\index_parse.h">
  1002. + <Filter>Header Files\libbluray\bdnav</Filter>
  1003. + </ClInclude>
  1004. + <ClInclude Include="src\libbluray\bdnav\meta_data.h">
  1005. + <Filter>Header Files\libbluray\bdnav</Filter>
  1006. + </ClInclude>
  1007. + <ClInclude Include="src\libbluray\bdnav\meta_parse.h">
  1008. + <Filter>Header Files\libbluray\bdnav</Filter>
  1009. + </ClInclude>
  1010. + <ClInclude Include="src\libbluray\bdnav\mpls_parse.h">
  1011. + <Filter>Header Files\libbluray\bdnav</Filter>
  1012. + </ClInclude>
  1013. + <ClInclude Include="src\libbluray\bdnav\navigation.h">
  1014. + <Filter>Header Files\libbluray\bdnav</Filter>
  1015. + </ClInclude>
  1016. + <ClInclude Include="src\libbluray\bdnav\sound_parse.h">
  1017. + <Filter>Header Files\libbluray\bdnav</Filter>
  1018. + </ClInclude>
  1019. + <ClInclude Include="src\libbluray\decoders\graphics_controller.h">
  1020. + <Filter>Header Files\libbluray\decoders</Filter>
  1021. + </ClInclude>
  1022. + <ClInclude Include="src\libbluray\decoders\pg_decode.h">
  1023. + <Filter>Header Files\libbluray\decoders</Filter>
  1024. + </ClInclude>
  1025. + <ClInclude Include="src\libbluray\decoders\graphics_processor.h">
  1026. + <Filter>Header Files\libbluray\decoders</Filter>
  1027. + </ClInclude>
  1028. + <ClInclude Include="src\libbluray\decoders\ig.h">
  1029. + <Filter>Header Files\libbluray\decoders</Filter>
  1030. + </ClInclude>
  1031. + <ClInclude Include="src\libbluray\decoders\ig_decode.h">
  1032. + <Filter>Header Files\libbluray\decoders</Filter>
  1033. + </ClInclude>
  1034. + <ClInclude Include="src\libbluray\decoders\m2ts_demux.h">
  1035. + <Filter>Header Files\libbluray\decoders</Filter>
  1036. + </ClInclude>
  1037. + <ClInclude Include="src\libbluray\decoders\overlay.h">
  1038. + <Filter>Header Files\libbluray\decoders</Filter>
  1039. + </ClInclude>
  1040. + <ClInclude Include="src\libbluray\decoders\pes_buffer.h">
  1041. + <Filter>Header Files\libbluray\decoders</Filter>
  1042. + </ClInclude>
  1043. + <ClInclude Include="src\libbluray\decoders\pg.h">
  1044. + <Filter>Header Files\libbluray\decoders</Filter>
  1045. + </ClInclude>
  1046. + <ClInclude Include="src\libbluray\hdmv\hdmv_insn.h">
  1047. + <Filter>Header Files\libbluray\hdmv</Filter>
  1048. + </ClInclude>
  1049. + <ClInclude Include="src\libbluray\hdmv\mobj_parse.h">
  1050. + <Filter>Header Files\libbluray\hdmv</Filter>
  1051. + </ClInclude>
  1052. + <ClInclude Include="src\libbluray\hdmv\hdmv_vm.h">
  1053. + <Filter>Header Files\libbluray\hdmv</Filter>
  1054. + </ClInclude>
  1055. + <ClInclude Include="src\libbluray\bdnav\bdid_parse.h">
  1056. + <Filter>Header Files\libbluray\bdnav</Filter>
  1057. + </ClInclude>
  1058. + <ClInclude Include="src\libbluray\bdnav\clpi_data.h">
  1059. + <Filter>Header Files\libbluray\bdnav</Filter>
  1060. + </ClInclude>
  1061. + <ClInclude Include="src\libbluray\bdnav\extdata_parse.h">
  1062. + <Filter>Header Files\libbluray\bdnav</Filter>
  1063. + </ClInclude>
  1064. + <ClInclude Include="src\libbluray\decoders\textst.h">
  1065. + <Filter>Header Files\libbluray\decoders</Filter>
  1066. + </ClInclude>
  1067. + <ClInclude Include="src\libbluray\decoders\textst_render.h">
  1068. + <Filter>Header Files\libbluray\decoders</Filter>
  1069. + </ClInclude>
  1070. + <ClInclude Include="src\libbluray\decoders\textst_decode.h">
  1071. + <Filter>Header Files\libbluray\decoders</Filter>
  1072. + </ClInclude>
  1073. + <ClInclude Include="src\libbluray\decoders\rle.h">
  1074. + <Filter>Header Files\libbluray\decoders</Filter>
  1075. + </ClInclude>
  1076. + <ClInclude Include="src\util\refcnt.h">
  1077. + <Filter>Header Files\util</Filter>
  1078. + </ClInclude>
  1079. + <ClInclude Include="src\util\time.h">
  1080. + <Filter>Header Files\util</Filter>
  1081. + </ClInclude>
  1082. + <ClInclude Include="src\libbluray\bluray_internal.h">
  1083. + <Filter>Header Files\libbluray</Filter>
  1084. + </ClInclude>
  1085. + <ClInclude Include="src\libbluray\decoders\m2ts_filter.h">
  1086. + <Filter>Header Files\libbluray\decoders</Filter>
  1087. + </ClInclude>
  1088. + <ClInclude Include="src\file\dirs.h">
  1089. + <Filter>Header Files\file</Filter>
  1090. + </ClInclude>
  1091. + <ClInclude Include="src\libbluray\bluray-version.h">
  1092. + <Filter>Header Files\libbluray</Filter>
  1093. + </ClInclude>
  1094. + <ClInclude Include="src\util\array.h">
  1095. + <Filter>Header Files\util</Filter>
  1096. + </ClInclude>
  1097. + <ClInclude Include="src\libbluray\disc\aacs.h">
  1098. + <Filter>Header Files\libbluray\disc</Filter>
  1099. + </ClInclude>
  1100. + <ClInclude Include="src\libbluray\disc\bdplus.h">
  1101. + <Filter>Header Files\libbluray\disc</Filter>
  1102. + </ClInclude>
  1103. + <ClInclude Include="src\libbluray\disc\dec.h">
  1104. + <Filter>Header Files\libbluray\disc</Filter>
  1105. + </ClInclude>
  1106. + <ClInclude Include="src\libbluray\disc\disc.h">
  1107. + <Filter>Header Files\libbluray\disc</Filter>
  1108. + </ClInclude>
  1109. + <ClInclude Include="src\libbluray\disc\enc_info.h">
  1110. + <Filter>Header Files\libbluray\disc</Filter>
  1111. + </ClInclude>
  1112. + <ClInclude Include="src\file\mount.h">
  1113. + <Filter>Header Files\file</Filter>
  1114. + </ClInclude>
  1115. + </ItemGroup>
  1116. + <ItemGroup>
  1117. + <ClCompile Include="src\util\logging.c">
  1118. + <Filter>Source Files\util</Filter>
  1119. + </ClCompile>
  1120. + <ClCompile Include="src\util\strutl.c">
  1121. + <Filter>Source Files\util</Filter>
  1122. + </ClCompile>
  1123. + <ClCompile Include="src\file\filesystem.c">
  1124. + <Filter>Source Files\file</Filter>
  1125. + </ClCompile>
  1126. + <ClCompile Include="src\libbluray\bluray.c">
  1127. + <Filter>Source Files\libbluray</Filter>
  1128. + </ClCompile>
  1129. + <ClCompile Include="src\libbluray\register.c">
  1130. + <Filter>Source Files\libbluray</Filter>
  1131. + </ClCompile>
  1132. + <ClCompile Include="src\libbluray\bdnav\clpi_parse.c">
  1133. + <Filter>Source Files\libbluray\bdnav</Filter>
  1134. + </ClCompile>
  1135. + <ClCompile Include="src\libbluray\bdnav\sound_parse.c">
  1136. + <Filter>Source Files\libbluray\bdnav</Filter>
  1137. + </ClCompile>
  1138. + <ClCompile Include="src\libbluray\bdnav\index_parse.c">
  1139. + <Filter>Source Files\libbluray\bdnav</Filter>
  1140. + </ClCompile>
  1141. + <ClCompile Include="src\libbluray\bdnav\meta_parse.c">
  1142. + <Filter>Source Files\libbluray\bdnav</Filter>
  1143. + </ClCompile>
  1144. + <ClCompile Include="src\libbluray\bdnav\mpls_parse.c">
  1145. + <Filter>Source Files\libbluray\bdnav</Filter>
  1146. + </ClCompile>
  1147. + <ClCompile Include="src\libbluray\bdnav\navigation.c">
  1148. + <Filter>Source Files\libbluray\bdnav</Filter>
  1149. + </ClCompile>
  1150. + <ClCompile Include="src\libbluray\decoders\graphics_controller.c">
  1151. + <Filter>Source Files\libbluray\decoders</Filter>
  1152. + </ClCompile>
  1153. + <ClCompile Include="src\libbluray\decoders\pg_decode.c">
  1154. + <Filter>Source Files\libbluray\decoders</Filter>
  1155. + </ClCompile>
  1156. + <ClCompile Include="src\libbluray\decoders\graphics_processor.c">
  1157. + <Filter>Source Files\libbluray\decoders</Filter>
  1158. + </ClCompile>
  1159. + <ClCompile Include="src\libbluray\decoders\ig_decode.c">
  1160. + <Filter>Source Files\libbluray\decoders</Filter>
  1161. + </ClCompile>
  1162. + <ClCompile Include="src\libbluray\decoders\m2ts_demux.c">
  1163. + <Filter>Source Files\libbluray\decoders</Filter>
  1164. + </ClCompile>
  1165. + <ClCompile Include="src\libbluray\decoders\pes_buffer.c">
  1166. + <Filter>Source Files\libbluray\decoders</Filter>
  1167. + </ClCompile>
  1168. + <ClCompile Include="src\libbluray\hdmv\hdmv_vm.c">
  1169. + <Filter>Source Files\libbluray\hdmv</Filter>
  1170. + </ClCompile>
  1171. + <ClCompile Include="src\libbluray\hdmv\mobj_print.c">
  1172. + <Filter>Source Files\libbluray\hdmv</Filter>
  1173. + </ClCompile>
  1174. + <ClCompile Include="src\libbluray\hdmv\mobj_parse.c">
  1175. + <Filter>Source Files\libbluray\hdmv</Filter>
  1176. + </ClCompile>
  1177. + <ClCompile Include="src\libbluray\bdnav\bdid_parse.c">
  1178. + <Filter>Source Files\libbluray\bdnav</Filter>
  1179. + </ClCompile>
  1180. + <ClCompile Include="src\libbluray\bdnav\extdata_parse.c">
  1181. + <Filter>Source Files\libbluray\bdnav</Filter>
  1182. + </ClCompile>
  1183. + <ClCompile Include="src\util\bits.c">
  1184. + <Filter>Source Files\util</Filter>
  1185. + </ClCompile>
  1186. + <ClCompile Include="src\file\dir_win32.c">
  1187. + <Filter>Source Files\file</Filter>
  1188. + </ClCompile>
  1189. + <ClCompile Include="src\file\dirs_win32.c">
  1190. + <Filter>Source Files\file</Filter>
  1191. + </ClCompile>
  1192. + <ClCompile Include="src\file\dl_win32.c">
  1193. + <Filter>Source Files\file</Filter>
  1194. + </ClCompile>
  1195. + <ClCompile Include="src\libbluray\decoders\textst_decode.c">
  1196. + <Filter>Source Files\libbluray\decoders</Filter>
  1197. + </ClCompile>
  1198. + <ClCompile Include="src\libbluray\decoders\textst_render.c">
  1199. + <Filter>Source Files\libbluray\decoders</Filter>
  1200. + </ClCompile>
  1201. + <ClCompile Include="src\util\refcnt.c">
  1202. + <Filter>Source Files\util</Filter>
  1203. + </ClCompile>
  1204. + <ClCompile Include="src\libbluray\decoders\m2ts_filter.c">
  1205. + <Filter>Source Files\libbluray\decoders</Filter>
  1206. + </ClCompile>
  1207. + <ClCompile Include="src\libbluray\decoders\rle.c">
  1208. + <Filter>Source Files\libbluray\decoders</Filter>
  1209. + </ClCompile>
  1210. + <ClCompile Include="src\file\file_win32.c">
  1211. + <Filter>Source Files\file</Filter>
  1212. + </ClCompile>
  1213. + <ClCompile Include="src\file\file.c">
  1214. + <Filter>Source Files\file</Filter>
  1215. + </ClCompile>
  1216. + <ClCompile Include="src\util\array.c">
  1217. + <Filter>Source Files\util</Filter>
  1218. + </ClCompile>
  1219. + <ClCompile Include="src\util\mutex.c">
  1220. + <Filter>Source Files\util</Filter>
  1221. + </ClCompile>
  1222. + <ClCompile Include="src\libbluray\disc\aacs.c">
  1223. + <Filter>Source Files\libbluray\disc</Filter>
  1224. + </ClCompile>
  1225. + <ClCompile Include="src\libbluray\disc\bdplus.c">
  1226. + <Filter>Source Files\libbluray\disc</Filter>
  1227. + </ClCompile>
  1228. + <ClCompile Include="src\libbluray\disc\dec.c">
  1229. + <Filter>Source Files\libbluray\disc</Filter>
  1230. + </ClCompile>
  1231. + <ClCompile Include="src\libbluray\disc\disc.c">
  1232. + <Filter>Source Files\libbluray\disc</Filter>
  1233. + </ClCompile>
  1234. + <ClCompile Include="src\util\time.c">
  1235. + <Filter>Source Files\util</Filter>
  1236. + </ClCompile>
  1237. + <ClCompile Include="src\file\mount.c">
  1238. + <Filter>Source Files\file</Filter>
  1239. + </ClCompile>
  1240. + </ItemGroup>
  1241. + <ItemGroup>
  1242. + <None Include="libbluray.def">
  1243. + <Filter>Source Files</Filter>
  1244. + </None>
  1245. + </ItemGroup>
  1246. +</Project>
  1247. \ No newline at end of file
  1248. diff --git a/src/devtools/bdj_test.c b/src/devtools/bdj_test.c
  1249. new file mode 100644
  1250. index 0000000..d9ebd16
  1251. --- /dev/null
  1252. +++ b/src/devtools/bdj_test.c
  1253. @@ -0,0 +1,67 @@
  1254. +/*
  1255. + * This file is part of libbluray
  1256. + * Copyright (C) 2010 William Hahne
  1257. + *
  1258. + * This program is free software; you can redistribute it and/or
  1259. + * modify it under the terms of the GNU General Public License
  1260. + * as published by the Free Software Foundation; either version 2
  1261. + * of the License, or (at your option) any later version.
  1262. + *
  1263. + * This program is distributed in the hope that it will be useful,
  1264. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1265. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  1266. + * GNU General Public License for more details.
  1267. + *
  1268. + * You should have received a copy of the GNU General Public License
  1269. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  1270. + *
  1271. + * In addition, as a special exception, the copyright holders of libbluray
  1272. + * gives permission to link the code of its release of libbluray with the
  1273. + * OpenSSL project's "OpenSSL" library (or with modified versions of it
  1274. + * that use the same license as the "OpenSSL" library), and distribute
  1275. + * the linked executables. You must obey the GNU General Public License
  1276. + * in all respects for all of the code used other than "OpenSSL". If you
  1277. + * modify this file, you may extend this exception to your version of the
  1278. + * file, but you are not obligated to do so. If you do not wish to do
  1279. + * so, delete this exception statement from your version.
  1280. + */
  1281. +
  1282. +#include <stdio.h>
  1283. +#include <stdlib.h>
  1284. +#include <unistd.h>
  1285. +
  1286. +#include "libbluray/bluray.h"
  1287. +
  1288. +#if defined(_WIN32)
  1289. +#include <windows.h>
  1290. +#define sleep(x) Sleep(x)
  1291. +#endif
  1292. +
  1293. +static void _usage(void) {
  1294. + printf("Usage: [path to disc] [starting object]\n");
  1295. +}
  1296. +
  1297. +int main(int argc, char** argv)
  1298. +{
  1299. + if (argc < 3) {
  1300. + _usage();
  1301. + return 0;
  1302. + }
  1303. +
  1304. + printf("%s %s\n", argv[1], argv[2]);
  1305. +
  1306. + BLURAY* bd = bd_open(argv[1], NULL);
  1307. +
  1308. + bd_get_titles(bd, TITLES_ALL, 0);
  1309. +
  1310. + if (!bd_start_bdj(bd, argv[2])) {
  1311. + printf("Failed to start BD-J application.\n");
  1312. + } else {
  1313. + while (1) { sleep(20); }
  1314. + bd_stop_bdj(bd);
  1315. + }
  1316. +
  1317. + bd_close(bd);
  1318. +
  1319. + return 0;
  1320. +}
  1321. diff --git a/src/devtools/bdjo_dump.c b/src/devtools/bdjo_dump.c
  1322. new file mode 100644
  1323. index 0000000..c9c8141
  1324. --- /dev/null
  1325. +++ b/src/devtools/bdjo_dump.c
  1326. @@ -0,0 +1,206 @@
  1327. +/*
  1328. + * This file is part of libbluray
  1329. + * Copyright (C) 2014 Petri Hintukainen <phintuka@users.sourceforge.net>
  1330. + *
  1331. + * This library is free software; you can redistribute it and/or
  1332. + * modify it under the terms of the GNU Lesser General Public
  1333. + * License as published by the Free Software Foundation; either
  1334. + * version 2.1 of the License, or (at your option) any later version.
  1335. + *
  1336. + * This library is distributed in the hope that it will be useful,
  1337. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1338. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1339. + * Lesser General Public License for more details.
  1340. + *
  1341. + * You should have received a copy of the GNU Lesser General Public
  1342. + * License along with this library. If not, see
  1343. + * <http://www.gnu.org/licenses/>.
  1344. + */
  1345. +
  1346. +#include "libbluray/bluray.h"
  1347. +#include "libbluray/bdj/bdjo_data.h"
  1348. +
  1349. +#include <stdio.h>
  1350. +#include <string.h>
  1351. +
  1352. +static const char *_yes_no(int i)
  1353. +{
  1354. + return i > 0 ? "yes" : i < 0 ? "unknown" : "no";
  1355. +}
  1356. +
  1357. +static const char *_binding_str(int i)
  1358. +{
  1359. + switch (i) {
  1360. + case 0: return "unbound";
  1361. + case 1: return "disc bound";
  1362. + case 3: return "title bound";
  1363. + default: return "???";
  1364. + }
  1365. +}
  1366. +
  1367. +static const char *_visibility_str(int i)
  1368. +{
  1369. + switch (i) {
  1370. + case 0: return "none";
  1371. + case 1: return "applications";
  1372. + case 2: return "user";
  1373. + default: return "???";
  1374. + }
  1375. +}
  1376. +
  1377. +static void _terminal_info_print(const BDJO_TERMINAL_INFO *p)
  1378. +{
  1379. + printf("Terminal Info:\n");
  1380. + printf(" Default AWT font : %s\n", p->default_font);
  1381. + printf(" initial HaVi config : %d\n", p->initial_havi_config_id);
  1382. + printf(" Menu call mask : %d\n", p->menu_call_mask);
  1383. + printf(" Title search mask : %d\n", p->menu_call_mask);
  1384. +}
  1385. +
  1386. +static void _app_cache_item_print(const BDJO_APP_CACHE_ITEM *p)
  1387. +{
  1388. + printf(" %3.3s: %s%s\n",
  1389. + p->lang_code, p->ref_to_name,
  1390. + p->type == 1 ? ".jar" : p->type == 2 ? "/" : " (unknown type)");
  1391. +}
  1392. +
  1393. +static void _app_cache_info_print(const BDJO_APP_CACHE_INFO *p)
  1394. +{
  1395. + unsigned ii;
  1396. +
  1397. + printf("Application cache info:\n");
  1398. + for (ii = 0; ii < p->num_item; ii++) {
  1399. + _app_cache_item_print(&p->item[ii]);
  1400. + }
  1401. +}
  1402. +
  1403. +static void _accessible_playlists_print(const BDJO_ACCESSIBLE_PLAYLISTS *p)
  1404. +{
  1405. + unsigned ii;
  1406. +
  1407. + printf("Accessible playlists:\n");
  1408. + printf(" Access to all : %s\n", _yes_no(p->access_to_all_flag));
  1409. + printf(" Autostart first : %s\n", _yes_no(p->autostart_first_playlist_flag));
  1410. +
  1411. + if (p->num_pl) {
  1412. + printf(" Playlists : %d\n", p->num_pl);
  1413. + for (ii = 0; ii < p->num_pl; ii++) {
  1414. + printf(" %s.mpls\n", p->pl[ii].name);
  1415. + }
  1416. + }
  1417. +}
  1418. +
  1419. +static void _app_profile_print(BDJO_APP_PROFILE *p)
  1420. +{
  1421. + printf(" Profile %d Version %d.%d.%d\n",
  1422. + p->profile_number, p->major_version, p->minor_version, p->micro_version);
  1423. +}
  1424. +
  1425. +static void _app_print(const BDJO_APP *p)
  1426. +{
  1427. + unsigned ii;
  1428. +
  1429. + printf(" Control code: : %d (%s)\n", p->control_code,
  1430. + p->control_code == 1 ? "autostart" : p->control_code == 2 ? "present" : "???");
  1431. + printf(" Type : %d (%s)\n", p->type,
  1432. + p->type == 1 ? "BD-J App" : "???");
  1433. + printf(" Organization ID : %08X\n", p->org_id);
  1434. + printf(" Application ID : %04X\n", p->app_id);
  1435. + printf(" Priority : %d\n", p->priority);
  1436. + printf(" Binding : %d (%s)\n", p->binding, _binding_str(p->binding));
  1437. + printf(" Visibility : %d (%s)\n", p->visibility, _visibility_str(p->visibility));
  1438. +
  1439. + if (p->num_profile) {
  1440. + printf(" Profiles:\n");
  1441. + for (ii = 0; ii < p->num_profile; ii++) {
  1442. + _app_profile_print(&p->profile[ii]);
  1443. + }
  1444. + }
  1445. +
  1446. + if (p->num_name) {
  1447. + printf(" Names:\n");
  1448. + for (ii = 0; ii < p->num_name; ii++) {
  1449. + printf(" %s: %s\n", p->name[ii].lang, p->name[ii].name);
  1450. + }
  1451. + }
  1452. +
  1453. + printf(" Base directory : %s\n", p->base_dir);
  1454. + printf(" Icon locator : %s\n", p->icon_locator);
  1455. + printf(" Icon flags : 0x%04x\n", p->icon_flags);
  1456. + printf(" Classpath extension : %s\n", p->classpath_extension);
  1457. + printf(" Initial class : %s\n", p->initial_class);
  1458. + printf(" Parameters : ");
  1459. + for (ii = 0; ii < p->num_param; ii++) {
  1460. + printf("%s ", p->param[ii].param);
  1461. + }
  1462. + printf("\n");
  1463. +}
  1464. +
  1465. +static void _app_management_table_print(const BDJO_APP_MANAGEMENT_TABLE *p)
  1466. +{
  1467. + unsigned ii;
  1468. +
  1469. + for (ii = 0; ii < p->num_app; ii++) {
  1470. + printf("Application %u:\n", ii);
  1471. + _app_print(&p->app[ii]);
  1472. + }
  1473. +}
  1474. +
  1475. +static void _key_interest_table_print(const BDJO_KEY_INTEREST_TABLE *p)
  1476. +{
  1477. + unsigned int v;
  1478. + memcpy(&v, p, sizeof(unsigned int));
  1479. + if (v) {
  1480. + printf("Key interest table:\n");
  1481. + printf(" %s%s%s%s%s%s%s%s%s%s%s\n",
  1482. + p->vk_play ? "VK_PLAY " : "",
  1483. + p->vk_stop ? "VK_STOP " : "",
  1484. + p->vk_ffw ? "VK_FFW " : "",
  1485. + p->vk_rew ? "VK_REW " : "",
  1486. + p->vk_track_next ? "VK_TRACK_NEXT " : "",
  1487. + p->vk_track_prev ? "VK_TRACK_PREV " : "",
  1488. + p->vk_pause ? "VK_PAUSE " : "",
  1489. + p->vk_still_off ? "VK_STILL_OFF " : "",
  1490. + p->vk_sec_audio_ena_dis ? "VK_SEC_AUDIO " : "",
  1491. + p->vk_sec_video_ena_dis ? "VK_SEC_VIDEO " : "",
  1492. + p->pg_textst_ena_dis ? "VK_PG_TEXTST " : "");
  1493. + }
  1494. +}
  1495. +
  1496. +static void _file_access_info_print(const BDJO_FILE_ACCESS_INFO *p)
  1497. +{
  1498. + printf("File access info:\n %s\n", p->path);
  1499. +}
  1500. +
  1501. +static void _bdjo_print(const BDJO *p)
  1502. +{
  1503. + _terminal_info_print(&p->terminal_info);
  1504. + _app_cache_info_print(&p->app_cache_info);
  1505. + _accessible_playlists_print(&p->accessible_playlists);
  1506. + _app_management_table_print(&p->app_table);
  1507. + _key_interest_table_print(&p->key_interest_table);
  1508. + _file_access_info_print(&p->file_access_info);
  1509. +}
  1510. +
  1511. +int main(int argc, const char *argv[])
  1512. +{
  1513. + if (argc < 2) {
  1514. + fprintf(stderr, "usage: %s <bdjo_file>\n", argv[0]);
  1515. + return 1;
  1516. + }
  1517. +
  1518. + int cnt;
  1519. + for (cnt = 1; cnt < argc; cnt++) {
  1520. +
  1521. + printf("%s\n", argv[cnt]);
  1522. +
  1523. + BDJO *bdjo = bd_read_bdjo(argv[cnt]);
  1524. + if (bdjo) {
  1525. + _bdjo_print(bdjo);
  1526. + bd_free_bdjo(bdjo);
  1527. + }
  1528. + printf("\n");
  1529. + }
  1530. +
  1531. + return 0;
  1532. +}
  1533. diff --git a/src/devtools/clpi_dump.c b/src/devtools/clpi_dump.c
  1534. new file mode 100644
  1535. index 0000000..bd64783
  1536. --- /dev/null
  1537. +++ b/src/devtools/clpi_dump.c
  1538. @@ -0,0 +1,487 @@
  1539. +/*
  1540. + * This file is part of libbluray
  1541. + * Copyright (C) 2009-2010 John Stebbins
  1542. + * Copyright (C) 2012-2013 Petri Hintukainen <phintuka@users.sourceforge.net>
  1543. + *
  1544. + * This library is free software; you can redistribute it and/or
  1545. + * modify it under the terms of the GNU Lesser General Public
  1546. + * License as published by the Free Software Foundation; either
  1547. + * version 2.1 of the License, or (at your option) any later version.
  1548. + *
  1549. + * This library is distributed in the hope that it will be useful,
  1550. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  1551. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  1552. + * Lesser General Public License for more details.
  1553. + *
  1554. + * You should have received a copy of the GNU Lesser General Public
  1555. + * License along with this library. If not, see
  1556. + * <http://www.gnu.org/licenses/>.
  1557. + */
  1558. +
  1559. +#include <stdio.h>
  1560. +#include <stdlib.h>
  1561. +#include <unistd.h>
  1562. +#include <inttypes.h>
  1563. +
  1564. +#include "libbluray/bdnav/clpi_data.h"
  1565. +#include "libbluray/bluray.h"
  1566. +
  1567. +#include "util.h"
  1568. +
  1569. +static int verbose;
  1570. +
  1571. +typedef struct {
  1572. + int value;
  1573. + const char *str;
  1574. +} VALUE_MAP;
  1575. +
  1576. +static inline const char*
  1577. +_lookup_str(const VALUE_MAP *map, int val)
  1578. +{
  1579. + int ii;
  1580. +
  1581. + for (ii = 0; map[ii].str; ii++) {
  1582. + if (val == map[ii].value) {
  1583. + return map[ii].str;
  1584. + }
  1585. + }
  1586. + return "?";
  1587. +}
  1588. +
  1589. +const VALUE_MAP codec_map[] = {
  1590. + {0x01, "MPEG-1 Video"},
  1591. + {0x02, "MPEG-2 Video"},
  1592. + {0x03, "MPEG-1 Audio"},
  1593. + {0x04, "MPEG-2 Audio"},
  1594. + {0x80, "LPCM"},
  1595. + {0x81, "AC-3"},
  1596. + {0x82, "DTS"},
  1597. + {0x83, "TrueHD"},
  1598. + {0x84, "AC-3 Plus"},
  1599. + {0x85, "DTS-HD"},
  1600. + {0x86, "DTS-HD Master"},
  1601. + {0xa1, "AC-3 Plus for secondary audio"},
  1602. + {0xa2, "DTS-HD for secondary audio"},
  1603. + {0xea, "VC-1"},
  1604. + {0x1b, "H.264"},
  1605. + {0x20, "H.264 MVC dep."},
  1606. + {0x90, "Presentation Graphics"},
  1607. + {0x91, "Presentation Graphics"},
  1608. + {0x92, "Interactive Graphics"},
  1609. + {0, NULL}
  1610. +};
  1611. +
  1612. +const VALUE_MAP video_format_map[] = {
  1613. + {0, "Reserved"},
  1614. + {1, "480i"},
  1615. + {2, "576i"},
  1616. + {3, "480p"},
  1617. + {4, "1080i"},
  1618. + {5, "720p"},
  1619. + {6, "1080p"},
  1620. + {7, "576p"},
  1621. + {0, NULL}
  1622. +};
  1623. +
  1624. +const VALUE_MAP video_rate_map[] = {
  1625. + {0, "Reserved1"},
  1626. + {1, "23.976"},
  1627. + {2, "24"},
  1628. + {3, "25"},
  1629. + {4, "29.97"},
  1630. + {5, "Reserved2"},
  1631. + {6, "50"},
  1632. + {7, "59.94"},
  1633. + {0, NULL}
  1634. +};
  1635. +
  1636. +const VALUE_MAP video_aspect_map[] = {
  1637. + {0, "Reserved1"},
  1638. + {1, "Reserved2"},
  1639. + {2, "4:3"},
  1640. + {3, "16:9"},
  1641. + {0, NULL}
  1642. +};
  1643. +
  1644. +const VALUE_MAP audio_format_map[] = {
  1645. + {0, "Reserved1"},
  1646. + {1, "Mono"},
  1647. + {2, "Reserved2"},
  1648. + {3, "Stereo"},
  1649. + {4, "Reserved3"},
  1650. + {5, "Reserved4"},
  1651. + {6, "Multi Channel"},
  1652. + {12, "Combo"},
  1653. + {0, NULL}
  1654. +};
  1655. +
  1656. +const VALUE_MAP audio_rate_map[] = {
  1657. + {0, "Reserved1"},
  1658. + {1, "48 Khz"},
  1659. + {2, "Reserved2"},
  1660. + {3, "Reserved3"},
  1661. + {4, "96 Khz"},
  1662. + {5, "192 Khz"},
  1663. + {12, "48/192 Khz"},
  1664. + {14, "48/96 Khz"},
  1665. + {0, NULL}
  1666. +};
  1667. +
  1668. +const VALUE_MAP application_type_map[] = {
  1669. + {1, "Main TS for a main-path of Movie"},
  1670. + {2, "Main TS for a main-path of Time based slide show"},
  1671. + {3, "Main TS for a main-path of Browsable slide show"},
  1672. + {4, "Sub TS for a sub-path of Browsable slide show"},
  1673. + {5, "Sub TS for a sub-path of Interactive Graphics menu"},
  1674. + {6, "Sub TS for a sub-path of Text subtitle"},
  1675. + {7, "Sub TS for a sub-path of one or more elementary streams path"},
  1676. + {0, NULL},
  1677. +};
  1678. +
  1679. +static void
  1680. +_show_stream(CLPI_PROG_STREAM *ss, int level)
  1681. +{
  1682. + indent_printf(level, "Codec (%04x): %s", ss->coding_type,
  1683. + _lookup_str(codec_map, ss->coding_type));
  1684. + indent_printf(level, "PID: %04x", ss->pid);
  1685. + switch (ss->coding_type) {
  1686. + case 0x01:
  1687. + case 0x02:
  1688. + case 0xea:
  1689. + case 0x1b:
  1690. + case 0x20:
  1691. + indent_printf(level, "Format %02x: %s", ss->format,
  1692. + _lookup_str(video_format_map, ss->format));
  1693. + indent_printf(level, "Rate %02x: %s", ss->rate,
  1694. + _lookup_str(video_rate_map, ss->rate));
  1695. + indent_printf(level, "Aspect %02x: %s", ss->aspect,
  1696. + _lookup_str(video_aspect_map, ss->aspect));
  1697. + indent_printf(level, "oc_flag %02x", ss->oc_flag);
  1698. + break;
  1699. +
  1700. + case 0x03:
  1701. + case 0x04:
  1702. + case 0x80:
  1703. + case 0x81:
  1704. + case 0x82:
  1705. + case 0x83:
  1706. + case 0x84:
  1707. + case 0x85:
  1708. + case 0x86:
  1709. + case 0xa1:
  1710. + case 0xa2:
  1711. + indent_printf(level, "Format %02x: %s", ss->format,
  1712. + _lookup_str(audio_format_map, ss->format));
  1713. + indent_printf(level, "Rate %02x: %s", ss->rate,
  1714. + _lookup_str(audio_rate_map, ss->rate));
  1715. + indent_printf(level, "Language: %s", ss->lang);
  1716. + break;
  1717. +
  1718. + case 0x90:
  1719. + case 0x91:
  1720. + case 0xa0:
  1721. + indent_printf(level, "Language: %s", ss->lang);
  1722. + break;
  1723. +
  1724. + case 0x92:
  1725. + indent_printf(level, "Char Code: %02x", ss->char_code);
  1726. + indent_printf(level, "Language: %s", ss->lang);
  1727. + break;
  1728. +
  1729. + default:
  1730. + fprintf(stderr, "unrecognized coding type %02x\n", ss->coding_type);
  1731. + break;
  1732. + };
  1733. +}
  1734. +
  1735. +static void
  1736. +_show_clip_info(CLPI_CL *cl, int level)
  1737. +{
  1738. + CLPI_CLIP_INFO *ci = &cl->clip;
  1739. + int ii;
  1740. +
  1741. + indent_printf(level, "Clip Info");
  1742. + indent_printf(level+1, "Clip Stream Type: %02x", ci->clip_stream_type);
  1743. + indent_printf(level+1, "Clip Application Type (%02x): %s",
  1744. + ci->application_type, _lookup_str(application_type_map, ci->application_type));
  1745. + indent_printf(level+1, "is_ATC_delta: %s", ci->is_atc_delta ? "True" : "False");
  1746. + indent_printf(level+1, "ATC delta count: %d", ci->atc_delta_count);
  1747. + indent_printf(level+1, "TS Recording Rate: %u", ci->ts_recording_rate);
  1748. + indent_printf(level+1, "Number Source Packets: %u", ci->num_source_packets);
  1749. + // Show ts type info
  1750. + indent_printf(level+1, "TS Type Info");
  1751. + indent_printf(level+2, "Validity Flags %02x", ci->ts_type_info.validity);
  1752. + indent_printf(level+2, "Format Id %s", ci->ts_type_info.format_id);
  1753. + // Show cc5 thing
  1754. + for (ii = 0; ii < ci->atc_delta_count; ii++) {
  1755. + indent_printf(level+1, "ATC delta[ %d ]", ii);
  1756. + indent_printf(level+2, "Delta %08x", ci->atc_delta[ii].delta);
  1757. + indent_printf(level+2, "File Id %s", ci->atc_delta[ii].file_id);
  1758. + indent_printf(level+2, "File Code %s", ci->atc_delta[ii].file_code);
  1759. + }
  1760. + // show fonts
  1761. + if (cl->font_info.font_count) {
  1762. + indent_printf(level+1, "Font files");
  1763. + for (ii = 0; ii < cl->font_info.font_count; ii++) {
  1764. + indent_printf(level+2, "Font file %d: %s.otf", ii+1, cl->font_info.font[ii].file_id);
  1765. + }
  1766. + }
  1767. +
  1768. + printf("\n");
  1769. +}
  1770. +
  1771. +static void
  1772. +_show_seq_info(CLPI_SEQ_INFO *si, int level)
  1773. +{
  1774. + CLPI_ATC_SEQ *atc;
  1775. + CLPI_STC_SEQ *stc;
  1776. + int ii, jj;
  1777. +
  1778. + indent_printf(level, "Sequence Info");
  1779. + indent_printf(level+1, "Number ATC Sequences: %d", si->num_atc_seq);
  1780. + for (ii = 0; ii < si->num_atc_seq; ii++) {
  1781. + atc = &si->atc_seq[ii];
  1782. + indent_printf(level+1, "ATC Sequence %d", ii);
  1783. + indent_printf(level+2, "SPN ATC Start: %u", atc->spn_atc_start);
  1784. + indent_printf(level+2, "Offset STC Id: %d", atc->offset_stc_id);
  1785. + indent_printf(level+2, "Number STC Sequences: %d", atc->num_stc_seq);
  1786. + for (jj = 0; jj < atc->num_stc_seq; jj++) {
  1787. + stc = &atc->stc_seq[jj];
  1788. + indent_printf(level+2, "ATC Sequence %d", jj);
  1789. + indent_printf(level+3, "SPN STC Start: %u", stc->spn_stc_start);
  1790. + indent_printf(level+3, "PCR PID: %04x", stc->pcr_pid);
  1791. + indent_printf(level+3, "Presentation Start: %u",
  1792. + stc->presentation_start_time);
  1793. + indent_printf(level+3, "Presentation End: %u",
  1794. + stc->presentation_end_time);
  1795. + }
  1796. + }
  1797. +}
  1798. +
  1799. +static void
  1800. +_show_prog_info(CLPI_PROG_INFO *pi, int level)
  1801. +{
  1802. + CLPI_PROG *prog;
  1803. + int ii, jj;
  1804. +
  1805. + indent_printf(level, "Program Info");
  1806. + indent_printf(level+1, "Number Programs: %d", pi->num_prog);
  1807. + for (ii = 0; ii < pi->num_prog; ii++) {
  1808. + prog = &pi->progs[ii];
  1809. + indent_printf(level+1, "Program %d", ii);
  1810. + indent_printf(level+2, "SPN Program Sequence Start: %d",
  1811. + prog->spn_program_sequence_start);
  1812. + indent_printf(level+2, "Program Map PID: %d", prog->program_map_pid);
  1813. + indent_printf(level+2, "Number Streams: %d", prog->num_streams);
  1814. + indent_printf(level+2, "Number Groups: %d", prog->num_groups);
  1815. + for (jj = 0; jj < prog->num_streams; jj++) {
  1816. + indent_printf(level+2, "Stream %d", jj);
  1817. + _show_stream(&prog->streams[jj], level+3);
  1818. + }
  1819. + }
  1820. +}
  1821. +
  1822. +static void
  1823. +_show_extent_start(CLPI_EXTENT_START *es, int level)
  1824. +{
  1825. + unsigned int ii;
  1826. +
  1827. + indent_printf(level, "Extension data: Extent Start Point");
  1828. +
  1829. + if (!es->num_point) {
  1830. + indent_printf(level+1, "(no data)");
  1831. +
  1832. + } else {
  1833. + indent_printf(level+1, "Number of Start Points: %d", es->num_point);
  1834. +
  1835. + if (verbose) {
  1836. + for (ii = 0; ii < es->num_point; ii++) {
  1837. + indent_printf(level+1, "Extent %5d: SPN 0x%08X", ii, es->point[ii]);
  1838. + }
  1839. + }
  1840. + }
  1841. +}
  1842. +
  1843. +static void
  1844. +_show_cpi_info(CLPI_CPI *cpi, int level)
  1845. +{
  1846. + CLPI_EP_MAP_ENTRY *entry;
  1847. + CLPI_EP_COARSE *coarse;
  1848. + CLPI_EP_FINE *fine;
  1849. + int ii, jj, kk;
  1850. +
  1851. + indent_printf(level, "CPI");
  1852. + indent_printf(level+1, "Number Stream PID: %d", cpi->num_stream_pid);
  1853. + for (ii = 0; ii < cpi->num_stream_pid; ii++) {
  1854. + entry = &cpi->entry[ii];
  1855. + indent_printf(level+1, "Stream: %d", ii);
  1856. + indent_printf(level+2, "PID: %04x", entry->pid);
  1857. + indent_printf(level+2, "EP Stream Type: %d", entry->ep_stream_type);
  1858. + indent_printf(level+2, "Number EP Coarse: %d", entry->num_ep_coarse);
  1859. + indent_printf(level+2, "Number EP Fine: %d", entry->num_ep_fine);
  1860. + indent_printf(level+2, "EP Map Start: %d",
  1861. + entry->ep_map_stream_start_addr);
  1862. + for (jj = 0; jj < entry->num_ep_coarse; jj++) {
  1863. + coarse = &entry->coarse[jj];
  1864. + indent_printf(level+2, "Coarse: %d", jj);
  1865. + indent_printf(level+3, "Ref EP Fine: %d", coarse->ref_ep_fine_id);
  1866. + indent_printf(level+3, "PTS EP: %d", coarse->pts_ep);
  1867. + indent_printf(level+3, "SPN EP: %d", coarse->spn_ep);
  1868. + }
  1869. + for (jj = 0; jj < entry->num_ep_fine; jj++) {
  1870. + fine = &entry->fine[jj];
  1871. + indent_printf(level+2, "Fine: %d", jj);
  1872. + indent_printf(level+3, "Angle Change Point: %s",
  1873. + fine->is_angle_change_point ? "True":"False");
  1874. + indent_printf(level+3, "I End Offset: %d",
  1875. + fine->i_end_position_offset);
  1876. + indent_printf(level+3, "PTS EP: %d", fine->pts_ep);
  1877. + indent_printf(level+3, "SPN EP: %d", fine->spn_ep);
  1878. + }
  1879. + if (verbose) {
  1880. + uint64_t pts;
  1881. + uint32_t spn;
  1882. +
  1883. + indent_printf(level+2, "PTS - SPN Map");
  1884. + for (jj = 0; jj < entry->num_ep_coarse; jj++) {
  1885. + int start, end;
  1886. +
  1887. + indent_printf(level+3, "Coarse: %d", jj);
  1888. + coarse = &entry->coarse[jj];
  1889. + start = coarse->ref_ep_fine_id;
  1890. + if (jj < entry->num_ep_coarse - 1) {
  1891. + end = entry->coarse[jj+1].ref_ep_fine_id;
  1892. + } else {
  1893. + end = entry->num_ep_fine;
  1894. + }
  1895. + for (kk = start; kk < end; kk++) {
  1896. + fine = &entry->fine[kk];
  1897. + pts = ((uint64_t) (coarse->pts_ep & ~0x01) << 19) +
  1898. + ((uint64_t)fine->pts_ep << 9);
  1899. + spn = (coarse->spn_ep & ~0x1FFFF) + fine->spn_ep;
  1900. + indent_printf(level+4, "PTS %8"PRIu64"/%8"PRIu64" -- SPN %u",
  1901. + pts, pts >> 1, spn);
  1902. + }
  1903. + }
  1904. + }
  1905. + }
  1906. +}
  1907. +
  1908. +
  1909. +static void
  1910. +_usage(char *cmd)
  1911. +{
  1912. + fprintf(stderr,
  1913. +"Usage: %s -vcspi <clpi file> [<clpi file> ...]\n"
  1914. +"With no options, produces no output (not very useful)\n"
  1915. +"Options:\n"
  1916. +" v - Verbose output.\n"
  1917. +" c - Shows the Clip Info structure\n"
  1918. +" s - Shows the Sequence Info structure\n"
  1919. +" p - Shows the Program Info structure\n"
  1920. +" i - Shows the CPI. PTS to SPN map\n"
  1921. +" e - Shows Extent Start Table\n"
  1922. +, cmd);
  1923. +
  1924. + exit(EXIT_FAILURE);
  1925. +}
  1926. +
  1927. +#define OPTS "vcspie"
  1928. +
  1929. +int
  1930. +main(int argc, char *argv[])
  1931. +{
  1932. + CLPI_CL *cl;
  1933. + int opt;
  1934. + int opt_clip_info = 0, opt_seq_info = 0, opt_prog_info = 0;
  1935. + int opt_cpi_info = 0, opt_extent_start = 0;
  1936. + int ii;
  1937. +
  1938. + do {
  1939. + opt = getopt(argc, argv, OPTS);
  1940. + switch (opt) {
  1941. + case -1: break;
  1942. +
  1943. + case 'v':
  1944. + verbose = 1;
  1945. + break;
  1946. +
  1947. + case 's':
  1948. + opt_seq_info = 1;
  1949. + break;
  1950. +
  1951. + case 'i':
  1952. + opt_cpi_info = 1;
  1953. + break;
  1954. +
  1955. + case 'c':
  1956. + opt_clip_info = 1;
  1957. + break;
  1958. +
  1959. + case 'p':
  1960. + opt_prog_info = 1;
  1961. + break;
  1962. +
  1963. + case 'e':
  1964. + opt_extent_start = 1;
  1965. + break;
  1966. +
  1967. + default:
  1968. + _usage(argv[0]);
  1969. + break;
  1970. + }
  1971. + } while (opt != -1);
  1972. +
  1973. + if (optind >= argc) {
  1974. + _usage(argv[0]);
  1975. + }
  1976. +
  1977. + for (ii = optind; ii < argc; ii++) {
  1978. + cl = bd_read_clpi(argv[ii]);
  1979. + if (cl == NULL) {
  1980. + fprintf(stderr, "Parsing %s failed\n", argv[ii]);
  1981. + continue;
  1982. + }
  1983. + if (opt_clip_info) {
  1984. + // Show clip info
  1985. + _show_clip_info(cl, 1);
  1986. + }
  1987. + if (opt_seq_info) {
  1988. + // Show sequence info
  1989. + _show_seq_info(&cl->sequence, 1);
  1990. + }
  1991. + if (opt_prog_info) {
  1992. + // Show program info
  1993. + _show_prog_info(&cl->program, 1);
  1994. + }
  1995. + if (opt_cpi_info) {
  1996. + // Show cpi
  1997. + _show_cpi_info(&cl->cpi, 1);
  1998. + }
  1999. +
  2000. + if (opt_prog_info) {
  2001. + if (cl->program_ss.num_prog) {
  2002. + printf("\n");
  2003. + indent_printf(1, "Extension: Program Info SS");
  2004. + _show_prog_info(&cl->program_ss, 1);
  2005. + }
  2006. + }
  2007. + if (opt_cpi_info) {
  2008. + if (cl->program_ss.num_prog) {
  2009. + printf("\n");
  2010. + indent_printf(1, "Extension: CPI SS");
  2011. + _show_cpi_info(&cl->cpi_ss, 1);
  2012. + }
  2013. + }
  2014. + if (opt_extent_start) {
  2015. + // Show extent start point
  2016. + if (cl->extent_start.num_point > 0) {
  2017. + _show_extent_start(&cl->extent_start, 1);
  2018. + }
  2019. + }
  2020. +
  2021. + bd_free_clpi(cl);
  2022. + }
  2023. + return 0;
  2024. +}
  2025. +
  2026. diff --git a/src/devtools/hdmv_test.c b/src/devtools/hdmv_test.c
  2027. new file mode 100644
  2028. index 0000000..585ed70
  2029. --- /dev/null
  2030. +++ b/src/devtools/hdmv_test.c
  2031. @@ -0,0 +1,257 @@
  2032. +/*
  2033. + * This file is part of libbluray
  2034. + * Copyright (C) 2010 hpi1
  2035. + *
  2036. + * This library is free software; you can redistribute it and/or
  2037. + * modify it under the terms of the GNU Lesser General Public
  2038. + * License as published by the Free Software Foundation; either
  2039. + * version 2.1 of the License, or (at your option) any later version.
  2040. + *
  2041. + * This library is distributed in the hope that it will be useful,
  2042. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2043. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  2044. + * Lesser General Public License for more details.
  2045. + *
  2046. + * You should have received a copy of the GNU Lesser General Public
  2047. + * License along with this library. If not, see
  2048. + * <http://www.gnu.org/licenses/>.
  2049. + */
  2050. +
  2051. +#include <stdio.h>
  2052. +#include <stdlib.h>
  2053. +#include <string.h>
  2054. +#include <inttypes.h>
  2055. +
  2056. +#include "util/log_control.h"
  2057. +#include "libbluray/bluray.h"
  2058. +
  2059. +static void _print_event(BD_EVENT *ev)
  2060. +{
  2061. + switch (ev->event) {
  2062. + case BD_EVENT_NONE:
  2063. + break;
  2064. + case BD_EVENT_ERROR:
  2065. + printf("EVENT_ERROR:\t%d\n", ev->param);
  2066. + break;
  2067. + case BD_EVENT_READ_ERROR:
  2068. + printf("EVENT_READ_ERROR:\t%d\n", ev->param);
  2069. + break;
  2070. + case BD_EVENT_ENCRYPTED:
  2071. + printf("EVENT_ENCRYPTED:\t%d\n", ev->param);
  2072. + break;
  2073. +
  2074. + /* current playback position */
  2075. +
  2076. + case BD_EVENT_ANGLE:
  2077. + printf("EVENT_ANGLE:\t%d\n", ev->param);
  2078. + break;
  2079. + case BD_EVENT_TITLE:
  2080. + printf("EVENT_TITLE:\t%d\n", ev->param);
  2081. + break;
  2082. + case BD_EVENT_PLAYLIST:
  2083. + printf("EVENT_PLAYLIST:\t%d\n", ev->param);
  2084. + break;
  2085. + case BD_EVENT_PLAYITEM:
  2086. + printf("EVENT_PLAYITEM:\t%d\n", ev->param);
  2087. + break;
  2088. + case BD_EVENT_CHAPTER:
  2089. + printf("EVENT_CHAPTER:\t%d\n", ev->param);
  2090. + break;
  2091. +
  2092. + /* */
  2093. +
  2094. + case BD_EVENT_STILL:
  2095. + printf("EVENT_STILL:\t%d\n", ev->param);
  2096. + break;
  2097. +
  2098. + case BD_EVENT_SEEK:
  2099. + printf("EVENT_SEEK:\t%d\n", ev->param);
  2100. + break;
  2101. +
  2102. + case BD_EVENT_STILL_TIME:
  2103. + if (ev->param) {
  2104. + printf("EVENT_STILL_TIME:\t%d\n", ev->param);
  2105. + } else {
  2106. + printf("EVENT_STILL_TIME:\tinfinite\n");
  2107. + }
  2108. + break;
  2109. +
  2110. + /* stream selection */
  2111. +
  2112. + case BD_EVENT_AUDIO_STREAM:
  2113. + printf("EVENT_AUDIO_STREAM:\t%d\n", ev->param);
  2114. + break;
  2115. + case BD_EVENT_IG_STREAM:
  2116. + printf("EVENT_IG_STREAM:\t%d\n", ev->param);
  2117. + break;
  2118. + case BD_EVENT_PG_TEXTST_STREAM:
  2119. + printf("EVENT_PG_TEXTST_STREAM:\t%d\n", ev->param);
  2120. + break;
  2121. + case BD_EVENT_SECONDARY_AUDIO_STREAM:
  2122. + printf("EVENT_SECONDARY_AUDIO_STREAM:\t%d\n", ev->param);
  2123. + break;
  2124. + case BD_EVENT_SECONDARY_VIDEO_STREAM:
  2125. + printf("EVENT_SECONDARY_VIDEO_STREAM:\t%d\n", ev->param);
  2126. + break;
  2127. +
  2128. + case BD_EVENT_PG_TEXTST:
  2129. + printf("EVENT_PG_TEXTST:\t%s\n", ev->param ? "enable" : "disable");
  2130. + break;
  2131. + case BD_EVENT_SECONDARY_AUDIO:
  2132. + printf("EVENT_SECONDARY_AUDIO:\t%s\n", ev->param ? "enable" : "disable");
  2133. + break;
  2134. + case BD_EVENT_SECONDARY_VIDEO:
  2135. + printf("EVENT_SECONDARY_VIDEO:\t%s\n", ev->param ? "enable" : "disable");
  2136. + break;
  2137. + case BD_EVENT_SECONDARY_VIDEO_SIZE:
  2138. + printf("EVENT_SECONDARY_VIDEO_SIZE:\t%s\n", ev->param==0 ? "PIP" : "fullscreen");
  2139. + break;
  2140. +
  2141. + default:
  2142. + printf("UNKNOWN EVENT %d:\t%d\n", ev->event, ev->param);
  2143. + break;
  2144. + }
  2145. +
  2146. + fflush(stdout);
  2147. +}
  2148. +
  2149. +static void _read_to_eof(BLURAY *bd)
  2150. +{
  2151. + BD_EVENT ev;
  2152. + int bytes;
  2153. + uint64_t total = 0;
  2154. + uint8_t buf[6144];
  2155. +
  2156. + bd_seek(bd, bd_get_title_size(bd) - 6144);
  2157. +
  2158. + do {
  2159. + bytes = bd_read_ext(bd, buf, 6144, &ev);
  2160. + total += bytes < 0 ? 0 : bytes;
  2161. + _print_event(&ev);
  2162. + } while (bytes > 0);
  2163. +
  2164. + printf("_read_to_eof(): read %"PRIu64" bytes\n", total);
  2165. +}
  2166. +
  2167. +static void _print_events(BLURAY *bd)
  2168. +{
  2169. + BD_EVENT ev;
  2170. +
  2171. + do {
  2172. + bd_read_ext(bd, NULL, 0, &ev);
  2173. + _print_event(&ev);
  2174. + } while (ev.event != BD_EVENT_NONE && ev.event != BD_EVENT_ERROR);
  2175. +}
  2176. +
  2177. +static void _play_pl(BLURAY *bd)
  2178. +{
  2179. + printf("Playing playlist\n");
  2180. +
  2181. + fflush(stdout);
  2182. + _read_to_eof(bd);
  2183. +
  2184. + printf("Playing playlist done\n\n");
  2185. +
  2186. + _print_events(bd);
  2187. +
  2188. + printf("\n");
  2189. +}
  2190. +
  2191. +int main(int argc, char *argv[])
  2192. +{
  2193. + int title = -1;
  2194. + int verbose = 0;
  2195. + int args = 0;
  2196. +
  2197. + /*
  2198. + * parse arguments
  2199. + */
  2200. +
  2201. + if (argc < 2) {
  2202. + printf("\nUsage:\n %s [-v] [-t <title>] <media_path> [<keyfile_path>]\n\n", argv[0]);
  2203. + return -1;
  2204. + }
  2205. +
  2206. + if (!strcmp(argv[1+args], "-v")) {
  2207. + verbose = 1;
  2208. + args++;
  2209. + }
  2210. +
  2211. + if (!strcmp(argv[1+args], "-t")) {
  2212. + args++;
  2213. + title = atoi(argv[1+args]);
  2214. + args++;
  2215. + printf("Requested title %d\n", title);
  2216. + }
  2217. +
  2218. + if (verbose) {
  2219. + printf("Enabling verbose debug\n");
  2220. + bd_set_debug_mask(bd_get_debug_mask() | DBG_HDMV | DBG_BLURAY);
  2221. + }
  2222. +
  2223. + printf("\n");
  2224. +
  2225. + /*
  2226. + * open and setup
  2227. + */
  2228. +
  2229. + BLURAY *bd = bd_open(argv[1+args], argv[2+args]);
  2230. +
  2231. + if (!bd) {
  2232. + printf("bd_open(\'%s\') failed\n", argv[1]);
  2233. + return -1;
  2234. + }
  2235. +
  2236. + bd_set_player_setting (bd, BLURAY_PLAYER_SETTING_PARENTAL, 99);
  2237. + bd_set_player_setting_str(bd, BLURAY_PLAYER_SETTING_AUDIO_LANG, "eng");
  2238. + bd_set_player_setting_str(bd, BLURAY_PLAYER_SETTING_PG_LANG, "eng");
  2239. + bd_set_player_setting_str(bd, BLURAY_PLAYER_SETTING_MENU_LANG, "eng");
  2240. + bd_set_player_setting_str(bd, BLURAY_PLAYER_SETTING_COUNTRY_CODE, NULL);
  2241. +
  2242. + /*
  2243. + * play
  2244. + */
  2245. +
  2246. + printf("Running first play movie object\n");
  2247. +
  2248. + fflush(stdout);
  2249. + bd_play(bd);
  2250. +
  2251. + _print_events(bd);
  2252. +
  2253. + printf("\n");
  2254. +
  2255. + /*
  2256. + * play title
  2257. + */
  2258. +
  2259. + if (title >= 0) {
  2260. + printf("Playing title %d\n", title);
  2261. +
  2262. + fflush(stdout);
  2263. + bd_play_title(bd, title);
  2264. +
  2265. + _print_events(bd);
  2266. +
  2267. + printf("\n");
  2268. + }
  2269. +
  2270. + /*
  2271. + * play playlist
  2272. + */
  2273. +
  2274. + _play_pl(bd);
  2275. +
  2276. + _play_pl(bd);
  2277. +
  2278. + _play_pl(bd);
  2279. +
  2280. + /*
  2281. + * clean up
  2282. + */
  2283. +
  2284. + bd_close(bd);
  2285. +
  2286. + return 0;
  2287. +}
  2288. +
  2289. diff --git a/src/devtools/mobj_dump.c b/src/devtools/mobj_dump.c
  2290. new file mode 100644
  2291. index 0000000..3eaf9f4
  2292. --- /dev/null
  2293. +++ b/src/devtools/mobj_dump.c
  2294. @@ -0,0 +1,83 @@
  2295. +/*
  2296. + * This file is part of libbluray
  2297. + * Copyright (C) 2010 hpi1
  2298. + *
  2299. + * This library is free software; you can redistribute it and/or
  2300. + * modify it under the terms of the GNU Lesser General Public
  2301. + * License as published by the Free Software Foundation; either
  2302. + * version 2.1 of the License, or (at your option) any later version.
  2303. + *
  2304. + * This library is distributed in the hope that it will be useful,
  2305. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2306. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  2307. + * Lesser General Public License for more details.
  2308. + *
  2309. + * You should have received a copy of the GNU Lesser General Public
  2310. + * License along with this library. If not, see
  2311. + * <http://www.gnu.org/licenses/>.
  2312. + */
  2313. +
  2314. +#include "libbluray/bluray.h"
  2315. +
  2316. +#include "libbluray/hdmv/mobj_data.h"
  2317. +#include "libbluray/hdmv/mobj_print.h"
  2318. +
  2319. +#include <stdio.h>
  2320. +#include <string.h>
  2321. +
  2322. +static void _mobj_print(MOBJ_OBJECTS *objects, int disasm)
  2323. +{
  2324. + int o, c;
  2325. +
  2326. + printf("Number of objects: %d\n", objects->num_objects);
  2327. +
  2328. + for (o = 0; o < objects->num_objects; o++) {
  2329. +
  2330. + printf("Object %d:\n"
  2331. + " number of commands: %d\n"
  2332. + " resume intention flag: %d\n"
  2333. + " menu call mask: %d\n"
  2334. + " title search mask: %d\n",
  2335. + o, objects->objects[o].num_cmds,
  2336. + objects->objects[o].resume_intention_flag,
  2337. + objects->objects[o].menu_call_mask,
  2338. + objects->objects[o].title_search_mask);
  2339. +
  2340. + if (disasm) {
  2341. + printf(" program:\n");
  2342. + for (c = 0; c < objects->objects[o].num_cmds; c++) {
  2343. + char buf[256];
  2344. + mobj_sprint_cmd(buf, &objects->objects[o].cmds[c]);
  2345. + printf(" %04d: %s\n", c, buf);
  2346. + }
  2347. + }
  2348. + }
  2349. +}
  2350. +
  2351. +int main(int argc, const char *argv[])
  2352. +{
  2353. + int disasm = 0;
  2354. + MOBJ_OBJECTS *mobj = NULL;
  2355. +
  2356. + if (argc < 2) {
  2357. + fprintf(stderr,
  2358. + "usage: %s [-d] <file>\n"
  2359. + "Options:\n"
  2360. + " d disassemble object code\n",
  2361. + argv[0]);
  2362. + return 1;
  2363. + }
  2364. + if (argc > 2) {
  2365. + disasm = !strcmp(argv[1], "-d");
  2366. + }
  2367. +
  2368. + mobj = bd_read_mobj(argv[argc-1]);
  2369. +
  2370. + if (mobj) {
  2371. + _mobj_print(mobj, disasm);
  2372. +
  2373. + bd_free_mobj(mobj);
  2374. + }
  2375. +
  2376. + return 0;
  2377. +}
  2378. diff --git a/src/devtools/mpls_dump.c b/src/devtools/mpls_dump.c
  2379. new file mode 100644
  2380. index 0000000..405b6a1
  2381. --- /dev/null
  2382. +++ b/src/devtools/mpls_dump.c
  2383. @@ -0,0 +1,799 @@
  2384. +/*
  2385. + * This file is part of libbluray
  2386. + * Copyright (C) 2009-2010 John Stebbins
  2387. + *
  2388. + * This library is free software; you can redistribute it and/or
  2389. + * modify it under the terms of the GNU Lesser General Public
  2390. + * License as published by the Free Software Foundation; either
  2391. + * version 2.1 of the License, or (at your option) any later version.
  2392. + *
  2393. + * This library is distributed in the hope that it will be useful,
  2394. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  2395. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  2396. + * Lesser General Public License for more details.
  2397. + *
  2398. + * You should have received a copy of the GNU Lesser General Public
  2399. + * License along with this library. If not, see
  2400. + * <http://www.gnu.org/licenses/>.
  2401. + */
  2402. +
  2403. +#include <sys/stat.h>
  2404. +#include <dirent.h>
  2405. +#include <stdio.h>
  2406. +#include <stdlib.h>
  2407. +#include <unistd.h>
  2408. +#include <string.h>
  2409. +#include <libgen.h>
  2410. +
  2411. +#include "libbluray/bdnav/mpls_parse.h"
  2412. +#include "libbluray/bluray.h"
  2413. +
  2414. +#include "util.h"
  2415. +
  2416. +#ifdef _WIN32
  2417. +# define DIR_SEP "\\"
  2418. +# define PLAYLIST_DIR "\\BDMV\\PLAYLIST"
  2419. +#else
  2420. +# define DIR_SEP "/"
  2421. +# define PLAYLIST_DIR "/BDMV/PLAYLIST"
  2422. +#endif
  2423. +
  2424. +
  2425. +static int verbose;
  2426. +
  2427. +typedef struct {
  2428. + int value;
  2429. + const char *str;
  2430. +} VALUE_MAP;
  2431. +
  2432. +const VALUE_MAP codec_map[] = {
  2433. + {0x01, "MPEG-1 Video"},
  2434. + {0x02, "MPEG-2 Video"},
  2435. + {0x03, "MPEG-1 Audio"},
  2436. + {0x04, "MPEG-2 Audio"},
  2437. + {0x80, "LPCM"},
  2438. + {0x81, "AC-3"},
  2439. + {0x82, "DTS"},
  2440. + {0x83, "TrueHD"},
  2441. + {0x84, "AC-3 Plus"},
  2442. + {0x85, "DTS-HD"},
  2443. + {0x86, "DTS-HD Master"},
  2444. + {0xa1, "AC-3 Plus for secondary audio"},
  2445. + {0xa2, "DTS-HD for secondary audio"},
  2446. + {0xea, "VC-1"},
  2447. + {0x1b, "H.264"},
  2448. + {0x90, "Presentation Graphics"},
  2449. + {0x91, "Interactive Graphics"},
  2450. + {0x92, "Text Subtitle"},
  2451. + {0, NULL}
  2452. +};
  2453. +
  2454. +const VALUE_MAP video_format_map[] = {
  2455. + {0, "Reserved"},
  2456. + {1, "480i"},
  2457. + {2, "576i"},
  2458. + {3, "480p"},
  2459. + {4, "1080i"},
  2460. + {5, "720p"},
  2461. + {6, "1080p"},
  2462. + {7, "576p"},
  2463. + {0, NULL}
  2464. +};
  2465. +
  2466. +const VALUE_MAP video_rate_map[] = {
  2467. + {0, "Reserved1"},
  2468. + {1, "23.976"},
  2469. + {2, "24"},
  2470. + {3, "25"},
  2471. + {4, "29.97"},
  2472. + {5, "Reserved2"},
  2473. + {6, "50"},
  2474. + {7, "59.94"},
  2475. + {0, NULL}
  2476. +};
  2477. +
  2478. +const VALUE_MAP audio_format_map[] = {
  2479. + {0, "Reserved1"},
  2480. + {1, "Mono"},
  2481. + {2, "Reserved2"},
  2482. + {3, "Stereo"},
  2483. + {4, "Reserved3"},
  2484. + {5, "Reserved4"},
  2485. + {6, "Multi Channel"},
  2486. + {12, "Combo"},
  2487. + {0, NULL}
  2488. +};
  2489. +
  2490. +const VALUE_MAP audio_rate_map[] = {
  2491. + {0, "Reserved1"},
  2492. + {1, "48 Khz"},
  2493. + {2, "Reserved2"},
  2494. + {3, "Reserved3"},
  2495. + {4, "96 Khz"},
  2496. + {5, "192 Khz"},
  2497. + {12, "48/192 Khz"},
  2498. + {14, "48/96 Khz"},
  2499. + {0, NULL}
  2500. +};
  2501. +
  2502. +const VALUE_MAP subpath_type_map[] = {
  2503. + {2, "Primary audio of the Browsable slideshow"},
  2504. + {3, "Interactive Graphics presentation menu"},
  2505. + {4, "Text Subtitle"},
  2506. + {5, "Out-of-mux Synchronous elementary streams"},
  2507. + {6, "Out-of-mux Asynchronous Picture-in-Picture presentation"},
  2508. + {7, "In-mux Synchronous Picture-in-Picture presentation"},
  2509. + {8, "SS Video"},
  2510. + {0,NULL}
  2511. +};
  2512. +
  2513. +const VALUE_MAP playback_type_map[] = {
  2514. + {1, "Sequential"},
  2515. + {2, "Random"},
  2516. + {3, "Shuffle"},
  2517. + {0, NULL}
  2518. +};
  2519. +
  2520. +const VALUE_MAP connection_type_map[] = {
  2521. + {1, "Non-seamless"},
  2522. + {5, "Seamless"},
  2523. + {6, "Seamless"},
  2524. + {0, NULL}
  2525. +};
  2526. +
  2527. +static const char*
  2528. +_lookup_str(const VALUE_MAP *map, int val)
  2529. +{
  2530. + int ii;
  2531. +
  2532. + for (ii = 0; map[ii].str; ii++) {
  2533. + if (val == map[ii].value) {
  2534. + return map[ii].str;
  2535. + }
  2536. + }
  2537. + return "?";
  2538. +}
  2539. +
  2540. +static char *
  2541. +_mk_path(const char *base, const char *sub)
  2542. +{
  2543. + size_t n1 = strlen(base);
  2544. + size_t n2 = strlen(sub);
  2545. + char *result = (char*)malloc(n1 + n2 + strlen(DIR_SEP) + 1);
  2546. + strcpy(result, base);
  2547. + strcat(result, DIR_SEP);
  2548. + strcat(result, sub);
  2549. +
  2550. + return result;
  2551. +}
  2552. +
  2553. +static void
  2554. +_show_stream(MPLS_STREAM *ss, int level)
  2555. +{
  2556. + indent_printf(level, "Codec (%04x): %s", ss->coding_type,
  2557. + _lookup_str(codec_map, ss->coding_type));
  2558. + switch (ss->stream_type) {
  2559. + case 1:
  2560. + indent_printf(level, "PID: %04x", ss->pid);
  2561. + break;
  2562. +
  2563. + case 2:
  2564. + case 4:
  2565. + indent_printf(level, "SubPath Id: %02x", ss->subpath_id);
  2566. + indent_printf(level, "SubClip Id: %02x", ss->subclip_id);
  2567. + indent_printf(level, "PID: %04x", ss->pid);
  2568. + break;
  2569. +
  2570. + case 3:
  2571. + indent_printf(level, "SubPath Id: %02x", ss->subpath_id);
  2572. + indent_printf(level, "PID: %04x", ss->pid);
  2573. + break;
  2574. +
  2575. + default:
  2576. + fprintf(stderr, "unrecognized stream type %02x\n", ss->stream_type);
  2577. + break;
  2578. + };
  2579. +
  2580. + switch (ss->coding_type) {
  2581. + case 0x01:
  2582. + case 0x02:
  2583. + case 0xea:
  2584. + case 0x1b:
  2585. + indent_printf(level, "Format %02x: %s", ss->format,
  2586. + _lookup_str(video_format_map, ss->format));
  2587. + indent_printf(level, "Rate %02x: %s", ss->rate,
  2588. + _lookup_str(video_rate_map, ss->rate));
  2589. + break;
  2590. +
  2591. + case 0x03:
  2592. + case 0x04:
  2593. + case 0x80:
  2594. + case 0x81:
  2595. + case 0x82:
  2596. + case 0x83:
  2597. + case 0x84:
  2598. + case 0x85:
  2599. + case 0x86:
  2600. + case 0xa1:
  2601. + case 0xa2:
  2602. + indent_printf(level, "Format %02x: %s", ss->format,
  2603. + _lookup_str(audio_format_map, ss->format));
  2604. + indent_printf(level, "Rate %02x: %s", ss->rate,
  2605. + _lookup_str(audio_rate_map, ss->rate));
  2606. + indent_printf(level, "Language: %s", ss->lang);
  2607. + break;
  2608. +
  2609. + case 0x90:
  2610. + case 0x91:
  2611. + indent_printf(level, "Language: %s", ss->lang);
  2612. + break;
  2613. +
  2614. + case 0x92:
  2615. + indent_printf(level, "Char Code: %02x", ss->char_code);
  2616. + indent_printf(level, "Language: %s", ss->lang);
  2617. + break;
  2618. +
  2619. + default:
  2620. + fprintf(stderr, "unrecognized coding type %02x\n", ss->coding_type);
  2621. + break;
  2622. + };
  2623. +}
  2624. +
  2625. +static void
  2626. +_show_details(MPLS_PL *pl, int level)
  2627. +{
  2628. + int ii, jj, kk;
  2629. +
  2630. + for (ii = 0; ii < pl->list_count; ii++) {
  2631. + MPLS_PI *pi;
  2632. +
  2633. + pi = &pl->play_item[ii];
  2634. + indent_printf(level, "Clip Id %s", pi->clip[0].clip_id);
  2635. + indent_printf(level+1, "Stc Id: %02x", pi->clip[0].stc_id);
  2636. + indent_printf(level+1, "Connection Condition: %s (%02x)",
  2637. + _lookup_str(connection_type_map, pi->connection_condition),
  2638. + pi->connection_condition);
  2639. + indent_printf(level+1, "In-Time: %d", pi->in_time);
  2640. + indent_printf(level+1, "Out-Time: %d", pi->out_time);
  2641. + if (pi->still_mode == 1) {
  2642. + indent_printf(level+1, "Still time: %ds\n", pi->still_time);
  2643. + }
  2644. + if (pi->still_mode == 2) {
  2645. + indent_printf(level+1, "Still time: infinite\n");
  2646. + }
  2647. + if (pi->angle_count > 1) {
  2648. + for (jj = 1; jj < pi->angle_count; jj++) {
  2649. + indent_printf(level+1, "Angle %d:", jj);
  2650. + indent_printf(level+2, "Clip Id %s", pi->clip[jj].clip_id);
  2651. + indent_printf(level+2, "Stc Id: %02x", pi->clip[jj].stc_id);
  2652. + }
  2653. + }
  2654. + for (jj = 0; jj < pi->stn.num_video; jj++) {
  2655. + indent_printf(level+1, "Video Stream %d:", jj);
  2656. + _show_stream(&pi->stn.video[jj], level + 2);
  2657. + }
  2658. + for (jj = 0; jj < pi->stn.num_audio; jj++) {
  2659. + indent_printf(level+1, "Audio Stream %d:", jj);
  2660. + _show_stream(&pi->stn.audio[jj], level + 2);
  2661. + }
  2662. + for (jj = 0; jj < pi->stn.num_ig; jj++) {
  2663. + indent_printf(level+1, "Interactive Graphics Stream %d:", jj);
  2664. + _show_stream(&pi->stn.ig[jj], level + 2);
  2665. + }
  2666. + for (jj = 0; jj < (pi->stn.num_pg + pi->stn.num_pip_pg); jj++) {
  2667. + if (jj < pi->stn.num_pg) {
  2668. + indent_printf(level+1, "Presentation Graphics Stream %d:", jj);
  2669. + } else {
  2670. + indent_printf(level+1, "PIP Presentation Graphics Stream %d:", jj);
  2671. + }
  2672. + _show_stream(&pi->stn.pg[jj], level + 2);
  2673. + }
  2674. + for (jj = 0; jj < pi->stn.num_secondary_video; jj++) {
  2675. + indent_printf(level+1, "Secondary Video Stream %d:", jj);
  2676. + _show_stream(&pi->stn.secondary_video[jj], level + 2);
  2677. + for (kk = 0; kk < pi->stn.secondary_video[jj].sv_num_secondary_audio_ref; kk++) {
  2678. + indent_printf(level+2, "Secondary Audio Ref %d: %d", kk,pi->stn.secondary_video[jj].sv_secondary_audio_ref[kk]);
  2679. + }
  2680. + for (kk = 0; kk < pi->stn.secondary_video[jj].sv_num_pip_pg_ref; kk++) {
  2681. + indent_printf(level+2, "PIP Presentation Graphic Ref %d: %d", kk,pi->stn.secondary_video[jj].sv_pip_pg_ref[kk]);
  2682. + }
  2683. + }
  2684. + for (jj = 0; jj < pi->stn.num_secondary_audio; jj++) {
  2685. + indent_printf(level+1, "Secondary Audio Stream %d:", jj);
  2686. + _show_stream(&pi->stn.secondary_audio[jj], level + 2);
  2687. + for (kk = 0; kk < pi->stn.secondary_audio[jj].sa_num_primary_audio_ref; kk++) {
  2688. + indent_printf(level+2, "Primary Audio Ref %d: %d", kk,pi->stn.secondary_audio[jj].sa_primary_audio_ref[kk]);
  2689. + }
  2690. + }
  2691. + printf("\n");
  2692. + }
  2693. +}
  2694. +
  2695. +static void
  2696. +_show_ai(MPLS_PL *pl, int level)
  2697. +{
  2698. + indent_printf(level, "Playback type: %s (%d)",
  2699. + _lookup_str(playback_type_map, pl->app_info.playback_type),
  2700. + pl->app_info.playback_type);
  2701. + if (pl->app_info.playback_type == 2 || pl->app_info.playback_type == 3) {
  2702. + indent_printf(level+1, "Playback count: %d", pl->app_info.playback_count);
  2703. + }
  2704. +}
  2705. +
  2706. +static void
  2707. +_show_marks(MPLS_PL *pl, int level)
  2708. +{
  2709. + int ii;
  2710. +
  2711. + indent_printf(level, "PlayMark Count %d", pl->mark_count);
  2712. + for (ii = 0; ii < pl->mark_count; ii++) {
  2713. + MPLS_PI *pi;
  2714. + MPLS_PLM *plm;
  2715. + int min;
  2716. + double sec;
  2717. +
  2718. + plm = &pl->play_mark[ii];
  2719. + indent_printf(level, "PlayMark %d", ii);
  2720. + indent_printf(level+1, "Type: %02x", plm->mark_type);
  2721. + if (plm->play_item_ref < pl->list_count) {
  2722. + pi = &pl->play_item[plm->play_item_ref];
  2723. + indent_printf(level+1, "PlayItem: %s", pi->clip[0].clip_id);
  2724. + } else {
  2725. + indent_printf(level+1, "PlayItem: Invalid reference");
  2726. + }
  2727. + indent_printf(level+1, "Time (ticks): %u", plm->time);
  2728. + min = plm->duration / (45000*60);
  2729. + sec = (double)(plm->duration - min * 45000 * 60) / 45000;
  2730. + indent_printf(level+1, "Duration (mm:ss.ms, ticks): %d:%.2f, %u",
  2731. + min, sec, plm->duration);
  2732. + printf("\n");
  2733. + }
  2734. +}
  2735. +
  2736. +static void
  2737. +_show_clip_list(MPLS_PL *pl, int level)
  2738. +{
  2739. + int ii, jj;
  2740. +
  2741. + for (ii = 0; ii < pl->list_count; ii++) {
  2742. + MPLS_PI *pi;
  2743. +
  2744. + pi = &pl->play_item[ii];
  2745. + if (verbose) {
  2746. + uint32_t duration;
  2747. +
  2748. + duration = pi->out_time - pi->in_time;
  2749. + indent_printf(level, "%s.m2ts -- Duration: %3d:%02d",
  2750. + pi->clip[0].clip_id,
  2751. + duration / (45000 * 60), (duration / 45000) % 60);
  2752. + } else {
  2753. + indent_printf(level, "%s.m2ts", pi->clip[0].clip_id);
  2754. + }
  2755. + if (pi->angle_count > 1) {
  2756. + for (jj = 1; jj < pi->angle_count; jj++) {
  2757. + indent_printf(level+1, "Angle %d: %s.m2ts", jj+1, pi->clip[jj].clip_id);
  2758. + }
  2759. + }
  2760. + }
  2761. + printf("\n");
  2762. +}
  2763. +
  2764. +static void
  2765. +_show_sub_path(MPLS_SUB *sub, int level)
  2766. +{
  2767. + int ii;
  2768. +
  2769. + indent_printf(level+1, "Type: %d (%s)", sub->type, _lookup_str(subpath_type_map, sub->type));
  2770. + indent_printf(level+1, "Repeat: %d", sub->is_repeat);
  2771. + indent_printf(level+1, "Sub playitem count: %d", sub->sub_playitem_count);
  2772. +
  2773. + for (ii = 0; ii < sub->sub_playitem_count; ii++) {
  2774. + MPLS_SUB_PI *pi;
  2775. +
  2776. + pi = &sub->sub_play_item[ii];
  2777. +
  2778. + if (verbose) {
  2779. + indent_printf(level+1, "Sub playitem %d", ii);
  2780. + indent_printf(level+2, "Clip Id %s", pi->clip[0].clip_id);
  2781. + indent_printf(level+2, "Multi clip: %d", pi->is_multi_clip);
  2782. + indent_printf(level+2, "Clip count: %d", pi->clip_count);
  2783. + indent_printf(level+2, "Connection Condition: %s (%02x)",
  2784. + _lookup_str(connection_type_map, pi->connection_condition),
  2785. + pi->connection_condition);
  2786. + indent_printf(level+2, "In-Time: %d", pi->in_time);
  2787. + indent_printf(level+2, "Out-Time: %d", pi->out_time);
  2788. + indent_printf(level+2, "Sync playitem Id: %d", pi->sync_play_item_id);
  2789. + indent_printf(level+2, "Sync PTS: %d", pi->sync_pts);
  2790. + } else {
  2791. + indent_printf(level+1, "%s.m2ts", pi->clip[0].clip_id);
  2792. + }
  2793. + }
  2794. +}
  2795. +
  2796. +static void
  2797. +_show_pip_metadata_block(MPLS_PIP_METADATA *block, int level)
  2798. +{
  2799. + int ii;
  2800. +
  2801. + indent_printf(level, "Clip ref: %d", block->clip_ref);
  2802. + indent_printf(level, "Secondary video ref: %d", block->secondary_video_ref);
  2803. + indent_printf(level, "Timeline type: %d", block->timeline_type);
  2804. + indent_printf(level, "Luma key flag: %d", block->luma_key_flag);
  2805. + if (block->luma_key_flag) {
  2806. + indent_printf(level, "Upper limit luma key: %d", block->upper_limit_luma_key);
  2807. + }
  2808. + indent_printf(level, "Trick play flag: %d", block->trick_play_flag);
  2809. +
  2810. + for (ii = 0; ii < block->data_count; ii++) {
  2811. + indent_printf(level, "data block %d:", ii);
  2812. + indent_printf(level+1, "Timestamp: %d", block->data[ii].time);
  2813. + indent_printf(level+1, "Horizontal position %d", block->data[ii].xpos);
  2814. + indent_printf(level+1, "Vertical position: %d", block->data[ii].ypos);
  2815. + indent_printf(level+1, "Scaling factor: %d", block->data[ii].scale_factor);
  2816. + }
  2817. +}
  2818. +
  2819. +static void
  2820. +_show_pip_metadata(MPLS_PL *pl, int level)
  2821. +{
  2822. + int ii;
  2823. +
  2824. + for (ii = 0; ii < pl->ext_pip_data_count; ii++) {
  2825. + MPLS_PIP_METADATA *data;
  2826. +
  2827. + data = &pl->ext_pip_data[ii];
  2828. +
  2829. + indent_printf(level, "PiP metadata block %d:", ii);
  2830. + _show_pip_metadata_block(data, level+1);
  2831. + }
  2832. +}
  2833. +
  2834. +static void
  2835. +_show_sub_paths(MPLS_PL *pl, int level)
  2836. +{
  2837. + int ss;
  2838. +
  2839. + for (ss = 0; ss < pl->sub_count; ss++) {
  2840. + MPLS_SUB *sub;
  2841. +
  2842. + sub = &pl->sub_path[ss];
  2843. +
  2844. + indent_printf(level, "Sub Path %d:", ss);
  2845. + _show_sub_path(sub, level+1);
  2846. + }
  2847. +}
  2848. +
  2849. +static void
  2850. +_show_sub_paths_ss(MPLS_PL *pl, int level)
  2851. +{
  2852. + int ss;
  2853. +
  2854. + for (ss = 0; ss < pl->ext_sub_count; ss++) {
  2855. + MPLS_SUB *sub;
  2856. +
  2857. + sub = &pl->ext_sub_path[ss];
  2858. +
  2859. + indent_printf(level, "Extension Sub Path %d:", ss);
  2860. + _show_sub_path(sub, level+1);
  2861. + }
  2862. +}
  2863. +
  2864. +static uint32_t
  2865. +_pl_duration(MPLS_PL *pl)
  2866. +{
  2867. + int ii;
  2868. + uint32_t duration = 0;
  2869. + MPLS_PI *pi;
  2870. +
  2871. + for (ii = 0; ii < pl->list_count; ii++) {
  2872. + pi = &pl->play_item[ii];
  2873. + duration += pi->out_time - pi->in_time;
  2874. + }
  2875. + return duration;
  2876. +}
  2877. +
  2878. +static int
  2879. +_filter_dup(MPLS_PL *pl_list[], int count, MPLS_PL *pl)
  2880. +{
  2881. + int ii, jj;
  2882. +
  2883. + for (ii = 0; ii < count; ii++) {
  2884. + if (pl->list_count != pl_list[ii]->list_count ||
  2885. + _pl_duration(pl) != _pl_duration(pl_list[ii])) {
  2886. + continue;
  2887. + }
  2888. + for (jj = 0; jj < pl->list_count; jj++) {
  2889. + MPLS_PI *pi1, *pi2;
  2890. +
  2891. + pi1 = &pl->play_item[jj];
  2892. + pi2 = &pl_list[ii]->play_item[jj];
  2893. +
  2894. + if (memcmp(pi1->clip[0].clip_id, pi2->clip[0].clip_id, 5) != 0 ||
  2895. + pi1->in_time != pi2->in_time ||
  2896. + pi1->out_time != pi2->out_time) {
  2897. + break;
  2898. + }
  2899. + }
  2900. + if (jj != pl->list_count) {
  2901. + continue;
  2902. + }
  2903. + return 0;
  2904. + }
  2905. + return 1;
  2906. +}
  2907. +
  2908. +static int
  2909. +_find_repeats(MPLS_PL *pl, const char *m2ts)
  2910. +{
  2911. + int ii, count = 0;
  2912. +
  2913. + for (ii = 0; ii < pl->list_count; ii++) {
  2914. + MPLS_PI *pi;
  2915. +
  2916. + pi = &pl->play_item[ii];
  2917. + // Ignore titles with repeated segments
  2918. + if (strcmp(pi->clip[0].clip_id, m2ts) == 0) {
  2919. + count++;
  2920. + }
  2921. + }
  2922. + return count;
  2923. +}
  2924. +
  2925. +static int
  2926. +_filter_short(MPLS_PL *pl, unsigned int seconds)
  2927. +{
  2928. + // Ignore short playlists
  2929. + if (_pl_duration(pl) / 45000 <= seconds) {
  2930. + return 0;
  2931. + }
  2932. + return 1;
  2933. +}
  2934. +
  2935. +static int
  2936. +_filter_repeats(MPLS_PL *pl, int repeats)
  2937. +{
  2938. + int ii;
  2939. +
  2940. + for (ii = 0; ii < pl->list_count; ii++) {
  2941. + MPLS_PI *pi;
  2942. +
  2943. + pi = &pl->play_item[ii];
  2944. + // Ignore titles with repeated segments
  2945. + if (_find_repeats(pl, pi->clip[0].clip_id) > repeats) {
  2946. + return 0;
  2947. + }
  2948. + }
  2949. + return 1;
  2950. +}
  2951. +
  2952. +static int clip_list = 0, playlist_info = 0, chapter_marks = 0, sub_paths = 0, pip_metadata = 0;
  2953. +static int repeats = 0, seconds = 0, dups = 0;
  2954. +
  2955. +static MPLS_PL*
  2956. +_process_file(char *name, MPLS_PL *pl_list[], int pl_count)
  2957. +{
  2958. + MPLS_PL *pl;
  2959. +
  2960. + pl = bd_read_mpls(name);
  2961. + if (pl == NULL) {
  2962. + fprintf(stderr, "Parse failed: %s\n", name);
  2963. + return NULL;
  2964. + }
  2965. + if (seconds) {
  2966. + if (!_filter_short(pl, seconds)) {
  2967. + bd_free_mpls(pl);
  2968. + return NULL;
  2969. + }
  2970. + }
  2971. + if (repeats) {
  2972. + if (!_filter_repeats(pl, repeats)) {
  2973. + bd_free_mpls(pl);
  2974. + return NULL;
  2975. + }
  2976. + }
  2977. + if (dups) {
  2978. + if (!_filter_dup(pl_list, pl_count, pl)) {
  2979. + bd_free_mpls(pl);
  2980. + return NULL;
  2981. + }
  2982. + }
  2983. + if (verbose) {
  2984. + indent_printf(0,
  2985. + "%s -- Num Clips: %3d , Duration: minutes %4u:%02u",
  2986. + basename(name),
  2987. + pl->list_count,
  2988. + _pl_duration(pl) / (45000 * 60),
  2989. + (_pl_duration(pl) / 45000) % 60);
  2990. + _show_ai(pl, 1);
  2991. + } else {
  2992. + indent_printf(0, "%s -- Duration: minutes %4u:%02u",
  2993. + basename(name),
  2994. + _pl_duration(pl) / (45000 * 60),
  2995. + (_pl_duration(pl) / 45000) % 60);
  2996. + }
  2997. + if (playlist_info) {
  2998. + _show_details(pl, 1);
  2999. + }
  3000. + if (chapter_marks) {
  3001. + _show_marks(pl, 1);
  3002. + }
  3003. + if (pip_metadata) {
  3004. + _show_pip_metadata(pl, 1);
  3005. + }
  3006. + if (clip_list) {
  3007. + _show_clip_list(pl, 1);
  3008. + }
  3009. + if (sub_paths) {
  3010. + _show_sub_paths(pl, 1);
  3011. + _show_sub_paths_ss(pl, 1);
  3012. + }
  3013. + return pl;
  3014. +}
  3015. +
  3016. +static void
  3017. +_usage(char *cmd)
  3018. +{
  3019. + fprintf(stderr,
  3020. +"Usage: %s -vli <mpls file> [<mpls file> ...]\n"
  3021. +"With no options, produces a list of the playlist(s) with durations\n"
  3022. +"Options:\n"
  3023. +" v - Verbose output.\n"
  3024. +" l - Produces a list of the m2ts clips\n"
  3025. +" i - Dumps detailed information about each clip\n"
  3026. +" c - Show chapter marks\n"
  3027. +" p - Show sub paths\n"
  3028. +" P - Show picture-in-picture metadata\n"
  3029. +" r <N> - Filter out titles that have >N repeating clips\n"
  3030. +" d - Filter out duplicate titles\n"
  3031. +" s <seconds> - Filter out short titles\n"
  3032. +" f - Filter combination -r2 -d -s900\n"
  3033. +, cmd);
  3034. +
  3035. + exit(EXIT_FAILURE);
  3036. +}
  3037. +
  3038. +#define OPTS "vlicpPfr:ds:"
  3039. +
  3040. +static int
  3041. +_qsort_str_cmp(const void *a, const void *b)
  3042. +{
  3043. + const char *stra = *(char * const *)a;
  3044. + const char *strb = *(char * const *)b;
  3045. +
  3046. + return strcmp(stra, strb);
  3047. +}
  3048. +
  3049. +int
  3050. +main(int argc, char *argv[])
  3051. +{
  3052. + MPLS_PL *pl;
  3053. + int opt;
  3054. + int ii, pl_ii;
  3055. + MPLS_PL *pl_list[1000];
  3056. + struct stat st;
  3057. + char *path = NULL;
  3058. + DIR *dir = NULL;
  3059. +
  3060. + do {
  3061. + opt = getopt(argc, argv, OPTS);
  3062. + switch (opt) {
  3063. + case -1:
  3064. + break;
  3065. +
  3066. + case 'v':
  3067. + verbose = 1;
  3068. + break;
  3069. +
  3070. + case 'l':
  3071. + clip_list = 1;
  3072. + break;
  3073. +
  3074. + case 'i':
  3075. + playlist_info = 1;
  3076. + break;
  3077. +
  3078. + case 'c':
  3079. + chapter_marks = 1;
  3080. + break;
  3081. +
  3082. + case 'p':
  3083. + sub_paths = 1;
  3084. + break;
  3085. +
  3086. + case 'P':
  3087. + pip_metadata = 1;
  3088. + break;
  3089. +
  3090. + case 'd':
  3091. + dups = 1;
  3092. + break;
  3093. +
  3094. + case 'r':
  3095. + repeats = atoi(optarg);
  3096. + break;
  3097. +
  3098. + case 'f':
  3099. + repeats = 2;
  3100. + dups = 1;
  3101. + seconds = 900;
  3102. + break;
  3103. +
  3104. + case 's':
  3105. + seconds = atoi(optarg);
  3106. + break;
  3107. +
  3108. + default:
  3109. + _usage(argv[0]);
  3110. + break;
  3111. + }
  3112. + } while (opt != -1);
  3113. +
  3114. + if (optind >= argc) {
  3115. + _usage(argv[0]);
  3116. + }
  3117. +
  3118. + for (pl_ii = 0, ii = optind; pl_ii < 1000 && ii < argc; ii++) {
  3119. +
  3120. + if (stat(argv[ii], &st)) {
  3121. + continue;
  3122. + }
  3123. + dir = NULL;
  3124. + if (S_ISDIR(st.st_mode)) {
  3125. +
  3126. + printf("Directory: %s:\n", argv[ii]);
  3127. + path = _mk_path(argv[ii], PLAYLIST_DIR);
  3128. + if (path == NULL) {
  3129. + fprintf(stderr, "Failed to find playlist path: %s\n", argv[ii]);
  3130. + continue;
  3131. + }
  3132. + dir = opendir(path);
  3133. + if (dir == NULL) {
  3134. + fprintf(stderr, "Failed to open dir: %s\n", path);
  3135. + free(path);
  3136. + continue;
  3137. + }
  3138. + }
  3139. + if (dir != NULL) {
  3140. + char **dirlist = (char**)calloc(10001, sizeof(char*));
  3141. + struct dirent *ent;
  3142. + int jj = 0;
  3143. + for (ent = readdir(dir); ent != NULL; ent = readdir(dir)) {
  3144. + dirlist[jj++] = strcpy((char*)malloc(strlen(ent->d_name)), ent->d_name);
  3145. + }
  3146. + qsort(dirlist, jj, sizeof(char*), _qsort_str_cmp);
  3147. + for (jj = 0; dirlist[jj] != NULL; jj++) {
  3148. + char *name = NULL;
  3149. + name = _mk_path(path, dirlist[jj]);
  3150. + free(dirlist[jj]);
  3151. + if (stat(name, &st)) {
  3152. + free(name);
  3153. + continue;
  3154. + }
  3155. + if (!S_ISREG(st.st_mode)) {
  3156. + free(name);
  3157. + continue;
  3158. + }
  3159. + pl = _process_file(name, pl_list, pl_ii);
  3160. + free(name);
  3161. + if (pl != NULL) {
  3162. + pl_list[pl_ii++] = pl;
  3163. + }
  3164. + }
  3165. + free(dirlist);
  3166. + free(path);
  3167. + closedir(dir);
  3168. + dir = NULL;
  3169. + } else {
  3170. + pl = _process_file(argv[ii], pl_list, pl_ii);
  3171. + if (pl != NULL) {
  3172. + pl_list[pl_ii++] = pl;
  3173. + }
  3174. + }
  3175. + }
  3176. + // Cleanup
  3177. + for (ii = 0; ii < pl_ii; ii++) {
  3178. + bd_free_mpls(pl_list[ii]);
  3179. + }
  3180. + return 0;
  3181. +}
  3182. +
  3183. diff --git a/src/devtools/util.c b/src/devtools/util.c
  3184. new file mode 100644
  3185. index 0000000..aaa4c46
  3186. --- /dev/null
  3187. +++ b/src/devtools/util.c
  3188. @@ -0,0 +1,40 @@
  3189. +/*
  3190. + * This file is part of libbluray
  3191. + * Copyright (C) 2009-2010 John Stebbins
  3192. + *
  3193. + * This library is free software; you can redistribute it and/or
  3194. + * modify it under the terms of the GNU Lesser General Public
  3195. + * License as published by the Free Software Foundation; either
  3196. + * version 2.1 of the License, or (at your option) any later version.
  3197. + *
  3198. + * This library is distributed in the hope that it will be useful,
  3199. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3200. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  3201. + * Lesser General Public License for more details.
  3202. + *
  3203. + * You should have received a copy of the GNU Lesser General Public
  3204. + * License along with this library. If not, see
  3205. + * <http://www.gnu.org/licenses/>.
  3206. + */
  3207. +
  3208. +#include <stdio.h>
  3209. +#include <stdarg.h>
  3210. +
  3211. +#include "util.h"
  3212. +
  3213. +void
  3214. +indent_printf(int level, const char *fmt, ...)
  3215. +{
  3216. + va_list ap;
  3217. + int ii;
  3218. +
  3219. + for (ii = 0; ii < level; ii++)
  3220. + {
  3221. + printf(" ");
  3222. + }
  3223. + va_start(ap, fmt);
  3224. + vprintf(fmt, ap);
  3225. + va_end(ap);
  3226. + printf("\n");
  3227. +}
  3228. +
  3229. diff --git a/src/devtools/util.h b/src/devtools/util.h
  3230. new file mode 100644
  3231. index 0000000..144f8ec
  3232. --- /dev/null
  3233. +++ b/src/devtools/util.h
  3234. @@ -0,0 +1,43 @@
  3235. +/*
  3236. + * This file is part of libbluray
  3237. + * Copyright (C) 2009-2010 John Stebbins
  3238. + *
  3239. + * This library is free software; you can redistribute it and/or
  3240. + * modify it under the terms of the GNU Lesser General Public
  3241. + * License as published by the Free Software Foundation; either
  3242. + * version 2.1 of the License, or (at your option) any later version.
  3243. + *
  3244. + * This library is distributed in the hope that it will be useful,
  3245. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3246. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  3247. + * Lesser General Public License for more details.
  3248. + *
  3249. + * You should have received a copy of the GNU Lesser General Public
  3250. + * License along with this library. If not, see
  3251. + * <http://www.gnu.org/licenses/>.
  3252. + */
  3253. +
  3254. +#include <stdint.h>
  3255. +
  3256. +#include "util/attributes.h"
  3257. +
  3258. +#if defined( __MINGW32__ )
  3259. +# undef lseek
  3260. +# define lseek _lseeki64
  3261. +# undef fseeko
  3262. +# define fseeko fseeko64
  3263. +# undef ftello
  3264. +# define ftello ftello64
  3265. +# define flockfile(...)
  3266. +# define funlockfile(...)
  3267. +# define getc_unlocked getc
  3268. +# undef off_t
  3269. +# define off_t off64_t
  3270. +# undef stat
  3271. +# define stat _stati64
  3272. +# define fstat _fstati64
  3273. +# define wstat _wstati64
  3274. +#endif
  3275. +
  3276. +void indent_printf(int level, const char *fmt, ...) BD_ATTR_FORMAT_PRINTF(2,3);
  3277. +
  3278. diff --git a/src/examples/bdj_test.c b/src/examples/bdj_test.c
  3279. deleted file mode 100644
  3280. index d9ebd16..0000000
  3281. --- a/src/examples/bdj_test.c
  3282. +++ /dev/null
  3283. @@ -1,67 +0,0 @@
  3284. -/*
  3285. - * This file is part of libbluray
  3286. - * Copyright (C) 2010 William Hahne
  3287. - *
  3288. - * This program is free software; you can redistribute it and/or
  3289. - * modify it under the terms of the GNU General Public License
  3290. - * as published by the Free Software Foundation; either version 2
  3291. - * of the License, or (at your option) any later version.
  3292. - *
  3293. - * This program is distributed in the hope that it will be useful,
  3294. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3295. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  3296. - * GNU General Public License for more details.
  3297. - *
  3298. - * You should have received a copy of the GNU General Public License
  3299. - * along with this program. If not, see <http://www.gnu.org/licenses/>.
  3300. - *
  3301. - * In addition, as a special exception, the copyright holders of libbluray
  3302. - * gives permission to link the code of its release of libbluray with the
  3303. - * OpenSSL project's "OpenSSL" library (or with modified versions of it
  3304. - * that use the same license as the "OpenSSL" library), and distribute
  3305. - * the linked executables. You must obey the GNU General Public License
  3306. - * in all respects for all of the code used other than "OpenSSL". If you
  3307. - * modify this file, you may extend this exception to your version of the
  3308. - * file, but you are not obligated to do so. If you do not wish to do
  3309. - * so, delete this exception statement from your version.
  3310. - */
  3311. -
  3312. -#include <stdio.h>
  3313. -#include <stdlib.h>
  3314. -#include <unistd.h>
  3315. -
  3316. -#include "libbluray/bluray.h"
  3317. -
  3318. -#if defined(_WIN32)
  3319. -#include <windows.h>
  3320. -#define sleep(x) Sleep(x)
  3321. -#endif
  3322. -
  3323. -static void _usage(void) {
  3324. - printf("Usage: [path to disc] [starting object]\n");
  3325. -}
  3326. -
  3327. -int main(int argc, char** argv)
  3328. -{
  3329. - if (argc < 3) {
  3330. - _usage();
  3331. - return 0;
  3332. - }
  3333. -
  3334. - printf("%s %s\n", argv[1], argv[2]);
  3335. -
  3336. - BLURAY* bd = bd_open(argv[1], NULL);
  3337. -
  3338. - bd_get_titles(bd, TITLES_ALL, 0);
  3339. -
  3340. - if (!bd_start_bdj(bd, argv[2])) {
  3341. - printf("Failed to start BD-J application.\n");
  3342. - } else {
  3343. - while (1) { sleep(20); }
  3344. - bd_stop_bdj(bd);
  3345. - }
  3346. -
  3347. - bd_close(bd);
  3348. -
  3349. - return 0;
  3350. -}
  3351. diff --git a/src/examples/bdjo_dump.c b/src/examples/bdjo_dump.c
  3352. deleted file mode 100644
  3353. index bcbd2af..0000000
  3354. --- a/src/examples/bdjo_dump.c
  3355. +++ /dev/null
  3356. @@ -1,206 +0,0 @@
  3357. -/*
  3358. - * This file is part of libbluray
  3359. - * Copyright (C) 2014 Petri Hintukainen <phintuka@users.sourceforge.net>
  3360. - *
  3361. - * This library is free software; you can redistribute it and/or
  3362. - * modify it under the terms of the GNU Lesser General Public
  3363. - * License as published by the Free Software Foundation; either
  3364. - * version 2.1 of the License, or (at your option) any later version.
  3365. - *
  3366. - * This library is distributed in the hope that it will be useful,
  3367. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3368. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  3369. - * Lesser General Public License for more details.
  3370. - *
  3371. - * You should have received a copy of the GNU Lesser General Public
  3372. - * License along with this library. If not, see
  3373. - * <http://www.gnu.org/licenses/>.
  3374. - */
  3375. -
  3376. -#include "libbluray/bluray.h"
  3377. -#include "libbluray/bdj/bdjo_data.h"
  3378. -
  3379. -#include <stdio.h>
  3380. -#include <string.h>
  3381. -
  3382. -static const char *_yes_no(int i)
  3383. -{
  3384. - return i > 0 ? "yes" : i < 0 ? "unknown" : "no";
  3385. -}
  3386. -
  3387. -static const char *_binding_str(int i)
  3388. -{
  3389. - switch (i) {
  3390. - case 0: return "unbound";
  3391. - case 1: return "disc bound";
  3392. - case 3: return "title bound";
  3393. - default: return "???";
  3394. - }
  3395. -}
  3396. -
  3397. -static const char *_visibility_str(int i)
  3398. -{
  3399. - switch (i) {
  3400. - case 0: return "none";
  3401. - case 1: return "applications";
  3402. - case 2: return "user";
  3403. - default: return "???";
  3404. - }
  3405. -}
  3406. -
  3407. -static void _terminal_info_print(const BDJO_TERMINAL_INFO *p)
  3408. -{
  3409. - printf("Terminal Info:\n");
  3410. - printf(" Default AWT font : %s\n", p->default_font);
  3411. - printf(" initial HaVi config : %d\n", p->initial_havi_config_id);
  3412. - printf(" Menu call mask : %d\n", p->menu_call_mask);
  3413. - printf(" Title search mask : %d\n", p->menu_call_mask);
  3414. -}
  3415. -
  3416. -static void _app_cache_item_print(const BDJO_APP_CACHE_ITEM *p)
  3417. -{
  3418. - printf(" %3.3s: %s%s\n",
  3419. - p->lang_code, p->ref_to_name,
  3420. - p->type == 1 ? ".jar" : p->type == 2 ? "/" : " (unknown type)");
  3421. -}
  3422. -
  3423. -static void _app_cache_info_print(const BDJO_APP_CACHE_INFO *p)
  3424. -{
  3425. - unsigned ii;
  3426. -
  3427. - printf("Application cache info:\n");
  3428. - for (ii = 0; ii < p->num_item; ii++) {
  3429. - _app_cache_item_print(&p->item[ii]);
  3430. - }
  3431. -}
  3432. -
  3433. -static void _accessible_playlists_print(const BDJO_ACCESSIBLE_PLAYLISTS *p)
  3434. -{
  3435. - unsigned ii;
  3436. -
  3437. - printf("Accessible playlists:\n");
  3438. - printf(" Access to all : %s\n", _yes_no(p->access_to_all_flag));
  3439. - printf(" Autostart first : %s\n", _yes_no(p->autostart_first_playlist_flag));
  3440. -
  3441. - if (p->num_pl) {
  3442. - printf(" Playlists : %d\n", p->num_pl);
  3443. - for (ii = 0; ii < p->num_pl; ii++) {
  3444. - printf(" %s.mpls\n", p->pl[ii].name);
  3445. - }
  3446. - }
  3447. -}
  3448. -
  3449. -static void _app_profile_print(BDJO_APP_PROFILE *p)
  3450. -{
  3451. - printf(" Profile %d Version %d.%d.%d\n",
  3452. - p->profile_number, p->major_version, p->minor_version, p->micro_version);
  3453. -}
  3454. -
  3455. -static void _app_print(const BDJO_APP *p)
  3456. -{
  3457. - unsigned ii;
  3458. -
  3459. - printf(" Control code: : %d (%s)\n", p->control_code,
  3460. - p->control_code == 1 ? "autostart" : p->control_code == 2 ? "present" : "???");
  3461. - printf(" Type : %d (%s)\n", p->type,
  3462. - p->type == 1 ? "BD-J App" : "???");
  3463. - printf(" Organization ID : %08X\n", p->org_id);
  3464. - printf(" Application ID : %04X\n", p->app_id);
  3465. - printf(" Priority : %d\n", p->priority);
  3466. - printf(" Binding : %d (%s)\n", p->binding, _binding_str(p->binding));
  3467. - printf(" Visibility : %d (%s)\n", p->visibility, _visibility_str(p->visibility));
  3468. -
  3469. - if (p->num_profile) {
  3470. - printf(" Profiles:\n");
  3471. - for (ii = 0; ii < p->num_profile; ii++) {
  3472. - _app_profile_print(&p->profile[ii]);
  3473. - }
  3474. - }
  3475. -
  3476. - if (p->num_name) {
  3477. - printf(" Names:\n");
  3478. - for (ii = 0; ii < p->num_name; ii++) {
  3479. - printf(" %s: %s\n", p->name[ii].lang, p->name[ii].name);
  3480. - }
  3481. - }
  3482. -
  3483. - printf(" Base directory : %s\n", p->base_dir);
  3484. - printf(" Icon locator : %s\n", p->icon_locator);
  3485. - printf(" Icon flags : 0x%04x\n", p->icon_flags);
  3486. - printf(" Classpath extension : %s\n", p->classpath_extension);
  3487. - printf(" Initial class : %s\n", p->initial_class);
  3488. - printf(" Parameters : ");
  3489. - for (ii = 0; ii < p->num_param; ii++) {
  3490. - printf("%s ", p->param[ii].param);
  3491. - }
  3492. - printf("\n");
  3493. -}
  3494. -
  3495. -static void _app_management_table_print(const BDJO_APP_MANAGEMENT_TABLE *p)
  3496. -{
  3497. - unsigned ii;
  3498. -
  3499. - for (ii = 0; ii < p->num_app; ii++) {
  3500. - printf("Application %d:\n", ii);
  3501. - _app_print(&p->app[ii]);
  3502. - }
  3503. -}
  3504. -
  3505. -static void _key_interest_table_print(const BDJO_KEY_INTEREST_TABLE *p)
  3506. -{
  3507. - unsigned int v;
  3508. - memcpy(&v, p, sizeof(unsigned int));
  3509. - if (v) {
  3510. - printf("Key interest table:\n");
  3511. - printf(" %s%s%s%s%s%s%s%s%s%s%s\n",
  3512. - p->vk_play ? "VK_PLAY " : "",
  3513. - p->vk_stop ? "VK_STOP " : "",
  3514. - p->vk_ffw ? "VK_FFW " : "",
  3515. - p->vk_rew ? "VK_REW " : "",
  3516. - p->vk_track_next ? "VK_TRACK_NEXT " : "",
  3517. - p->vk_track_prev ? "VK_TRACK_PREV " : "",
  3518. - p->vk_pause ? "VK_PAUSE " : "",
  3519. - p->vk_still_off ? "VK_STILL_OFF " : "",
  3520. - p->vk_sec_audio_ena_dis ? "VK_SEC_AUDIO " : "",
  3521. - p->vk_sec_video_ena_dis ? "VK_SEC_VIDEO " : "",
  3522. - p->pg_textst_ena_dis ? "VK_PG_TEXTST " : "");
  3523. - }
  3524. -}
  3525. -
  3526. -static void _file_access_info_print(const BDJO_FILE_ACCESS_INFO *p)
  3527. -{
  3528. - printf("File access info:\n %s\n", p->path);
  3529. -}
  3530. -
  3531. -static void _bdjo_print(const BDJO *p)
  3532. -{
  3533. - _terminal_info_print(&p->terminal_info);
  3534. - _app_cache_info_print(&p->app_cache_info);
  3535. - _accessible_playlists_print(&p->accessible_playlists);
  3536. - _app_management_table_print(&p->app_table);
  3537. - _key_interest_table_print(&p->key_interest_table);
  3538. - _file_access_info_print(&p->file_access_info);
  3539. -}
  3540. -
  3541. -int main(int argc, const char *argv[])
  3542. -{
  3543. - if (argc < 2) {
  3544. - fprintf(stderr, "usage: %s <bdjo_file>\n", argv[0]);
  3545. - return 1;
  3546. - }
  3547. -
  3548. - int cnt;
  3549. - for (cnt = 1; cnt < argc; cnt++) {
  3550. -
  3551. - printf("%s\n", argv[cnt]);
  3552. -
  3553. - BDJO *bdjo = bd_read_bdjo(argv[cnt]);
  3554. - if (bdjo) {
  3555. - _bdjo_print(bdjo);
  3556. - bd_free_bdjo(bdjo);
  3557. - }
  3558. - printf("\n");
  3559. - }
  3560. -
  3561. - return 0;
  3562. -}
  3563. diff --git a/src/examples/clpi_dump.c b/src/examples/clpi_dump.c
  3564. deleted file mode 100644
  3565. index bd64783..0000000
  3566. --- a/src/examples/clpi_dump.c
  3567. +++ /dev/null
  3568. @@ -1,487 +0,0 @@
  3569. -/*
  3570. - * This file is part of libbluray
  3571. - * Copyright (C) 2009-2010 John Stebbins
  3572. - * Copyright (C) 2012-2013 Petri Hintukainen <phintuka@users.sourceforge.net>
  3573. - *
  3574. - * This library is free software; you can redistribute it and/or
  3575. - * modify it under the terms of the GNU Lesser General Public
  3576. - * License as published by the Free Software Foundation; either
  3577. - * version 2.1 of the License, or (at your option) any later version.
  3578. - *
  3579. - * This library is distributed in the hope that it will be useful,
  3580. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3581. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  3582. - * Lesser General Public License for more details.
  3583. - *
  3584. - * You should have received a copy of the GNU Lesser General Public
  3585. - * License along with this library. If not, see
  3586. - * <http://www.gnu.org/licenses/>.
  3587. - */
  3588. -
  3589. -#include <stdio.h>
  3590. -#include <stdlib.h>
  3591. -#include <unistd.h>
  3592. -#include <inttypes.h>
  3593. -
  3594. -#include "libbluray/bdnav/clpi_data.h"
  3595. -#include "libbluray/bluray.h"
  3596. -
  3597. -#include "util.h"
  3598. -
  3599. -static int verbose;
  3600. -
  3601. -typedef struct {
  3602. - int value;
  3603. - const char *str;
  3604. -} VALUE_MAP;
  3605. -
  3606. -static inline const char*
  3607. -_lookup_str(const VALUE_MAP *map, int val)
  3608. -{
  3609. - int ii;
  3610. -
  3611. - for (ii = 0; map[ii].str; ii++) {
  3612. - if (val == map[ii].value) {
  3613. - return map[ii].str;
  3614. - }
  3615. - }
  3616. - return "?";
  3617. -}
  3618. -
  3619. -const VALUE_MAP codec_map[] = {
  3620. - {0x01, "MPEG-1 Video"},
  3621. - {0x02, "MPEG-2 Video"},
  3622. - {0x03, "MPEG-1 Audio"},
  3623. - {0x04, "MPEG-2 Audio"},
  3624. - {0x80, "LPCM"},
  3625. - {0x81, "AC-3"},
  3626. - {0x82, "DTS"},
  3627. - {0x83, "TrueHD"},
  3628. - {0x84, "AC-3 Plus"},
  3629. - {0x85, "DTS-HD"},
  3630. - {0x86, "DTS-HD Master"},
  3631. - {0xa1, "AC-3 Plus for secondary audio"},
  3632. - {0xa2, "DTS-HD for secondary audio"},
  3633. - {0xea, "VC-1"},
  3634. - {0x1b, "H.264"},
  3635. - {0x20, "H.264 MVC dep."},
  3636. - {0x90, "Presentation Graphics"},
  3637. - {0x91, "Presentation Graphics"},
  3638. - {0x92, "Interactive Graphics"},
  3639. - {0, NULL}
  3640. -};
  3641. -
  3642. -const VALUE_MAP video_format_map[] = {
  3643. - {0, "Reserved"},
  3644. - {1, "480i"},
  3645. - {2, "576i"},
  3646. - {3, "480p"},
  3647. - {4, "1080i"},
  3648. - {5, "720p"},
  3649. - {6, "1080p"},
  3650. - {7, "576p"},
  3651. - {0, NULL}
  3652. -};
  3653. -
  3654. -const VALUE_MAP video_rate_map[] = {
  3655. - {0, "Reserved1"},
  3656. - {1, "23.976"},
  3657. - {2, "24"},
  3658. - {3, "25"},
  3659. - {4, "29.97"},
  3660. - {5, "Reserved2"},
  3661. - {6, "50"},
  3662. - {7, "59.94"},
  3663. - {0, NULL}
  3664. -};
  3665. -
  3666. -const VALUE_MAP video_aspect_map[] = {
  3667. - {0, "Reserved1"},
  3668. - {1, "Reserved2"},
  3669. - {2, "4:3"},
  3670. - {3, "16:9"},
  3671. - {0, NULL}
  3672. -};
  3673. -
  3674. -const VALUE_MAP audio_format_map[] = {
  3675. - {0, "Reserved1"},
  3676. - {1, "Mono"},
  3677. - {2, "Reserved2"},
  3678. - {3, "Stereo"},
  3679. - {4, "Reserved3"},
  3680. - {5, "Reserved4"},
  3681. - {6, "Multi Channel"},
  3682. - {12, "Combo"},
  3683. - {0, NULL}
  3684. -};
  3685. -
  3686. -const VALUE_MAP audio_rate_map[] = {
  3687. - {0, "Reserved1"},
  3688. - {1, "48 Khz"},
  3689. - {2, "Reserved2"},
  3690. - {3, "Reserved3"},
  3691. - {4, "96 Khz"},
  3692. - {5, "192 Khz"},
  3693. - {12, "48/192 Khz"},
  3694. - {14, "48/96 Khz"},
  3695. - {0, NULL}
  3696. -};
  3697. -
  3698. -const VALUE_MAP application_type_map[] = {
  3699. - {1, "Main TS for a main-path of Movie"},
  3700. - {2, "Main TS for a main-path of Time based slide show"},
  3701. - {3, "Main TS for a main-path of Browsable slide show"},
  3702. - {4, "Sub TS for a sub-path of Browsable slide show"},
  3703. - {5, "Sub TS for a sub-path of Interactive Graphics menu"},
  3704. - {6, "Sub TS for a sub-path of Text subtitle"},
  3705. - {7, "Sub TS for a sub-path of one or more elementary streams path"},
  3706. - {0, NULL},
  3707. -};
  3708. -
  3709. -static void
  3710. -_show_stream(CLPI_PROG_STREAM *ss, int level)
  3711. -{
  3712. - indent_printf(level, "Codec (%04x): %s", ss->coding_type,
  3713. - _lookup_str(codec_map, ss->coding_type));
  3714. - indent_printf(level, "PID: %04x", ss->pid);
  3715. - switch (ss->coding_type) {
  3716. - case 0x01:
  3717. - case 0x02:
  3718. - case 0xea:
  3719. - case 0x1b:
  3720. - case 0x20:
  3721. - indent_printf(level, "Format %02x: %s", ss->format,
  3722. - _lookup_str(video_format_map, ss->format));
  3723. - indent_printf(level, "Rate %02x: %s", ss->rate,
  3724. - _lookup_str(video_rate_map, ss->rate));
  3725. - indent_printf(level, "Aspect %02x: %s", ss->aspect,
  3726. - _lookup_str(video_aspect_map, ss->aspect));
  3727. - indent_printf(level, "oc_flag %02x", ss->oc_flag);
  3728. - break;
  3729. -
  3730. - case 0x03:
  3731. - case 0x04:
  3732. - case 0x80:
  3733. - case 0x81:
  3734. - case 0x82:
  3735. - case 0x83:
  3736. - case 0x84:
  3737. - case 0x85:
  3738. - case 0x86:
  3739. - case 0xa1:
  3740. - case 0xa2:
  3741. - indent_printf(level, "Format %02x: %s", ss->format,
  3742. - _lookup_str(audio_format_map, ss->format));
  3743. - indent_printf(level, "Rate %02x: %s", ss->rate,
  3744. - _lookup_str(audio_rate_map, ss->rate));
  3745. - indent_printf(level, "Language: %s", ss->lang);
  3746. - break;
  3747. -
  3748. - case 0x90:
  3749. - case 0x91:
  3750. - case 0xa0:
  3751. - indent_printf(level, "Language: %s", ss->lang);
  3752. - break;
  3753. -
  3754. - case 0x92:
  3755. - indent_printf(level, "Char Code: %02x", ss->char_code);
  3756. - indent_printf(level, "Language: %s", ss->lang);
  3757. - break;
  3758. -
  3759. - default:
  3760. - fprintf(stderr, "unrecognized coding type %02x\n", ss->coding_type);
  3761. - break;
  3762. - };
  3763. -}
  3764. -
  3765. -static void
  3766. -_show_clip_info(CLPI_CL *cl, int level)
  3767. -{
  3768. - CLPI_CLIP_INFO *ci = &cl->clip;
  3769. - int ii;
  3770. -
  3771. - indent_printf(level, "Clip Info");
  3772. - indent_printf(level+1, "Clip Stream Type: %02x", ci->clip_stream_type);
  3773. - indent_printf(level+1, "Clip Application Type (%02x): %s",
  3774. - ci->application_type, _lookup_str(application_type_map, ci->application_type));
  3775. - indent_printf(level+1, "is_ATC_delta: %s", ci->is_atc_delta ? "True" : "False");
  3776. - indent_printf(level+1, "ATC delta count: %d", ci->atc_delta_count);
  3777. - indent_printf(level+1, "TS Recording Rate: %u", ci->ts_recording_rate);
  3778. - indent_printf(level+1, "Number Source Packets: %u", ci->num_source_packets);
  3779. - // Show ts type info
  3780. - indent_printf(level+1, "TS Type Info");
  3781. - indent_printf(level+2, "Validity Flags %02x", ci->ts_type_info.validity);
  3782. - indent_printf(level+2, "Format Id %s", ci->ts_type_info.format_id);
  3783. - // Show cc5 thing
  3784. - for (ii = 0; ii < ci->atc_delta_count; ii++) {
  3785. - indent_printf(level+1, "ATC delta[ %d ]", ii);
  3786. - indent_printf(level+2, "Delta %08x", ci->atc_delta[ii].delta);
  3787. - indent_printf(level+2, "File Id %s", ci->atc_delta[ii].file_id);
  3788. - indent_printf(level+2, "File Code %s", ci->atc_delta[ii].file_code);
  3789. - }
  3790. - // show fonts
  3791. - if (cl->font_info.font_count) {
  3792. - indent_printf(level+1, "Font files");
  3793. - for (ii = 0; ii < cl->font_info.font_count; ii++) {
  3794. - indent_printf(level+2, "Font file %d: %s.otf", ii+1, cl->font_info.font[ii].file_id);
  3795. - }
  3796. - }
  3797. -
  3798. - printf("\n");
  3799. -}
  3800. -
  3801. -static void
  3802. -_show_seq_info(CLPI_SEQ_INFO *si, int level)
  3803. -{
  3804. - CLPI_ATC_SEQ *atc;
  3805. - CLPI_STC_SEQ *stc;
  3806. - int ii, jj;
  3807. -
  3808. - indent_printf(level, "Sequence Info");
  3809. - indent_printf(level+1, "Number ATC Sequences: %d", si->num_atc_seq);
  3810. - for (ii = 0; ii < si->num_atc_seq; ii++) {
  3811. - atc = &si->atc_seq[ii];
  3812. - indent_printf(level+1, "ATC Sequence %d", ii);
  3813. - indent_printf(level+2, "SPN ATC Start: %u", atc->spn_atc_start);
  3814. - indent_printf(level+2, "Offset STC Id: %d", atc->offset_stc_id);
  3815. - indent_printf(level+2, "Number STC Sequences: %d", atc->num_stc_seq);
  3816. - for (jj = 0; jj < atc->num_stc_seq; jj++) {
  3817. - stc = &atc->stc_seq[jj];
  3818. - indent_printf(level+2, "ATC Sequence %d", jj);
  3819. - indent_printf(level+3, "SPN STC Start: %u", stc->spn_stc_start);
  3820. - indent_printf(level+3, "PCR PID: %04x", stc->pcr_pid);
  3821. - indent_printf(level+3, "Presentation Start: %u",
  3822. - stc->presentation_start_time);
  3823. - indent_printf(level+3, "Presentation End: %u",
  3824. - stc->presentation_end_time);
  3825. - }
  3826. - }
  3827. -}
  3828. -
  3829. -static void
  3830. -_show_prog_info(CLPI_PROG_INFO *pi, int level)
  3831. -{
  3832. - CLPI_PROG *prog;
  3833. - int ii, jj;
  3834. -
  3835. - indent_printf(level, "Program Info");
  3836. - indent_printf(level+1, "Number Programs: %d", pi->num_prog);
  3837. - for (ii = 0; ii < pi->num_prog; ii++) {
  3838. - prog = &pi->progs[ii];
  3839. - indent_printf(level+1, "Program %d", ii);
  3840. - indent_printf(level+2, "SPN Program Sequence Start: %d",
  3841. - prog->spn_program_sequence_start);
  3842. - indent_printf(level+2, "Program Map PID: %d", prog->program_map_pid);
  3843. - indent_printf(level+2, "Number Streams: %d", prog->num_streams);
  3844. - indent_printf(level+2, "Number Groups: %d", prog->num_groups);
  3845. - for (jj = 0; jj < prog->num_streams; jj++) {
  3846. - indent_printf(level+2, "Stream %d", jj);
  3847. - _show_stream(&prog->streams[jj], level+3);
  3848. - }
  3849. - }
  3850. -}
  3851. -
  3852. -static void
  3853. -_show_extent_start(CLPI_EXTENT_START *es, int level)
  3854. -{
  3855. - unsigned int ii;
  3856. -
  3857. - indent_printf(level, "Extension data: Extent Start Point");
  3858. -
  3859. - if (!es->num_point) {
  3860. - indent_printf(level+1, "(no data)");
  3861. -
  3862. - } else {
  3863. - indent_printf(level+1, "Number of Start Points: %d", es->num_point);
  3864. -
  3865. - if (verbose) {
  3866. - for (ii = 0; ii < es->num_point; ii++) {
  3867. - indent_printf(level+1, "Extent %5d: SPN 0x%08X", ii, es->point[ii]);
  3868. - }
  3869. - }
  3870. - }
  3871. -}
  3872. -
  3873. -static void
  3874. -_show_cpi_info(CLPI_CPI *cpi, int level)
  3875. -{
  3876. - CLPI_EP_MAP_ENTRY *entry;
  3877. - CLPI_EP_COARSE *coarse;
  3878. - CLPI_EP_FINE *fine;
  3879. - int ii, jj, kk;
  3880. -
  3881. - indent_printf(level, "CPI");
  3882. - indent_printf(level+1, "Number Stream PID: %d", cpi->num_stream_pid);
  3883. - for (ii = 0; ii < cpi->num_stream_pid; ii++) {
  3884. - entry = &cpi->entry[ii];
  3885. - indent_printf(level+1, "Stream: %d", ii);
  3886. - indent_printf(level+2, "PID: %04x", entry->pid);
  3887. - indent_printf(level+2, "EP Stream Type: %d", entry->ep_stream_type);
  3888. - indent_printf(level+2, "Number EP Coarse: %d", entry->num_ep_coarse);
  3889. - indent_printf(level+2, "Number EP Fine: %d", entry->num_ep_fine);
  3890. - indent_printf(level+2, "EP Map Start: %d",
  3891. - entry->ep_map_stream_start_addr);
  3892. - for (jj = 0; jj < entry->num_ep_coarse; jj++) {
  3893. - coarse = &entry->coarse[jj];
  3894. - indent_printf(level+2, "Coarse: %d", jj);
  3895. - indent_printf(level+3, "Ref EP Fine: %d", coarse->ref_ep_fine_id);
  3896. - indent_printf(level+3, "PTS EP: %d", coarse->pts_ep);
  3897. - indent_printf(level+3, "SPN EP: %d", coarse->spn_ep);
  3898. - }
  3899. - for (jj = 0; jj < entry->num_ep_fine; jj++) {
  3900. - fine = &entry->fine[jj];
  3901. - indent_printf(level+2, "Fine: %d", jj);
  3902. - indent_printf(level+3, "Angle Change Point: %s",
  3903. - fine->is_angle_change_point ? "True":"False");
  3904. - indent_printf(level+3, "I End Offset: %d",
  3905. - fine->i_end_position_offset);
  3906. - indent_printf(level+3, "PTS EP: %d", fine->pts_ep);
  3907. - indent_printf(level+3, "SPN EP: %d", fine->spn_ep);
  3908. - }
  3909. - if (verbose) {
  3910. - uint64_t pts;
  3911. - uint32_t spn;
  3912. -
  3913. - indent_printf(level+2, "PTS - SPN Map");
  3914. - for (jj = 0; jj < entry->num_ep_coarse; jj++) {
  3915. - int start, end;
  3916. -
  3917. - indent_printf(level+3, "Coarse: %d", jj);
  3918. - coarse = &entry->coarse[jj];
  3919. - start = coarse->ref_ep_fine_id;
  3920. - if (jj < entry->num_ep_coarse - 1) {
  3921. - end = entry->coarse[jj+1].ref_ep_fine_id;
  3922. - } else {
  3923. - end = entry->num_ep_fine;
  3924. - }
  3925. - for (kk = start; kk < end; kk++) {
  3926. - fine = &entry->fine[kk];
  3927. - pts = ((uint64_t) (coarse->pts_ep & ~0x01) << 19) +
  3928. - ((uint64_t)fine->pts_ep << 9);
  3929. - spn = (coarse->spn_ep & ~0x1FFFF) + fine->spn_ep;
  3930. - indent_printf(level+4, "PTS %8"PRIu64"/%8"PRIu64" -- SPN %u",
  3931. - pts, pts >> 1, spn);
  3932. - }
  3933. - }
  3934. - }
  3935. - }
  3936. -}
  3937. -
  3938. -
  3939. -static void
  3940. -_usage(char *cmd)
  3941. -{
  3942. - fprintf(stderr,
  3943. -"Usage: %s -vcspi <clpi file> [<clpi file> ...]\n"
  3944. -"With no options, produces no output (not very useful)\n"
  3945. -"Options:\n"
  3946. -" v - Verbose output.\n"
  3947. -" c - Shows the Clip Info structure\n"
  3948. -" s - Shows the Sequence Info structure\n"
  3949. -" p - Shows the Program Info structure\n"
  3950. -" i - Shows the CPI. PTS to SPN map\n"
  3951. -" e - Shows Extent Start Table\n"
  3952. -, cmd);
  3953. -
  3954. - exit(EXIT_FAILURE);
  3955. -}
  3956. -
  3957. -#define OPTS "vcspie"
  3958. -
  3959. -int
  3960. -main(int argc, char *argv[])
  3961. -{
  3962. - CLPI_CL *cl;
  3963. - int opt;
  3964. - int opt_clip_info = 0, opt_seq_info = 0, opt_prog_info = 0;
  3965. - int opt_cpi_info = 0, opt_extent_start = 0;
  3966. - int ii;
  3967. -
  3968. - do {
  3969. - opt = getopt(argc, argv, OPTS);
  3970. - switch (opt) {
  3971. - case -1: break;
  3972. -
  3973. - case 'v':
  3974. - verbose = 1;
  3975. - break;
  3976. -
  3977. - case 's':
  3978. - opt_seq_info = 1;
  3979. - break;
  3980. -
  3981. - case 'i':
  3982. - opt_cpi_info = 1;
  3983. - break;
  3984. -
  3985. - case 'c':
  3986. - opt_clip_info = 1;
  3987. - break;
  3988. -
  3989. - case 'p':
  3990. - opt_prog_info = 1;
  3991. - break;
  3992. -
  3993. - case 'e':
  3994. - opt_extent_start = 1;
  3995. - break;
  3996. -
  3997. - default:
  3998. - _usage(argv[0]);
  3999. - break;
  4000. - }
  4001. - } while (opt != -1);
  4002. -
  4003. - if (optind >= argc) {
  4004. - _usage(argv[0]);
  4005. - }
  4006. -
  4007. - for (ii = optind; ii < argc; ii++) {
  4008. - cl = bd_read_clpi(argv[ii]);
  4009. - if (cl == NULL) {
  4010. - fprintf(stderr, "Parsing %s failed\n", argv[ii]);
  4011. - continue;
  4012. - }
  4013. - if (opt_clip_info) {
  4014. - // Show clip info
  4015. - _show_clip_info(cl, 1);
  4016. - }
  4017. - if (opt_seq_info) {
  4018. - // Show sequence info
  4019. - _show_seq_info(&cl->sequence, 1);
  4020. - }
  4021. - if (opt_prog_info) {
  4022. - // Show program info
  4023. - _show_prog_info(&cl->program, 1);
  4024. - }
  4025. - if (opt_cpi_info) {
  4026. - // Show cpi
  4027. - _show_cpi_info(&cl->cpi, 1);
  4028. - }
  4029. -
  4030. - if (opt_prog_info) {
  4031. - if (cl->program_ss.num_prog) {
  4032. - printf("\n");
  4033. - indent_printf(1, "Extension: Program Info SS");
  4034. - _show_prog_info(&cl->program_ss, 1);
  4035. - }
  4036. - }
  4037. - if (opt_cpi_info) {
  4038. - if (cl->program_ss.num_prog) {
  4039. - printf("\n");
  4040. - indent_printf(1, "Extension: CPI SS");
  4041. - _show_cpi_info(&cl->cpi_ss, 1);
  4042. - }
  4043. - }
  4044. - if (opt_extent_start) {
  4045. - // Show extent start point
  4046. - if (cl->extent_start.num_point > 0) {
  4047. - _show_extent_start(&cl->extent_start, 1);
  4048. - }
  4049. - }
  4050. -
  4051. - bd_free_clpi(cl);
  4052. - }
  4053. - return 0;
  4054. -}
  4055. -
  4056. diff --git a/src/examples/hdmv_test.c b/src/examples/hdmv_test.c
  4057. deleted file mode 100644
  4058. index 585ed70..0000000
  4059. --- a/src/examples/hdmv_test.c
  4060. +++ /dev/null
  4061. @@ -1,257 +0,0 @@
  4062. -/*
  4063. - * This file is part of libbluray
  4064. - * Copyright (C) 2010 hpi1
  4065. - *
  4066. - * This library is free software; you can redistribute it and/or
  4067. - * modify it under the terms of the GNU Lesser General Public
  4068. - * License as published by the Free Software Foundation; either
  4069. - * version 2.1 of the License, or (at your option) any later version.
  4070. - *
  4071. - * This library is distributed in the hope that it will be useful,
  4072. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4073. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  4074. - * Lesser General Public License for more details.
  4075. - *
  4076. - * You should have received a copy of the GNU Lesser General Public
  4077. - * License along with this library. If not, see
  4078. - * <http://www.gnu.org/licenses/>.
  4079. - */
  4080. -
  4081. -#include <stdio.h>
  4082. -#include <stdlib.h>
  4083. -#include <string.h>
  4084. -#include <inttypes.h>
  4085. -
  4086. -#include "util/log_control.h"
  4087. -#include "libbluray/bluray.h"
  4088. -
  4089. -static void _print_event(BD_EVENT *ev)
  4090. -{
  4091. - switch (ev->event) {
  4092. - case BD_EVENT_NONE:
  4093. - break;
  4094. - case BD_EVENT_ERROR:
  4095. - printf("EVENT_ERROR:\t%d\n", ev->param);
  4096. - break;
  4097. - case BD_EVENT_READ_ERROR:
  4098. - printf("EVENT_READ_ERROR:\t%d\n", ev->param);
  4099. - break;
  4100. - case BD_EVENT_ENCRYPTED:
  4101. - printf("EVENT_ENCRYPTED:\t%d\n", ev->param);
  4102. - break;
  4103. -
  4104. - /* current playback position */
  4105. -
  4106. - case BD_EVENT_ANGLE:
  4107. - printf("EVENT_ANGLE:\t%d\n", ev->param);
  4108. - break;
  4109. - case BD_EVENT_TITLE:
  4110. - printf("EVENT_TITLE:\t%d\n", ev->param);
  4111. - break;
  4112. - case BD_EVENT_PLAYLIST:
  4113. - printf("EVENT_PLAYLIST:\t%d\n", ev->param);
  4114. - break;
  4115. - case BD_EVENT_PLAYITEM:
  4116. - printf("EVENT_PLAYITEM:\t%d\n", ev->param);
  4117. - break;
  4118. - case BD_EVENT_CHAPTER:
  4119. - printf("EVENT_CHAPTER:\t%d\n", ev->param);
  4120. - break;
  4121. -
  4122. - /* */
  4123. -
  4124. - case BD_EVENT_STILL:
  4125. - printf("EVENT_STILL:\t%d\n", ev->param);
  4126. - break;
  4127. -
  4128. - case BD_EVENT_SEEK:
  4129. - printf("EVENT_SEEK:\t%d\n", ev->param);
  4130. - break;
  4131. -
  4132. - case BD_EVENT_STILL_TIME:
  4133. - if (ev->param) {
  4134. - printf("EVENT_STILL_TIME:\t%d\n", ev->param);
  4135. - } else {
  4136. - printf("EVENT_STILL_TIME:\tinfinite\n");
  4137. - }
  4138. - break;
  4139. -
  4140. - /* stream selection */
  4141. -
  4142. - case BD_EVENT_AUDIO_STREAM:
  4143. - printf("EVENT_AUDIO_STREAM:\t%d\n", ev->param);
  4144. - break;
  4145. - case BD_EVENT_IG_STREAM:
  4146. - printf("EVENT_IG_STREAM:\t%d\n", ev->param);
  4147. - break;
  4148. - case BD_EVENT_PG_TEXTST_STREAM:
  4149. - printf("EVENT_PG_TEXTST_STREAM:\t%d\n", ev->param);
  4150. - break;
  4151. - case BD_EVENT_SECONDARY_AUDIO_STREAM:
  4152. - printf("EVENT_SECONDARY_AUDIO_STREAM:\t%d\n", ev->param);
  4153. - break;
  4154. - case BD_EVENT_SECONDARY_VIDEO_STREAM:
  4155. - printf("EVENT_SECONDARY_VIDEO_STREAM:\t%d\n", ev->param);
  4156. - break;
  4157. -
  4158. - case BD_EVENT_PG_TEXTST:
  4159. - printf("EVENT_PG_TEXTST:\t%s\n", ev->param ? "enable" : "disable");
  4160. - break;
  4161. - case BD_EVENT_SECONDARY_AUDIO:
  4162. - printf("EVENT_SECONDARY_AUDIO:\t%s\n", ev->param ? "enable" : "disable");
  4163. - break;
  4164. - case BD_EVENT_SECONDARY_VIDEO:
  4165. - printf("EVENT_SECONDARY_VIDEO:\t%s\n", ev->param ? "enable" : "disable");
  4166. - break;
  4167. - case BD_EVENT_SECONDARY_VIDEO_SIZE:
  4168. - printf("EVENT_SECONDARY_VIDEO_SIZE:\t%s\n", ev->param==0 ? "PIP" : "fullscreen");
  4169. - break;
  4170. -
  4171. - default:
  4172. - printf("UNKNOWN EVENT %d:\t%d\n", ev->event, ev->param);
  4173. - break;
  4174. - }
  4175. -
  4176. - fflush(stdout);
  4177. -}
  4178. -
  4179. -static void _read_to_eof(BLURAY *bd)
  4180. -{
  4181. - BD_EVENT ev;
  4182. - int bytes;
  4183. - uint64_t total = 0;
  4184. - uint8_t buf[6144];
  4185. -
  4186. - bd_seek(bd, bd_get_title_size(bd) - 6144);
  4187. -
  4188. - do {
  4189. - bytes = bd_read_ext(bd, buf, 6144, &ev);
  4190. - total += bytes < 0 ? 0 : bytes;
  4191. - _print_event(&ev);
  4192. - } while (bytes > 0);
  4193. -
  4194. - printf("_read_to_eof(): read %"PRIu64" bytes\n", total);
  4195. -}
  4196. -
  4197. -static void _print_events(BLURAY *bd)
  4198. -{
  4199. - BD_EVENT ev;
  4200. -
  4201. - do {
  4202. - bd_read_ext(bd, NULL, 0, &ev);
  4203. - _print_event(&ev);
  4204. - } while (ev.event != BD_EVENT_NONE && ev.event != BD_EVENT_ERROR);
  4205. -}
  4206. -
  4207. -static void _play_pl(BLURAY *bd)
  4208. -{
  4209. - printf("Playing playlist\n");
  4210. -
  4211. - fflush(stdout);
  4212. - _read_to_eof(bd);
  4213. -
  4214. - printf("Playing playlist done\n\n");
  4215. -
  4216. - _print_events(bd);
  4217. -
  4218. - printf("\n");
  4219. -}
  4220. -
  4221. -int main(int argc, char *argv[])
  4222. -{
  4223. - int title = -1;
  4224. - int verbose = 0;
  4225. - int args = 0;
  4226. -
  4227. - /*
  4228. - * parse arguments
  4229. - */
  4230. -
  4231. - if (argc < 2) {
  4232. - printf("\nUsage:\n %s [-v] [-t <title>] <media_path> [<keyfile_path>]\n\n", argv[0]);
  4233. - return -1;
  4234. - }
  4235. -
  4236. - if (!strcmp(argv[1+args], "-v")) {
  4237. - verbose = 1;
  4238. - args++;
  4239. - }
  4240. -
  4241. - if (!strcmp(argv[1+args], "-t")) {
  4242. - args++;
  4243. - title = atoi(argv[1+args]);
  4244. - args++;
  4245. - printf("Requested title %d\n", title);
  4246. - }
  4247. -
  4248. - if (verbose) {
  4249. - printf("Enabling verbose debug\n");
  4250. - bd_set_debug_mask(bd_get_debug_mask() | DBG_HDMV | DBG_BLURAY);
  4251. - }
  4252. -
  4253. - printf("\n");
  4254. -
  4255. - /*
  4256. - * open and setup
  4257. - */
  4258. -
  4259. - BLURAY *bd = bd_open(argv[1+args], argv[2+args]);
  4260. -
  4261. - if (!bd) {
  4262. - printf("bd_open(\'%s\') failed\n", argv[1]);
  4263. - return -1;
  4264. - }
  4265. -
  4266. - bd_set_player_setting (bd, BLURAY_PLAYER_SETTING_PARENTAL, 99);
  4267. - bd_set_player_setting_str(bd, BLURAY_PLAYER_SETTING_AUDIO_LANG, "eng");
  4268. - bd_set_player_setting_str(bd, BLURAY_PLAYER_SETTING_PG_LANG, "eng");
  4269. - bd_set_player_setting_str(bd, BLURAY_PLAYER_SETTING_MENU_LANG, "eng");
  4270. - bd_set_player_setting_str(bd, BLURAY_PLAYER_SETTING_COUNTRY_CODE, NULL);
  4271. -
  4272. - /*
  4273. - * play
  4274. - */
  4275. -
  4276. - printf("Running first play movie object\n");
  4277. -
  4278. - fflush(stdout);
  4279. - bd_play(bd);
  4280. -
  4281. - _print_events(bd);
  4282. -
  4283. - printf("\n");
  4284. -
  4285. - /*
  4286. - * play title
  4287. - */
  4288. -
  4289. - if (title >= 0) {
  4290. - printf("Playing title %d\n", title);
  4291. -
  4292. - fflush(stdout);
  4293. - bd_play_title(bd, title);
  4294. -
  4295. - _print_events(bd);
  4296. -
  4297. - printf("\n");
  4298. - }
  4299. -
  4300. - /*
  4301. - * play playlist
  4302. - */
  4303. -
  4304. - _play_pl(bd);
  4305. -
  4306. - _play_pl(bd);
  4307. -
  4308. - _play_pl(bd);
  4309. -
  4310. - /*
  4311. - * clean up
  4312. - */
  4313. -
  4314. - bd_close(bd);
  4315. -
  4316. - return 0;
  4317. -}
  4318. -
  4319. diff --git a/src/examples/list_titles.c b/src/examples/list_titles.c
  4320. index 2e0cae8..768f078 100644
  4321. --- a/src/examples/list_titles.c
  4322. +++ b/src/examples/list_titles.c
  4323. @@ -78,7 +78,10 @@ int main(int argc, char *argv[])
  4324. _usage(argv[0]);
  4325. }
  4326. bd = bd_open(bd_dir, NULL);
  4327. -
  4328. + if (!bd) {
  4329. + fprintf(stderr, "bd_open(%s) failed\n", bd_dir);
  4330. + exit(EXIT_FAILURE);
  4331. + }
  4332. count = bd_get_titles(bd, flags, seconds);
  4333. main_title = bd_get_main_title(bd);
  4334. if (main_title >= 0) {
  4335. @@ -89,7 +92,7 @@ int main(int argc, char *argv[])
  4336. BLURAY_TITLE_INFO* ti;
  4337. ti = bd_get_title_info(bd, ii, 0);
  4338. printf(
  4339. - "index: %d duration: %02"PRIu64":%02"PRIu64":%02"PRIu64" chapters: %3d angles: %2u clips: %3u (playlist: %05d.mpls) "
  4340. + "index: %3d duration: %02"PRIu64":%02"PRIu64":%02"PRIu64" chapters: %3d angles: %2u clips: %3u (playlist: %05d.mpls) "
  4341. "V:%d A:%-2d PG:%-2d IG:%-2d SV:%d SA:%d\n",
  4342. ii + 1,
  4343. (ti->duration / 90000) / (3600),
  4344. diff --git a/src/examples/mobj_dump.c b/src/examples/mobj_dump.c
  4345. deleted file mode 100644
  4346. index 3eaf9f4..0000000
  4347. --- a/src/examples/mobj_dump.c
  4348. +++ /dev/null
  4349. @@ -1,83 +0,0 @@
  4350. -/*
  4351. - * This file is part of libbluray
  4352. - * Copyright (C) 2010 hpi1
  4353. - *
  4354. - * This library is free software; you can redistribute it and/or
  4355. - * modify it under the terms of the GNU Lesser General Public
  4356. - * License as published by the Free Software Foundation; either
  4357. - * version 2.1 of the License, or (at your option) any later version.
  4358. - *
  4359. - * This library is distributed in the hope that it will be useful,
  4360. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4361. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  4362. - * Lesser General Public License for more details.
  4363. - *
  4364. - * You should have received a copy of the GNU Lesser General Public
  4365. - * License along with this library. If not, see
  4366. - * <http://www.gnu.org/licenses/>.
  4367. - */
  4368. -
  4369. -#include "libbluray/bluray.h"
  4370. -
  4371. -#include "libbluray/hdmv/mobj_data.h"
  4372. -#include "libbluray/hdmv/mobj_print.h"
  4373. -
  4374. -#include <stdio.h>
  4375. -#include <string.h>
  4376. -
  4377. -static void _mobj_print(MOBJ_OBJECTS *objects, int disasm)
  4378. -{
  4379. - int o, c;
  4380. -
  4381. - printf("Number of objects: %d\n", objects->num_objects);
  4382. -
  4383. - for (o = 0; o < objects->num_objects; o++) {
  4384. -
  4385. - printf("Object %d:\n"
  4386. - " number of commands: %d\n"
  4387. - " resume intention flag: %d\n"
  4388. - " menu call mask: %d\n"
  4389. - " title search mask: %d\n",
  4390. - o, objects->objects[o].num_cmds,
  4391. - objects->objects[o].resume_intention_flag,
  4392. - objects->objects[o].menu_call_mask,
  4393. - objects->objects[o].title_search_mask);
  4394. -
  4395. - if (disasm) {
  4396. - printf(" program:\n");
  4397. - for (c = 0; c < objects->objects[o].num_cmds; c++) {
  4398. - char buf[256];
  4399. - mobj_sprint_cmd(buf, &objects->objects[o].cmds[c]);
  4400. - printf(" %04d: %s\n", c, buf);
  4401. - }
  4402. - }
  4403. - }
  4404. -}
  4405. -
  4406. -int main(int argc, const char *argv[])
  4407. -{
  4408. - int disasm = 0;
  4409. - MOBJ_OBJECTS *mobj = NULL;
  4410. -
  4411. - if (argc < 2) {
  4412. - fprintf(stderr,
  4413. - "usage: %s [-d] <file>\n"
  4414. - "Options:\n"
  4415. - " d disassemble object code\n",
  4416. - argv[0]);
  4417. - return 1;
  4418. - }
  4419. - if (argc > 2) {
  4420. - disasm = !strcmp(argv[1], "-d");
  4421. - }
  4422. -
  4423. - mobj = bd_read_mobj(argv[argc-1]);
  4424. -
  4425. - if (mobj) {
  4426. - _mobj_print(mobj, disasm);
  4427. -
  4428. - bd_free_mobj(mobj);
  4429. - }
  4430. -
  4431. - return 0;
  4432. -}
  4433. diff --git a/src/examples/mpls_dump.c b/src/examples/mpls_dump.c
  4434. deleted file mode 100644
  4435. index 619b6b2..0000000
  4436. --- a/src/examples/mpls_dump.c
  4437. +++ /dev/null
  4438. @@ -1,797 +0,0 @@
  4439. -/*
  4440. - * This file is part of libbluray
  4441. - * Copyright (C) 2009-2010 John Stebbins
  4442. - *
  4443. - * This library is free software; you can redistribute it and/or
  4444. - * modify it under the terms of the GNU Lesser General Public
  4445. - * License as published by the Free Software Foundation; either
  4446. - * version 2.1 of the License, or (at your option) any later version.
  4447. - *
  4448. - * This library is distributed in the hope that it will be useful,
  4449. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  4450. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  4451. - * Lesser General Public License for more details.
  4452. - *
  4453. - * You should have received a copy of the GNU Lesser General Public
  4454. - * License along with this library. If not, see
  4455. - * <http://www.gnu.org/licenses/>.
  4456. - */
  4457. -
  4458. -#include <sys/stat.h>
  4459. -#include <dirent.h>
  4460. -#include <stdio.h>
  4461. -#include <stdlib.h>
  4462. -#include <unistd.h>
  4463. -#include <string.h>
  4464. -#include <libgen.h>
  4465. -
  4466. -#include "libbluray/bdnav/mpls_parse.h"
  4467. -#include "libbluray/bluray.h"
  4468. -
  4469. -#include "util.h"
  4470. -
  4471. -#ifdef _WIN32
  4472. -# define DIR_SEP "\\"
  4473. -# define PLAYLIST_DIR "\\BDMV\\PLAYLIST"
  4474. -#else
  4475. -# define DIR_SEP "/"
  4476. -# define PLAYLIST_DIR "/BDMV/PLAYLIST"
  4477. -#endif
  4478. -
  4479. -
  4480. -static int verbose;
  4481. -
  4482. -typedef struct {
  4483. - int value;
  4484. - const char *str;
  4485. -} VALUE_MAP;
  4486. -
  4487. -const VALUE_MAP codec_map[] = {
  4488. - {0x01, "MPEG-1 Video"},
  4489. - {0x02, "MPEG-2 Video"},
  4490. - {0x03, "MPEG-1 Audio"},
  4491. - {0x04, "MPEG-2 Audio"},
  4492. - {0x80, "LPCM"},
  4493. - {0x81, "AC-3"},
  4494. - {0x82, "DTS"},
  4495. - {0x83, "TrueHD"},
  4496. - {0x84, "AC-3 Plus"},
  4497. - {0x85, "DTS-HD"},
  4498. - {0x86, "DTS-HD Master"},
  4499. - {0xa1, "AC-3 Plus for secondary audio"},
  4500. - {0xa2, "DTS-HD for secondary audio"},
  4501. - {0xea, "VC-1"},
  4502. - {0x1b, "H.264"},
  4503. - {0x90, "Presentation Graphics"},
  4504. - {0x91, "Interactive Graphics"},
  4505. - {0x92, "Text Subtitle"},
  4506. - {0, NULL}
  4507. -};
  4508. -
  4509. -const VALUE_MAP video_format_map[] = {
  4510. - {0, "Reserved"},
  4511. - {1, "480i"},
  4512. - {2, "576i"},
  4513. - {3, "480p"},
  4514. - {4, "1080i"},
  4515. - {5, "720p"},
  4516. - {6, "1080p"},
  4517. - {7, "576p"},
  4518. - {0, NULL}
  4519. -};
  4520. -
  4521. -const VALUE_MAP video_rate_map[] = {
  4522. - {0, "Reserved1"},
  4523. - {1, "23.976"},
  4524. - {2, "24"},
  4525. - {3, "25"},
  4526. - {4, "29.97"},
  4527. - {5, "Reserved2"},
  4528. - {6, "50"},
  4529. - {7, "59.94"},
  4530. - {0, NULL}
  4531. -};
  4532. -
  4533. -const VALUE_MAP audio_format_map[] = {
  4534. - {0, "Reserved1"},
  4535. - {1, "Mono"},
  4536. - {2, "Reserved2"},
  4537. - {3, "Stereo"},
  4538. - {4, "Reserved3"},
  4539. - {5, "Reserved4"},
  4540. - {6, "Multi Channel"},
  4541. - {12, "Combo"},
  4542. - {0, NULL}
  4543. -};
  4544. -
  4545. -const VALUE_MAP audio_rate_map[] = {
  4546. - {0, "Reserved1"},
  4547. - {1, "48 Khz"},
  4548. - {2, "Reserved2"},
  4549. - {3, "Reserved3"},
  4550. - {4, "96 Khz"},
  4551. - {5, "192 Khz"},
  4552. - {12, "48/192 Khz"},
  4553. - {14, "48/96 Khz"},
  4554. - {0, NULL}
  4555. -};
  4556. -
  4557. -const VALUE_MAP subpath_type_map[] = {
  4558. - {2, "Primary audio of the Browsable slideshow"},
  4559. - {3, "Interactive Graphics presentation menu"},
  4560. - {4, "Text Subtitle"},
  4561. - {5, "Out-of-mux Synchronous elementary streams"},
  4562. - {6, "Out-of-mux Asynchronous Picture-in-Picture presentation"},
  4563. - {7, "In-mux Synchronous Picture-in-Picture presentation"},
  4564. - {8, "SS Video"},
  4565. - {0,NULL}
  4566. -};
  4567. -
  4568. -const VALUE_MAP playback_type_map[] = {
  4569. - {1, "Sequential"},
  4570. - {2, "Random"},
  4571. - {3, "Shuffle"},
  4572. - {0, NULL}
  4573. -};
  4574. -
  4575. -const VALUE_MAP connection_type_map[] = {
  4576. - {1, "Non-seamless"},
  4577. - {5, "Seamless"},
  4578. - {6, "Seamless"},
  4579. - {0, NULL}
  4580. -};
  4581. -
  4582. -static const char*
  4583. -_lookup_str(const VALUE_MAP *map, int val)
  4584. -{
  4585. - int ii;
  4586. -
  4587. - for (ii = 0; map[ii].str; ii++) {
  4588. - if (val == map[ii].value) {
  4589. - return map[ii].str;
  4590. - }
  4591. - }
  4592. - return "?";
  4593. -}
  4594. -
  4595. -static char *
  4596. -_mk_path(const char *base, const char *sub)
  4597. -{
  4598. - size_t n1 = strlen(base);
  4599. - size_t n2 = strlen(sub);
  4600. - char *result = (char*)malloc(n1 + n2 + strlen(DIR_SEP) + 1);
  4601. - strcpy(result, base);
  4602. - strcat(result, DIR_SEP);
  4603. - strcat(result, sub);
  4604. -
  4605. - return result;
  4606. -}
  4607. -
  4608. -static void
  4609. -_show_stream(MPLS_STREAM *ss, int level)
  4610. -{
  4611. - indent_printf(level, "Codec (%04x): %s", ss->coding_type,
  4612. - _lookup_str(codec_map, ss->coding_type));
  4613. - switch (ss->stream_type) {
  4614. - case 1:
  4615. - indent_printf(level, "PID: %04x", ss->pid);
  4616. - break;
  4617. -
  4618. - case 2:
  4619. - case 4:
  4620. - indent_printf(level, "SubPath Id: %02x", ss->subpath_id);
  4621. - indent_printf(level, "SubClip Id: %02x", ss->subclip_id);
  4622. - indent_printf(level, "PID: %04x", ss->pid);
  4623. - break;
  4624. -
  4625. - case 3:
  4626. - indent_printf(level, "SubPath Id: %02x", ss->subpath_id);
  4627. - indent_printf(level, "PID: %04x", ss->pid);
  4628. - break;
  4629. -
  4630. - default:
  4631. - fprintf(stderr, "unrecognized stream type %02x\n", ss->stream_type);
  4632. - break;
  4633. - };
  4634. -
  4635. - switch (ss->coding_type) {
  4636. - case 0x01:
  4637. - case 0x02:
  4638. - case 0xea:
  4639. - case 0x1b:
  4640. - indent_printf(level, "Format %02x: %s", ss->format,
  4641. - _lookup_str(video_format_map, ss->format));
  4642. - indent_printf(level, "Rate %02x: %s", ss->rate,
  4643. - _lookup_str(video_rate_map, ss->rate));
  4644. - break;
  4645. -
  4646. - case 0x03:
  4647. - case 0x04:
  4648. - case 0x80:
  4649. - case 0x81:
  4650. - case 0x82:
  4651. - case 0x83:
  4652. - case 0x84:
  4653. - case 0x85:
  4654. - case 0x86:
  4655. - case 0xa1:
  4656. - case 0xa2:
  4657. - indent_printf(level, "Format %02x: %s", ss->format,
  4658. - _lookup_str(audio_format_map, ss->format));
  4659. - indent_printf(level, "Rate %02x: %s", ss->rate,
  4660. - _lookup_str(audio_rate_map, ss->rate));
  4661. - indent_printf(level, "Language: %s", ss->lang);
  4662. - break;
  4663. -
  4664. - case 0x90:
  4665. - case 0x91:
  4666. - indent_printf(level, "Language: %s", ss->lang);
  4667. - break;
  4668. -
  4669. - case 0x92:
  4670. - indent_printf(level, "Char Code: %02x", ss->char_code);
  4671. - indent_printf(level, "Language: %s", ss->lang);
  4672. - break;
  4673. -
  4674. - default:
  4675. - fprintf(stderr, "unrecognized coding type %02x\n", ss->coding_type);
  4676. - break;
  4677. - };
  4678. -}
  4679. -
  4680. -static void
  4681. -_show_details(MPLS_PL *pl, int level)
  4682. -{
  4683. - int ii, jj, kk;
  4684. -
  4685. - for (ii = 0; ii < pl->list_count; ii++) {
  4686. - MPLS_PI *pi;
  4687. -
  4688. - pi = &pl->play_item[ii];
  4689. - indent_printf(level, "Clip Id %s", pi->clip[0].clip_id);
  4690. - indent_printf(level+1, "Stc Id: %02x", pi->clip[0].stc_id);
  4691. - indent_printf(level+1, "Connection Condition: %s (%02x)",
  4692. - _lookup_str(connection_type_map, pi->connection_condition),
  4693. - pi->connection_condition);
  4694. - indent_printf(level+1, "In-Time: %d", pi->in_time);
  4695. - indent_printf(level+1, "Out-Time: %d", pi->out_time);
  4696. - if (pi->still_mode == 1) {
  4697. - indent_printf(level+1, "Still time: %ds\n", pi->still_time);
  4698. - }
  4699. - if (pi->still_mode == 2) {
  4700. - indent_printf(level+1, "Still time: infinite\n");
  4701. - }
  4702. - if (pi->angle_count > 1) {
  4703. - for (jj = 1; jj < pi->angle_count; jj++) {
  4704. - indent_printf(level+1, "Angle %d:", jj);
  4705. - indent_printf(level+2, "Clip Id %s", pi->clip[jj].clip_id);
  4706. - indent_printf(level+2, "Stc Id: %02x", pi->clip[jj].stc_id);
  4707. - }
  4708. - }
  4709. - for (jj = 0; jj < pi->stn.num_video; jj++) {
  4710. - indent_printf(level+1, "Video Stream %d:", jj);
  4711. - _show_stream(&pi->stn.video[jj], level + 2);
  4712. - }
  4713. - for (jj = 0; jj < pi->stn.num_audio; jj++) {
  4714. - indent_printf(level+1, "Audio Stream %d:", jj);
  4715. - _show_stream(&pi->stn.audio[jj], level + 2);
  4716. - }
  4717. - for (jj = 0; jj < pi->stn.num_ig; jj++) {
  4718. - indent_printf(level+1, "Interactive Graphics Stream %d:", jj);
  4719. - _show_stream(&pi->stn.ig[jj], level + 2);
  4720. - }
  4721. - for (jj = 0; jj < (pi->stn.num_pg + pi->stn.num_pip_pg); jj++) {
  4722. - if (jj < pi->stn.num_pg) {
  4723. - indent_printf(level+1, "Presentation Graphics Stream %d:", jj);
  4724. - } else {
  4725. - indent_printf(level+1, "PIP Presentation Graphics Stream %d:", jj);
  4726. - }
  4727. - _show_stream(&pi->stn.pg[jj], level + 2);
  4728. - }
  4729. - for (jj = 0; jj < pi->stn.num_secondary_video; jj++) {
  4730. - indent_printf(level+1, "Secondary Video Stream %d:", jj);
  4731. - _show_stream(&pi->stn.secondary_video[jj], level + 2);
  4732. - for (kk = 0; kk < pi->stn.secondary_video[jj].sv_num_secondary_audio_ref; kk++) {
  4733. - indent_printf(level+2, "Secondary Audio Ref %d: %d", kk,pi->stn.secondary_video[jj].sv_secondary_audio_ref[kk]);
  4734. - }
  4735. - for (kk = 0; kk < pi->stn.secondary_video[jj].sv_num_pip_pg_ref; kk++) {
  4736. - indent_printf(level+2, "PIP Presentation Graphic Ref %d: %d", kk,pi->stn.secondary_video[jj].sv_pip_pg_ref[kk]);
  4737. - }
  4738. - }
  4739. - for (jj = 0; jj < pi->stn.num_secondary_audio; jj++) {
  4740. - indent_printf(level+1, "Secondary Audio Stream %d:", jj);
  4741. - _show_stream(&pi->stn.secondary_audio[jj], level + 2);
  4742. - for (kk = 0; kk < pi->stn.secondary_audio[jj].sa_num_primary_audio_ref; kk++) {
  4743. - indent_printf(level+2, "Primary Audio Ref %d: %d", kk,pi->stn.secondary_audio[jj].sa_primary_audio_ref[kk]);
  4744. - }
  4745. - }
  4746. - printf("\n");
  4747. - }
  4748. -}
  4749. -
  4750. -static void
  4751. -_show_ai(MPLS_PL *pl, int level)
  4752. -{
  4753. - indent_printf(level, "Playback type: %s (%d)",
  4754. - _lookup_str(playback_type_map, pl->app_info.playback_type),
  4755. - pl->app_info.playback_type);
  4756. - if (pl->app_info.playback_type == 2 || pl->app_info.playback_type == 3) {
  4757. - indent_printf(level+1, "Playback count: %d", pl->app_info.playback_count);
  4758. - }
  4759. -}
  4760. -
  4761. -static void
  4762. -_show_marks(MPLS_PL *pl, int level)
  4763. -{
  4764. - int ii;
  4765. -
  4766. - indent_printf(level, "PlayMark Count %d", pl->mark_count);
  4767. - for (ii = 0; ii < pl->mark_count; ii++) {
  4768. - MPLS_PI *pi;
  4769. - MPLS_PLM *plm;
  4770. - int min;
  4771. - double sec;
  4772. -
  4773. - plm = &pl->play_mark[ii];
  4774. - indent_printf(level, "PlayMark %d", ii);
  4775. - indent_printf(level+1, "Type: %02x", plm->mark_type);
  4776. - if (plm->play_item_ref < pl->list_count) {
  4777. - pi = &pl->play_item[plm->play_item_ref];
  4778. - indent_printf(level+1, "PlayItem: %s", pi->clip[0].clip_id);
  4779. - } else {
  4780. - indent_printf(level+1, "PlayItem: Invalid reference");
  4781. - }
  4782. - indent_printf(level+1, "Time (ticks): %u", plm->time);
  4783. - min = plm->duration / (45000*60);
  4784. - sec = (double)(plm->duration - min * 45000 * 60) / 45000;
  4785. - indent_printf(level+1, "Duration (mm:ss.ms, ticks): %d:%.2f, %u",
  4786. - min, sec, plm->duration);
  4787. - printf("\n");
  4788. - }
  4789. -}
  4790. -
  4791. -static void
  4792. -_show_clip_list(MPLS_PL *pl, int level)
  4793. -{
  4794. - int ii, jj;
  4795. -
  4796. - for (ii = 0; ii < pl->list_count; ii++) {
  4797. - MPLS_PI *pi;
  4798. -
  4799. - pi = &pl->play_item[ii];
  4800. - if (verbose) {
  4801. - uint32_t duration;
  4802. -
  4803. - duration = pi->out_time - pi->in_time;
  4804. - indent_printf(level, "%s.m2ts -- Duration: %3d:%02d",
  4805. - pi->clip[0].clip_id,
  4806. - duration / (45000 * 60), (duration / 45000) % 60);
  4807. - } else {
  4808. - indent_printf(level, "%s.m2ts", pi->clip[0].clip_id);
  4809. - }
  4810. - if (pi->angle_count > 1) {
  4811. - for (jj = 1; jj < pi->angle_count; jj++) {
  4812. - indent_printf(level+1, "Angle %d: %s.m2ts", jj+1, pi->clip[jj].clip_id);
  4813. - }
  4814. - }
  4815. - }
  4816. - printf("\n");
  4817. -}
  4818. -
  4819. -static void
  4820. -_show_sub_path(MPLS_SUB *sub, int level)
  4821. -{
  4822. - int ii;
  4823. -
  4824. - indent_printf(level+1, "Type: %d (%s)", sub->type, _lookup_str(subpath_type_map, sub->type));
  4825. - indent_printf(level+1, "Repeat: %d", sub->is_repeat);
  4826. - indent_printf(level+1, "Sub playitem count: %d", sub->sub_playitem_count);
  4827. -
  4828. - for (ii = 0; ii < sub->sub_playitem_count; ii++) {
  4829. - MPLS_SUB_PI *pi;
  4830. -
  4831. - pi = &sub->sub_play_item[ii];
  4832. -
  4833. - if (verbose) {
  4834. - indent_printf(level+1, "Sub playitem %d", ii);
  4835. - indent_printf(level+2, "Clip Id %s", pi->clip[0].clip_id);
  4836. - indent_printf(level+2, "Multi clip: %d", pi->is_multi_clip);
  4837. - indent_printf(level+2, "Clip count: %d", pi->clip_count);
  4838. - indent_printf(level+2, "Connection Condition: %s (%02x)",
  4839. - _lookup_str(connection_type_map, pi->connection_condition),
  4840. - pi->connection_condition);
  4841. - indent_printf(level+2, "In-Time: %d", pi->in_time);
  4842. - indent_printf(level+2, "Out-Time: %d", pi->out_time);
  4843. - indent_printf(level+2, "Sync playitem Id: %d", pi->sync_play_item_id);
  4844. - indent_printf(level+2, "Sync PTS: %d", pi->sync_pts);
  4845. - } else {
  4846. - indent_printf(level+1, "%s.m2ts", pi->clip[0].clip_id);
  4847. - }
  4848. - }
  4849. -}
  4850. -
  4851. -static void
  4852. -_show_pip_metadata_block(MPLS_PIP_METADATA *block, int level)
  4853. -{
  4854. - int ii;
  4855. -
  4856. - indent_printf(level, "Clip ref: %d", block->clip_ref);
  4857. - indent_printf(level, "Secondary video ref: %d", block->secondary_video_ref);
  4858. - indent_printf(level, "Timeline type: %d", block->timeline_type);
  4859. - indent_printf(level, "Luma key flag: %d", block->luma_key_flag);
  4860. - if (block->luma_key_flag) {
  4861. - indent_printf(level, "Upper limit luma key: %d", block->upper_limit_luma_key);
  4862. - }
  4863. - indent_printf(level, "Trick play flag: %d", block->trick_play_flag);
  4864. -
  4865. - for (ii = 0; ii < block->data_count; ii++) {
  4866. - indent_printf(level, "data block %d:", ii);
  4867. - indent_printf(level+1, "Timestamp: %d", block->data[ii].time);
  4868. - indent_printf(level+1, "Horizontal position %d", block->data[ii].xpos);
  4869. - indent_printf(level+1, "Vertical position: %d", block->data[ii].ypos);
  4870. - indent_printf(level+1, "Scaling factor: %d", block->data[ii].scale_factor);
  4871. - }
  4872. -}
  4873. -
  4874. -static void
  4875. -_show_pip_metadata(MPLS_PL *pl, int level)
  4876. -{
  4877. - int ii;
  4878. -
  4879. - for (ii = 0; ii < pl->ext_pip_data_count; ii++) {
  4880. - MPLS_PIP_METADATA *data;
  4881. -
  4882. - data = &pl->ext_pip_data[ii];
  4883. -
  4884. - indent_printf(level, "PiP metadata block %d:", ii);
  4885. - _show_pip_metadata_block(data, level+1);
  4886. - }
  4887. -}
  4888. -
  4889. -static void
  4890. -_show_sub_paths(MPLS_PL *pl, int level)
  4891. -{
  4892. - int ss;
  4893. -
  4894. - for (ss = 0; ss < pl->sub_count; ss++) {
  4895. - MPLS_SUB *sub;
  4896. -
  4897. - sub = &pl->sub_path[ss];
  4898. -
  4899. - indent_printf(level, "Sub Path %d:", ss);
  4900. - _show_sub_path(sub, level+1);
  4901. - }
  4902. -}
  4903. -
  4904. -static void
  4905. -_show_sub_paths_ss(MPLS_PL *pl, int level)
  4906. -{
  4907. - int ss;
  4908. -
  4909. - for (ss = 0; ss < pl->ext_sub_count; ss++) {
  4910. - MPLS_SUB *sub;
  4911. -
  4912. - sub = &pl->ext_sub_path[ss];
  4913. -
  4914. - indent_printf(level, "Extension Sub Path %d:", ss);
  4915. - _show_sub_path(sub, level+1);
  4916. - }
  4917. -}
  4918. -
  4919. -static uint32_t
  4920. -_pl_duration(MPLS_PL *pl)
  4921. -{
  4922. - int ii;
  4923. - uint32_t duration = 0;
  4924. - MPLS_PI *pi;
  4925. -
  4926. - for (ii = 0; ii < pl->list_count; ii++) {
  4927. - pi = &pl->play_item[ii];
  4928. - duration += pi->out_time - pi->in_time;
  4929. - }
  4930. - return duration;
  4931. -}
  4932. -
  4933. -static int
  4934. -_filter_dup(MPLS_PL *pl_list[], int count, MPLS_PL *pl)
  4935. -{
  4936. - int ii, jj;
  4937. -
  4938. - for (ii = 0; ii < count; ii++) {
  4939. - if (pl->list_count != pl_list[ii]->list_count ||
  4940. - _pl_duration(pl) != _pl_duration(pl_list[ii])) {
  4941. - continue;
  4942. - }
  4943. - for (jj = 0; jj < pl->list_count; jj++) {
  4944. - MPLS_PI *pi1, *pi2;
  4945. -
  4946. - pi1 = &pl->play_item[jj];
  4947. - pi2 = &pl_list[ii]->play_item[jj];
  4948. -
  4949. - if (memcmp(pi1->clip[0].clip_id, pi2->clip[0].clip_id, 5) != 0 ||
  4950. - pi1->in_time != pi2->in_time ||
  4951. - pi1->out_time != pi2->out_time) {
  4952. - break;
  4953. - }
  4954. - }
  4955. - if (jj != pl->list_count) {
  4956. - continue;
  4957. - }
  4958. - return 0;
  4959. - }
  4960. - return 1;
  4961. -}
  4962. -
  4963. -static int
  4964. -_find_repeats(MPLS_PL *pl, const char *m2ts)
  4965. -{
  4966. - int ii, count = 0;
  4967. -
  4968. - for (ii = 0; ii < pl->list_count; ii++) {
  4969. - MPLS_PI *pi;
  4970. -
  4971. - pi = &pl->play_item[ii];
  4972. - // Ignore titles with repeated segments
  4973. - if (strcmp(pi->clip[0].clip_id, m2ts) == 0) {
  4974. - count++;
  4975. - }
  4976. - }
  4977. - return count;
  4978. -}
  4979. -
  4980. -static int
  4981. -_filter_short(MPLS_PL *pl, unsigned int seconds)
  4982. -{
  4983. - // Ignore short playlists
  4984. - if (_pl_duration(pl) / 45000 <= seconds) {
  4985. - return 0;
  4986. - }
  4987. - return 1;
  4988. -}
  4989. -
  4990. -static int
  4991. -_filter_repeats(MPLS_PL *pl, int repeats)
  4992. -{
  4993. - int ii;
  4994. -
  4995. - for (ii = 0; ii < pl->list_count; ii++) {
  4996. - MPLS_PI *pi;
  4997. -
  4998. - pi = &pl->play_item[ii];
  4999. - // Ignore titles with repeated segments
  5000. - if (_find_repeats(pl, pi->clip[0].clip_id) > repeats) {
  5001. - return 0;
  5002. - }
  5003. - }
  5004. - return 1;
  5005. -}
  5006. -
  5007. -static int clip_list = 0, playlist_info = 0, chapter_marks = 0, sub_paths = 0, pip_metadata = 0;
  5008. -static int repeats = 0, seconds = 0, dups = 0;
  5009. -
  5010. -static MPLS_PL*
  5011. -_process_file(char *name, MPLS_PL *pl_list[], int pl_count)
  5012. -{
  5013. - MPLS_PL *pl;
  5014. -
  5015. - pl = bd_read_mpls(name);
  5016. - if (pl == NULL) {
  5017. - fprintf(stderr, "Parse failed: %s\n", name);
  5018. - return NULL;
  5019. - }
  5020. - if (seconds) {
  5021. - if (!_filter_short(pl, seconds)) {
  5022. - bd_free_mpls(pl);
  5023. - return NULL;
  5024. - }
  5025. - }
  5026. - if (repeats) {
  5027. - if (!_filter_repeats(pl, repeats)) {
  5028. - bd_free_mpls(pl);
  5029. - return NULL;
  5030. - }
  5031. - }
  5032. - if (dups) {
  5033. - if (!_filter_dup(pl_list, pl_count, pl)) {
  5034. - bd_free_mpls(pl);
  5035. - return NULL;
  5036. - }
  5037. - }
  5038. - if (verbose) {
  5039. - indent_printf(0,
  5040. - "%s -- Num Clips: %3d , Duration: minutes %4u:%02u",
  5041. - basename(name),
  5042. - pl->list_count,
  5043. - _pl_duration(pl) / (45000 * 60),
  5044. - (_pl_duration(pl) / 45000) % 60);
  5045. - _show_ai(pl, 1);
  5046. - } else {
  5047. - indent_printf(0, "%s -- Duration: minutes %4u:%02u",
  5048. - basename(name),
  5049. - _pl_duration(pl) / (45000 * 60),
  5050. - (_pl_duration(pl) / 45000) % 60);
  5051. - }
  5052. - if (playlist_info) {
  5053. - _show_details(pl, 1);
  5054. - }
  5055. - if (chapter_marks) {
  5056. - _show_marks(pl, 1);
  5057. - }
  5058. - if (pip_metadata) {
  5059. - _show_pip_metadata(pl, 1);
  5060. - }
  5061. - if (clip_list) {
  5062. - _show_clip_list(pl, 1);
  5063. - }
  5064. - if (sub_paths) {
  5065. - _show_sub_paths(pl, 1);
  5066. - _show_sub_paths_ss(pl, 1);
  5067. - }
  5068. - return pl;
  5069. -}
  5070. -
  5071. -static void
  5072. -_usage(char *cmd)
  5073. -{
  5074. - fprintf(stderr,
  5075. -"Usage: %s -vli <mpls file> [<mpls file> ...]\n"
  5076. -"With no options, produces a list of the playlist(s) with durations\n"
  5077. -"Options:\n"
  5078. -" v - Verbose output.\n"
  5079. -" l - Produces a list of the m2ts clips\n"
  5080. -" i - Dumps detailed information about each clip\n"
  5081. -" c - Show chapter marks\n"
  5082. -" p - Show sub paths\n"
  5083. -" P - Show picture-in-picture metadata\n"
  5084. -" r <N> - Filter out titles that have >N repeating clips\n"
  5085. -" d - Filter out duplicate titles\n"
  5086. -" s <seconds> - Filter out short titles\n"
  5087. -" f - Filter combination -r2 -d -s900\n"
  5088. -, cmd);
  5089. -
  5090. - exit(EXIT_FAILURE);
  5091. -}
  5092. -
  5093. -#define OPTS "vlicpPfr:ds:"
  5094. -
  5095. -static int
  5096. -_qsort_str_cmp(const void *a, const void *b)
  5097. -{
  5098. - const char *stra = *(char * const *)a;
  5099. - const char *strb = *(char * const *)b;
  5100. -
  5101. - return strcmp(stra, strb);
  5102. -}
  5103. -
  5104. -int
  5105. -main(int argc, char *argv[])
  5106. -{
  5107. - MPLS_PL *pl;
  5108. - int opt;
  5109. - int ii, pl_ii;
  5110. - MPLS_PL *pl_list[1000];
  5111. - struct stat st;
  5112. - char *path = NULL;
  5113. - DIR *dir = NULL;
  5114. -
  5115. - do {
  5116. - opt = getopt(argc, argv, OPTS);
  5117. - switch (opt) {
  5118. - case -1:
  5119. - break;
  5120. -
  5121. - case 'v':
  5122. - verbose = 1;
  5123. - break;
  5124. -
  5125. - case 'l':
  5126. - clip_list = 1;
  5127. - break;
  5128. -
  5129. - case 'i':
  5130. - playlist_info = 1;
  5131. - break;
  5132. -
  5133. - case 'c':
  5134. - chapter_marks = 1;
  5135. - break;
  5136. -
  5137. - case 'p':
  5138. - sub_paths = 1;
  5139. - break;
  5140. -
  5141. - case 'P':
  5142. - pip_metadata = 1;
  5143. - break;
  5144. -
  5145. - case 'd':
  5146. - dups = 1;
  5147. - break;
  5148. -
  5149. - case 'r':
  5150. - repeats = atoi(optarg);
  5151. - break;
  5152. -
  5153. - case 'f':
  5154. - repeats = 2;
  5155. - dups = 1;
  5156. - seconds = 900;
  5157. - break;
  5158. -
  5159. - case 's':
  5160. - seconds = atoi(optarg);
  5161. - break;
  5162. -
  5163. - default:
  5164. - _usage(argv[0]);
  5165. - break;
  5166. - }
  5167. - } while (opt != -1);
  5168. -
  5169. - if (optind >= argc) {
  5170. - _usage(argv[0]);
  5171. - }
  5172. -
  5173. - for (pl_ii = 0, ii = optind; pl_ii < 1000 && ii < argc; ii++) {
  5174. -
  5175. - if (stat(argv[ii], &st)) {
  5176. - continue;
  5177. - }
  5178. - dir = NULL;
  5179. - if (S_ISDIR(st.st_mode)) {
  5180. -
  5181. - printf("Directory: %s:\n", argv[ii]);
  5182. - path = _mk_path(argv[ii], PLAYLIST_DIR);
  5183. - if (path == NULL) {
  5184. - fprintf(stderr, "Failed to find playlist path: %s\n", argv[ii]);
  5185. - continue;
  5186. - }
  5187. - dir = opendir(path);
  5188. - if (dir == NULL) {
  5189. - fprintf(stderr, "Failed to open dir: %s\n", path);
  5190. - free(path);
  5191. - continue;
  5192. - }
  5193. - }
  5194. - if (dir != NULL) {
  5195. - char **dirlist = (char**)calloc(10001, sizeof(char*));
  5196. - struct dirent *ent;
  5197. - int jj = 0;
  5198. - for (ent = readdir(dir); ent != NULL; ent = readdir(dir)) {
  5199. - dirlist[jj++] = strcpy((char*)malloc(strlen(ent->d_name)), ent->d_name);
  5200. - }
  5201. - qsort(dirlist, jj, sizeof(char*), _qsort_str_cmp);
  5202. - for (jj = 0; dirlist[jj] != NULL; jj++) {
  5203. - char *name = NULL;
  5204. - name = _mk_path(path, dirlist[jj]);
  5205. - free(dirlist[jj]);
  5206. - if (stat(name, &st)) {
  5207. - free(name);
  5208. - continue;
  5209. - }
  5210. - if (!S_ISREG(st.st_mode)) {
  5211. - free(name);
  5212. - continue;
  5213. - }
  5214. - pl = _process_file(name, pl_list, pl_ii);
  5215. - free(name);
  5216. - if (pl != NULL) {
  5217. - pl_list[pl_ii++] = pl;
  5218. - }
  5219. - }
  5220. - free(dirlist);
  5221. - free(path);
  5222. - } else {
  5223. - pl = _process_file(argv[ii], pl_list, pl_ii);
  5224. - if (pl != NULL) {
  5225. - pl_list[pl_ii++] = pl;
  5226. - }
  5227. - }
  5228. - }
  5229. - // Cleanup
  5230. - for (ii = 0; ii < pl_ii; ii++) {
  5231. - bd_free_mpls(pl_list[ii]);
  5232. - }
  5233. - return 0;
  5234. -}
  5235. -
  5236. diff --git a/src/examples/util.c b/src/examples/util.c
  5237. deleted file mode 100644
  5238. index aaa4c46..0000000
  5239. --- a/src/examples/util.c
  5240. +++ /dev/null
  5241. @@ -1,40 +0,0 @@
  5242. -/*
  5243. - * This file is part of libbluray
  5244. - * Copyright (C) 2009-2010 John Stebbins
  5245. - *
  5246. - * This library is free software; you can redistribute it and/or
  5247. - * modify it under the terms of the GNU Lesser General Public
  5248. - * License as published by the Free Software Foundation; either
  5249. - * version 2.1 of the License, or (at your option) any later version.
  5250. - *
  5251. - * This library is distributed in the hope that it will be useful,
  5252. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  5253. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5254. - * Lesser General Public License for more details.
  5255. - *
  5256. - * You should have received a copy of the GNU Lesser General Public
  5257. - * License along with this library. If not, see
  5258. - * <http://www.gnu.org/licenses/>.
  5259. - */
  5260. -
  5261. -#include <stdio.h>
  5262. -#include <stdarg.h>
  5263. -
  5264. -#include "util.h"
  5265. -
  5266. -void
  5267. -indent_printf(int level, const char *fmt, ...)
  5268. -{
  5269. - va_list ap;
  5270. - int ii;
  5271. -
  5272. - for (ii = 0; ii < level; ii++)
  5273. - {
  5274. - printf(" ");
  5275. - }
  5276. - va_start(ap, fmt);
  5277. - vprintf(fmt, ap);
  5278. - va_end(ap);
  5279. - printf("\n");
  5280. -}
  5281. -
  5282. diff --git a/src/examples/util.h b/src/examples/util.h
  5283. deleted file mode 100644
  5284. index 144f8ec..0000000
  5285. --- a/src/examples/util.h
  5286. +++ /dev/null
  5287. @@ -1,43 +0,0 @@
  5288. -/*
  5289. - * This file is part of libbluray
  5290. - * Copyright (C) 2009-2010 John Stebbins
  5291. - *
  5292. - * This library is free software; you can redistribute it and/or
  5293. - * modify it under the terms of the GNU Lesser General Public
  5294. - * License as published by the Free Software Foundation; either
  5295. - * version 2.1 of the License, or (at your option) any later version.
  5296. - *
  5297. - * This library is distributed in the hope that it will be useful,
  5298. - * but WITHOUT ANY WARRANTY; without even the implied warranty of
  5299. - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  5300. - * Lesser General Public License for more details.
  5301. - *
  5302. - * You should have received a copy of the GNU Lesser General Public
  5303. - * License along with this library. If not, see
  5304. - * <http://www.gnu.org/licenses/>.
  5305. - */
  5306. -
  5307. -#include <stdint.h>
  5308. -
  5309. -#include "util/attributes.h"
  5310. -
  5311. -#if defined( __MINGW32__ )
  5312. -# undef lseek
  5313. -# define lseek _lseeki64
  5314. -# undef fseeko
  5315. -# define fseeko fseeko64
  5316. -# undef ftello
  5317. -# define ftello ftello64
  5318. -# define flockfile(...)
  5319. -# define funlockfile(...)
  5320. -# define getc_unlocked getc
  5321. -# undef off_t
  5322. -# define off_t off64_t
  5323. -# undef stat
  5324. -# define stat _stati64
  5325. -# define fstat _fstati64
  5326. -# define wstat _wstati64
  5327. -#endif
  5328. -
  5329. -void indent_printf(int level, const char *fmt, ...) BD_ATTR_FORMAT_PRINTF(2,3);
  5330. -
  5331. diff --git a/src/file/dir_win32.c b/src/file/dir_win32.c
  5332. index 2690658..f42114d 100644
  5333. --- a/src/file/dir_win32.c
  5334. +++ b/src/file/dir_win32.c
  5335. @@ -86,8 +86,8 @@ static BD_DIR_H *_dir_open_win32(const char* dirname)
  5336. dir->internal = priv;
  5337. - wchar_t wfilespec[MAX_PATH];
  5338. - if (MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filespec, -1, wfilespec, MAX_PATH))
  5339. + wchar_t wfilespec[4096 + 1] = {0};
  5340. + if (MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filespec, -1, wfilespec, 4096))
  5341. priv->handle = _wfindfirst(wfilespec, &priv->info);
  5342. else
  5343. priv->handle = -1;
  5344. diff --git a/src/file/dirs_win32.c b/src/file/dirs_win32.c
  5345. index e165fea..3d07251 100644
  5346. --- a/src/file/dirs_win32.c
  5347. +++ b/src/file/dirs_win32.c
  5348. @@ -36,7 +36,7 @@
  5349. char *win32_get_font_dir(const char *font_file)
  5350. {
  5351. - wchar_t wdir[MAX_PATH];
  5352. + wchar_t wdir[MAX_PATH+1] = {0};
  5353. if (S_OK != SHGetFolderPathW(NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, wdir)) {
  5354. int lenght = GetWindowsDirectoryW(wdir, MAX_PATH);
  5355. if (lenght == 0 || lenght > (MAX_PATH - 8)) {
  5356. @@ -67,7 +67,7 @@ char *file_get_config_home(void)
  5357. char *file_get_data_home(void)
  5358. {
  5359. - wchar_t wdir[MAX_PATH];
  5360. + wchar_t wdir[MAX_PATH+1] = {0};
  5361. /* Get the "Application Data" folder for the user */
  5362. if (S_OK == SHGetFolderPathW(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE,
  5363. @@ -92,7 +92,7 @@ char *file_get_cache_home(void)
  5364. const char *file_get_config_system(const char *dir)
  5365. {
  5366. static char *appdir = NULL;
  5367. - wchar_t wdir[MAX_PATH];
  5368. + wchar_t wdir[MAX_PATH+1] = {0};
  5369. if (!dir) {
  5370. // first call
  5371. diff --git a/src/file/dl_win32.c b/src/file/dl_win32.c
  5372. index e4492e1..7f6ae73 100644
  5373. --- a/src/file/dl_win32.c
  5374. +++ b/src/file/dl_win32.c
  5375. @@ -57,7 +57,7 @@ void *dl_dlopen(const char *path, const char *version)
  5376. {
  5377. (void)version;
  5378. - wchar_t wname[MAX_PATH];
  5379. + wchar_t wname[MAX_PATH+1] = {0};
  5380. char *name;
  5381. void *result;
  5382. @@ -109,7 +109,7 @@ const char *dl_get_path(void)
  5383. if (!initialized) {
  5384. initialized = 1;
  5385. - static char path[MAX_PATH];
  5386. + static char path[MAX_PATH + 1];
  5387. HMODULE hModule;
  5388. wchar_t wpath[MAX_PATH];
  5389. diff --git a/src/file/file_win32.c b/src/file/file_win32.c
  5390. index 5eb52d7..c0f48e4 100644
  5391. --- a/src/file/file_win32.c
  5392. +++ b/src/file/file_win32.c
  5393. @@ -97,9 +97,9 @@ static BD_FILE_H *_file_open(const char* filename, const char *mode)
  5394. {
  5395. BD_FILE_H *file;
  5396. FILE *fp;
  5397. - wchar_t wfilename[MAX_PATH], wmode[8];
  5398. + wchar_t wfilename[4096 + 1] = {0}, wmode[8] = {0};
  5399. - if (!MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filename, -1, wfilename, MAX_PATH) ||
  5400. + if (!MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filename, -1, wfilename, 4096) ||
  5401. !MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, mode, -1, wmode, 8)) {
  5402. BD_DEBUG(DBG_FILE, "Error opening file %s\n", filename);
  5403. @@ -112,6 +112,9 @@ static BD_FILE_H *_file_open(const char* filename, const char *mode)
  5404. return NULL;
  5405. }
  5406. + // Set file buffer
  5407. + setvbuf(fp, NULL, _IOFBF, 6144 * 10);
  5408. +
  5409. file = calloc(1, sizeof(BD_FILE_H));
  5410. if (!file) {
  5411. BD_DEBUG(DBG_FILE | DBG_CRIT, "Error opening file %s (out of memory)\n", filename);
  5412. diff --git a/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java b/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
  5413. index 54c24e5..77ce66e 100644
  5414. --- a/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
  5415. +++ b/src/libbluray/bdj/java-j2se/java/awt/BDGraphics.java
  5416. @@ -53,6 +53,7 @@ class BDGraphics extends BDGraphicsBase {
  5417. public java.awt.font.FontRenderContext getFontRenderContext()
  5418. {
  5419. + logger.unimplemented("getFontRenderContext");
  5420. return null;
  5421. }
  5422. public void setPaint(Paint p) {
  5423. diff --git a/src/libbluray/bdj/java/java/awt/BDToolkitBase.java b/src/libbluray/bdj/java/java/awt/BDToolkitBase.java
  5424. index dc61bef..0f5e3e0 100644
  5425. --- a/src/libbluray/bdj/java/java/awt/BDToolkitBase.java
  5426. +++ b/src/libbluray/bdj/java/java/awt/BDToolkitBase.java
  5427. @@ -124,6 +124,10 @@ abstract class BDToolkitBase extends Toolkit {
  5428. }
  5429. public Image getImage(String filename) {
  5430. + if (BDJXletContext.getCurrentContext() == null) {
  5431. + logger.error("getImage(): no context " + Logger.dumpStack());
  5432. + }
  5433. +
  5434. if (cachedImages.containsKey(filename))
  5435. return (Image)cachedImages.get(filename);
  5436. Image newImage = createImage(filename);
  5437. @@ -133,6 +137,10 @@ abstract class BDToolkitBase extends Toolkit {
  5438. }
  5439. public Image getImage(URL url) {
  5440. + if (BDJXletContext.getCurrentContext() == null) {
  5441. + logger.error("getImage(): no context " + Logger.dumpStack());
  5442. + }
  5443. +
  5444. if (cachedImages.containsKey(url))
  5445. return (Image)cachedImages.get(url);
  5446. Image newImage = createImage(url);
  5447. @@ -142,6 +150,10 @@ abstract class BDToolkitBase extends Toolkit {
  5448. }
  5449. public Image createImage(String filename) {
  5450. + if (BDJXletContext.getCurrentContext() == null) {
  5451. + logger.error("createImage(): no context " + Logger.dumpStack());
  5452. + }
  5453. +
  5454. if (!new File(filename).isAbsolute()) {
  5455. String home = BDJXletContext.getCurrentXletHome();
  5456. if (home != null) {
  5457. @@ -161,6 +173,9 @@ abstract class BDToolkitBase extends Toolkit {
  5458. }
  5459. public Image createImage(URL url) {
  5460. + if (BDJXletContext.getCurrentContext() == null) {
  5461. + logger.error("createImage(): no context " + Logger.dumpStack());
  5462. + }
  5463. ImageProducer ip = new URLImageSource(url);
  5464. Image newImage = createImage(ip);
  5465. return newImage;
  5466. @@ -169,12 +184,20 @@ abstract class BDToolkitBase extends Toolkit {
  5467. public Image createImage(byte[] imagedata,
  5468. int imageoffset,
  5469. int imagelength) {
  5470. +
  5471. + if (BDJXletContext.getCurrentContext() == null) {
  5472. + logger.error("createImage(): no context " + Logger.dumpStack());
  5473. + }
  5474. +
  5475. ImageProducer ip = new ByteArrayImageSource(imagedata, imageoffset, imagelength);
  5476. Image newImage = createImage(ip);
  5477. return newImage;
  5478. }
  5479. public Image createImage(ImageProducer producer) {
  5480. + if (BDJXletContext.getCurrentContext() == null) {
  5481. + logger.error("createImage(): no context " + Logger.dumpStack());
  5482. + }
  5483. return new BDImageConsumer(producer);
  5484. }
  5485. diff --git a/src/libbluray/bdj/java/javax/media/MediaLocator.java b/src/libbluray/bdj/java/javax/media/MediaLocator.java
  5486. index a182e8d..245ac54 100644
  5487. --- a/src/libbluray/bdj/java/javax/media/MediaLocator.java
  5488. +++ b/src/libbluray/bdj/java/javax/media/MediaLocator.java
  5489. @@ -25,11 +25,11 @@ import java.net.URL;
  5490. public class MediaLocator implements Serializable
  5491. {
  5492. - public MediaLocator(URL url) {
  5493. + public MediaLocator(URL url) {
  5494. this(url.toExternalForm());
  5495. }
  5496. - public MediaLocator(String locatorString) {
  5497. + public MediaLocator(String locatorString) {
  5498. int index = locatorString.indexOf(":");
  5499. if (index <= 0)
  5500. throw new IllegalArgumentException("Bad locator string.");
  5501. @@ -56,7 +56,7 @@ public class MediaLocator implements Serializable
  5502. public String toExternalForm() {
  5503. return protocol + ":" + remainder;
  5504. }
  5505. -
  5506. +
  5507. private String protocol = "";
  5508. private String remainder = "";
  5509. diff --git a/src/libbluray/bdj/java/javax/tv/locator/LocatorImpl.java b/src/libbluray/bdj/java/javax/tv/locator/LocatorImpl.java
  5510. index e14825c..a87269a 100644
  5511. --- a/src/libbluray/bdj/java/javax/tv/locator/LocatorImpl.java
  5512. +++ b/src/libbluray/bdj/java/javax/tv/locator/LocatorImpl.java
  5513. @@ -24,7 +24,7 @@ public class LocatorImpl implements Locator {
  5514. this.url = url;
  5515. }
  5516. - public boolean hasMultipleTransformations() {
  5517. + public boolean hasMultipleTransformations() {
  5518. return false;
  5519. }
  5520. diff --git a/src/libbluray/bdj/java/org/videolan/BDJLoader.java b/src/libbluray/bdj/java/org/videolan/BDJLoader.java
  5521. index 59410c5..b2bcff3 100644
  5522. --- a/src/libbluray/bdj/java/org/videolan/BDJLoader.java
  5523. +++ b/src/libbluray/bdj/java/org/videolan/BDJLoader.java
  5524. @@ -185,11 +185,6 @@ public class BDJLoader {
  5525. throw new InvalidObjectException("bdjo not loaded");
  5526. AppEntry[] appTable = bdjo.getAppTable();
  5527. - // initialize AppCaches
  5528. - if (vfsCache != null) {
  5529. - vfsCache.add(bdjo.getAppCaches());
  5530. - }
  5531. -
  5532. // reuse appProxys
  5533. BDJAppProxy[] proxys = new BDJAppProxy[appTable.length];
  5534. AppsDatabase db = AppsDatabase.getAppsDatabase();
  5535. @@ -215,7 +210,6 @@ public class BDJLoader {
  5536. proxy.stop(true);
  5537. } else {
  5538. logger.info("Keeping xlet " + appTable[i].getInitialClass());
  5539. - proxy.getXletContext().update(appTable[i], bdjo.getAppCaches());
  5540. proxys[i] = proxy;
  5541. proxy = null;
  5542. }
  5543. @@ -240,6 +234,11 @@ public class BDJLoader {
  5544. Libbluray.setUOMask(terminfo.getMenuCallMask(), terminfo.getTitleSearchMask());
  5545. Libbluray.setKeyInterest(bdjo.getKeyInterestTable());
  5546. + // initialize AppCaches
  5547. + if (vfsCache != null) {
  5548. + vfsCache.add(bdjo.getAppCaches());
  5549. + }
  5550. +
  5551. // initialize appProxys
  5552. for (int i = 0; i < appTable.length; i++) {
  5553. if (proxys[i] == null) {
  5554. @@ -256,6 +255,7 @@ public class BDJLoader {
  5555. }
  5556. logger.info("Loaded class: " + appTable[i].getInitialClass() + p + " from " + appTable[i].getBasePath() + ".jar");
  5557. } else {
  5558. + proxys[i].getXletContext().update(appTable[i], bdjo.getAppCaches());
  5559. logger.info("Reused class: " + appTable[i].getInitialClass() + " from " + appTable[i].getBasePath() + ".jar");
  5560. }
  5561. }
  5562. @@ -266,6 +266,19 @@ public class BDJLoader {
  5563. // notify AppsDatabase
  5564. ((BDJAppsDatabase)BDJAppsDatabase.getAppsDatabase()).newDatabase(bdjo, proxys);
  5565. + // auto start playlist
  5566. + try {
  5567. + PlayListTable plt = bdjo.getAccessiblePlaylists();
  5568. + if ((plt != null) && (plt.isAutostartFirst())) {
  5569. + logger.info("Auto-starting playlist");
  5570. + String[] pl = plt.getPlayLists();
  5571. + if (pl.length > 0)
  5572. + Manager.createPlayer(new MediaLocator(new BDLocator("bd://PLAYLIST:" + pl[0]))).start();
  5573. + }
  5574. + } catch (Exception e) {
  5575. + logger.error("loadN(): autoplaylist failed: " + e + "\n" + Logger.dumpStack(e));
  5576. + }
  5577. +
  5578. // now run all the xlets
  5579. for (int i = 0; i < appTable.length; i++) {
  5580. int code = appTable[i].getControlCode();
  5581. @@ -282,15 +295,6 @@ public class BDJLoader {
  5582. logger.info("Finished initializing and starting xlets.");
  5583. - // auto start playlist
  5584. - PlayListTable plt = bdjo.getAccessiblePlaylists();
  5585. - if ((plt != null) && (plt.isAutostartFirst())) {
  5586. - logger.info("Auto-starting playlist");
  5587. - String[] pl = plt.getPlayLists();
  5588. - if (pl.length > 0)
  5589. - Manager.createPlayer(new MediaLocator(new BDLocator("bd://PLAYLIST:" + pl[0]))).start();
  5590. - }
  5591. -
  5592. return true;
  5593. } catch (Throwable e) {
  5594. diff --git a/src/libbluray/bdj/java/org/videolan/BDJXletContext.java b/src/libbluray/bdj/java/org/videolan/BDJXletContext.java
  5595. index 359cd28..8ee818a 100644
  5596. --- a/src/libbluray/bdj/java/org/videolan/BDJXletContext.java
  5597. +++ b/src/libbluray/bdj/java/org/videolan/BDJXletContext.java
  5598. @@ -70,7 +70,12 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
  5599. try {
  5600. int homeJarID = Integer.parseInt(home);
  5601. long time = System.currentTimeMillis();
  5602. - homeMountPoint = MountManager.mount(homeJarID, false) + java.io.File.separator;
  5603. + homeMountPoint = MountManager.mount(homeJarID, false);
  5604. + if (homeMountPoint == null) {
  5605. + logger.error("Failed mounting " + home + ".jar");
  5606. + } else {
  5607. + homeMountPoint = homeMountPoint + java.io.File.separator;
  5608. + }
  5609. time = System.currentTimeMillis() - time;
  5610. logger.info("Mounted Xlet home directory from " + home + ".jar " +
  5611. "to " + homeMountPoint + "(" + time + "ms)");
  5612. diff --git a/src/libbluray/bdj/java/org/videolan/IxcRegistryImpl.java b/src/libbluray/bdj/java/org/videolan/IxcRegistryImpl.java
  5613. index 144f1ab..bae986f 100644
  5614. --- a/src/libbluray/bdj/java/org/videolan/IxcRegistryImpl.java
  5615. +++ b/src/libbluray/bdj/java/org/videolan/IxcRegistryImpl.java
  5616. @@ -452,7 +452,7 @@ public class IxcRegistryImpl {
  5617. }
  5618. Object remoteObj = wrapOrCopy(wrappedObj, wrappedObj.context, (BDJXletContext)xc);
  5619. - Debug("IxcRegistry.lookup(" + path + ") => " + remoteObj);
  5620. + Debug("IxcRegistry.lookup(" + path + ") => OK");
  5621. return (Remote)remoteObj;
  5622. }
  5623. diff --git a/src/libbluray/bdj/java/org/videolan/MountManager.java b/src/libbluray/bdj/java/org/videolan/MountManager.java
  5624. index 5c9660a..6f6fd52 100644
  5625. --- a/src/libbluray/bdj/java/org/videolan/MountManager.java
  5626. +++ b/src/libbluray/bdj/java/org/videolan/MountManager.java
  5627. @@ -185,6 +185,7 @@ public class MountManager {
  5628. new PrivilegedAction() {
  5629. public Object run() {
  5630. if (mountPoint.decRefCount() < 1) {
  5631. + logger.error("Removing JAR " + id + " from mount cache");
  5632. mountPoints.remove(id);
  5633. }
  5634. return null;
  5635. diff --git a/src/libbluray/bdj/java/org/videolan/media/content/PlayerManager.java b/src/libbluray/bdj/java/org/videolan/media/content/PlayerManager.java
  5636. index cc06e84..d45358b 100644
  5637. --- a/src/libbluray/bdj/java/org/videolan/media/content/PlayerManager.java
  5638. +++ b/src/libbluray/bdj/java/org/videolan/media/content/PlayerManager.java
  5639. @@ -19,6 +19,7 @@
  5640. package org.videolan.media.content;
  5641. import java.util.ArrayList;
  5642. +import org.videolan.Logger;
  5643. public class PlayerManager {
  5644. @@ -81,7 +82,7 @@ public class PlayerManager {
  5645. return;
  5646. }
  5647. - System.err.println("unknown player type: " + player.getClass().getName());
  5648. + logger.error("unknown player type: " + player.getClass().getName());
  5649. }
  5650. protected boolean allocateResource(BDHandler player) {
  5651. @@ -91,6 +92,9 @@ public class PlayerManager {
  5652. }
  5653. synchronized (playlistPlayerLock) {
  5654. if (playlistPlayer != null && player != playlistPlayer) {
  5655. +
  5656. + logger.info("allocateResource(): Stopping old playlist player");
  5657. +
  5658. playlistPlayer.stop();
  5659. playlistPlayer.deallocate();
  5660. }
  5661. @@ -108,7 +112,7 @@ public class PlayerManager {
  5662. return true;
  5663. }
  5664. - System.err.println("unknown player type: " + player.getClass().getName());
  5665. + logger.error("allocateResource(): unknown player type: " + player.getClass().getName());
  5666. return false;
  5667. }
  5668. @@ -153,4 +157,6 @@ public class PlayerManager {
  5669. }
  5670. }
  5671. }
  5672. +
  5673. + private static final Logger logger = Logger.getLogger(PlayerManager.class.getName());
  5674. }
  5675. diff --git a/src/libbluray/bdnav/clpi_parse.c b/src/libbluray/bdnav/clpi_parse.c
  5676. index ec57a38..f0826de 100644
  5677. --- a/src/libbluray/bdnav/clpi_parse.c
  5678. +++ b/src/libbluray/bdnav/clpi_parse.c
  5679. @@ -39,6 +39,7 @@
  5680. #define CLPI_SIG1 ('H' << 24 | 'D' << 16 | 'M' << 8 | 'V')
  5681. #define CLPI_SIG2A ('0' << 24 | '2' << 16 | '0' << 8 | '0')
  5682. #define CLPI_SIG2B ('0' << 24 | '1' << 16 | '0' << 8 | '0')
  5683. +#define CLPI_SIG2C ('0' << 24 | '2' << 16 | '4' << 8 | '0')
  5684. static void
  5685. _human_readable_sig(char *sig, uint32_t s1, uint32_t s2)
  5686. @@ -129,7 +130,8 @@ _parse_header(BITSTREAM *bits, CLPI_CL *cl)
  5687. cl->type_indicator2 = bs_read(bits, 32);
  5688. if (cl->type_indicator != CLPI_SIG1 ||
  5689. (cl->type_indicator2 != CLPI_SIG2A &&
  5690. - cl->type_indicator2 != CLPI_SIG2B)) {
  5691. + cl->type_indicator2 != CLPI_SIG2B &&
  5692. + cl->type_indicator2 != CLPI_SIG2C)) {
  5693. char sig[9];
  5694. char expect[9];
  5695. diff --git a/src/libbluray/bdnav/mpls_parse.c b/src/libbluray/bdnav/mpls_parse.c
  5696. index da01f7b..8bfbb8c 100644
  5697. --- a/src/libbluray/bdnav/mpls_parse.c
  5698. +++ b/src/libbluray/bdnav/mpls_parse.c
  5699. @@ -39,6 +39,7 @@
  5700. #define MPLS_SIG1 ('M' << 24 | 'P' << 16 | 'L' << 8 | 'S')
  5701. #define MPLS_SIG2A ('0' << 24 | '2' << 16 | '0' << 8 | '0')
  5702. #define MPLS_SIG2B ('0' << 24 | '1' << 16 | '0' << 8 | '0')
  5703. +#define MPLS_SIG2C ('0' << 24 | '2' << 16 | '4' << 8 | '0')
  5704. static void
  5705. _human_readable_sig(char *sig, uint32_t s1, uint32_t s2)
  5706. @@ -137,8 +138,9 @@ _parse_appinfo(BITSTREAM *bits, MPLS_AI *ai)
  5707. ai->random_access_flag = bs_read(bits, 1);
  5708. ai->audio_mix_flag = bs_read(bits, 1);
  5709. ai->lossless_bypass_flag = bs_read(bits, 1);
  5710. + ai->mvc_base_view_r_flag = bs_read(bits, 1);
  5711. // Reserved
  5712. - bs_skip(bits, 13);
  5713. + bs_skip(bits, 12);
  5714. bs_seek_byte(bits, pos + len);
  5715. return 1;
  5716. }
  5717. @@ -155,7 +157,8 @@ _parse_header(BITSTREAM *bits, MPLS_PL *pl)
  5718. pl->type_indicator2 = bs_read(bits, 32);
  5719. if (pl->type_indicator != MPLS_SIG1 ||
  5720. (pl->type_indicator2 != MPLS_SIG2A &&
  5721. - pl->type_indicator2 != MPLS_SIG2B)) {
  5722. + pl->type_indicator2 != MPLS_SIG2B &&
  5723. + pl->type_indicator2 != MPLS_SIG2C)) {
  5724. char sig[9];
  5725. char expect[9];
  5726. @@ -259,6 +262,7 @@ _parse_stream(BITSTREAM *bits, MPLS_STREAM *s)
  5727. break;
  5728. };
  5729. s->lang[3] = '\0';
  5730. + s->ss_offset_sequence_id = 0xFF;
  5731. bs_seek_byte(bits, pos + len);
  5732. return 1;
  5733. @@ -882,6 +886,99 @@ _parse_subpath_extension(BITSTREAM *bits, MPLS_PL *pl)
  5734. }
  5735. static int
  5736. +_parse_stn_ss_extension(BITSTREAM *bits, MPLS_PL *pl)
  5737. +{
  5738. + int ii, s;
  5739. + int64_t pos;
  5740. +
  5741. + for (ii = 0; ii < pl->list_count; ii++) {
  5742. + uint32_t len = bs_read(bits, 16);
  5743. + pos = bs_pos(bits) >> 3;
  5744. + int Fixed_offset_during_PopUp_flag = bs_read(bits, 1);
  5745. + bs_skip(bits, 15); // reserved
  5746. +
  5747. + for (s = 0; s < pl->play_item[ii].stn.num_video; s++) {
  5748. + // stream_entry
  5749. + uint32_t slen = bs_read(bits, 8);
  5750. + bs_skip(bits, slen * 8);
  5751. +
  5752. + // stream_attributes_ss
  5753. + slen = bs_read(bits, 8);
  5754. + bs_skip(bits, slen * 8);
  5755. +
  5756. + bs_skip(bits, 10); // reserved
  5757. + bs_skip(bits, 6); // number_of_offset_sequences
  5758. + }
  5759. +
  5760. + for (s = 0; s < pl->play_item[ii].stn.num_pg; s++) {
  5761. + pl->play_item[ii].stn.pg[s].ss_offset_sequence_id = bs_read(bits, 8);
  5762. +
  5763. + bs_skip(bits, 4); // reserved
  5764. + bs_skip(bits, 1); // dialog_region_offset_valid_flag
  5765. + int is_SS_PG = bs_read(bits, 1);
  5766. + int is_top_AS_PG_textST = bs_read(bits, 1);
  5767. + int is_bottom_AS_PG_textST = bs_read(bits, 1);
  5768. + if (is_SS_PG) {
  5769. + // stream_entry left eye
  5770. + uint32_t slen = bs_read(bits, 8);
  5771. + bs_skip(bits, slen * 8);
  5772. +
  5773. + // stream_entry right eye
  5774. + slen = bs_read(bits, 8);
  5775. + bs_skip(bits, slen * 8);
  5776. +
  5777. + bs_skip(bits, 8); // reserved
  5778. + bs_skip(bits, 8); // PG offset
  5779. + }
  5780. + if (is_top_AS_PG_textST) {
  5781. + // stream_entry
  5782. + uint32_t slen = bs_read(bits, 8);
  5783. + bs_skip(bits, slen * 8);
  5784. +
  5785. + bs_skip(bits, 8); // reserved
  5786. + bs_skip(bits, 8); // PG offset
  5787. + }
  5788. + if (is_bottom_AS_PG_textST) {
  5789. + // stream_entry
  5790. + uint32_t slen = bs_read(bits, 8);
  5791. + bs_skip(bits, slen * 8);
  5792. +
  5793. + bs_skip(bits, 8); // reserved
  5794. + bs_skip(bits, 8); // PG offset
  5795. + }
  5796. + }
  5797. +
  5798. + for (s = 0; s < pl->play_item[ii].stn.num_ig; s++) {
  5799. + if (Fixed_offset_during_PopUp_flag)
  5800. + bs_skip(bits, 8);
  5801. + else
  5802. + pl->play_item[ii].stn.ig[s].ss_offset_sequence_id = bs_read(bits, 8);
  5803. +
  5804. + bs_skip(bits, 16); // IG_Plane_offset_during_BB_video
  5805. + bs_skip(bits, 7); // reserved
  5806. + int is_SS_IG = bs_read(bits, 1);
  5807. + if (is_SS_IG) {
  5808. + // stream_entry left eye
  5809. + uint32_t slen = bs_read(bits, 8);
  5810. + bs_skip(bits, slen * 8);
  5811. +
  5812. + // stream_entry right eye
  5813. + slen = bs_read(bits, 8);
  5814. + bs_skip(bits, slen * 8);
  5815. +
  5816. + bs_skip(bits, 8); // reserved
  5817. + bs_skip(bits, 8); // PG offset
  5818. + }
  5819. + }
  5820. +
  5821. + // Skip to next play item
  5822. + bs_seek_byte(bits, pos + len);
  5823. + }
  5824. +
  5825. + return 0;
  5826. +}
  5827. +
  5828. +static int
  5829. _parse_mpls_extension(BITSTREAM *bits, int id1, int id2, void *handle)
  5830. {
  5831. MPLS_PL *pl = (MPLS_PL*)handle;
  5832. @@ -895,7 +992,7 @@ _parse_mpls_extension(BITSTREAM *bits, int id1, int id2, void *handle)
  5833. if (id1 == 2) {
  5834. if (id2 == 1) {
  5835. - return 0;
  5836. + return _parse_stn_ss_extension(bits, pl);
  5837. }
  5838. if (id2 == 2) {
  5839. // SubPath entries extension
  5840. diff --git a/src/libbluray/bdnav/mpls_parse.h b/src/libbluray/bdnav/mpls_parse.h
  5841. index f9f7a18..94add53 100644
  5842. --- a/src/libbluray/bdnav/mpls_parse.h
  5843. +++ b/src/libbluray/bdnav/mpls_parse.h
  5844. @@ -49,6 +49,7 @@ typedef struct
  5845. uint8_t sv_num_pip_pg_ref;
  5846. uint8_t *sv_secondary_audio_ref;
  5847. uint8_t *sv_pip_pg_ref;
  5848. + uint8_t ss_offset_sequence_id;
  5849. } MPLS_STREAM;
  5850. typedef struct
  5851. @@ -110,6 +111,7 @@ typedef struct
  5852. uint8_t random_access_flag;
  5853. uint8_t audio_mix_flag;
  5854. uint8_t lossless_bypass_flag;
  5855. + uint8_t mvc_base_view_r_flag;
  5856. } MPLS_AI;
  5857. typedef struct
  5858. diff --git a/src/libbluray/bdnav/navigation.c b/src/libbluray/bdnav/navigation.c
  5859. index 39be4b7..cfd7739 100644
  5860. --- a/src/libbluray/bdnav/navigation.c
  5861. +++ b/src/libbluray/bdnav/navigation.c
  5862. @@ -174,6 +174,21 @@ _pl_duration(MPLS_PL *pl)
  5863. return duration;
  5864. }
  5865. +static uint32_t
  5866. +_pl_chapter_count(MPLS_PL *pl)
  5867. +{
  5868. + unsigned ii, chapters = 0;
  5869. +
  5870. + // Count the number of "entry" marks (skipping "link" marks)
  5871. + // This is the the number of chapters
  5872. + for (ii = 0; ii < pl->mark_count; ii++) {
  5873. + if (pl->play_mark[ii].mark_type == BD_MARK_ENTRY) {
  5874. + chapters++;
  5875. + }
  5876. + }
  5877. + return chapters;
  5878. +}
  5879. +
  5880. NAV_TITLE_LIST* nav_get_title_list(BD_DISC *disc, uint32_t flags, uint32_t min_title_length)
  5881. {
  5882. BD_DIR_H *dir;
  5883. @@ -446,7 +461,7 @@ static void _fill_clip(NAV_TITLE *title,
  5884. NAV_TITLE* nav_title_open(BD_DISC *disc, const char *playlist, unsigned angle)
  5885. {
  5886. NAV_TITLE *title = NULL;
  5887. - unsigned ii, ss, chapters = 0;
  5888. + unsigned ii, ss;
  5889. uint32_t pos = 0;
  5890. uint32_t time = 0;
  5891. @@ -506,15 +521,8 @@ NAV_TITLE* nav_title_open(BD_DISC *disc, const char *playlist, unsigned angle)
  5892. }
  5893. }
  5894. - // Count the number of "entry" marks (skipping "link" marks)
  5895. - // This is the the number of chapters
  5896. - for (ii = 0; ii < title->pl->mark_count; ii++) {
  5897. - if (title->pl->play_mark[ii].mark_type == BD_MARK_ENTRY) {
  5898. - chapters++;
  5899. - }
  5900. - }
  5901. - title->chap_list.count = chapters;
  5902. - title->chap_list.mark = calloc(chapters, sizeof(NAV_MARK));
  5903. + title->chap_list.count = _pl_chapter_count(title->pl);
  5904. + title->chap_list.mark = calloc(title->chap_list.count, sizeof(NAV_MARK));
  5905. title->mark_list.count = title->pl->mark_count;
  5906. title->mark_list.mark = calloc(title->pl->mark_count, sizeof(NAV_MARK));
  5907. diff --git a/src/libbluray/bdnav/sound_parse.c b/src/libbluray/bdnav/sound_parse.c
  5908. index b5d11fd..7c267da 100644
  5909. --- a/src/libbluray/bdnav/sound_parse.c
  5910. +++ b/src/libbluray/bdnav/sound_parse.c
  5911. @@ -169,7 +169,7 @@ static SOUND_DATA *_sound_parse(BD_FILE_H *fp)
  5912. data_offsets = calloc(num_sounds, sizeof(uint32_t));
  5913. data = calloc(1, sizeof(SOUND_DATA));
  5914. - if (!data_offsets | !data) {
  5915. + if (!data_offsets || !data) {
  5916. BD_DEBUG(DBG_CRIT, "out of memory\n");
  5917. goto error;
  5918. }
  5919. diff --git a/src/libbluray/bluray.c b/src/libbluray/bluray.c
  5920. index 1aedf2c..27beed7 100644
  5921. --- a/src/libbluray/bluray.c
  5922. +++ b/src/libbluray/bluray.c
  5923. @@ -952,6 +952,7 @@ static void _fill_disc_info(BLURAY *bd, BD_ENC_INFO *enc_info)
  5924. bd->disc_info.bdplus_handled = enc_info->bdplus_handled;
  5925. bd->disc_info.bdplus_gen = enc_info->bdplus_gen;
  5926. bd->disc_info.bdplus_date = enc_info->bdplus_date;
  5927. + bd->disc_info.no_menu_support = enc_info->no_menu_support;
  5928. bd->disc_info.udf_volume_id = disc_volume_id(bd->disc);
  5929. @@ -1098,6 +1099,10 @@ static void _fill_disc_info(BLURAY *bd, BD_ENC_INFO *enc_info)
  5930. indx_free(&index);
  5931. }
  5932. + if (!bd->disc_info.first_play_supported || !bd->disc_info.top_menu_supported) {
  5933. + bd->disc_info.no_menu_support = 1;
  5934. + }
  5935. +
  5936. if (bd->disc_info.bdj_detected) {
  5937. BDID_DATA *bdid = bdid_get(bd->disc); /* parse id.bdmv */
  5938. if (bdid) {
  5939. @@ -1637,6 +1642,25 @@ int64_t bd_seek_time(BLURAY *bd, uint64_t tick)
  5940. return bd->s_pos;
  5941. }
  5942. +int64_t bd_find_seek_point(BLURAY *bd, uint64_t tick)
  5943. +{
  5944. + uint32_t clip_pkt, out_pkt;
  5945. + NAV_CLIP *clip;
  5946. +
  5947. + tick /= 2;
  5948. +
  5949. + if (bd->title &&
  5950. + tick < bd->title->duration) {
  5951. +
  5952. + // Find the closest access unit to the requested position
  5953. + clip = nav_time_search(bd->title, (uint32_t)tick, &clip_pkt, &out_pkt);
  5954. +
  5955. + return (int64_t)out_pkt * 192;
  5956. + }
  5957. +
  5958. + return bd->s_pos;
  5959. +}
  5960. +
  5961. uint64_t bd_tell_time(BLURAY *bd)
  5962. {
  5963. uint32_t clip_pkt = 0, out_pkt = 0, out_time = 0;
  5964. @@ -2539,6 +2563,9 @@ uint32_t bd_get_titles(BLURAY *bd, uint8_t flags, uint32_t min_title_length)
  5965. int bd_get_main_title(BLURAY *bd)
  5966. {
  5967. + if (!bd) {
  5968. + return -1;
  5969. + }
  5970. if (bd->title_type != title_undef) {
  5971. BD_DEBUG(DBG_CRIT | DBG_BLURAY, "bd_get_main_title() can't be used with BluRay menus\n");
  5972. }
  5973. @@ -2606,6 +2633,7 @@ static BLURAY_TITLE_INFO* _fill_title_info(NAV_TITLE* title, uint32_t title_idx,
  5974. BLURAY_CLIP_INFO *ci = &title_info->clips[ii];
  5975. NAV_CLIP *nc = &title->clip_list.clip[ii];
  5976. + ci->idx = nc->clip_id;
  5977. ci->pkt_count = nc->end_pkt - nc->start_pkt;
  5978. ci->start_time = (uint64_t)nc->title_time * 2;
  5979. ci->in_time = (uint64_t)pi->in_time * 2;
  5980. @@ -2632,6 +2660,8 @@ static BLURAY_TITLE_INFO* _fill_title_info(NAV_TITLE* title, uint32_t title_idx,
  5981. _copy_streams(nc, ci->sec_audio_streams, pi->stn.secondary_audio, ci->sec_audio_stream_count);
  5982. }
  5983. + title_info->mvc_base_view_r_flag = title->pl->app_info.mvc_base_view_r_flag;
  5984. +
  5985. return title_info;
  5986. }
  5987. @@ -2745,7 +2775,7 @@ int bd_set_player_setting(BLURAY *bd, uint32_t idx, uint32_t value)
  5988. for (i = 0; i < sizeof(map) / sizeof(map[0]); i++) {
  5989. if (idx == map[i].idx) {
  5990. bd_mutex_lock(&bd->mutex);
  5991. - result = !bd_psr_setting_write(bd->regs, idx, value);
  5992. + result = !bd_psr_setting_write(bd->regs, map[i].psr, value);
  5993. bd_mutex_unlock(&bd->mutex);
  5994. return result;
  5995. }
  5996. @@ -3119,6 +3149,11 @@ static int _play_title(BLURAY *bd, unsigned title)
  5997. return 0;
  5998. }
  5999. + if (bd->disc_info.no_menu_support) {
  6000. + BD_DEBUG(DBG_BLURAY | DBG_CRIT, "bd_play(): no menu support\n");
  6001. + return 0;
  6002. + }
  6003. +
  6004. /* first play object ? */
  6005. if (title == BLURAY_TITLE_FIRST_PLAY) {
  6006. @@ -3743,3 +3778,28 @@ void bd_free_bdjo(struct bdjo_data *obj)
  6007. (void)obj;
  6008. #endif
  6009. }
  6010. +
  6011. +int bd_get_clip_infos(BLURAY *bd, unsigned clip, uint64_t *clip_start_time, uint64_t *stream_start_time, uint64_t *pos, uint64_t *duration)
  6012. +{
  6013. + if (bd && bd->title && bd->title->clip_list.count > clip) {
  6014. + if (clip_start_time)
  6015. + *clip_start_time = (uint64_t)bd->title->clip_list.clip[clip].title_time << 1;
  6016. + if (stream_start_time)
  6017. + *stream_start_time = (uint64_t)bd->title->clip_list.clip[clip].in_time << 1;
  6018. + if (pos)
  6019. + *pos = (uint64_t)bd->title->clip_list.clip[clip].title_pkt * 192;
  6020. + if (duration)
  6021. + *duration = (uint64_t)bd->title->clip_list.clip[clip].duration << 1;
  6022. +
  6023. + return 1;
  6024. + }
  6025. + return 0;
  6026. +}
  6027. +
  6028. +struct mpls_pl* bd_get_title_mpls(BLURAY * bd)
  6029. +{
  6030. + if (bd && bd->title) {
  6031. + return bd->title->pl;
  6032. + }
  6033. + return NULL;
  6034. +}
  6035. diff --git a/src/libbluray/bluray.h b/src/libbluray/bluray.h
  6036. index ae9f412..6e74df4 100644
  6037. --- a/src/libbluray/bluray.h
  6038. +++ b/src/libbluray/bluray.h
  6039. @@ -32,6 +32,7 @@ extern "C" {
  6040. */
  6041. #include <stdint.h>
  6042. +#include "bdnav/clpi_data.h"
  6043. #define TITLES_ALL 0 /**< all titles. */
  6044. #define TITLES_FILTER_DUP_TITLE 0x01 /**< remove duplicate titles. */
  6045. @@ -119,6 +120,9 @@ typedef struct {
  6046. char bdj_disc_id[33]; /* (BD-J) disc ID */
  6047. const char *udf_volume_id; /* optional UDF volume identifier */
  6048. +
  6049. + uint8_t no_menu_support; /* 1 if this disc can't be played using on-disc menus */
  6050. +
  6051. } BLURAY_DISC_INFO;
  6052. /*
  6053. @@ -216,6 +220,7 @@ typedef struct bd_stream_info {
  6054. } BLURAY_STREAM_INFO;
  6055. typedef struct bd_clip {
  6056. + uint32_t idx;
  6057. uint32_t pkt_count;
  6058. uint8_t still_mode;
  6059. uint16_t still_time; /* seconds */
  6060. @@ -266,6 +271,8 @@ typedef struct bd_title_info {
  6061. uint32_t mark_count;
  6062. BLURAY_TITLE_MARK *marks;
  6063. +
  6064. + uint8_t mvc_base_view_r_flag;
  6065. } BLURAY_TITLE_INFO;
  6066. /*
  6067. @@ -458,6 +465,16 @@ uint32_t bd_get_current_title(BLURAY *bd);
  6068. /**
  6069. *
  6070. + * Find the byte position to specific time in 90Khz ticks
  6071. + *
  6072. + * @param bd BLURAY ojbect
  6073. + * @param tick tick count
  6074. + * @return byte position
  6075. + */
  6076. +int64_t bd_find_seek_point(BLURAY *bd, uint64_t tick);
  6077. +
  6078. +/**
  6079. + *
  6080. * Read from currently selected title file, decrypt if possible
  6081. *
  6082. * @param bd BLURAY object
  6083. @@ -981,7 +998,6 @@ int bd_mouse_select(BLURAY *bd, int64_t pts, uint16_t x, uint16_t y);
  6084. /* access to internal information */
  6085. -struct clpi_cl;
  6086. /**
  6087. *
  6088. * Get copy of clip information for requested playitem.
  6089. @@ -1034,6 +1050,28 @@ void bd_stop_bdj(BLURAY *bd); // shutdown BD-J and clean up resources
  6090. */
  6091. int bd_read_file(BLURAY *, const char *path, void **data, int64_t *size);
  6092. +/**
  6093. + *
  6094. + * Get information about the clip
  6095. + *
  6096. + * @param bd BLURAY object
  6097. + * @param clip clip index
  6098. + * @param clip_start_time start of the clip (in the total title) (in 90khz)
  6099. + * @param stream_start_time first pts in the clip (in 90khz)
  6100. + * @param byte position of the clip (absolute)
  6101. + * @param duration duration of the clip (in 90khz)
  6102. + */
  6103. +int bd_get_clip_infos(BLURAY *bd, unsigned clip, uint64_t *clip_start_time, uint64_t *stream_start_time, uint64_t *pos, uint64_t *duration);
  6104. +
  6105. +/**
  6106. + * Get the MPLS struct of the current title
  6107. + *
  6108. + * @param bd BLURAY object
  6109. + * @return the MPLS struct
  6110. + *
  6111. + * Lifetime of the MPLS pointer is limited to the lifetime of the BD title
  6112. + */
  6113. +struct mpls_pl* bd_get_title_mpls(BLURAY * bd);
  6114. #ifdef __cplusplus
  6115. }
  6116. diff --git a/src/libbluray/decoders/graphics_controller.c b/src/libbluray/decoders/graphics_controller.c
  6117. index dabde1c..d3c775a 100644
  6118. --- a/src/libbluray/decoders/graphics_controller.c
  6119. +++ b/src/libbluray/decoders/graphics_controller.c
  6120. @@ -825,6 +825,8 @@ void gc_free(GRAPHICS_CONTROLLER **p)
  6121. bd_mutex_destroy(&gc->mutex);
  6122. + X_FREE(gc->saved_bog_data);
  6123. +
  6124. X_FREE(*p);
  6125. }
  6126. }
  6127. diff --git a/src/libbluray/disc/aacs.c b/src/libbluray/disc/aacs.c
  6128. index 3059d66..9ae8efb 100644
  6129. --- a/src/libbluray/disc/aacs.c
  6130. +++ b/src/libbluray/disc/aacs.c
  6131. @@ -47,6 +47,8 @@ struct bd_aacs {
  6132. fptr_p_void get_device_binding_id;
  6133. fptr_p_void get_device_nonce;
  6134. fptr_p_void get_media_key;
  6135. +
  6136. + int impl_id;
  6137. };
  6138. @@ -58,15 +60,19 @@ static void _libaacs_close(BD_AACS *p)
  6139. }
  6140. }
  6141. -void libaacs_unload(BD_AACS **p)
  6142. +static void _unload(BD_AACS *p)
  6143. {
  6144. - if (p && *p) {
  6145. - _libaacs_close(*p);
  6146. + _libaacs_close(p);
  6147. - if ((*p)->h_libaacs) {
  6148. - dl_dlclose((*p)->h_libaacs);
  6149. - }
  6150. + if (p->h_libaacs) {
  6151. + dl_dlclose(p->h_libaacs);
  6152. + }
  6153. +}
  6154. +void libaacs_unload(BD_AACS **p)
  6155. +{
  6156. + if (p && *p) {
  6157. + _unload(*p);
  6158. X_FREE(*p);
  6159. }
  6160. }
  6161. @@ -82,7 +88,7 @@ int libaacs_required(void *have_file_handle, int (*have_file)(void *, const char
  6162. return 0;
  6163. }
  6164. -static void *_open_libaacs(void)
  6165. +static void *_open_libaacs(int *impl_id)
  6166. {
  6167. const char * const libaacs[] = {
  6168. getenv("LIBAACS_PATH"),
  6169. @@ -91,10 +97,11 @@ static void *_open_libaacs(void)
  6170. };
  6171. unsigned ii;
  6172. - for (ii = 0; ii < sizeof(libaacs) / sizeof(libaacs[0]); ii++) {
  6173. + for (ii = *impl_id; ii < sizeof(libaacs) / sizeof(libaacs[0]); ii++) {
  6174. if (libaacs[ii]) {
  6175. void *handle = dl_dlopen(libaacs[ii], "0");
  6176. if (handle) {
  6177. + *impl_id = ii;
  6178. BD_DEBUG(DBG_BLURAY, "Using %s for AACS\n", libaacs[ii]);
  6179. return handle;
  6180. }
  6181. @@ -105,14 +112,15 @@ static void *_open_libaacs(void)
  6182. return NULL;
  6183. }
  6184. -BD_AACS *libaacs_load(void)
  6185. +static BD_AACS *_load(int impl_id)
  6186. {
  6187. BD_AACS *p = calloc(1, sizeof(BD_AACS));
  6188. if (!p) {
  6189. return NULL;
  6190. }
  6191. + p->impl_id = impl_id;
  6192. - p->h_libaacs = _open_libaacs();
  6193. + p->h_libaacs = _open_libaacs(&p->impl_id);
  6194. if (!p->h_libaacs) {
  6195. X_FREE(p);
  6196. return NULL;
  6197. @@ -143,6 +151,11 @@ BD_AACS *libaacs_load(void)
  6198. return p;
  6199. }
  6200. +BD_AACS *libaacs_load(void)
  6201. +{
  6202. + return _load(0);
  6203. +}
  6204. +
  6205. int libaacs_open(BD_AACS *p, const char *device,
  6206. void *file_open_handle, void *file_open_fp,
  6207. const char *keyfile_path)
  6208. @@ -180,6 +193,22 @@ int libaacs_open(BD_AACS *p, const char *device,
  6209. BD_DEBUG(DBG_BLURAY, "aacs_open() not found\n");
  6210. }
  6211. + if (error_code) {
  6212. + /* failed. try next aacs implementation if available. */
  6213. + BD_AACS *p2 = _load(p->impl_id + 1);
  6214. + if (p2) {
  6215. + if (!libaacs_open(p2, device, file_open_handle, file_open_fp, keyfile_path)) {
  6216. + /* succeed - swap implementations */
  6217. + _unload(p);
  6218. + *p = *p2;
  6219. + X_FREE(p2);
  6220. + return 0;
  6221. + }
  6222. + /* failed - report original errors */
  6223. + libaacs_unload(&p2);
  6224. + }
  6225. + }
  6226. +
  6227. if (p->aacs) {
  6228. if (aacs_get_mkb_version) {
  6229. p->mkbv = aacs_get_mkb_version(p->aacs);
  6230. diff --git a/src/libbluray/disc/dec.c b/src/libbluray/disc/dec.c
  6231. index 290dd4d..1c8a601 100644
  6232. --- a/src/libbluray/disc/dec.c
  6233. +++ b/src/libbluray/disc/dec.c
  6234. @@ -179,6 +179,8 @@ static int _libaacs_init(BD_DEC *dec, struct dec_dev *dev,
  6235. int result;
  6236. const uint8_t *disc_id;
  6237. + memset(i, 0, sizeof(*i));
  6238. +
  6239. libaacs_unload(&dec->aacs);
  6240. i->aacs_detected = libaacs_required((void*)dev, _bdrom_have_file);
  6241. @@ -205,7 +207,7 @@ static int _libaacs_init(BD_DEC *dec, struct dec_dev *dev,
  6242. }
  6243. if (result) {
  6244. - BD_DEBUG(DBG_BLURAY | DBG_CRIT, "aacs_open() failed!\n");
  6245. + BD_DEBUG(DBG_BLURAY | DBG_CRIT, "aacs_open() failed: %d!\n", result);
  6246. libaacs_unload(&dec->aacs);
  6247. return 0;
  6248. }
  6249. @@ -259,6 +261,13 @@ static int _libbdplus_init(BD_DEC *dec, struct dec_dev *dev,
  6250. i->bdplus_gen = libbdplus_get_gen(dec->bdplus);
  6251. i->bdplus_date = libbdplus_get_date(dec->bdplus);
  6252. i->bdplus_handled = 1;
  6253. +
  6254. + if (i->bdplus_date == 0) {
  6255. + // libmmbd -> no menu support
  6256. + BD_DEBUG(DBG_BLURAY | DBG_CRIT, "WARNING: using libmmbd for BD+. On-disc menus will not work.\n");
  6257. + i->no_menu_support = 1;
  6258. + }
  6259. +
  6260. return 1;
  6261. }
  6262. diff --git a/src/libbluray/disc/disc.c b/src/libbluray/disc/disc.c
  6263. index 8f275b8..757b6ed 100644
  6264. --- a/src/libbluray/disc/disc.c
  6265. +++ b/src/libbluray/disc/disc.c
  6266. @@ -69,7 +69,7 @@ static BD_FILE_H *_bdrom_open_path(void *p, const char *rel_path)
  6267. return NULL;
  6268. }
  6269. - fp = file_open(abs_path, "rb");
  6270. + fp = file_open(abs_path, "rbS");
  6271. X_FREE(abs_path);
  6272. return fp;
  6273. @@ -177,7 +177,7 @@ static void _comb_dir_append(BD_DIR_H *dp, BD_DIRENT *entry)
  6274. }
  6275. /* append */
  6276. - priv = realloc(priv, sizeof(*priv) + priv->count * sizeof(BD_DIRENT));
  6277. + priv = realloc(dp->internal, sizeof(*priv) + priv->count * sizeof(BD_DIRENT));
  6278. if (!priv) {
  6279. return;
  6280. }
  6281. diff --git a/src/libbluray/disc/enc_info.h b/src/libbluray/disc/enc_info.h
  6282. index d45d891..47ca94f 100644
  6283. --- a/src/libbluray/disc/enc_info.h
  6284. +++ b/src/libbluray/disc/enc_info.h
  6285. @@ -34,6 +34,8 @@ typedef struct bd_enc_info {
  6286. uint8_t disc_id[20];
  6287. uint8_t bdplus_gen;
  6288. uint32_t bdplus_date;
  6289. +
  6290. + uint8_t no_menu_support;
  6291. } BD_ENC_INFO;
  6292. #endif /* _BD_DISC_ENC_INFO_H_ */