summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-14 17:59:26 +0200
committerwm4 <wm4@nowhere>2013-07-14 17:59:26 +0200
commite18ffd6b998858ca0797cb0ce4aabd4a509655dd (patch)
tree199bddd30923db1175a1331191eb86ba684e9e41 /stream
parent3e7d483ac89289f613138002be2043ec5f479bb0 (diff)
parent5ead20bdb3328d199dad693039d18e7a05eb2465 (diff)
downloadmpv-e18ffd6b998858ca0797cb0ce4aabd4a509655dd.tar.bz2
mpv-e18ffd6b998858ca0797cb0ce4aabd4a509655dd.tar.xz
Merge branch 'remove_old_demuxers'
The merged branch doesn't actually just remove old demuxers, but also includes a branch of cleanups and some refactoring. Conflicts: stream/stream.c
Diffstat (limited to 'stream')
-rw-r--r--stream/dvbin.h1
-rw-r--r--stream/stream.c78
-rw-r--r--stream/stream.h81
-rw-r--r--stream/stream_avdevice.c9
-rw-r--r--stream/stream_bluray.c14
-rw-r--r--stream/stream_cdda.c11
-rw-r--r--stream/stream_dvb.c15
-rw-r--r--stream/stream_dvd.c17
-rw-r--r--stream/stream_file.c43
-rw-r--r--stream/stream_lavf.c15
-rw-r--r--stream/stream_memory.c7
-rw-r--r--stream/stream_mf.c9
-rw-r--r--stream/stream_null.c10
-rw-r--r--stream/stream_pvr.c10
-rw-r--r--stream/stream_radio.c10
-rw-r--r--stream/stream_smb.c35
-rw-r--r--stream/stream_tv.c9
-rw-r--r--stream/stream_vcd.c54
-rw-r--r--stream/tv.c79
-rw-r--r--stream/tv.h4
-rw-r--r--stream/vcd_read.h2
21 files changed, 190 insertions, 323 deletions
diff --git a/stream/dvbin.h b/stream/dvbin.h
index 8f7ff28d40..ccaf0db66c 100644
--- a/stream/dvbin.h
+++ b/stream/dvbin.h
@@ -76,6 +76,7 @@ typedef struct {
} dvb_config_t;
typedef struct {
+ int fd;
int card;
int fe_fd;
int sec_fd;
diff --git a/stream/stream.c b/stream/stream.c
index 92d2f84f41..523fcc2e8e 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -118,10 +118,8 @@ static stream_t *new_stream(size_t min_size);
static int stream_seek_unbuffered(stream_t *s, int64_t newpos);
static stream_t *open_stream_plugin(const stream_info_t *sinfo,
- const char *filename,
- int mode, struct MPOpts *options,
- int *file_format, int *ret,
- char **redirected_url)
+ const char *filename, int mode,
+ struct MPOpts *options, int *ret)
{
void *arg = NULL;
stream_t *s;
@@ -146,12 +144,11 @@ static stream_t *open_stream_plugin(const stream_info_t *sinfo,
}
s = new_stream(0);
s->opts = options;
- s->url = strdup(filename);
+ s->url = talloc_strdup(s, filename);
s->flags = 0;
s->mode = mode;
- *ret = sinfo->open(s, mode, arg, file_format);
+ *ret = sinfo->open(s, mode, arg);
if ((*ret) != STREAM_OK) {
- free(s->url);
talloc_free(s);
return NULL;
}
@@ -159,8 +156,6 @@ static stream_t *open_stream_plugin(const stream_info_t *sinfo,
if (!s->read_chunk)
s->read_chunk = 4 * (s->sector_size ? s->sector_size : STREAM_BUFFER_SIZE);
- if (s->type <= -2)
- mp_msg(MSGT_OPEN, MSGL_WARN, "Warning streams need a type !!!!\n");
if (!s->seek)
s->flags &= ~MP_STREAM_SEEK;
if (s->seek && !(s->flags & MP_STREAM_SEEK))
@@ -170,10 +165,7 @@ static stream_t *open_stream_plugin(const stream_info_t *sinfo,
s->uncached_type = s->type;
- mp_msg(MSGT_OPEN, MSGL_V, "STREAM: [%s] %s\n", sinfo->name, filename);
- mp_msg(MSGT_OPEN, MSGL_V, "STREAM: Description: %s\n", sinfo->info);
- mp_msg(MSGT_OPEN, MSGL_V, "STREAM: Author: %s\n", sinfo->author);
- mp_msg(MSGT_OPEN, MSGL_V, "STREAM: Comment: %s\n", sinfo->comment);
+ mp_msg(MSGT_OPEN, MSGL_V, "[stream] [%s] %s\n", sinfo->name, filename);
if (s->mime_type)
mp_msg(MSGT_OPEN, MSGL_V, "Mime-type: '%s'\n", s->mime_type);
@@ -183,21 +175,14 @@ static stream_t *open_stream_plugin(const stream_info_t *sinfo,
static stream_t *open_stream_full(const char *filename, int mode,
- struct MPOpts *options, int *file_format)
+ struct MPOpts *options)
{
int i, j, l, r;
const stream_info_t *sinfo;
stream_t *s;
- char *redirected_url = NULL;
assert(filename);
- int dummy;
- if (!file_format)
- file_format = &dummy;
-
- *file_format = DEMUXER_TYPE_UNKNOWN;
-
for (i = 0; auto_open_streams[i]; i++) {
sinfo = auto_open_streams[i];
if (!sinfo->protocols) {
@@ -212,22 +197,10 @@ static stream_t *open_stream_full(const char *filename, int mode,
if ((l == 0 && !strstr(filename, "://")) ||
((strncasecmp(sinfo->protocols[j], filename, l) == 0) &&
(strncmp("://", filename + l, 3) == 0))) {
- *file_format = DEMUXER_TYPE_UNKNOWN;
- s =
- open_stream_plugin(sinfo, filename, mode, options,
- file_format,
- &r,
- &redirected_url);
+ s = open_stream_plugin(sinfo, filename, mode, options, &r);
if (s)
return s;
- if (r == STREAM_REDIRECTED && redirected_url) {
- mp_msg(MSGT_OPEN, MSGL_V, "[%s] open %s redirected to %s\n",
- sinfo->info, filename, redirected_url);
- s = open_stream_full(redirected_url, mode, options,
- file_format);
- free(redirected_url);
- return s;
- } else if (r != STREAM_UNSUPPORTED) {
+ if (r != STREAM_UNSUPPORTED) {
mp_tmsg(MSGT_OPEN, MSGL_ERR, "Failed to open %s.\n",
filename);
return NULL;
@@ -241,15 +214,14 @@ static stream_t *open_stream_full(const char *filename, int mode,
return NULL;
}
-stream_t *open_stream(const char *filename, struct MPOpts *options,
- int *file_format)
+struct stream *stream_open(const char *filename, struct MPOpts *options)
{
- return open_stream_full(filename, STREAM_READ, options, file_format);
+ return open_stream_full(filename, STREAM_READ, options);
}
stream_t *open_output_stream(const char *filename, struct MPOpts *options)
{
- return open_stream_full(filename, STREAM_WRITE, options, NULL);
+ return open_stream_full(filename, STREAM_WRITE, options);
}
static int stream_reconnect(stream_t *s)
@@ -322,13 +294,7 @@ static int stream_read_unbuffered(stream_t *s, void *buf, int len)
int orig_len = len;
s->buf_pos = s->buf_len = 0;
// we will retry even if we already reached EOF previously.
- if (s->fill_buffer) {
- len = s->fill_buffer(s, buf, len);
- } else if (s->fd >= 0) {
- len = read(s->fd, buf, len);
- } else {
- len = 0;
- }
+ len = s->fill_buffer ? s->fill_buffer(s, buf, len) : -1;
if (len < 0)
len = 0;
if (len == 0) {
@@ -597,24 +563,19 @@ static stream_t *new_stream(size_t min_size)
min_size = FFMAX(min_size, TOTAL_BUFFER_SIZE);
stream_t *s = talloc_size(NULL, sizeof(stream_t) + min_size);
memset(s, 0, sizeof(stream_t));
-
- s->fd = -2;
- s->type = -2;
return s;
}
void free_stream(stream_t *s)
{
+ if (!s)
+ return;
+
stream_set_capture_file(s, NULL);
if (s->close)
s->close(s);
- if (s->fd > 0) {
- close(s->fd);
- }
- free(s->url);
- if (s->uncached_stream)
- free_stream(s->uncached_stream);
+ free_stream(s->uncached_stream);
talloc_free(s);
}
@@ -637,7 +598,7 @@ int stream_check_interrupt(int time)
stream_t *open_memory_stream(void *data, int len)
{
assert(len >= 0);
- stream_t *s = open_stream("memory://", NULL, NULL);
+ stream_t *s = stream_open("memory://", NULL);
assert(s);
stream_control(s, STREAM_CTRL_SET_CONTENTS, &(bstr){data, len});
return s;
@@ -678,16 +639,15 @@ static int stream_enable_cache(stream_t **stream, int64_t size, int64_t min,
orig->buf_len = orig->buf_pos = 0;
stream_t *cache = new_stream(0);
- cache->type = STREAMTYPE_CACHE;
cache->uncached_type = orig->type;
cache->uncached_stream = orig;
cache->flags |= MP_STREAM_SEEK;
cache->mode = STREAM_READ;
cache->read_chunk = 4 * STREAM_BUFFER_SIZE;
- cache->url = strdup(orig->url);
+ cache->url = talloc_strdup(cache, orig->url);
cache->mime_type = talloc_strdup(cache, orig->mime_type);
- cache->lavf_type = orig->lavf_type;
+ cache->lavf_type = talloc_strdup(cache, orig->lavf_type);
cache->opts = orig->opts;
cache->start_pos = orig->start_pos;
cache->end_pos = orig->end_pos;
diff --git a/stream/stream.h b/stream/stream.h
index f1033ed38f..a0cd3d58fc 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -34,25 +34,17 @@
#define O_BINARY 0
#endif
-#define STREAMTYPE_DUMMY -1 // for placeholders, when the actual reading is handled in the demuxer
-#define STREAMTYPE_FILE 0 // read from seekable file
-#define STREAMTYPE_VCD 1 // raw mode-2 CDROM reading, 2324 bytes/sector
-#define STREAMTYPE_DVD 3 // libdvdread
-#define STREAMTYPE_MEMORY 4
-#define STREAMTYPE_PLAYLIST 6 // FIXME!!! same as STREAMTYPE_FILE now
-#define STREAMTYPE_CDDA 10 // raw audio CD reader
-#define STREAMTYPE_SMB 11 // smb:// url, using libsmbclient (samba)
-#define STREAMTYPE_VCDBINCUE 12 // vcd directly from bin/cue files
-#define STREAMTYPE_DVB 13
-#define STREAMTYPE_VSTREAM 14
-#define STREAMTYPE_SDP 15
-#define STREAMTYPE_PVR 16
-#define STREAMTYPE_TV 17
-#define STREAMTYPE_MF 18
-#define STREAMTYPE_RADIO 19
-#define STREAMTYPE_BLURAY 20
-#define STREAMTYPE_AVDEVICE 21
-#define STREAMTYPE_CACHE 22
+enum streamtype {
+ STREAMTYPE_GENERIC = 0,
+ STREAMTYPE_FILE,
+ STREAMTYPE_RADIO,
+ STREAMTYPE_DVB,
+ STREAMTYPE_DVD,
+ STREAMTYPE_PVR,
+ STREAMTYPE_TV,
+ STREAMTYPE_MF,
+ STREAMTYPE_AVDEVICE,
+};
#define STREAM_BUFFER_SIZE 2048
#define STREAM_MAX_SECTOR_SIZE (8 * 1024)
@@ -70,7 +62,6 @@
#define MP_STREAM_SEEK_FW 4
#define MP_STREAM_SEEK (MP_STREAM_SEEK_BW | MP_STREAM_SEEK_FW)
-#define STREAM_REDIRECTED -2
#define STREAM_UNSUPPORTED -1
#define STREAM_ERROR 0
#define STREAM_OK 1
@@ -116,12 +107,9 @@ struct stream_dvd_info_req {
struct stream;
typedef struct stream_info_st {
- const char *info;
const char *name;
- const char *author;
- const char *comment;
// opts is set from ->opts
- int (*open)(struct stream *st, int mode, void *opts, int *file_format);
+ int (*open)(struct stream *st, int mode, void *opts);
const char *protocols[MAX_STREAM_PROTOCOLS];
const void *opts;
int opts_url; /* If this is 1 we will parse the url as an option string
@@ -143,9 +131,8 @@ typedef struct stream {
// Close
void (*close)(struct stream *s);
- int fd; // file descriptor, see man open(2)
- int type; // see STREAMTYPE_*
- int uncached_type; // like (uncached_stream ? uncached_stream->type : type)
+ enum streamtype type; // see STREAMTYPE_*
+ enum streamtype uncached_type; // if stream is cache, type of wrapped str.
int flags; // MP_STREAM_SEEK_* or'ed flags
int sector_size; // sector size (seek will be aligned on this size if non 0)
int read_chunk; // maximum amount of data to read at once to limit latency
@@ -157,6 +144,7 @@ typedef struct stream {
void *priv; // used for DVD, TV, RTSP etc
char *url; // strdup() of filename/url
char *mime_type; // when HTTP streaming is used
+ char *demuxer; // request demuxer to be used
char *lavf_type; // name of expected demuxer type for lavf
struct MPOpts *opts;
@@ -190,14 +178,6 @@ inline static int stream_read_char(stream_t *s)
(stream_fill_buffer(s) ? s->buffer[s->buf_pos++] : -256);
}
-inline static unsigned int stream_read_word(stream_t *s)
-{
- int x, y;
- x = stream_read_char(s);
- y = stream_read_char(s);
- return (x << 8) | y;
-}
-
inline static unsigned int stream_read_dword(stream_t *s)
{
unsigned int y;
@@ -208,26 +188,6 @@ inline static unsigned int stream_read_dword(stream_t *s)
return y;
}
-#define stream_read_fourcc stream_read_dword_le
-
-inline static unsigned int stream_read_word_le(stream_t *s)
-{
- int x, y;
- x = stream_read_char(s);
- y = stream_read_char(s);
- return (y << 8) | x;
-}
-
-inline static uint32_t stream_read_dword_le(stream_t *s)
-{
- unsigned int y;
- y = stream_read_char(s);
- y |= stream_read_char(s) << 8;
- y |= stream_read_char(s) << 16;
- y |= stream_read_char(s) << 24;
- return y;
-}
-
inline static uint64_t stream_read_qword(stream_t *s)
{
uint64_t y;
@@ -242,14 +202,6 @@ inline static uint64_t stream_read_qword(stream_t *s)
return y;
}
-inline static uint64_t stream_read_qword_le(stream_t *s)
-{
- uint64_t y;
- y = stream_read_dword_le(s);
- y |= (uint64_t)stream_read_dword_le(s) << 32;
- return y;
-}
-
unsigned char *stream_read_line(stream_t *s, unsigned char *mem, int max,
int utf16);
@@ -276,8 +228,7 @@ struct bstr stream_read_complete(struct stream *s, void *talloc_ctx,
int stream_control(stream_t *s, int cmd, void *arg);
void stream_update_size(stream_t *s);
void free_stream(stream_t *s);
-stream_t *open_stream(const char *filename, struct MPOpts *options,
- int *file_format);
+struct stream *stream_open(const char *filename, struct MPOpts *options);
stream_t *open_output_stream(const char *filename, struct MPOpts *options);
stream_t *open_memory_stream(void *data, int len);
struct demux_stream;
diff --git a/stream/stream_avdevice.c b/stream/stream_avdevice.c
index e26d5a9060..5d94b35d70 100644
--- a/stream/stream_avdevice.c
+++ b/stream/stream_avdevice.c
@@ -19,31 +19,26 @@
#include "config.h"
#include "stream.h"
-#include "demux/demux.h"
static int fill_buffer(stream_t *s, char *buffer, int max_len)
{
return -1;
}
-static int open_f(stream_t *stream, int mode, void *opts, int *file_format)
+static int open_f(stream_t *stream, int mode, void *opts)
{
if (mode != STREAM_READ)
return STREAM_ERROR;
stream->fill_buffer = fill_buffer;
stream->type = STREAMTYPE_AVDEVICE;
+ stream->demuxer = "lavf";
- *file_format = DEMUXER_TYPE_LAVF;
return STREAM_OK;
}
const stream_info_t stream_info_avdevice = {
- .info = "FFmpeg libavdevice",
.name = "avdevice",
- .author = "",
- .comment =
- "Force a libavformat/libavdevice demuxer with avdevice://demuxer:args",
.open = open_f,
.protocols = { "avdevice", "av", NULL },
};
diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c
index 64d1856873..30145203df 100644
--- a/stream/stream_bluray.c
+++ b/stream/stream_bluray.c
@@ -29,18 +29,19 @@
*
*/
-#include <libbluray/bluray.h>
#include <string.h>
#include <assert.h>
+#include <libbluray/bluray.h>
+#include <libavutil/common.h>
+
#include "config.h"
-#include "libavutil/common.h"
-#include "demux/demux.h"
#include "talloc.h"
#include "core/mp_msg.h"
#include "core/m_struct.h"
#include "core/m_option.h"
#include "stream.h"
+#include "demux/stheader.h"
#define BLURAY_SECTOR_SIZE 6144
@@ -291,8 +292,7 @@ static int bluray_stream_control(stream_t *s, int cmd, void *arg)
return STREAM_UNSUPPORTED;
}
-static int bluray_stream_open(stream_t *s, int mode,
- void *opts, int *file_format)
+static int bluray_stream_open(stream_t *s, int mode, void *opts)
{
struct stream_priv_s *p = opts;
struct bluray_priv_s *b;
@@ -409,7 +409,6 @@ err_no_info:
s->sector_size = BLURAY_SECTOR_SIZE;
s->flags = MP_STREAM_SEEK;
s->priv = b;
- s->type = STREAMTYPE_BLURAY;
s->url = strdup("br://");
mp_tmsg(MSGT_OPEN, MSGL_V, "Blu-ray successfully opened.\n");
@@ -418,10 +417,7 @@ err_no_info:
}
const stream_info_t stream_info_bluray = {
- "Blu-ray Disc",
"bd",
- "Benjamin Zores",
- "Play Blu-ray discs through external libbluray",
bluray_stream_open,
{ "bd", "br", "bluray", NULL },
&bluray_stream_opts,
diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c
index 4e45e51a07..670f47e156 100644
--- a/stream/stream_cdda.c
+++ b/stream/stream_cdda.c
@@ -1,6 +1,8 @@
/*
* This file is part of MPlayer.
*
+ * Original author: Albeu
+ *
* MPlayer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -44,7 +46,6 @@
#include "core/m_struct.h"
#include "libavutil/common.h"
#include "compat/mpbswap.h"
-#include "demux/demux.h"
#include "cdd.h"
@@ -333,7 +334,7 @@ static int control(stream_t *stream, int cmd, void *arg)
return STREAM_UNSUPPORTED;
}
-static int open_cdda(stream_t *st, int m, void *opts, int *file_format)
+static int open_cdda(stream_t *st, int m, void *opts)
{
struct cdda_params *p = (struct cdda_params *)opts;
int mode = p->paranoia_mode;
@@ -471,7 +472,6 @@ static int open_cdda(stream_t *st, int m, void *opts, int *file_format)
st->priv = priv;
st->start_pos = priv->start_sector * CDIO_CD_FRAMESIZE_RAW;
st->end_pos = (priv->end_sector + 1) * CDIO_CD_FRAMESIZE_RAW;
- st->type = STREAMTYPE_CDDA;
st->sector_size = CDIO_CD_FRAMESIZE_RAW;
st->fill_buffer = fill_buffer;
@@ -479,7 +479,7 @@ static int open_cdda(stream_t *st, int m, void *opts, int *file_format)
st->control = control;
st->close = close_cdda;
- *file_format = DEMUXER_TYPE_RAWAUDIO;
+ st->demuxer = "rawaudio";
m_struct_free(&stream_opts, opts);
@@ -489,10 +489,7 @@ static int open_cdda(stream_t *st, int m, void *opts, int *file_format)
}
const stream_info_t stream_info_cdda = {
- "CDDA",
"cdda",
- "Albeu",
- "",
open_cdda,
{"cdda", NULL },
&stream_opts,
diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c
index 40c27f9aac..53761e8f60 100644
--- a/stream/stream_dvb.c
+++ b/stream/stream_dvb.c
@@ -3,6 +3,8 @@
dvbstream
(C) Dave Chapman <dave@dchapman.com> 2001, 2002.
+Original authors: Nico, probably Arpi
+
The latest version can be found at http://www.linuxstb.org/dvbstream
Modified for use with MPlayer, for details see the changelog at
@@ -40,7 +42,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include <errno.h>
#include "stream.h"
-#include "demux/demux.h"
#include "core/m_option.h"
#include "core/m_struct.h"
#include "core/path.h"
@@ -444,7 +445,7 @@ static int dvb_streaming_read(stream_t *stream, char *buffer, int size)
tries = priv->retry + 1;
- fd = stream->fd;
+ fd = priv->fd;
while(pos < size)
{
pfds[0].fd = fd;
@@ -536,7 +537,7 @@ int dvb_set_channel(stream_t *stream, int card, int n)
priv->list = new_list;
priv->retry = 5;
new_list->current = n;
- stream->fd = priv->dvr_fd;
+ priv->fd = priv->dvr_fd;
mp_msg(MSGT_DEMUX, MSGL_V, "DVB_SET_CHANNEL: new channel name=%s, card: %d, channel %d\n", channel->name, card, n);
stream->buf_pos = stream->buf_len = 0;
@@ -659,7 +660,7 @@ static int dvb_streaming_start(stream_t *stream, struct stream_priv_s *opts, int
-static int dvb_open(stream_t *stream, int mode, void *opts, int *file_format)
+static int dvb_open(stream_t *stream, int mode, void *opts)
{
// I don't force the file format bacause, although it's almost always TS,
// there are some providers that stream an IP multicast with M$ Mpeg4 inside
@@ -739,7 +740,8 @@ static int dvb_open(stream_t *stream, int mode, void *opts, int *file_format)
stream->close = dvbin_close;
m_struct_free(&stream_opts, opts);
- *file_format = DEMUXER_TYPE_MPEG_TS;
+ stream->demuxer = "lavf";
+ stream->lavf_type = "mpegts";
return STREAM_OK;
}
@@ -855,10 +857,7 @@ dvb_config_t *dvb_get_config(void)
const stream_info_t stream_info_dvb = {
- "Dvb Input",
"dvbin",
- "Nico",
- "based on the code from ??? (probably Arpi)",
dvb_open,
{ "dvb", NULL },
&stream_opts,
diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c
index bf9cb9d4c7..565054d81b 100644
--- a/stream/stream_dvd.c
+++ b/stream/stream_dvd.c
@@ -1,6 +1,8 @@
/*
* This file is part of MPlayer.
*
+ * Original author: Benjamin Zores
+ *
* MPlayer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -745,7 +747,8 @@ static int control(stream_t *stream,int cmd,void* arg)
}
-static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
+static int open_s(stream_t *stream,int mode, void* opts)
+{
struct stream_priv_s* p = (struct stream_priv_s*)opts;
int k;
@@ -1059,7 +1062,7 @@ fail:
return STREAM_UNSUPPORTED;
}
-static int ifo_stream_open (stream_t *stream, int mode, void *opts, int *file_format)
+static int ifo_stream_open (stream_t *stream, int mode, void *opts)
{
char* filename;
struct stream_priv_s *spriv;
@@ -1085,14 +1088,11 @@ static int ifo_stream_open (stream_t *stream, int mode, void *opts, int *file_fo
free(stream->url);
stream->url=strdup("dvd://");
- return open_s(stream, mode, spriv, file_format);
+ return open_s(stream, mode, spriv);
}
const stream_info_t stream_info_dvd = {
- "DVD stream",
- "null",
- "",
- "",
+ "dvd",
open_s,
{ "dvd", NULL },
&stream_opts,
@@ -1100,10 +1100,7 @@ const stream_info_t stream_info_dvd = {
};
const stream_info_t stream_info_ifo = {
- "DVD IFO input",
"ifo",
- "Benjamin Zores",
- "Mostly used to play DVDs on disk through OSD Menu",
ifo_stream_open,
{ "file", "", NULL },
NULL,
diff --git a/stream/stream_file.c b/stream/stream_file.c
index 924eb31dad..b9e4f2f2e1 100644
--- a/stream/stream_file.c
+++ b/stream/stream_file.c
@@ -1,6 +1,8 @@
/*
* This file is part of MPlayer.
*
+ * Original authors: Albeu, probably Arpi
+ *
* MPlayer is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
@@ -32,6 +34,11 @@
#include "core/m_option.h"
#include "core/m_struct.h"
+struct priv {
+ int fd;
+ bool close;
+};
+
static struct stream_priv_s {
char* filename;
char *filename2;
@@ -54,15 +61,17 @@ static const struct m_struct_st stream_opts = {
};
static int fill_buffer(stream_t *s, char* buffer, int max_len){
- int r = read(s->fd,buffer,max_len);
+ struct priv *p = s->priv;
+ int r = read(p->fd,buffer,max_len);
return (r <= 0) ? -1 : r;
}
static int write_buffer(stream_t *s, char* buffer, int len) {
+ struct priv *p = s->priv;
int r;
int wr = 0;
while (wr < len) {
- r = write(s->fd,buffer,len);
+ r = write(p->fd,buffer,len);
if (r <= 0)
return -1;
wr += r;
@@ -72,8 +81,9 @@ static int write_buffer(stream_t *s, char* buffer, int len) {
}
static int seek(stream_t *s,int64_t newpos) {
+ struct priv *p = s->priv;
s->pos = newpos;
- if(lseek(s->fd,s->pos,SEEK_SET)<0) {
+ if(lseek(p->fd,s->pos,SEEK_SET)<0) {
return 0;
}
return 1;
@@ -95,12 +105,13 @@ static int seek_forward(stream_t *s,int64_t newpos) {
}
static int control(stream_t *s, int cmd, void *arg) {
+ struct priv *p = s->priv;
switch(cmd) {
case STREAM_CTRL_GET_SIZE: {
off_t size;
- size = lseek(s->fd, 0, SEEK_END);
- lseek(s->fd, s->pos, SEEK_SET);
+ size = lseek(p->fd, 0, SEEK_END);
+ lseek(p->fd, s->pos, SEEK_SET);
if(size != (off_t)-1) {
*(uint64_t*)arg = size;
return 1;
@@ -110,12 +121,23 @@ static int control(stream_t *s, int cmd, void *arg) {
return STREAM_UNSUPPORTED;
}
-static int open_f(stream_t *stream,int mode, void* opts, int* file_format) {
+static void s_close(stream_t *s)
+{
+ struct priv *p = s->priv;
+ if (p->close && p->fd >= 0)
+ close(p->fd);
+}
+
+static int open_f(stream_t *stream,int mode, void* opts)
+{
int f;
mode_t m = 0;
int64_t len;
unsigned char *filename;
struct stream_priv_s* p = (struct stream_priv_s*)opts;
+ struct priv *priv = talloc_ptrtype(stream, priv);
+ *priv = (struct priv) { .fd = -1 };
+ stream->priv = priv;
if(mode == STREAM_READ)
m = O_RDONLY;
@@ -162,6 +184,8 @@ static int open_f(stream_t *stream,int mode, void* opts, int* file_format) {
setmode(fileno(stdout),O_BINARY);
#endif
}
+ priv->fd = f;
+ priv->close = false;
} else {
mode_t openmode = S_IRUSR|S_IWUSR;
#ifndef __MINGW32__
@@ -183,6 +207,8 @@ static int open_f(stream_t *stream,int mode, void* opts, int* file_format) {
return STREAM_ERROR;
}
#endif
+ priv->fd = f;
+ priv->close = true;
}
len=lseek(f,0,SEEK_END); lseek(f,0,SEEK_SET);
@@ -202,21 +228,18 @@ static int open_f(stream_t *stream,int mode, void* opts, int* file_format) {
mp_msg(MSGT_OPEN,MSGL_V,"[file] File size is %"PRId64" bytes\n", (int64_t)len);
- stream->fd = f;
stream->fill_buffer = fill_buffer;
stream->write_buffer = write_buffer;
stream->control = control;
stream->read_chunk = 64*1024;
+ stream->close = s_close;
m_struct_free(&stream_opts,opts);
return STREAM_OK;
}
const stream_info_t stream_info_file = {
- "File",
"file",
- "Albeu",
- "based on the code from ??? (probably Arpi)",
open_f,
{ "file", "", NULL },
&stream_opts,
diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c
index 48d5e9d173..82241e83f3 100644
--- a/stream/stream_lavf.c
+++ b/stream/stream_lavf.c
@@ -26,14 +26,13 @@
#include "stream.h"
#include "core/m_option.h"
#include "core/m_struct.h"
-#include "demux/demux.h"
#include "cookies.h"
#include "core/bstr.h"
#include "core/mp_talloc.h"
-static int open_f(stream_t *stream, int mode, void *opts, int *file_format);
+static int open_f(stream_t *stream, int mode, void *opts);
static char **read_icy(stream_t *stream);
static int fill_buffer(stream_t *s, char *buffer, int max_len)
@@ -115,7 +114,7 @@ static int control(stream_t *s, int cmd, void *arg)
// avio doesn't seem to support this - emulate it by reopening
close_f(s);
s->priv = NULL;
- return open_f(s, STREAM_READ, NULL, &(int) {0});
+ return open_f(s, STREAM_READ, NULL);
}
}
return STREAM_UNSUPPORTED;
@@ -132,7 +131,7 @@ static bool mp_avio_has_opts(AVIOContext *avio)
static const char * const prefix[] = { "lavf://", "ffmpeg://" };
-static int open_f(stream_t *stream, int mode, void *opts, int *file_format)
+static int open_f(stream_t *stream, int mode, void *opts)
{
int flags = 0;
AVIOContext *avio = NULL;
@@ -163,7 +162,7 @@ static int open_f(stream_t *stream, int mode, void *opts, int *file_format)
* stream layer. demux_lavf will do all the real work.
*/
stream->seek = NULL;
- *file_format = DEMUXER_TYPE_LAVF;
+ stream->demuxer = "lavf";
stream->lavf_type = "rtsp";
return STREAM_OK;
}
@@ -216,14 +215,13 @@ static int open_f(stream_t *stream, int mode, void *opts, int *file_format)
char *rtmp[] = {"rtmp:", "rtmpt:", "rtmpe:", "rtmpte:", "rtmps:"};
for (int i = 0; i < FF_ARRAY_ELEMS(rtmp); i++)
if (!strncmp(filename, rtmp[i], strlen(rtmp[i]))) {
- *file_format = DEMUXER_TYPE_LAVF;
+ stream->demuxer = "lavf";
stream->lavf_type = "flv";
}
stream->priv = avio;
int64_t size = avio_size(avio);
if (size >= 0)
stream->end_pos = size;
- stream->type = STREAMTYPE_FILE;
stream->seek = seek;
if (!avio->seekable)
stream->seek = NULL;
@@ -307,10 +305,7 @@ done:
}
const stream_info_t stream_info_ffmpeg = {
- "FFmpeg",
"ffmpeg",
- "",
- "",
open_f,
{ "lavf", "ffmpeg", "rtmp", "rtsp", "http", "https", "mms", "mmst", "mmsh",
"mmshttp", "udp", "ftp", "rtp", "httpproxy", NULL },
diff --git a/stream/stream_memory.c b/stream/stream_memory.c
index 0994e0816f..79bfea459d 100644
--- a/stream/stream_memory.c
+++ b/stream/stream_memory.c
@@ -54,10 +54,8 @@ static int control(stream_t *s, int cmd, void *arg)
return STREAM_UNSUPPORTED;
}
-static int open_f(stream_t *stream, int mode, void* opts, int* file_format)
+static