disc.h 3.9 KB
Newer Older
Petri Hintukainen's avatar
Petri Hintukainen committed
1 2
/*
 * This file is part of libbluray
3
 * Copyright (C) 2014-2017  Petri Hintukainen <phintuka@users.sourceforge.net>
Petri Hintukainen's avatar
Petri Hintukainen committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
 *
 * This library 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 (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see
 * <http://www.gnu.org/licenses/>.
 */

#if !defined(_BD_DISC_H_)
#define _BD_DISC_H_

#include "util/attributes.h"

#include <stdint.h>
26
#include <stddef.h> /* size_t */
Petri Hintukainen's avatar
Petri Hintukainen committed
27 28 29

struct bd_file_s;
struct bd_dir_s;
npzacs's avatar
npzacs committed
30
struct bd_enc_info;
Petri Hintukainen's avatar
Petri Hintukainen committed
31

32 33 34 35 36 37 38 39 40 41 42 43
/* application provided file system access (optional) */
typedef struct fs_access {
    void *fs_handle;

    /* method 1: block (device) access */
    int (*read_blocks)(void *fs_handle, void *buf, int lba, int num_blocks);

    /* method 2: file access */
    struct bd_dir_s  *(*open_dir) (void *fs_handle, const char *rel_path);
    struct bd_file_s *(*open_file)(void *fs_handle, const char *rel_path);
} fs_access;

Petri Hintukainen's avatar
Petri Hintukainen committed
44 45 46 47 48 49 50 51
/*
 * BluRay Virtual File System
 *
 * Map file access to BD-ROM file system or binding unit data area
 */

typedef struct bd_disc BD_DISC;

npzacs's avatar
npzacs committed
52
BD_PRIVATE BD_DISC *disc_open(const char *device_path,
53
                              fs_access *p_fs,
npzacs's avatar
npzacs committed
54 55 56 57
                              struct bd_enc_info *enc_info,
                              const char *keyfile_path,
                              void *regs, void *psr_read, void *psr_write);

Petri Hintukainen's avatar
Petri Hintukainen committed
58 59 60 61 62
BD_PRIVATE void     disc_close(BD_DISC **);

/* Get BD-ROM root path */
BD_PRIVATE const char *disc_root(BD_DISC *disc);

63 64 65
/* Get UDF volume ID */
BD_PRIVATE const char *disc_volume_id(BD_DISC *);

66
/* Generate pseudo disc ID */
67
BD_PRIVATE int disc_pseudo_id(BD_DISC *, uint8_t *id/*[20]*/);
68

Petri Hintukainen's avatar
Petri Hintukainen committed
69 70 71 72 73 74 75 76
/* Open VFS file (relative to disc root) */
BD_PRIVATE struct bd_file_s *disc_open_file(BD_DISC *disc, const char *dir, const char *file);
BD_PRIVATE struct bd_file_s *disc_open_path(BD_DISC *disc, const char *path);

/* Open VFS directory (relative to disc root) */
BD_PRIVATE struct bd_dir_s *disc_open_dir (BD_DISC *disc, const char *dir);

/* Read VFS file */
77
BD_PRIVATE size_t disc_read_file(BD_DISC *disc, const char *dir, const char *file,
Petri Hintukainen's avatar
Petri Hintukainen committed
78 79
                                  uint8_t **data);

80 81 82
/* Update virtual package */
BD_PRIVATE void disc_update(BD_DISC *disc, const char *overlay_root);

83 84
BD_PRIVATE int  disc_cache_bdrom_file(BD_DISC *p, const char *rel_path, const char *cache_path);

85 86 87
/* open BD-ROM directory (relative to disc root) */
BD_PRIVATE struct bd_dir_s  *disc_open_bdrom_dir(BD_DISC *disc, const char *path);

npzacs's avatar
npzacs committed
88 89 90 91 92 93
/*
 * m2ts stream interface
 */

BD_PRIVATE struct bd_file_s *disc_open_stream(BD_DISC *disc, const char *file);

94 95 96 97 98 99 100 101 102 103 104
/*
 * Store / fetch persistent properties for disc.
 * Data is stored in cache directory and persists between playback sessions.
 *
 * Property name is ASCII string. '=' or '\n' is not allowed in name.
 * property data is UTF8 string without line feeds.
 */

BD_PRIVATE int   disc_property_put(BD_DISC *disc, const char *property, const char *value);
BD_PRIVATE char *disc_property_get(BD_DISC *disc, const char *property);

105
/* "Known" playlists */
106 107
#define DISC_PROPERTY_PLAYLISTS    "Playlists"
#define DISC_PROPERTY_MAIN_FEATURE "MainFeature"
108

npzacs's avatar
npzacs committed
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
/*
 *
 */

BD_PRIVATE const uint8_t *disc_get_data(BD_DISC *, int type);

enum {
    DISC_EVENT_START,       /* param: number of titles, 0 if playing with menus */
    DISC_EVENT_TITLE,       /* param: title number */
    DISC_EVENT_APPLICATION, /* param: app data */
};

BD_PRIVATE void disc_event(BD_DISC *, uint32_t event, uint32_t param);


Petri Hintukainen's avatar
Petri Hintukainen committed
124
#endif /* _BD_DISC_H_ */