libbluray
|
00001 /* 00002 * This file is part of libbluray 00003 * Copyright (C) 2009-2010 Obliter0n 00004 * Copyright (C) 2009-2010 John Stebbins 00005 * Copyright (C) 2010 hpi1 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library. If not, see 00019 * <http://www.gnu.org/licenses/>. 00020 */ 00021 00022 #ifndef BLURAY_H_ 00023 #define BLURAY_H_ 00024 00025 #ifdef __cplusplus 00026 extern "C" { 00027 #endif 00028 00034 #include <stdint.h> 00035 00036 #define TITLES_ALL 0 00037 #define TITLES_FILTER_DUP_TITLE 0x01 00038 #define TITLES_FILTER_DUP_CLIP 0x02 00040 #define TITLES_RELEVANT \ 00041 (TITLES_FILTER_DUP_TITLE | TITLES_FILTER_DUP_CLIP) 00044 typedef struct bluray BLURAY; 00045 00046 typedef enum { 00047 BLURAY_STREAM_TYPE_VIDEO_MPEG1 = 0x01, 00048 BLURAY_STREAM_TYPE_VIDEO_MPEG2 = 0x02, 00049 BLURAY_STREAM_TYPE_AUDIO_MPEG1 = 0x03, 00050 BLURAY_STREAM_TYPE_AUDIO_MPEG2 = 0x04, 00051 BLURAY_STREAM_TYPE_AUDIO_LPCM = 0x80, 00052 BLURAY_STREAM_TYPE_AUDIO_AC3 = 0x81, 00053 BLURAY_STREAM_TYPE_AUDIO_DTS = 0x82, 00054 BLURAY_STREAM_TYPE_AUDIO_TRUHD = 0x83, 00055 BLURAY_STREAM_TYPE_AUDIO_AC3PLUS = 0x84, 00056 BLURAY_STREAM_TYPE_AUDIO_DTSHD = 0x85, 00057 BLURAY_STREAM_TYPE_AUDIO_DTSHD_MASTER = 0x86, 00058 BLURAY_STREAM_TYPE_VIDEO_VC1 = 0xea, 00059 BLURAY_STREAM_TYPE_VIDEO_H264 = 0x1b, 00060 BLURAY_STREAM_TYPE_SUB_PG = 0x90, 00061 BLURAY_STREAM_TYPE_SUB_IG = 0x91, 00062 BLURAY_STREAM_TYPE_SUB_TEXT = 0x92 00063 } bd_stream_type_e; 00064 00065 typedef enum { 00066 BLURAY_VIDEO_FORMAT_480I = 1, // ITU-R BT.601-5 00067 BLURAY_VIDEO_FORMAT_576I = 2, // ITU-R BT.601-4 00068 BLURAY_VIDEO_FORMAT_480P = 3, // SMPTE 293M 00069 BLURAY_VIDEO_FORMAT_1080I = 4, // SMPTE 274M 00070 BLURAY_VIDEO_FORMAT_720P = 5, // SMPTE 296M 00071 BLURAY_VIDEO_FORMAT_1080P = 6, // SMPTE 274M 00072 BLURAY_VIDEO_FORMAT_576P = 7 // ITU-R BT.1358 00073 } bd_video_format_e; 00074 00075 typedef enum { 00076 BLURAY_VIDEO_RATE_24000_1001 = 1, // 23.976 00077 BLURAY_VIDEO_RATE_24 = 2, 00078 BLURAY_VIDEO_RATE_25 = 3, 00079 BLURAY_VIDEO_RATE_30000_1001 = 4, // 29.97 00080 BLURAY_VIDEO_RATE_50 = 6, 00081 BLURAY_VIDEO_RATE_60000_1001 = 7 // 59.94 00082 } bd_video_rate_e; 00083 00084 typedef enum { 00085 BLURAY_ASPECT_RATIO_4_3 = 2, 00086 BLURAY_ASPECT_RATIO_16_9 = 3 00087 } bd_video_aspect_e; 00088 00089 typedef enum { 00090 BLURAY_AUDIO_FORMAT_MONO = 1, 00091 BLURAY_AUDIO_FORMAT_STEREO = 3, 00092 BLURAY_AUDIO_FORMAT_MULTI_CHAN = 6, 00093 BLURAY_AUDIO_FORMAT_COMBO = 12 // Stereo ac3/dts, 00094 } bd_audio_format_e; 00095 // multi mlp/dts-hd 00096 00097 typedef enum { 00098 BLURAY_AUDIO_RATE_48 = 1, 00099 BLURAY_AUDIO_RATE_96 = 4, 00100 BLURAY_AUDIO_RATE_192 = 5, 00101 BLURAY_AUDIO_RATE_192_COMBO = 12, // 48 or 96 ac3/dts 00102 // 192 mpl/dts-hd 00103 BLURAY_AUDIO_RATE_96_COMBO = 14 // 48 ac3/dts 00104 // 96 mpl/dts-hd 00105 } bd_audio_rate_e; 00106 00107 typedef enum { 00108 BLURAY_TEXT_CHAR_CODE_UTF8 = 0x01, 00109 BLURAY_TEXT_CHAR_CODE_UTF16BE = 0x02, 00110 BLURAY_TEXT_CHAR_CODE_SHIFT_JIS = 0x03, 00111 BLURAY_TEXT_CHAR_CODE_EUC_KR = 0x04, 00112 BLURAY_TEXT_CHAR_CODE_GB18030_20001 = 0x05, 00113 BLURAY_TEXT_CHAR_CODE_CN_GB = 0x06, 00114 BLURAY_TEXT_CHAR_CODE_BIG5 = 0x07 00115 } bd_char_code_e; 00116 00117 typedef enum { 00118 BLURAY_STILL_NONE = 0x00, 00119 BLURAY_STILL_TIME = 0x01, 00120 BLURAY_STILL_INFINITE = 0x02, 00121 } bd_still_mode_e; 00122 00123 typedef struct bd_stream_info { 00124 uint8_t coding_type; 00125 uint8_t format; 00126 uint8_t rate; 00127 uint8_t char_code; 00128 uint8_t lang[4]; 00129 uint16_t pid; 00130 uint8_t aspect; 00131 } BLURAY_STREAM_INFO; 00132 00133 typedef struct bd_clip { 00134 uint32_t pkt_count; 00135 uint8_t still_mode; 00136 uint16_t still_time; /* seconds */ 00137 uint8_t video_stream_count; 00138 uint8_t audio_stream_count; 00139 uint8_t pg_stream_count; 00140 uint8_t ig_stream_count; 00141 uint8_t sec_audio_stream_count; 00142 uint8_t sec_video_stream_count; 00143 BLURAY_STREAM_INFO *video_streams; 00144 BLURAY_STREAM_INFO *audio_streams; 00145 BLURAY_STREAM_INFO *pg_streams; 00146 BLURAY_STREAM_INFO *ig_streams; 00147 BLURAY_STREAM_INFO *sec_audio_streams; 00148 BLURAY_STREAM_INFO *sec_video_streams; 00149 } BLURAY_CLIP_INFO; 00150 00151 typedef struct bd_chapter { 00152 uint32_t idx; 00153 uint64_t start; 00154 uint64_t duration; 00155 uint64_t offset; 00156 } BLURAY_TITLE_CHAPTER; 00157 00158 typedef struct bd_title_info { 00159 uint32_t idx; 00160 uint32_t playlist; 00161 uint64_t duration; 00162 uint32_t clip_count; 00163 uint8_t angle_count; 00164 uint32_t chapter_count; 00165 BLURAY_CLIP_INFO *clips; 00166 BLURAY_TITLE_CHAPTER *chapters; 00167 } BLURAY_TITLE_INFO; 00168 00180 uint32_t bd_get_titles(BLURAY *bd, uint8_t flags, uint32_t min_title_length); 00181 00191 BLURAY_TITLE_INFO* bd_get_title_info(BLURAY *bd, uint32_t title_idx, unsigned angle); 00192 00202 BLURAY_TITLE_INFO* bd_get_playlist_info(BLURAY *bd, uint32_t playlist, unsigned angle); 00203 00210 void bd_free_title_info(BLURAY_TITLE_INFO *title_info); 00211 00219 BLURAY *bd_open(const char* device_path, const char* keyfile_path); 00220 00226 void bd_close(BLURAY *bd); 00227 00235 int64_t bd_seek(BLURAY *bd, uint64_t pos); 00236 00245 int64_t bd_seek_time(BLURAY *bd, uint64_t tick); 00246 00256 int bd_read(BLURAY *bd, unsigned char *buf, int len); 00257 00265 int bd_read_skip_still(BLURAY *bd); 00266 00275 int64_t bd_seek_chapter(BLURAY *bd, unsigned chapter); 00276 00285 int64_t bd_chapter_pos(BLURAY *bd, unsigned chapter); 00286 00294 uint32_t bd_get_current_chapter(BLURAY *bd); 00295 00304 int64_t bd_seek_mark(BLURAY *bd, unsigned mark); 00305 00314 int bd_select_playlist(BLURAY *bd, uint32_t playlist); 00315 00324 int bd_select_title(BLURAY *bd, uint32_t title); 00325 00334 int bd_select_angle(BLURAY *bd, unsigned angle); 00335 00343 void bd_seamless_angle_change(BLURAY *bd, unsigned angle); 00344 00354 uint64_t bd_get_title_size(BLURAY *bd); 00355 00363 uint32_t bd_get_current_title(BLURAY *bd); 00364 00372 unsigned bd_get_current_angle(BLURAY *bd); 00373 00381 uint64_t bd_tell(BLURAY *bd); 00382 00390 uint64_t bd_tell_time(BLURAY *bd); 00391 00392 /* 00393 * Disc info 00394 */ 00395 00396 typedef struct { 00397 uint8_t bluray_detected; 00398 00399 uint8_t first_play_supported; 00400 uint8_t top_menu_supported; 00401 00402 uint32_t num_hdmv_titles; 00403 uint32_t num_bdj_titles; 00404 uint32_t num_unsupported_titles; 00405 00406 uint8_t aacs_detected; 00407 uint8_t libaacs_detected; 00408 uint8_t aacs_handled; 00409 00410 uint8_t bdplus_detected; 00411 uint8_t libbdplus_detected; 00412 uint8_t bdplus_handled; 00413 00414 } BLURAY_DISC_INFO; 00415 00423 const BLURAY_DISC_INFO *bd_get_disc_info(BLURAY*); 00424 00425 /* 00426 * player settings 00427 */ 00428 00429 typedef enum { 00430 BLURAY_PLAYER_SETTING_PARENTAL = 13, /* Age for parental control (years) */ 00431 BLURAY_PLAYER_SETTING_AUDIO_CAP = 15, /* Player capability for audio (bit mask) */ 00432 BLURAY_PLAYER_SETTING_AUDIO_LANG = 16, /* Initial audio language: ISO 639-2 string, ex. "eng" */ 00433 BLURAY_PLAYER_SETTING_PG_LANG = 17, /* Initial PG/SPU language: ISO 639-2 string, ex. "eng" */ 00434 BLURAY_PLAYER_SETTING_MENU_LANG = 18, /* Initial menu language: ISO 639-2 string, ex. "eng" */ 00435 BLURAY_PLAYER_SETTING_COUNTRY_CODE = 19, /* Player country code: ISO 3166-1 string, ex. "de" */ 00436 BLURAY_PLAYER_SETTING_REGION_CODE = 20, /* Player region code: 1 - region A, 2 - B, 4 - C */ 00437 BLURAY_PLAYER_SETTING_VIDEO_CAP = 29, /* Player capability for video (bit mask) */ 00438 BLURAY_PLAYER_SETTING_TEXT_CAP = 30, /* Player capability for text subtitle (bit mask) */ 00439 BLURAY_PLAYER_SETTING_PLAYER_PROFILE = 31, /* Profile1: 0, Profile1+: 1, Profile2: 3, Profile3: 8 */ 00440 } bd_player_setting; 00441 00452 int bd_set_player_setting(BLURAY *bd, uint32_t idx, uint32_t value); 00453 int bd_set_player_setting_str(BLURAY *bd, uint32_t idx, const char *s); 00454 00455 /* 00456 * Java 00457 */ 00458 int bd_start_bdj(BLURAY *bd, const char* start_object); // start BD-J from the specified BD-J object (should be a 5 character string) 00459 void bd_stop_bdj(BLURAY *bd); // shutdown BD-J and clean up resources 00460 00461 /* 00462 * events 00463 */ 00464 00465 typedef enum { 00466 BD_EVENT_NONE = 0, 00467 BD_EVENT_ERROR, 00468 BD_EVENT_ENCRYPTED, 00469 00470 /* current playback position */ 00471 BD_EVENT_ANGLE, /* current angle, 1...N */ 00472 BD_EVENT_TITLE, /* current title, 1...N (0 = top menu) */ 00473 BD_EVENT_PLAYLIST, /* current playlist (xxxxx.mpls) */ 00474 BD_EVENT_PLAYITEM, /* current play item */ 00475 BD_EVENT_CHAPTER, /* current chapter, 1...N */ 00476 BD_EVENT_END_OF_TITLE, 00477 00478 /* stream selection */ 00479 BD_EVENT_AUDIO_STREAM, /* 1..32, 0xff = none */ 00480 BD_EVENT_IG_STREAM, /* 1..32 */ 00481 BD_EVENT_PG_TEXTST_STREAM, /* 1..255, 0xfff = none */ 00482 BD_EVENT_PIP_PG_TEXTST_STREAM, /* 1..255, 0xfff = none */ 00483 BD_EVENT_SECONDARY_AUDIO_STREAM, /* 1..32, 0xff = none */ 00484 BD_EVENT_SECONDARY_VIDEO_STREAM, /* 1..32, 0xff = none */ 00485 00486 BD_EVENT_PG_TEXTST, /* 0 - disable, 1 - enable */ 00487 BD_EVENT_PIP_PG_TEXTST, /* 0 - disable, 1 - enable */ 00488 BD_EVENT_SECONDARY_AUDIO, /* 0 - disable, 1 - enable */ 00489 BD_EVENT_SECONDARY_VIDEO, /* 0 - disable, 1 - enable */ 00490 BD_EVENT_SECONDARY_VIDEO_SIZE, /* 0 - PIP, 0xf - fullscreen */ 00491 00492 /* HDMV VM or JVM seeked the stream. Next read() will return data from new position. */ 00493 BD_EVENT_SEEK, 00494 00495 /* still playback (pause) */ 00496 BD_EVENT_STILL, /* 0 - off, 1 - on */ 00497 00498 /* Still playback for n seconds (reached end of still mode play item) */ 00499 BD_EVENT_STILL_TIME, /* 0 = infinite ; 1...300 = seconds */ 00500 00501 } bd_event_e; 00502 00503 typedef struct { 00504 uint32_t event; /* bd_event_e */ 00505 uint32_t param; 00506 } BD_EVENT; 00507 00508 #define BLURAY_TITLE_FIRST_PLAY 0xffff 00509 #define BLURAY_TITLE_TOP_MENU 0 00510 00518 int bd_get_event(BLURAY *bd, BD_EVENT *event); 00519 00520 /* 00521 * navigaton mode 00522 */ 00523 00533 int bd_play(BLURAY *bd); 00534 00547 int bd_read_ext(BLURAY *bd, unsigned char *buf, int len, BD_EVENT *event); 00548 00561 int bd_play_title(BLURAY *bd, unsigned title); 00562 00573 int bd_menu_call(BLURAY *bd, int64_t pts); 00574 00575 /* 00576 * User interaction and On-screen display controller 00577 */ 00578 00579 struct bd_overlay_s; /* defined in overlay.h */ 00580 typedef void (*bd_overlay_proc_f)(void *, const struct bd_overlay_s * const); 00581 00591 void bd_register_overlay_proc(BLURAY *bd, void *handle, bd_overlay_proc_f func); 00592 00604 int bd_user_input(BLURAY *bd, int64_t pts, uint32_t key); 00605 00616 int bd_mouse_select(BLURAY *bd, int64_t pts, uint16_t x, uint16_t y); 00617 00618 /* 00619 * 00620 */ 00621 00622 struct meta_dl; 00630 struct meta_dl *bd_get_meta(BLURAY *bd); 00631 00632 00633 struct clpi_cl; 00642 struct clpi_cl *bd_get_clpi(BLURAY *bd, unsigned clip_ref); 00643 00650 void bd_free_clpi(struct clpi_cl *cl); 00651 00652 #ifdef __cplusplus 00653 }; 00654 #endif 00655 00656 #endif /* BLURAY_H_ */