1
0
Fork 0

add function to dump decrypted m2ts

This commit is contained in:
Yunxiang Li 2019-03-17 18:40:57 -04:00 committed by hpi1
parent ae061211e8
commit 000f083ad9
4 changed files with 59 additions and 0 deletions

View File

@ -3765,6 +3765,21 @@ int bd_read_file(BLURAY *bd, const char *path, void **data, int64_t *size)
return _bd_read_file(bd, NULL, path, data, size);
}
struct bd_dir_s *bd_open_dir(BLURAY *bd, const char *dir)
{
if (!bd || dir == NULL) {
return NULL;
}
return disc_open_dir(bd->disc, dir);
}
struct bd_file_s *bd_open_file_dec(BLURAY *bd, const char *path)
{
if (!bd || path == NULL) {
return NULL;
}
return disc_open_path_dec(bd->disc, path);
}
/*
* Metadata

View File

@ -1094,6 +1094,26 @@ void bd_stop_bdj(BLURAY *bd); // shutdown BD-J and clean up resources
*/
int bd_read_file(BLURAY *, const char *path, void **data, int64_t *size);
/**
*
* Open a file/dir from BluRay Virtual File System.
*
* encrypted streams are decrypted, and because of how
* decryption works, it can only seek to (N*6144) bytes,
* and read 6144 bytes at a time.
* DO NOT mix any play functionalities with these functions.
* It might cause broken stream. In general, accessing
* mutiple file on disk at the same time is a bad idea.
* Caller must close with file_close()/dir_close().
*
* @param bd BLURAY object
* @param dir target directory (relative to disc root)
* @param path path to the file (relative to disc root)
* @return BD_DIR_H * or BD_FILE_H *, NULL if failed
*/
struct bd_dir_s *bd_open_dir(BLURAY *, const char *dir);
struct bd_file_s *bd_open_file_dec(BLURAY *, const char *path);
#ifdef __cplusplus
}

View File

@ -579,6 +579,26 @@ int disc_cache_bdrom_file(BD_DISC *p, const char *rel_path, const char *cache_pa
return 0;
}
BD_FILE_H *disc_open_path_dec(BD_DISC *p, const char *rel_path)
{
size_t size = strlen(rel_path);
char *suf = (size > 5) ? rel_path + (size - 5) : rel_path;
/* check if it's a stream */
if (strncmp(rel_path, "BDMV" DIR_SEP "STREAM", 11)) { // not equal
return disc_open_path(p, rel_path);
} else if (!strcmp(suf, ".m2ts")) { // equal
return disc_open_stream(p, suf - 5);
} else if (!strcmp(suf+1, ".MTS")) { // equal
return disc_open_stream(p, suf - 4);
} else if (!strcmp(suf, ".ssif")) { // equal
BD_DEBUG(DBG_FILE | DBG_CRIT, "error opening file %s, ssif is not yet supported.\n", rel_path);
} else {
BD_DEBUG(DBG_FILE | DBG_CRIT, "error opening file %s\n", rel_path);
}
return NULL;
}
/*
* persistent properties storage
*/

View File

@ -80,8 +80,12 @@ BD_PRIVATE size_t disc_read_file(BD_DISC *disc, const char *dir, const char *fil
/* Update virtual package */
BD_PRIVATE void disc_update(BD_DISC *disc, const char *overlay_root);
/* Cache file directly from BD-ROM */
BD_PRIVATE int disc_cache_bdrom_file(BD_DISC *p, const char *rel_path, const char *cache_path);
/* Open decrypted file */
BD_PRIVATE struct bd_file_s *disc_open_path_dec(BD_DISC *p, const char *rel_path);
/* open BD-ROM directory (relative to disc root) */
BD_PRIVATE struct bd_dir_s *disc_open_bdrom_dir(BD_DISC *disc, const char *path);