summaryrefslogtreecommitdiffstats
path: root/stream/rar.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-08-25 22:58:29 +0200
committerwm4 <wm4@nowhere>2013-08-26 10:09:46 +0200
commit3fc3bf70f972f4e68258193f0f9c70ee6b85be5e (patch)
tree7c953cee512669da24d83c1b6ffefce74f3ddc53 /stream/rar.h
parent74b846e2f7d95e4dea2fdae4b1301a2c83f2acd3 (diff)
downloadmpv-3fc3bf70f972f4e68258193f0f9c70ee6b85be5e.tar.bz2
mpv-3fc3bf70f972f4e68258193f0f9c70ee6b85be5e.tar.xz
stream: add uncompressed rar support
Apparently, it is popular to store large files in uncompressed rar archives. Extracting files is not practical, and some media players suport playing directly from uncompressed rar (at least VLC and some DirectShow components). Storing or accessing files this way is completely idiotic, but it is a common practice, and the ones subjected to this practice can't do much to change this (at least that's what I assume/hope). Also, it's a feature request, so we say yes. This code is mostly taken from VLC (commit f6e7240 from their git tree). We also copy the way this is done: opening a rar file by itself yields a playlist, which contains URLs to the actual entries in the rar file. Compressed entries are simply skipped.
Diffstat (limited to 'stream/rar.h')
-rw-r--r--stream/rar.h60
1 files changed, 60 insertions, 0 deletions
diff --git a/stream/rar.h b/stream/rar.h
new file mode 100644
index 0000000000..6b001244a5
--- /dev/null
+++ b/stream/rar.h
@@ -0,0 +1,60 @@
+/*****************************************************************************
+ * rar.h: uncompressed RAR parser
+ *****************************************************************************
+ * Copyright (C) 2008-2010 Laurent Aimar
+ * $Id: 4dea45925c2d8f319d692475bc0307fdd9f6cfe7 $
+ *
+ * Author: Laurent Aimar <fenrir _AT_ videolan _DOT_ org>
+ *
+ * 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
+ * (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
+ * 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 program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef MP_RAR_H
+#define MP_RAR_H
+
+#include <inttypes.h>
+#include <sys/types.h>
+
+typedef struct {
+ char *mrl;
+ uint64_t offset;
+ uint64_t size;
+ uint64_t cummulated_size;
+} rar_file_chunk_t;
+
+typedef struct {
+ char *name;
+ uint64_t size;
+ bool is_complete;
+
+ int chunk_count;
+ rar_file_chunk_t **chunk;
+ uint64_t real_size; /* Gathered size */
+
+ // When actually reading the data
+ struct MPOpts *opts;
+ uint64_t i_pos;
+ stream_t *s;
+ rar_file_chunk_t *current_chunk;
+} rar_file_t;
+
+int RarProbe(struct stream *);
+void RarFileDelete(rar_file_t *);
+int RarParse(struct stream *, int *, rar_file_t ***);
+
+int RarSeek(rar_file_t *file, uint64_t position);
+ssize_t RarRead(rar_file_t *file, void *data, size_t size);
+
+#endif