[libbluray-devel] [Git][videolan/libbluray][master] add function to dump decrypted m2ts

Petri Hintukainen gitlab at videolan.org
Sat Jun 8 11:04:05 CEST 2019



Petri Hintukainen pushed to branch master at VideoLAN / libbluray


Commits:
000f083a by Yunxiang Li at 2019-06-08T08:40:49Z
add function to dump decrypted m2ts

- - - - -


4 changed files:

- src/libbluray/bluray.c
- src/libbluray/bluray.h
- src/libbluray/disc/disc.c
- src/libbluray/disc/disc.h


Changes:

=====================================
src/libbluray/bluray.c
=====================================
@@ -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


=====================================
src/libbluray/bluray.h
=====================================
@@ -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
 }


=====================================
src/libbluray/disc/disc.c
=====================================
@@ -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
  */


=====================================
src/libbluray/disc/disc.h
=====================================
@@ -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);
 



View it on GitLab: https://code.videolan.org/videolan/libbluray/commit/000f083ad98ef9d3b93e6edb4da0074f33317cc1

-- 
View it on GitLab: https://code.videolan.org/videolan/libbluray/commit/000f083ad98ef9d3b93e6edb4da0074f33317cc1
You're receiving this email because of your account on code.videolan.org.



More information about the libbluray-devel mailing list