bluray.c 47.2 KB
Newer Older
1 2 3
/*****************************************************************************
 * bluray.c: Blu-ray disc support plugin
 *****************************************************************************
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
4
 * Copyright © 2010-2012 VideoLAN, VLC authors and libbluray AUTHORS
5 6
 *
 * Authors: Jean-Baptiste Kempf <jb@videolan.org>
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
7
 *          Hugo Beauzée-Luyssen <hugo@videolan.org>
8
 *
9 10 11
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
12 13 14 15
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Jean-Baptiste Kempf's avatar
LGPL  
Jean-Baptiste Kempf committed
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
 * GNU Lesser General Public License for more details.
18
 *
19 20 21
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 23 24 25 26 27 28
 *****************************************************************************/

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <assert.h>
29
#include <limits.h>                         /* PATH_MAX */
30 31 32 33
#if defined (HAVE_MNTENT_H) && defined(HAVE_SYS_STAT_H)
#include <mntent.h>
#include <sys/stat.h>
#endif
34

35 36 37 38 39 40 41
#ifdef __APPLE__
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/ucred.h>
#include <sys/mount.h>
#endif

42 43
#include <vlc_common.h>
#include <vlc_plugin.h>
44 45
#include <vlc_demux.h>                      /* demux_t */
#include <vlc_input.h>                      /* Seekpoints, chapters */
46
#include <vlc_atomic.h>
47
#include <vlc_dialog.h>                     /* BD+/AACS warnings */
48
#include <vlc_vout.h>                       /* vout_PutSubpicture / subpicture_t */
49
#include <vlc_url.h>                        /* vlc_path2uri */
50 51

#include <libbluray/bluray.h>
52
#include <libbluray/keys.h>
53
#include <libbluray/meta_data.h>
54
#include <libbluray/overlay.h>
55 56 57 58 59

/*****************************************************************************
 * Module descriptor
 *****************************************************************************/

Christoph Miebach's avatar
Christoph Miebach committed
60 61
#define BD_MENU_TEXT        N_( "Blu-ray menus" )
#define BD_MENU_LONGTEXT    N_( "Use Blu-ray menus. If disabled, "\
62
                                "the movie will start directly" )
63 64 65 66 67 68 69 70 71 72
#define BD_REGION_TEXT      N_( "Region code" )
#define BD_REGION_LONGTEXT  N_( "Blu-Ray player region code. "\
                                "Some discs can be played only with a correct region code.")

static const char *const ppsz_region_code[] = {
    "A", "B", "C" };
static const char *const ppsz_region_code_text[] = {
    "Region A", "Region B", "Region C" };

#define REGION_DEFAULT   1   /* Index to region list. Actual region code is (1<<REGION_DEFAULT) */
73

74 75 76 77 78
/* Callbacks */
static int  blurayOpen ( vlc_object_t * );
static void blurayClose( vlc_object_t * );

vlc_module_begin ()
Christoph Miebach's avatar
Christoph Miebach committed
79 80
    set_shortname( N_("Blu-ray") )
    set_description( N_("Blu-ray Disc support (libbluray)") )
81 82 83

    set_category( CAT_INPUT )
    set_subcategory( SUBCAT_INPUT_ACCESS )
84
    set_capability( "access_demux", 200)
85
    add_bool( "bluray-menu", false, BD_MENU_TEXT, BD_MENU_LONGTEXT, false )
86 87
    add_string( "bluray-region", ppsz_region_code[REGION_DEFAULT], BD_REGION_TEXT, BD_REGION_LONGTEXT, false)
        change_string_list( ppsz_region_code, ppsz_region_code_text )
88

89
    add_shortcut( "bluray", "file" )
90 91 92 93

    set_callbacks( blurayOpen, blurayClose )
vlc_module_end ()

94 95
/* libbluray's overlay.h defines 2 types of overlay (bd_overlay_plane_e). */
#define MAX_OVERLAY 2
96

97 98 99 100 101 102 103 104
typedef enum OverlayStatus {
    Closed = 0,
    ToDisplay,  //Used to mark the overlay to be displayed the first time.
    Displayed,
    Outdated    //used to update the overlay after it has been sent to the vout
} OverlayStatus;

typedef struct bluray_overlay_t
105
{
106
    atomic_flag         released_once;
107 108 109 110 111 112 113 114 115
    vlc_mutex_t         lock;
    subpicture_t        *p_pic;
    OverlayStatus       status;
    subpicture_region_t *p_regions;
} bluray_overlay_t;

struct  demux_sys_t
{
    BLURAY              *bluray;
116 117

    /* Titles */
118 119
    unsigned int        i_title;
    unsigned int        i_longest_title;
120
    unsigned int        i_current_clip;
121
    input_title_t       **pp_title;
122

123 124 125
    /* Meta informations */
    const META_DL       *p_meta;

126
    /* Menus */
127 128 129 130 131 132 133
    bluray_overlay_t    *p_overlays[MAX_OVERLAY];
    int                 current_overlay; // -1 if no current overlay;
    bool                b_menu;

    /* */
    input_thread_t      *p_input;
    vout_thread_t       *p_vout;
134

135
    /* TS stream */
136
    es_out_t            *p_out;
137
    vlc_array_t         es;
138
    int                 i_audio_stream; /* Selected audio stream. -1 if default */
139
    int                 i_video_stream;
140
    stream_t            *p_parser;
141 142 143

    /* Used to store bluray disc path */
    char                *psz_bd_path;
144 145 146 147 148
};

struct subpicture_updater_sys_t
{
    bluray_overlay_t    *p_overlay;
149 150
};

151 152 153
/*****************************************************************************
 * Local prototypes
 *****************************************************************************/
154 155
static es_out_t *esOutNew( demux_t *p_demux );

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
156 157
static int   blurayControl(demux_t *, int, va_list);
static int   blurayDemux(demux_t *);
158

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
159 160
static int   blurayInitTitles(demux_t *p_demux );
static int   bluraySetTitle(demux_t *p_demux, int i_title);
161

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
162
static void  blurayOverlayProc(void *ptr, const BD_OVERLAY * const overlay);
163
static void  blurayArgbOverlayProc(void *ptr, const BD_ARGB_OVERLAY * const overlay);
164

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
165 166
static int   onMouseEvent(vlc_object_t *p_vout, const char *psz_var,
                          vlc_value_t old, vlc_value_t val, void *p_data);
167

168 169
static void  blurayResetParser(demux_t *p_demux);

170 171 172
#define FROM_TICKS(a) (a*CLOCK_FREQ / INT64_C(90000))
#define TO_TICKS(a)   (a*INT64_C(90000)/CLOCK_FREQ)
#define CUR_LENGTH    p_sys->pp_title[p_demux->info.i_title]->i_length
173 174 175 176 177 178

/*****************************************************************************
 * blurayOpen: module init function
 *****************************************************************************/
static int blurayOpen( vlc_object_t *object )
{
179 180
    demux_t *p_demux = (demux_t*)object;
    demux_sys_t *p_sys;
181

182
    const char *error_msg = NULL;
183

184
    if (strcmp(p_demux->psz_access, "bluray")) {
185
        // TODO BDMV support, once we figure out what to do in libbluray
186 187 188
        return VLC_EGENERIC;
    }

189
    /* */
190
    p_demux->p_sys = p_sys = calloc(1, sizeof(*p_sys));
191 192 193
    if (unlikely(!p_sys)) {
        return VLC_ENOMEM;
    }
194
    p_sys->current_overlay = -1;
195
    p_sys->i_audio_stream = -1;
196
    p_sys->i_video_stream = -1;
197 198 199 200 201

    /* init demux info fields */
    p_demux->info.i_update    = 0;
    p_demux->info.i_title     = 0;
    p_demux->info.i_seekpoint = 0;
202

203 204
    TAB_INIT( p_sys->i_title, p_sys->pp_title );

205
    /* store current bd path */
206
    if (p_demux->psz_file) {
207
        p_sys->psz_bd_path = strndup(p_demux->psz_file, strlen(p_demux->psz_file));
208
    }
209

210 211 212
#if defined (HAVE_MNTENT_H) && defined (HAVE_SYS_STAT_H)
    /* If we're passed a block device, try to convert it to the mount point. */
    struct stat st;
213
    if ( !stat (p_sys->psz_bd_path, &st)) {
214 215 216 217 218
        if (S_ISBLK (st.st_mode)) {
            FILE* mtab = setmntent ("/proc/self/mounts", "r");
            struct mntent* m;
            struct mntent mbuf;
            char buf [8192];
219
            /* bd path may be a symlink (e.g. /dev/dvd -> /dev/sr0), so make
220
             * sure we look up the real device */
221
            char* bd_device = realpath(p_sys->psz_bd_path, NULL);
222
            while ((m = getmntent_r (mtab, &mbuf, buf, sizeof(buf))) != NULL) {
223 224
                if (!strcmp (m->mnt_fsname, (bd_device == NULL ? p_sys->psz_bd_path : bd_device))) {
                    p_sys->psz_bd_path = strndup(m->mnt_dir, strlen(m->mnt_dir));
225 226 227
                    break;
                }
            }
Edward Wang's avatar
Edward Wang committed
228
            free(bd_device);
229 230 231 232
            endmntent (mtab);
        }
    }
#endif /* HAVE_MNTENT_H && HAVE_SYS_STAT_H */
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251
#ifdef __APPLE__
    /* If we're passed a block device, try to convert it to the mount point. */
    struct stat st;
    if ( !stat (p_sys->psz_bd_path, &st)) {
        if (S_ISBLK (st.st_mode)) {
            struct statfs mbuf[128];
            int fs_count;

            if ( (fs_count = getfsstat (NULL, 0, MNT_NOWAIT)) > 0 ) {
                getfsstat (mbuf, fs_count * sizeof(mbuf[0]), MNT_NOWAIT);
                for ( int i = 0; i < fs_count; ++i) {
                    if (!strcmp (mbuf[i].f_mntfromname, p_sys->psz_bd_path)) {
                        p_sys->psz_bd_path = strndup(mbuf[i].f_mntonname, strlen(mbuf[i].f_mntonname));
                    }
                }
            }
        }
    }
#endif
252
    p_sys->bluray = bd_open(p_sys->psz_bd_path, NULL);
253
    if (!p_sys->bluray) {
254 255 256 257
        free(p_sys);
        return VLC_EGENERIC;
    }

258 259
    /* Warning the user about AACS/BD+ */
    const BLURAY_DISC_INFO *disc_info = bd_get_disc_info(p_sys->bluray);
260 261 262

    /* Is it a bluray? */
    if (!disc_info->bluray_detected) {
Christoph Miebach's avatar
Christoph Miebach committed
263
        error_msg = "Path doesn't appear to be a Blu-ray";
264 265 266
        goto error;
    }

267 268
    msg_Info(p_demux, "First play: %i, Top menu: %i\n"
                      "HDMV Titles: %i, BD-J Titles: %i, Other: %i",
269 270 271 272 273 274 275
             disc_info->first_play_supported, disc_info->top_menu_supported,
             disc_info->num_hdmv_titles, disc_info->num_bdj_titles,
             disc_info->num_unsupported_titles);

    /* AACS */
    if (disc_info->aacs_detected) {
        if (!disc_info->libaacs_detected) {
Christoph Miebach's avatar
Christoph Miebach committed
276
            error_msg = _("This Blu-ray Disc needs a library for AACS decoding, "
277 278
                      "and your system does not have it.");
            goto error;
279 280
        }
        if (!disc_info->aacs_handled) {
281 282 283 284
#ifdef BD_AACS_CORRUPTED_DISC
            if (disc_info->aacs_error_code) {
                switch (disc_info->aacs_error_code) {
                    case BD_AACS_CORRUPTED_DISC:
Christoph Miebach's avatar
Christoph Miebach committed
285
                        error_msg = _("Blu-ray Disc is corrupted.");
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
                        break;
                    case BD_AACS_NO_CONFIG:
                        error_msg = _("Missing AACS configuration file!");
                        break;
                    case BD_AACS_NO_PK:
                        error_msg = _("No valid processing key found in AACS config file.");
                        break;
                    case BD_AACS_NO_CERT:
                        error_msg = _("No valid host certificate found in AACS config file.");
                        break;
                    case BD_AACS_CERT_REVOKED:
                        error_msg = _("AACS Host certificate revoked.");
                        break;
                    case BD_AACS_MMC_FAILED:
                        error_msg = _("AACS MMC failed.");
                        break;
                }
                goto error;
            }
#else
306 307 308
            error_msg = _("Your system AACS decoding library does not work. "
                      "Missing keys?");
            goto error;
309
#endif /* BD_AACS_CORRUPTED_DISC */
310 311 312 313 314 315
        }
    }

    /* BD+ */
    if (disc_info->bdplus_detected) {
        if (!disc_info->libbdplus_detected) {
Christoph Miebach's avatar
Christoph Miebach committed
316
            error_msg = _("This Blu-ray Disc needs a library for BD+ decoding, "
317 318
                      "and your system does not have it.");
            goto error;
319 320
        }
        if (!disc_info->bdplus_handled) {
321 322 323
            error_msg = _("Your system BD+ decoding library does not work. "
                      "Missing configuration?");
            goto error;
324 325 326
        }
    }

327 328 329 330 331 332
    /* set player region code */
    char *psz_region = var_InheritString(p_demux, "bluray-region");
    unsigned int region = psz_region ? (psz_region[0] - 'A') : REGION_DEFAULT;
    free(psz_region);
    bd_set_player_setting(p_sys->bluray, BLURAY_PLAYER_SETTING_REGION_CODE, 1<<region);

333
    /* Get titles and chapters */
334 335
    p_sys->p_meta = bd_get_meta(p_sys->bluray);
    if (!p_sys->p_meta)
336
        msg_Warn(p_demux, "Failed to get meta info." );
337

338
    if (blurayInitTitles(p_demux) != VLC_SUCCESS) {
339
        goto error;
340 341
    }

342 343 344 345 346
    /*
     * Initialize the event queue, so we can receive events in blurayDemux(Menu).
     */
    bd_get_event(p_sys->bluray, NULL);

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
347 348
    p_sys->b_menu = var_InheritBool(p_demux, "bluray-menu");
    if (p_sys->b_menu) {
349
        p_sys->p_input = demux_GetParentInput(p_demux);
Rafaël Carré's avatar
Rafaël Carré committed
350 351
        if (unlikely(!p_sys->p_input)) {
            error_msg = "Could not get parent input";
352
            goto error;
Rafaël Carré's avatar
Rafaël Carré committed
353
        }
354

355 356 357 358 359
        /* Register ARGB overlay handler for BD-J */
        if (disc_info->num_bdj_titles) {
            bd_register_argb_overlay_proc(p_sys->bluray, p_demux, blurayArgbOverlayProc, NULL);
        }

360
        /* libbluray will start playback from "First-Title" title */
361 362 363 364
        if (bd_play(p_sys->bluray) == 0) {
            error_msg = "Failed to start bluray playback. Please try without menu support.";
            goto error;
        }
365 366
        /* Registering overlay event handler */
        bd_register_overlay_proc(p_sys->bluray, p_demux, blurayOverlayProc);
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
367
    } else {
368
        /* set start title number */
369 370
        if (bluraySetTitle(p_demux, p_sys->i_longest_title) != VLC_SUCCESS) {
            msg_Err( p_demux, "Could not set the title %d", p_sys->i_longest_title );
371 372
            goto error;
        }
373 374
    }

375
    vlc_array_init(&p_sys->es);
376 377 378 379 380
    p_sys->p_out = esOutNew( p_demux );
    if (unlikely(p_sys->p_out == NULL)) {
        goto error;
    }

381
    blurayResetParser( p_demux );
382 383
    if (!p_sys->p_parser) {
        msg_Err(p_demux, "Failed to create TS demuxer");
384
        goto error;
385 386 387 388
    }

    p_demux->pf_control = blurayControl;
    p_demux->pf_demux   = blurayDemux;
389 390

    return VLC_SUCCESS;
391 392 393

error:
    if (error_msg)
Christoph Miebach's avatar
Christoph Miebach committed
394
        dialog_Fatal(p_demux, _("Blu-ray error"), "%s", error_msg);
395 396
    blurayClose(object);
    return VLC_EGENERIC;
397 398 399 400 401 402 403 404
}


/*****************************************************************************
 * blurayClose: module destroy function
 *****************************************************************************/
static void blurayClose( vlc_object_t *object )
{
405 406 407
    demux_t *p_demux = (demux_t*)object;
    demux_sys_t *p_sys = p_demux->p_sys;

408 409 410 411 412 413 414 415
    /*
     * Close libbluray first.
     * This will close all the overlays before we release p_vout
     * bd_close( NULL ) can crash
     */
    assert(p_sys->bluray);
    bd_close(p_sys->bluray);

416 417 418
    if (p_sys->p_vout != NULL) {
        var_DelCallback(p_sys->p_vout, "mouse-moved", &onMouseEvent, p_demux);
        var_DelCallback(p_sys->p_vout, "mouse-clicked", &onMouseEvent, p_demux);
419
        vlc_object_release(p_sys->p_vout);
420
    }
421 422
    if (p_sys->p_input != NULL)
        vlc_object_release(p_sys->p_input);
423 424
    if (p_sys->p_parser)
        stream_Delete(p_sys->p_parser);
425 426
    if (p_sys->p_out != NULL)
        es_out_Delete(p_sys->p_out);
427 428 429
    assert( vlc_array_count(&p_sys->es) == 0 );
    vlc_array_clear( &p_sys->es );

430 431 432 433 434
    /* Titles */
    for (unsigned int i = 0; i < p_sys->i_title; i++)
        vlc_input_title_Delete(p_sys->pp_title[i]);
    TAB_CLEAN( p_sys->i_title, p_sys->pp_title );

435
    free(p_sys->psz_bd_path);
436 437 438
    free(p_sys);
}

439 440 441 442 443 444 445 446
/*****************************************************************************
 * Elementary streams handling
 *****************************************************************************/

struct es_out_sys_t {
    demux_t *p_demux;
};

447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469
typedef struct  fmt_es_pair {
    int         i_id;
    es_out_id_t *p_es;
}               fmt_es_pair_t;

static int  findEsPairIndex( demux_sys_t *p_sys, int i_id )
{
    for ( int i = 0; i < vlc_array_count(&p_sys->es); ++i ) {
        if ( ((fmt_es_pair_t*)vlc_array_item_at_index(&p_sys->es, i))->i_id == i_id )
            return i;
    }
    return -1;
}

static int  findEsPairIndexByEs( demux_sys_t *p_sys, es_out_id_t *p_es )
{
    for ( int i = 0; i < vlc_array_count(&p_sys->es); ++i ) {
        if ( ((fmt_es_pair_t*)vlc_array_item_at_index(&p_sys->es, i))->p_es == p_es )
            return i;
    }
    return -1;
}

470 471
static es_out_id_t *esOutAdd( es_out_t *p_out, const es_format_t *p_fmt )
{
472 473 474 475 476 477 478
    demux_sys_t *p_sys = p_out->p_sys->p_demux->p_sys;
    es_format_t fmt;

    es_format_Copy(&fmt, p_fmt);
    switch (fmt.i_cat)
    {
    case VIDEO_ES:
479 480
        if ( p_sys->i_video_stream != -1 && p_sys->i_video_stream != p_fmt->i_id )
            fmt.i_priority = -2;
481 482 483 484 485 486 487 488 489 490
        break ;
    case AUDIO_ES:
        if ( p_sys->i_audio_stream != -1 && p_sys->i_audio_stream != p_fmt->i_id )
            fmt.i_priority = -2;
        break ;
    case SPU_ES:
        break ;
    }

    es_out_id_t *p_es = es_out_Add( p_out->p_sys->p_demux->out, &fmt );
491 492
    if ( p_fmt->i_id >= 0 ) {
        /* Ensure we are not overriding anything */
493
        int idx = findEsPairIndex(p_sys, p_fmt->i_id);
494 495 496 497 498
        if ( idx == -1 ) {
            fmt_es_pair_t *p_pair = malloc( sizeof(*p_pair) );
            if ( likely(p_pair != NULL) ) {
                p_pair->i_id = p_fmt->i_id;
                p_pair->p_es = p_es;
499
                msg_Info( p_out->p_sys->p_demux, "Adding ES %d", p_fmt->i_id );
500
                vlc_array_append(&p_sys->es, p_pair);
501 502 503
            }
        }
    }
504
    es_format_Clean(&fmt);
505
    return p_es;
506 507 508 509 510 511 512 513 514
}

static int esOutSend( es_out_t *p_out, es_out_id_t *p_es, block_t *p_block )
{
    return es_out_Send( p_out->p_sys->p_demux->out, p_es, p_block );
}

static void esOutDel( es_out_t *p_out, es_out_id_t *p_es )
{
515 516 517 518 519 520
    int idx = findEsPairIndexByEs( p_out->p_sys->p_demux->p_sys, p_es );
    if (idx >= 0)
    {
        free( vlc_array_item_at_index( &p_out->p_sys->p_demux->p_sys->es, idx) );
        vlc_array_remove(&p_out->p_sys->p_demux->p_sys->es, idx);
    }
521 522 523 524 525 526 527 528 529 530
    es_out_Del( p_out->p_sys->p_demux->out, p_es );
}

static int esOutControl( es_out_t *p_out, int i_query, va_list args )
{
    return es_out_vaControl( p_out->p_sys->p_demux->out, i_query, args );
}

static void esOutDestroy( es_out_t *p_out )
{
531 532 533
    for ( int i = 0; i < vlc_array_count(&p_out->p_sys->p_demux->p_sys->es); ++i )
        free( vlc_array_item_at_index(&p_out->p_sys->p_demux->p_sys->es, i) );
    vlc_array_clear(&p_out->p_sys->p_demux->p_sys->es);
534 535 536 537 538 539
    free( p_out->p_sys );
    free( p_out );
}

static es_out_t *esOutNew( demux_t *p_demux )
{
540
    assert( vlc_array_count(&p_demux->p_sys->es) == 0 );
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559
    es_out_t    *p_out = malloc( sizeof(*p_out) );
    if ( unlikely(p_out == NULL) )
        return NULL;

    p_out->pf_add       = &esOutAdd;
    p_out->pf_control   = &esOutControl;
    p_out->pf_del       = &esOutDel;
    p_out->pf_destroy   = &esOutDestroy;
    p_out->pf_send      = &esOutSend;

    p_out->p_sys = malloc( sizeof(*p_out->p_sys) );
    if ( unlikely( p_out->p_sys == NULL ) ) {
        free( p_out );
        return NULL;
    }
    p_out->p_sys->p_demux = p_demux;
    return p_out;
}

560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631
/*****************************************************************************
 * subpicture_updater_t functions:
 *****************************************************************************/
static int subpictureUpdaterValidate( subpicture_t *p_subpic,
                                      bool b_fmt_src, const video_format_t *p_fmt_src,
                                      bool b_fmt_dst, const video_format_t *p_fmt_dst,
                                      mtime_t i_ts )
{
    VLC_UNUSED( b_fmt_src );
    VLC_UNUSED( b_fmt_dst );
    VLC_UNUSED( p_fmt_src );
    VLC_UNUSED( p_fmt_dst );
    VLC_UNUSED( i_ts );

    subpicture_updater_sys_t *p_upd_sys = p_subpic->updater.p_sys;
    bluray_overlay_t         *p_overlay = p_upd_sys->p_overlay;

    vlc_mutex_lock(&p_overlay->lock);
    int res = p_overlay->status == Outdated;
    vlc_mutex_unlock(&p_overlay->lock);
    return res;
}

/* This should probably be moved to subpictures.c afterward */
static subpicture_region_t* subpicture_region_Clone(subpicture_region_t *p_region_src)
{
    if (!p_region_src)
        return NULL;
    subpicture_region_t *p_region_dst = subpicture_region_New(&p_region_src->fmt);
    if (unlikely(!p_region_dst))
        return NULL;

    p_region_dst->i_x      = p_region_src->i_x;
    p_region_dst->i_y      = p_region_src->i_y;
    p_region_dst->i_align  = p_region_src->i_align;
    p_region_dst->i_alpha  = p_region_src->i_alpha;

    p_region_dst->psz_text = p_region_src->psz_text ? strdup(p_region_src->psz_text) : NULL;
    p_region_dst->psz_html = p_region_src->psz_html ? strdup(p_region_src->psz_html) : NULL;
    if (p_region_src->p_style != NULL) {
        p_region_dst->p_style = malloc(sizeof(*p_region_dst->p_style));
        p_region_dst->p_style = text_style_Copy(p_region_dst->p_style,
                                                p_region_src->p_style);
    }

    //Palette is already copied by subpicture_region_New, we just have to duplicate p_pixels
    for (int i = 0; i < p_region_src->p_picture->i_planes; i++)
        memcpy(p_region_dst->p_picture->p[i].p_pixels,
               p_region_src->p_picture->p[i].p_pixels,
               p_region_src->p_picture->p[i].i_lines * p_region_src->p_picture->p[i].i_pitch);
    return p_region_dst;
}

static void subpictureUpdaterUpdate(subpicture_t *p_subpic,
                                    const video_format_t *p_fmt_src,
                                    const video_format_t *p_fmt_dst,
                                    mtime_t i_ts)
{
    VLC_UNUSED(p_fmt_src);
    VLC_UNUSED(p_fmt_dst);
    VLC_UNUSED(i_ts);
    subpicture_updater_sys_t *p_upd_sys = p_subpic->updater.p_sys;
    bluray_overlay_t         *p_overlay = p_upd_sys->p_overlay;

    /*
     * When this function is called, all p_subpic regions are gone.
     * We need to duplicate our regions (stored internaly) to this subpic.
     */
    vlc_mutex_lock(&p_overlay->lock);

    subpicture_region_t *p_src = p_overlay->p_regions;
    if (!p_src)
632 633
    {
        vlc_mutex_unlock(&p_overlay->lock);
634
        return;
635
    }
636 637 638 639 640

    subpicture_region_t **p_dst = &(p_subpic->p_region);
    while (p_src != NULL) {
        *p_dst = subpicture_region_Clone(p_src);
        if (*p_dst == NULL)
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
641
            break;
642 643 644 645 646 647 648 649 650
        p_dst = &((*p_dst)->p_next);
        p_src = p_src->p_next;
    }
    if (*p_dst != NULL)
        (*p_dst)->p_next = NULL;
    p_overlay->status = Displayed;
    vlc_mutex_unlock(&p_overlay->lock);
}

651 652
static void blurayCleanOverlayStruct(bluray_overlay_t *);

653 654
static void subpictureUpdaterDestroy(subpicture_t *p_subpic)
{
655
    blurayCleanOverlayStruct(p_subpic->updater.p_sys->p_overlay);
656 657
}

658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680
/*****************************************************************************
 * User input events:
 *****************************************************************************/
static int onMouseEvent(vlc_object_t *p_vout, const char *psz_var, vlc_value_t old,
                        vlc_value_t val, void *p_data)
{
    demux_t     *p_demux = (demux_t*)p_data;
    demux_sys_t *p_sys   = p_demux->p_sys;
    mtime_t     now      = mdate();
    VLC_UNUSED(old);
    VLC_UNUSED(p_vout);

    if (psz_var[6] == 'm')   //Mouse moved
        bd_mouse_select(p_sys->bluray, now, val.coords.x, val.coords.y);
    else if (psz_var[6] == 'c') {
        bd_mouse_select(p_sys->bluray, now, val.coords.x, val.coords.y);
        bd_user_input(p_sys->bluray, now, BD_VK_MOUSE_ACTIVATE);
    } else {
        assert(0);
    }
    return VLC_SUCCESS;
}

681 682 683 684 685 686 687 688 689
static int sendKeyEvent(demux_sys_t *p_sys, unsigned int key)
{
    mtime_t now = mdate();
    if (bd_user_input(p_sys->bluray, now, key) < 0) {
        return VLC_EGENERIC;
    }
    return VLC_SUCCESS;
}

690 691 692
/*****************************************************************************
 * libbluray overlay handling:
 *****************************************************************************/
693
static void blurayCleanOverlayStruct(bluray_overlay_t *p_overlay)
694
{
695 696
    if (!atomic_flag_test_and_set(&p_overlay->released_once))
        return;
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715
    /*
     * This will be called when destroying the picture.
     * Don't delete it again from here!
     */
    vlc_mutex_destroy(&p_overlay->lock);
    subpicture_region_Delete(p_overlay->p_regions);
    free(p_overlay);
}

static void blurayCloseAllOverlays(demux_t *p_demux)
{
    demux_sys_t *p_sys = p_demux->p_sys;

    p_demux->p_sys->current_overlay = -1;
    if (p_sys->p_vout != NULL) {
        for (int i = 0; i < 0; i++) {
            if (p_sys->p_overlays[i] != NULL) {
                vout_FlushSubpictureChannel(p_sys->p_vout,
                                            p_sys->p_overlays[i]->p_pic->i_channel);
716
                blurayCleanOverlayStruct(p_sys->p_overlays[i]);
717 718 719
                p_sys->p_overlays[i] = NULL;
            }
        }
720 721
        var_DelCallback(p_sys->p_vout, "mouse-moved", &onMouseEvent, p_demux);
        var_DelCallback(p_sys->p_vout, "mouse-clicked", &onMouseEvent, p_demux);
722 723 724 725 726 727 728 729 730 731 732 733
        vlc_object_release(p_sys->p_vout);
        p_sys->p_vout = NULL;
    }
}

/*
 * Mark the overlay as "ToDisplay" status.
 * This will not send the overlay to the vout instantly, as the vout
 * may not be acquired (not acquirable) yet.
 * If is has already been acquired, the overlay has already been sent to it,
 * therefore, we only flag the overlay as "Outdated"
 */
734
static void blurayActivateOverlay(demux_t *p_demux, int plane)
735 736 737 738 739 740 741
{
    demux_sys_t *p_sys = p_demux->p_sys;

    /*
     * If the overlay is already displayed, mark the picture as outdated.
     * We must NOT use vout_PutSubpicture if a picture is already displayed.
     */
742 743 744
    vlc_mutex_lock(&p_sys->p_overlays[plane]->lock);
    if ((p_sys->p_overlays[plane]->status == Displayed ||
            p_sys->p_overlays[plane]->status == Outdated)
745
            && p_sys->p_vout) {
746 747
        p_sys->p_overlays[plane]->status = Outdated;
        vlc_mutex_unlock(&p_sys->p_overlays[plane]->lock);
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
748
        return;
749 750 751 752 753 754
    }
    /*
     * Mark the overlay as available, but don't display it right now.
     * the blurayDemuxMenu will send it to vout, as it may be unavailable when
     * the overlay is computed
     */
755 756 757
    p_sys->current_overlay = plane;
    p_sys->p_overlays[plane]->status = ToDisplay;
    vlc_mutex_unlock(&p_sys->p_overlays[plane]->lock);
758 759
}

760
static void blurayInitOverlay(demux_t *p_demux, int plane, int width, int height)
761 762 763
{
    demux_sys_t *p_sys = p_demux->p_sys;

764
    assert(p_sys->p_overlays[plane] == NULL);
765

766 767
    p_sys->p_overlays[plane] = calloc(1, sizeof(**p_sys->p_overlays));
    if (unlikely(!p_sys->p_overlays[plane]))
768 769 770 771
        return;

    subpicture_updater_sys_t *p_upd_sys = malloc(sizeof(*p_upd_sys));
    if (unlikely(!p_upd_sys)) {
772 773
        free(p_sys->p_overlays[plane]);
        p_sys->p_overlays[plane] = NULL;
774 775
        return;
    }
776
    /* two references: vout + demux */
777
    p_sys->p_overlays[plane]->released_once = ATOMIC_FLAG_INIT;
778

779
    p_upd_sys->p_overlay = p_sys->p_overlays[plane];
780 781 782 783 784 785
    subpicture_updater_t updater = {
        .pf_validate = subpictureUpdaterValidate,
        .pf_update   = subpictureUpdaterUpdate,
        .pf_destroy  = subpictureUpdaterDestroy,
        .p_sys       = p_upd_sys,
    };
786 787 788 789 790 791
    vlc_mutex_init(&p_sys->p_overlays[plane]->lock);
    p_sys->p_overlays[plane]->p_pic = subpicture_New(&updater);
    p_sys->p_overlays[plane]->p_pic->i_original_picture_width = width;
    p_sys->p_overlays[plane]->p_pic->i_original_picture_height = height;
    p_sys->p_overlays[plane]->p_pic->b_ephemer = true;
    p_sys->p_overlays[plane]->p_pic->b_absolute = true;
792 793 794 795 796 797 798 799 800 801
}

/**
 * Destroy every regions in the subpicture.
 * This is done in two steps:
 * - Wiping our private regions list
 * - Flagging the overlay as outdated, so the changes are replicated from
 *   the subpicture_updater_t::pf_update
 * This doesn't destroy the subpicture, as the overlay may be used again by libbluray.
 */
802
static void blurayClearOverlay(demux_t *p_demux, int plane)
803 804 805
{
    demux_sys_t *p_sys = p_demux->p_sys;

806
    vlc_mutex_lock(&p_sys->p_overlays[plane]->lock);
807

808 809 810 811
    subpicture_region_ChainDelete(p_sys->p_overlays[plane]->p_regions);
    p_sys->p_overlays[plane]->p_regions = NULL;
    p_sys->p_overlays[plane]->status = Outdated;
    vlc_mutex_unlock(&p_sys->p_overlays[plane]->lock);
812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895
}

/*
 * This will draw to the overlay by adding a region to our region list
 * This will have to be copied to the subpicture used to render the overlay.
 */
static void blurayDrawOverlay(demux_t *p_demux, const BD_OVERLAY* const ov)
{
    demux_sys_t *p_sys = p_demux->p_sys;

    /*
     * Compute a subpicture_region_t.
     * It will be copied and sent to the vout later.
     */
    if (!ov->img)
        return;

    vlc_mutex_lock(&p_sys->p_overlays[ov->plane]->lock);

    /* Find a region to update */
    subpicture_region_t *p_reg = p_sys->p_overlays[ov->plane]->p_regions;
    subpicture_region_t *p_last = NULL;
    while (p_reg != NULL) {
        p_last = p_reg;
        if (p_reg->i_x == ov->x && p_reg->i_y == ov->y &&
                p_reg->fmt.i_width == ov->w && p_reg->fmt.i_height == ov->h)
            break;
        p_reg = p_reg->p_next;
    }

    /* If there is no region to update, create a new one. */
    if (!p_reg) {
        video_format_t fmt;
        video_format_Init(&fmt, 0);
        video_format_Setup(&fmt, VLC_CODEC_YUVP, ov->w, ov->h, 1, 1);

        p_reg = subpicture_region_New(&fmt);
        p_reg->i_x = ov->x;
        p_reg->i_y = ov->y;
        /* Append it to our list. */
        if (p_last != NULL)
            p_last->p_next = p_reg;
        else /* If we don't have a last region, then our list empty */
            p_sys->p_overlays[ov->plane]->p_regions = p_reg;
    }

    /* Now we can update the region, regardless it's an update or an insert */
    const BD_PG_RLE_ELEM *img = ov->img;
    for (int y = 0; y < ov->h; y++) {
        for (int x = 0; x < ov->w;) {
            memset(p_reg->p_picture->p[0].p_pixels +
                   y * p_reg->p_picture->p[0].i_pitch + x,
                   img->color, img->len);
            x += img->len;
            img++;
        }
    }
    if (ov->palette) {
        p_reg->fmt.p_palette->i_entries = 256;
        for (int i = 0; i < 256; ++i) {
            p_reg->fmt.p_palette->palette[i][0] = ov->palette[i].Y;
            p_reg->fmt.p_palette->palette[i][1] = ov->palette[i].Cb;
            p_reg->fmt.p_palette->palette[i][2] = ov->palette[i].Cr;
            p_reg->fmt.p_palette->palette[i][3] = ov->palette[i].T;
        }
    }
    vlc_mutex_unlock(&p_sys->p_overlays[ov->plane]->lock);
    /*
     * /!\ The region is now stored in our internal list, but not in the subpicture /!\
     */
}

static void blurayOverlayProc(void *ptr, const BD_OVERLAY *const overlay)
{
    demux_t *p_demux = (demux_t*)ptr;

    if (!overlay) {
        msg_Info(p_demux, "Closing overlay.");
        blurayCloseAllOverlays(p_demux);
        return;
    }
    switch (overlay->cmd) {
        case BD_OVERLAY_INIT:
            msg_Info(p_demux, "Initializing overlay");
896
            blurayInitOverlay(p_demux, overlay->plane, overlay->w, overlay->h);
897 898
            break;
        case BD_OVERLAY_CLEAR:
899
            blurayClearOverlay(p_demux, overlay->plane);
900 901
            break;
        case BD_OVERLAY_FLUSH:
902
            blurayActivateOverlay(p_demux, overlay->plane);
903 904 905 906 907 908 909 910 911 912
            break;
        case BD_OVERLAY_DRAW:
            blurayDrawOverlay(p_demux, overlay);
            break;
        default:
            msg_Warn(p_demux, "Unknown BD overlay command: %u", overlay->cmd);
            break;
    }
}

913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999
/*
 * ARGB overlay (BD-J)
 */

static void blurayInitArgbOverlay(demux_t *p_demux, int plane, int width, int height)
{
    demux_sys_t *p_sys = p_demux->p_sys;

    blurayInitOverlay(p_demux, plane, width, height);

    /* If there is no region, create a new one. */
    subpicture_region_t *p_reg = p_sys->p_overlays[plane]->p_regions;
    if (!p_reg) {
        video_format_t fmt;
        video_format_Init(&fmt, 0);
        video_format_Setup(&fmt, VLC_CODEC_RGBA, width, height, 1, 1);

        p_reg = subpicture_region_New(&fmt);
        p_reg->i_x = 0;
        p_reg->i_y = 0;
        p_sys->p_overlays[plane]->p_regions = p_reg;
    }
}

static void blurayDrawArgbOverlay(demux_t *p_demux, const BD_ARGB_OVERLAY* const ov)
{
    demux_sys_t *p_sys = p_demux->p_sys;

    vlc_mutex_lock(&p_sys->p_overlays[ov->plane]->lock);

    /* Find a region to update */
    subpicture_region_t *p_reg = p_sys->p_overlays[ov->plane]->p_regions;
    if (!p_reg) {
        vlc_mutex_unlock(&p_sys->p_overlays[ov->plane]->lock);
        return;
    }

    /* Now we can update the region */
    const uint32_t *src0 = ov->argb;
    uint8_t        *dst0 = p_reg->p_picture->p[0].p_pixels +
                           p_reg->p_picture->p[0].i_pitch * ov->y +
                           ov->x * 4;

    for (int y = 0; y < ov->h; y++) {
        // XXX: add support for this format ? Should be possible with OPENGL/VDPAU/...
        // - or add libbluray option to select the format ?
        for (int x = 0; x < ov->w; x++) {
            dst0[x*4  ] = src0[x]>>16; /* R */
            dst0[x*4+1] = src0[x]>>8;  /* G */
            dst0[x*4+2] = src0[x];     /* B */
            dst0[x*4+3] = src0[x]>>24; /* A */
        }

        src0 += ov->stride;
        dst0 += p_reg->p_picture->p[0].i_pitch;
    }

    vlc_mutex_unlock(&p_sys->p_overlays[ov->plane]->lock);
    /*
     * /!\ The region is now stored in our internal list, but not in the subpicture /!\
     */
}

static void blurayArgbOverlayProc(void *ptr, const BD_ARGB_OVERLAY *const overlay)
{
    demux_t *p_demux = (demux_t*)ptr;

    switch (overlay->cmd) {
        case BD_ARGB_OVERLAY_INIT:
            blurayInitArgbOverlay(p_demux, overlay->plane, overlay->w, overlay->h);
            break;
        case BD_ARGB_OVERLAY_CLOSE:
            blurayClearOverlay(p_demux, overlay->plane);
            // TODO: blurayCloseOverlay(p_demux, overlay->plane);
            break;
        case BD_ARGB_OVERLAY_FLUSH:
            blurayActivateOverlay(p_demux, overlay->plane);
            break;
        case BD_ARGB_OVERLAY_DRAW:
            blurayDrawArgbOverlay(p_demux, overlay);
            break;
        default:
            msg_Warn(p_demux, "Unknown BD ARGB overlay command: %u", overlay->cmd);
            break;
    }
}

1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013
static void bluraySendOverlayToVout(demux_t *p_demux)
{
    demux_sys_t *p_sys = p_demux->p_sys;

    assert(p_sys->current_overlay >= 0 &&
           p_sys->p_overlays[p_sys->current_overlay] != NULL &&
           p_sys->p_overlays[p_sys->current_overlay]->p_pic != NULL);

    p_sys->p_overlays[p_sys->current_overlay]->p_pic->i_start =
        p_sys->p_overlays[p_sys->current_overlay]->p_pic->i_stop = mdate();
    p_sys->p_overlays[p_sys->current_overlay]->p_pic->i_channel =
        vout_RegisterSubpictureChannel(p_sys->p_vout);
    /*
     * After this point, the picture should not be accessed from the demux thread,
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
1014
     * as it is held by the vout thread.
1015 1016 1017 1018 1019 1020 1021 1022 1023 1024
     * This must be done only once per subpicture, ie. only once between each
     * blurayInitOverlay & blurayCloseOverlay call.
     */
    vout_PutSubpicture(p_sys->p_vout, p_sys->p_overlays[p_sys->current_overlay]->p_pic);
    /*
     * Mark the picture as Outdated, as it contains no region for now.
     * This will make the subpicture_updater_t call pf_update
     */
    p_sys->p_overlays[p_sys->current_overlay]->status = Outdated;
}
1025 1026

static int blurayInitTitles(demux_t *p_demux )
1027
{
1028
    demux_sys_t *p_sys = p_demux->p_sys;
1029 1030

    /* get and set the titles */
1031
    unsigned i_title = bd_get_titles(p_sys->bluray, TITLES_RELEVANT, 60);
1032 1033 1034 1035 1036 1037 1038
    int64_t duration = 0;

    for (unsigned int i = 0; i < i_title; i++) {
        input_title_t *t = vlc_input_title_New();
        if (!t)
            break;

1039
        BLURAY_TITLE_INFO *title_info = bd_get_title_info(p_sys->bluray, i, 0);
1040 1041
        if (!title_info)
            break;
1042
        t->i_length = FROM_TICKS(title_info->duration);
1043 1044 1045 1046 1047 1048 1049 1050

        if (t->i_length > duration) {
            duration = t->i_length;
            p_sys->i_longest_title = i;
        }

        for ( unsigned int j = 0; j < title_info->chapter_count; j++) {
            seekpoint_t *s = vlc_seekpoint_New();
1051
            if (!s)
1052 1053 1054 1055 1056 1057 1058 1059 1060 1061
                break;
            s->i_time_offset = title_info->chapters[j].offset;

            TAB_APPEND( t->i_seekpoint, t->seekpoint, s );
        }
        TAB_APPEND( p_sys->i_title, p_sys->pp_title, t );
        bd_free_title_info(title_info);
    }
    return VLC_SUCCESS;
}
1062

1063 1064 1065 1066 1067 1068 1069 1070
static void blurayResetParser( demux_t *p_demux )
{
    /*
     * This is a hack and will have to be removed.
     * The parser should be flushed, and not destroy/created each time
     * we are changing title.
     */
    demux_sys_t *p_sys = p_demux->p_sys;
1071 1072
    if (p_sys->p_parser)
        stream_Delete(p_sys->p_parser);
1073
    p_sys->p_parser = stream_DemuxNew(p_demux, "ts", p_sys->p_out);
1074 1075 1076 1077 1078
    if (!p_sys->p_parser) {
        msg_Err(p_demux, "Failed to create TS demuxer");
    }
}

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
1079
static void blurayUpdateTitle(demux_t *p_demux, unsigned i_title)
1080
{
1081
    blurayResetParser(p_demux);
1082 1083
    if (i_title >= p_demux->p_sys->i_title)
        return;
1084

1085 1086 1087 1088 1089
    /* read title info and init some values */
    p_demux->info.i_title = i_title;
    p_demux->info.i_seekpoint = 0;
    p_demux->info.i_update |= INPUT_UPDATE_TITLE | INPUT_UPDATE_SEEKPOINT;
}
1090

1091 1092 1093
/*****************************************************************************
 * bluraySetTitle: select new BD title
 *****************************************************************************/
1094
static int bluraySetTitle(demux_t *p_demux, int i_title)
1095
{
1096
    demux_sys_t *p_sys = p_demux->p_sys;
1097

1098
    /* Looking for the main title, ie the longest duration */
1099
    if (i_title < 0)
1100
        i_title = p_sys->i_longest_title;
1101 1102
    else if ((unsigned)i_title > p_sys->i_title)
        return VLC_EGENERIC;
1103

1104
    msg_Dbg( p_demux, "Selecting Title %i", i_title);
1105

1106
    /* Select Blu-Ray title */
1107 1108
    if (bd_select_title(p_demux->p_sys->bluray, i_title) == 0 ) {
        msg_Err(p_demux, "cannot select bd title '%d'", p_demux->info.i_title);
1109 1110
        return VLC_EGENERIC;
    }
1111
    blurayUpdateTitle( p_demux, i_title );
1112 1113 1114 1115 1116 1117 1118 1119

    return VLC_SUCCESS;
}


/*****************************************************************************
 * blurayControl: handle the controls
 *****************************************************************************/
1120
static int blurayControl(demux_t *p_demux, int query, va_list args)
1121
{
1122
    demux_sys_t *p_sys = p_demux->p_sys;
1123 1124 1125 1126
    bool     *pb_bool;
    int64_t  *pi_64;

    switch (query) {
1127 1128 1129
        case DEMUX_CAN_SEEK:
        case DEMUX_CAN_PAUSE:
        case DEMUX_CAN_CONTROL_PACE:
1130 1131 1132 1133
             pb_bool = (bool*)va_arg( args, bool * );
             *pb_bool = true;
             break;

1134
        case DEMUX_GET_PTS_DELAY:
1135
            pi_64 = (int64_t*)va_arg( args, int64_t * );
1136 1137
            *pi_64 =
                INT64_C(1000) * var_InheritInteger( p_demux, "disc-caching" );
1138 1139
            break;

1140
        case DEMUX_SET_PAUSE_STATE:
1141 1142 1143
            /* Nothing to do */
            break;

1144
        case DEMUX_SET_TITLE:
1145 1146
        {
            int i_title = (int)va_arg( args, int );
1147
            if (bluraySetTitle(p_demux, i_title) != VLC_SUCCESS)
1148 1149 1150
                return VLC_EGENERIC;
            break;
        }
1151
        case DEMUX_SET_SEEKPOINT:
1152 1153 1154