summaryrefslogtreecommitdiffstats
path: root/stream/stream_rar.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-09-13 17:31:24 +0200
committerwm4 <wm4@nowhere>2019-09-13 17:35:06 +0200
commita25b3d61a1c4b98183f7660bc3249321c13093d3 (patch)
tree53c9fad0ab4d3dbc93a17f61616992e2c21f4edb /stream/stream_rar.c
parenta75b249b0b116b6ddc5c430f0a9974696361ebf9 (diff)
downloadmpv-a25b3d61a1c4b98183f7660bc3249321c13093d3.tar.bz2
mpv-a25b3d61a1c4b98183f7660bc3249321c13093d3.tar.xz
demux, stream: remove old rar support in favor of libarchive
The old rar code could do uncompressed rar, libarchive supports at least some rar compression algorithms. There is no need to keep the old rar code.
Diffstat (limited to 'stream/stream_rar.c')
-rw-r--r--stream/stream_rar.c147
1 files changed, 0 insertions, 147 deletions
diff --git a/stream/stream_rar.c b/stream/stream_rar.c
deleted file mode 100644
index 3ba689b539..0000000000
--- a/stream/stream_rar.c
+++ /dev/null
@@ -1,147 +0,0 @@
-// Major parts based on:
-/*****************************************************************************
- * access.c: uncompressed RAR access
- *****************************************************************************
- * Copyright (C) 2008-2010 Laurent Aimar
- * $Id: dcd973529e0029abe326d31f8d58cd13bbcc276c $
- *
- * 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.
- *****************************************************************************/
-
-#include "config.h"
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <errno.h>
-
-#include "osdep/io.h"
-
-#include "common/msg.h"
-#include "stream.h"
-#include "options/m_option.h"
-#include "rar.h"
-
-/*
-This works as follows:
-
-- stream_open() with file01.rar
- - is opened as normal file (stream_file.c or others) first
- - demux_rar.c detects it
- - if multi-part, opens file02.rar, file03.rar, etc. as actual streams
- - it returns a playlist with entries like this to the player:
- rar://bla01.rar|subfile.mkv
- (one such entry for each file contained in the rar)
-- stream_open() with the playlist entry, e.g. rar://bla01.rar|subfile.mkv
- - leads to rar_entry_open()
- - opens bla01.rar etc. again as actual streams
- - read accesses go into subfile.mkv contained in the rar file(s)
-*/
-
-static int rar_entry_fill_buffer(stream_t *s, char *buffer, int max_len)
-{
- rar_file_t *rar_file = s->priv;
- return RarRead(rar_file, buffer, max_len);
-}
-
-static int rar_entry_seek(stream_t *s, int64_t newpos)
-{
- rar_file_t *rar_file = s->priv;
- return RarSeek(rar_file, newpos);
-}
-
-static void rar_entry_close(stream_t *s)
-{
- rar_file_t *rar_file = s->priv;
- RarFileDelete(rar_file);
-}
-
-static int rar_entry_control(stream_t *s, int cmd, void *arg)
-{
- rar_file_t *rar_file = s->priv;
- switch (cmd) {
- case STREAM_CTRL_GET_BASE_FILENAME:
- *(char **)arg = talloc_strdup(NULL, rar_file->s->url);
- return STREAM_OK;
- case STREAM_CTRL_GET_SIZE:
- *(int64_t *)arg = rar_file->size;
- return STREAM_OK;
- }
- return STREAM_UNSUPPORTED;
-}
-
-static int rar_entry_open(stream_t *stream)
-{
- if (!strchr(stream->path, '|'))
- return STREAM_ERROR;
-
- char *base = talloc_strdup(stream, stream->path);
- char *name = strchr(base, '|');
- *name++ = '\0';
- mp_url_unescape_inplace(base);
-
- struct stream *rar = stream_create(base, STREAM_READ | STREAM_SAFE_ONLY,
- stream->cancel, stream->global);
- if (!rar)
- return STREAM_ERROR;
-
- int count;
- rar_file_t **files;
- if (RarProbe(rar) || RarParse(rar, &count, &files)) {
- free_stream(rar);
- return STREAM_ERROR;
- }
-
- rar_file_t *file = NULL;
- for (int i = 0; i < count; i++) {
- if (!file && strcmp(files[i]->name, name) == 0)
- file = files[i];
- else
- RarFileDelete(files[i]);
- }
- talloc_free(files);
- if (!file) {
- free_stream(rar);
- return STREAM_ERROR;
- }
-
- rar_file_chunk_t dummy = {
- .mrl = base,
- };
- file->current_chunk = &dummy;
- file->s = rar; // transfer ownership
- file->cancel = stream->cancel;
- file->global = stream->global;
- RarSeek(file, 0);
-
- stream->priv = file;
- stream->fill_buffer = rar_entry_fill_buffer;
- stream->seek = rar_entry_seek;
- stream->seekable = true;
- stream->close = rar_entry_close;
- stream->control = rar_entry_control;
-
- return STREAM_OK;
-}
-
-const stream_info_t stream_info_rar = {
- .name = "rar",
- .open = rar_entry_open,
- .protocols = (const char*const[]){ "rar", NULL },
-};