demux.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _DEMUX_SYS_H
00026 #define _DEMUX_SYS_H
00027
00028 #include "mkv.hpp"
00029
00030 #include "chapter_command.hpp"
00031 #include "virtual_segment.hpp"
00032
00033
00034 #undef ATTRIBUTE_PACKED
00035 #undef PRAGMA_PACK_BEGIN
00036 #undef PRAGMA_PACK_END
00037
00038 #if defined(__GNUC__)
00039 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
00040 #define ATTRIBUTE_PACKED __attribute__ ((packed))
00041 #define PRAGMA_PACK 0
00042 #endif
00043 #endif
00044
00045 #if !defined(ATTRIBUTE_PACKED)
00046 #define ATTRIBUTE_PACKED
00047 #define PRAGMA_PACK 1
00048 #endif
00049
00050 #if PRAGMA_PACK
00051 #pragma pack(1)
00052 #endif
00053
00054
00055
00056
00057
00058
00059
00060
00061 typedef struct {
00062 uint8_t hour;
00063 uint8_t minute;
00064 uint8_t second;
00065 uint8_t frame_u;
00066 } ATTRIBUTE_PACKED dvd_time_t;
00067
00068
00069
00070
00071 typedef struct {
00072 #ifdef WORDS_BIGENDIAN
00073 unsigned char zero : 7;
00074 unsigned char video_pres_mode_change : 1;
00075
00076 unsigned char karaoke_audio_pres_mode_change : 1;
00077 unsigned char angle_change : 1;
00078 unsigned char subpic_stream_change : 1;
00079 unsigned char audio_stream_change : 1;
00080 unsigned char pause_on : 1;
00081 unsigned char still_off : 1;
00082 unsigned char button_select_or_activate : 1;
00083 unsigned char resume : 1;
00084
00085 unsigned char chapter_menu_call : 1;
00086 unsigned char angle_menu_call : 1;
00087 unsigned char audio_menu_call : 1;
00088 unsigned char subpic_menu_call : 1;
00089 unsigned char root_menu_call : 1;
00090 unsigned char title_menu_call : 1;
00091 unsigned char backward_scan : 1;
00092 unsigned char forward_scan : 1;
00093
00094 unsigned char next_pg_search : 1;
00095 unsigned char prev_or_top_pg_search : 1;
00096 unsigned char time_or_chapter_search : 1;
00097 unsigned char go_up : 1;
00098 unsigned char stop : 1;
00099 unsigned char title_play : 1;
00100 unsigned char chapter_search_or_play : 1;
00101 unsigned char title_or_time_play : 1;
00102 #else
00103 unsigned char video_pres_mode_change : 1;
00104 unsigned char zero : 7;
00105
00106 unsigned char resume : 1;
00107 unsigned char button_select_or_activate : 1;
00108 unsigned char still_off : 1;
00109 unsigned char pause_on : 1;
00110 unsigned char audio_stream_change : 1;
00111 unsigned char subpic_stream_change : 1;
00112 unsigned char angle_change : 1;
00113 unsigned char karaoke_audio_pres_mode_change : 1;
00114
00115 unsigned char forward_scan : 1;
00116 unsigned char backward_scan : 1;
00117 unsigned char title_menu_call : 1;
00118 unsigned char root_menu_call : 1;
00119 unsigned char subpic_menu_call : 1;
00120 unsigned char audio_menu_call : 1;
00121 unsigned char angle_menu_call : 1;
00122 unsigned char chapter_menu_call : 1;
00123
00124 unsigned char title_or_time_play : 1;
00125 unsigned char chapter_search_or_play : 1;
00126 unsigned char title_play : 1;
00127 unsigned char stop : 1;
00128 unsigned char go_up : 1;
00129 unsigned char time_or_chapter_search : 1;
00130 unsigned char prev_or_top_pg_search : 1;
00131 unsigned char next_pg_search : 1;
00132 #endif
00133 } ATTRIBUTE_PACKED user_ops_t;
00134
00135
00136
00137
00138 typedef struct {
00139 uint8_t bytes[8];
00140 } ATTRIBUTE_PACKED vm_cmd_t;
00141 #define COMMAND_DATA_SIZE 8
00142
00143
00144
00145
00146 typedef struct {
00147 uint32_t nv_pck_lbn;
00148 uint16_t vobu_cat;
00149 uint16_t zero1;
00150 user_ops_t vobu_uop_ctl;
00151 uint32_t vobu_s_ptm;
00152 uint32_t vobu_e_ptm;
00153 uint32_t vobu_se_e_ptm;
00154 dvd_time_t e_eltm;
00155 char vobu_isrc[32];
00156 } ATTRIBUTE_PACKED pci_gi_t;
00157
00158
00159
00160
00161 typedef struct {
00162 uint32_t nsml_agl_dsta[9];
00163 } ATTRIBUTE_PACKED nsml_agli_t;
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 typedef struct {
00175 uint16_t hli_ss;
00176 uint32_t hli_s_ptm;
00177 uint32_t hli_e_ptm;
00178 uint32_t btn_se_e_ptm;
00179 #ifdef WORDS_BIGENDIAN
00180 unsigned char zero1 : 2;
00181 unsigned char btngr_ns : 2;
00182 unsigned char zero2 : 1;
00183 unsigned char btngr1_dsp_ty : 3;
00184 unsigned char zero3 : 1;
00185 unsigned char btngr2_dsp_ty : 3;
00186 unsigned char zero4 : 1;
00187 unsigned char btngr3_dsp_ty : 3;
00188 #else
00189 unsigned char btngr1_dsp_ty : 3;
00190 unsigned char zero2 : 1;
00191 unsigned char btngr_ns : 2;
00192 unsigned char zero1 : 2;
00193 unsigned char btngr3_dsp_ty : 3;
00194 unsigned char zero4 : 1;
00195 unsigned char btngr2_dsp_ty : 3;
00196 unsigned char zero3 : 1;
00197 #endif
00198 uint8_t btn_ofn;
00199 uint8_t btn_ns;
00200 uint8_t nsl_btn_ns;
00201 uint8_t zero5;
00202 uint8_t fosl_btnn;
00203 uint8_t foac_btnn;
00204 } ATTRIBUTE_PACKED hl_gi_t;
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215 typedef struct {
00216 uint32_t btn_coli[3][2];
00217 } ATTRIBUTE_PACKED btn_colit_t;
00218
00219
00220
00221
00222
00223
00224
00225
00226 typedef struct {
00227 #ifdef WORDS_BIGENDIAN
00228 uint32 btn_coln : 2;
00229 uint32 x_start : 10;
00230 uint32 zero1 : 2;
00231 uint32 x_end : 10;
00232
00233 uint32 zero3 : 2;
00234 uint32 up : 6;
00235
00236 uint32 auto_action_mode : 2;
00237 uint32 y_start : 10;
00238 uint32 zero2 : 2;
00239 uint32 y_end : 10;
00240
00241 uint32 zero4 : 2;
00242 uint32 down : 6;
00243 unsigned char zero5 : 2;
00244 unsigned char left : 6;
00245 unsigned char zero6 : 2;
00246 unsigned char right : 6;
00247 #else
00248 uint32 x_end : 10;
00249 uint32 zero1 : 2;
00250 uint32 x_start : 10;
00251 uint32 btn_coln : 2;
00252
00253 uint32 up : 6;
00254 uint32 zero3 : 2;
00255
00256 uint32 y_end : 10;
00257 uint32 zero2 : 2;
00258 uint32 y_start : 10;
00259 uint32 auto_action_mode : 2;
00260
00261 uint32 down : 6;
00262 uint32 zero4 : 2;
00263 unsigned char left : 6;
00264 unsigned char zero5 : 2;
00265 unsigned char right : 6;
00266 unsigned char zero6 : 2;
00267 #endif
00268 vm_cmd_t cmd;
00269 } ATTRIBUTE_PACKED btni_t;
00270
00271
00272
00273
00274 typedef struct {
00275 hl_gi_t hl_gi;
00276 btn_colit_t btn_colit;
00277 btni_t btnit[36];
00278 } ATTRIBUTE_PACKED hli_t;
00279
00280
00281
00282
00283 typedef struct {
00284 pci_gi_t pci_gi;
00285 nsml_agli_t nsml_agli;
00286 hli_t hli;
00287 uint8_t zero1[189];
00288 } ATTRIBUTE_PACKED pci_t;
00289
00290 #if PRAGMA_PACK
00291 #pragma pack()
00292 #endif
00293
00294
00295 class virtual_segment_c;
00296 class chapter_item_c;
00297
00298 typedef struct
00299 {
00300 VLC_COMMON_MEMBERS
00301
00302 demux_t *p_demux;
00303 vlc_mutex_t lock;
00304
00305 bool b_moved;
00306 bool b_clicked;
00307 int i_key_action;
00308
00309 } event_thread_t;
00310
00311
00312 class demux_sys_t
00313 {
00314 public:
00315 demux_sys_t( demux_t & demux )
00316 :demuxer(demux)
00317 ,i_pts(0)
00318 ,i_start_pts(0)
00319 ,i_chapter_time(0)
00320 ,meta(NULL)
00321 ,i_current_title(0)
00322 ,p_current_segment(NULL)
00323 ,dvd_interpretor( *this )
00324 ,f_duration(-1.0)
00325 ,b_ui_hooked(false)
00326 ,p_input(NULL)
00327 ,b_pci_packet_set(false)
00328 ,p_ev(NULL)
00329 {
00330 vlc_mutex_init( &lock_demuxer );
00331 }
00332
00333 virtual ~demux_sys_t();
00334
00335
00336 demux_t & demuxer;
00337
00338 mtime_t i_pts;
00339 mtime_t i_start_pts;
00340 mtime_t i_chapter_time;
00341
00342 vlc_meta_t *meta;
00343
00344 std::vector<input_title_t*> titles;
00345 size_t i_current_title;
00346
00347 std::vector<matroska_stream_c*> streams;
00348 std::vector<attachment_c*> stored_attachments;
00349 std::vector<matroska_segment_c*> opened_segments;
00350 std::vector<virtual_segment_c*> used_segments;
00351 virtual_segment_c *p_current_segment;
00352
00353 dvd_command_interpretor_c dvd_interpretor;
00354
00355
00356 float f_duration;
00357
00358 matroska_segment_c *FindSegment( const EbmlBinary & uid ) const;
00359 chapter_item_c *BrowseCodecPrivate( unsigned int codec_id,
00360 bool (*match)(const chapter_codec_cmds_c &data, const void *p_cookie, size_t i_cookie_size ),
00361 const void *p_cookie,
00362 size_t i_cookie_size,
00363 virtual_segment_c * & p_segment_found );
00364 chapter_item_c *FindChapter( int64_t i_find_uid, virtual_segment_c * & p_segment_found );
00365
00366 void PreloadFamily( const matroska_segment_c & of_segment );
00367 void PreloadLinked( matroska_segment_c *p_segment );
00368 bool PreparePlayback( virtual_segment_c *p_new_segment );
00369 matroska_stream_c *AnalyseAllSegmentsFound( demux_t *p_demux, EbmlStream *p_estream, bool b_initial = false );
00370 void JumpTo( virtual_segment_c & p_segment, chapter_item_c * p_chapter );
00371
00372 void StartUiThread();
00373 void StopUiThread();
00374 bool b_ui_hooked;
00375 void SwapButtons();
00376
00377
00378 input_thread_t *p_input;
00379 pci_t pci_packet;
00380 bool b_pci_packet_set;
00381 uint8_t palette[4][4];
00382 vlc_mutex_t lock_demuxer;
00383
00384
00385 event_thread_t *p_ev;
00386 static void * EventThread( vlc_object_t *p_this );
00387 static int EventMouse( vlc_object_t *p_this, char const *psz_var,
00388 vlc_value_t oldval, vlc_value_t newval, void *p_data );
00389 static int EventKey( vlc_object_t *p_this, char const *psz_var,
00390 vlc_value_t oldval, vlc_value_t newval, void *p_data );
00391
00392
00393
00394 protected:
00395 virtual_segment_c *VirtualFromSegments( matroska_segment_c *p_segment ) const;
00396 bool IsUsedSegment( matroska_segment_c &p_segment ) const;
00397 };
00398
00399
00400 #endif