aboutsummaryrefslogtreecommitdiffhomepage
path: root/stream
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2013-07-14 17:59:26 +0200
committerGravatar wm4 <wm4@nowhere>2013-07-14 17:59:26 +0200
commite18ffd6b998858ca0797cb0ce4aabd4a509655dd (patch)
tree199bddd30923db1175a1331191eb86ba684e9e41 /stream
parent3e7d483ac89289f613138002be2043ec5f479bb0 (diff)
parent5ead20bdb3328d199dad693039d18e7a05eb2465 (diff)
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 int open_f(stream_t *stream, int mode, void* opts)
{
- stream->type = STREAMTYPE_MEMORY;
-
stream->fill_buffer = fill_buffer;
stream->seek = seek;
stream->control = control;
@@ -75,10 +73,7 @@ static int open_f(stream_t *stream, int mode, void* opts, int* file_format)
}
const stream_info_t stream_info_memory = {
- "Memory",
"memory",
- "",
- "",
open_f,
{ "memory", NULL },
};
diff --git a/stream/stream_mf.c b/stream/stream_mf.c
index 9b8b47188a..9f87dad6b1 100644
--- a/stream/stream_mf.c
+++ b/stream/stream_mf.c
@@ -2,6 +2,7 @@
* stream layer for multiple files input, based on previous work from Albeu
*
* Copyright (C) 2006 Benjamin Zores
+ * Original author: Albeu
*
* This file is part of MPlayer.
*
@@ -26,22 +27,18 @@
#include <string.h>
#include "stream.h"
-#include "demux/demux.h"
static int
-mf_stream_open (stream_t *stream, int mode, void *opts, int *file_format)
+mf_stream_open (stream_t *stream, int mode, void *opts)
{
stream->type = STREAMTYPE_MF;
- *file_format = DEMUXER_TYPE_MF;
+ stream->demuxer = "mf";
return STREAM_OK;
}
const stream_info_t stream_info_mf = {
- "Multiple files input",
"mf",
- "Benjamin Zores, Albeu",
- "",
mf_stream_open,
{ "mf", NULL },
NULL,
diff --git a/stream/stream_null.c b/stream/stream_null.c
index 5465702be8..8bae12ff9d 100644
--- a/stream/stream_null.c
+++ b/stream/stream_null.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
@@ -23,18 +25,14 @@
#include "stream.h"
-static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
- stream->type = STREAMTYPE_DUMMY;
-
+static int open_s(stream_t *stream,int mode, void* opts)
+{
return 1;
}
const stream_info_t stream_info_null = {
- "Null stream",
"null",
- "Albeu",
- "",
open_s,
{ "null", NULL },
NULL,
diff --git a/stream/stream_pvr.c b/stream/stream_pvr.c
index aeea46cf62..6038ee9221 100644
--- a/stream/stream_pvr.c
+++ b/stream/stream_pvr.c
@@ -40,14 +40,15 @@
#include <linux/types.h>
#include <linux/videodev2.h>
+#include <libavutil/common.h>
+#include <libavutil/avstring.h>
+
#include "core/mp_msg.h"
#include "stream.h"
#include "pvr.h"
#include "frequencies.h"
-#include "libavutil/common.h"
-#include "libavutil/avstring.h"
#define PVR_DEFAULT_DEVICE "/dev/video0"
#define PVR_MAX_CONTROLS 10
@@ -1555,7 +1556,7 @@ pvr_stream_read (stream_t *stream, char *buffer, int size)
}
static int
-pvr_stream_open (stream_t *stream, int mode, void *opts, int *file_format)
+pvr_stream_open (stream_t *stream, int mode, void *opts)
{
struct v4l2_capability vcap;
struct v4l2_ext_controls ctrls;
@@ -1756,10 +1757,7 @@ pvr_force_freq_step (stream_t *stream, int step)
}
const stream_info_t stream_info_pvr = {
- "V4L2 MPEG Input (a.k.a PVR)",
"pvr",
- "Benjamin Zores",
- "",
pvr_stream_open,
{ "pvr", NULL },
NULL,
diff --git a/stream/stream_radio.c b/stream/stream_radio.c
index fae9be43d1..dd173175f0 100644
--- a/stream/stream_radio.c
+++ b/stream/stream_radio.c
@@ -824,7 +824,8 @@ static const radio_driver_t* radio_drivers[]={
* Stream initialization
* \return STREAM_OK if success, STREAM_ERROR otherwise
*/
-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)
+{
radio_priv_t* priv;
float frequency=0;
int i;
@@ -875,7 +876,7 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
stream->type = STREAMTYPE_RADIO;
/* using rawaudio demuxer */
- *file_format = DEMUXER_TYPE_RAWAUDIO;
+ stream->demuxer = "lavf";
stream->flags = STREAM_READ;
priv->radio_fd=-1;
@@ -967,10 +968,7 @@ static void close_s(struct stream *stream){
}
const stream_info_t stream_info_radio = {
- "Radio stream",
- "Radio",
- "Vladimir Voroshilov",
- "In development",
+ "radio",
open_s,
{ "radio", NULL },
&stream_opts,
diff --git a/stream/stream_smb.c b/stream/stream_smb.c
index 33b13f7a11..91c5c615d7 100644
--- a/stream/stream_smb.c
+++ b/stream/stream_smb.c
@@ -1,6 +1,8 @@
/*
* This file is part of MPlayer.
*
+ * Original author: M. Tourne
+ *
* 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
@@ -26,6 +28,10 @@
#include "core/m_option.h"
#include "core/m_struct.h"
+struct priv {
+ int fd;
+};
+
static struct stream_priv_s {
} stream_priv_dflts = {
};
@@ -72,10 +78,11 @@ static void smb_auth_fn(const char *server, const char *share,
}
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 = smbc_lseek(s->fd,0,SEEK_END);
- smbc_lseek(s->fd,s->pos,SEEK_SET);
+ off_t size = smbc_lseek(p->fd,0,SEEK_END);
+ smbc_lseek(p->fd,s->pos,SEEK_SET);
if(size != (off_t)-1) {
*(uint64_t *)arg = size;
return 1;
@@ -86,23 +93,26 @@ static int control(stream_t *s, int cmd, void *arg) {
}
static int seek(stream_t *s,int64_t newpos) {
+ struct priv *p = s->priv;
s->pos = newpos;
- if(smbc_lseek(s->fd,s->pos,SEEK_SET)<0) {
+ if(smbc_lseek(p->fd,s->pos,SEEK_SET)<0) {
return 0;
}
return 1;
}
static int fill_buffer(stream_t *s, char* buffer, int max_len){
- int r = smbc_read(s->fd,buffer,max_len);
+ struct priv *p = s->priv;
+ int r = smbc_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 = smbc_write(s->fd,buffer,len);
+ r = smbc_write(p->fd,buffer,len);
if (r <= 0)
return -1;
wr += r;
@@ -112,15 +122,20 @@ static int write_buffer(stream_t *s, char* buffer, int len) {
}
static void close_f(stream_t *s){
- smbc_close(s->fd);
+ struct priv *p = s->priv;
+ smbc_close(p->fd);
}
-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)
+{
char *filename;
mode_t m = 0;
int64_t len;
int fd, err;
+ struct priv *priv = talloc_zero(stream, struct priv);
+ stream->priv = priv;
+
filename = stream->url;
if(mode == STREAM_READ)
@@ -164,8 +179,7 @@ static int open_f (stream_t *stream, int mode, void *opts, int* file_format) {
stream->seek = seek;
if(mode == STREAM_READ) stream->end_pos = len;
}
- stream->type = STREAMTYPE_SMB;
- stream->fd = fd;
+ priv->fd = fd;
stream->fill_buffer = fill_buffer;
stream->write_buffer = write_buffer;
stream->close = close_f;
@@ -176,10 +190,7 @@ static int open_f (stream_t *stream, int mode, void *opts, int* file_format) {
}
const stream_info_t stream_info_smb = {
- "Server Message Block",
"smb",
- "M. Tourne",
- "based on the code from 'a bulgarian' (one says)",
open_f,
{"smb", NULL},
&stream_opts,
diff --git a/stream/stream_tv.c b/stream/stream_tv.c
index 595657dc43..d9a4636b00 100644
--- a/stream/stream_tv.c
+++ b/stream/stream_tv.c
@@ -2,6 +2,7 @@
* stream layer for TV Input, based on previous work from Albeu
*
* Copyright (C) 2006 Benjamin Zores
+ * Original author: Albeu
*
* This file is part of MPlayer.
*
@@ -26,7 +27,6 @@
#include <string.h>
#include "stream.h"
-#include "demux/demux.h"
#include "core/m_option.h"
#include "core/m_struct.h"
#include "tv.h"
@@ -97,22 +97,19 @@ tv_stream_close (stream_t *stream)
stream->priv=NULL;
}
static int
-tv_stream_open (stream_t *stream, int mode, void *opts, int *file_format)
+tv_stream_open (stream_t *stream, int mode, void *opts)
{
stream->type = STREAMTYPE_TV;
stream->priv = opts;
stream->close=tv_stream_close;
- *file_format = DEMUXER_TYPE_TV;
+ stream->demuxer = "tv";
return STREAM_OK;
}
const stream_info_t stream_info_tv = {
- "TV Input",
"tv",
- "Benjamin Zores, Albeu",
- "",
tv_stream_open,
{ "tv", NULL },
&stream_opts,
diff --git a/stream/stream_vcd.c b/stream/stream_vcd.c
index 422dea02cd..0fd2998c58 100644
--- a/stream/stream_vcd.c
+++ b/stream/stream_vcd.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
@@ -51,8 +53,6 @@
#include "vcd_read.h"
#endif
-#include "demux/demux.h"
-
extern char *cdrom_device;
static struct stream_priv_s {
@@ -94,46 +94,14 @@ static int seek(stream_t *s,int64_t newpos) {
return 1;
}
-static int control(stream_t *stream, int cmd, void *arg) {
- struct stream_priv_s *p = stream->priv;
- switch(cmd) {
- case STREAM_CTRL_GET_NUM_TITLES:
- case STREAM_CTRL_GET_NUM_CHAPTERS:
- {
- mp_vcd_priv_t *vcd = vcd_read_toc(stream->fd);
- if (!vcd)
- break;
- *(unsigned int *)arg = vcd_end_track(vcd);
- return STREAM_OK;
- }
- case STREAM_CTRL_SEEK_TO_CHAPTER:
- {
- int r;
- unsigned int track = *(unsigned int *)arg + 1;
- mp_vcd_priv_t *vcd = vcd_read_toc(stream->fd);
- if (!vcd)
- break;
- r = vcd_seek_to_track(vcd, track);
- if (r >= 0) {
- p->track = track;
- return STREAM_OK;
- }
- break;
- }
- case STREAM_CTRL_GET_CURRENT_CHAPTER:
- {
- *(unsigned int *)arg = p->track - 1;
- return STREAM_OK;
- }
- }
- return STREAM_UNSUPPORTED;
-}
-
static void close_s(stream_t *stream) {
- free(stream->priv);
+ mp_vcd_priv_t *p = stream->priv;
+ close(p->fd);
+ free(p);
}
-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 = opts;
int ret,ret2,f,sect,tmp;
mp_vcd_priv_t* vcd;
@@ -221,8 +189,6 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
}
#endif
- stream->fd = f;
- stream->type = STREAMTYPE_VCD;
stream->sector_size = VCD_SECTOR_DATA;
stream->start_pos=ret;
stream->end_pos=ret2;
@@ -230,19 +196,15 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
stream->fill_buffer = fill_buffer;
stream->seek = seek;
- stream->control = control;
stream->close = close_s;
- *file_format = DEMUXER_TYPE_MPEG_PS;
+ stream->demuxer = "lavf"; // mpegps ( or "vcd"?)
m_struct_free(&stream_opts,opts);
return STREAM_OK;
}
const stream_info_t stream_info_vcd = {
- "Video CD",
"vcd",
- "Albeu",
- "based on the code from ???",
open_s,
{ "vcd", NULL },
&stream_opts,
diff --git a/stream/tv.c b/stream/tv.c
index 1fcb13037d..9b1f8024e4 100644
--- a/stream/tv.c
+++ b/stream/tv.c
@@ -210,15 +210,28 @@ static void tv_scan(tvi_handle_t *tvh)
*/
/* fill demux->video and demux->audio */
-static int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds)
+static int demux_tv_fill_buffer(demuxer_t *demux)
{
tvi_handle_t *tvh=(tvi_handle_t*)(demux->priv);
demux_packet_t* dp;
unsigned int len=0;
+ struct sh_stream *want_audio = NULL, *want_video = NULL;
+
+ for (int n = 0; n < demux->num_streams; n++) {
+ struct sh_stream *sh = demux->streams[n];
+ if (!demuxer_stream_has_packets_queued(demux, sh) &&
+ demuxer_stream_is_selected(demux, sh))
+ {
+ if (sh->type == STREAM_AUDIO)
+ want_audio = sh;
+ if (sh->type == STREAM_VIDEO)
+ want_video = sh;
+ }
+ }
/* ================== ADD AUDIO PACKET =================== */
- if (ds==demux->audio && tvh->tv_param->noaudio == 0 &&
+ if (want_audio && tvh->tv_param->noaudio == 0 &&
tvh->functions->control(tvh->priv,
TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE)
{
@@ -227,19 +240,19 @@ static int demux_tv_fill_buffer(demuxer_t *demux, demux_stream_t *ds)
dp=new_demux_packet(len);
dp->keyframe = true;
dp->pts=tvh->functions->grab_audio_frame(tvh->priv, dp->buffer,len);
- ds_add_packet(demux->audio,dp);
+ demuxer_add_packet(demux, want_audio, dp);
}
/* ================== ADD VIDEO PACKET =================== */
- if (ds==demux->video && tvh->functions->control(tvh->priv,
+ if (want_video && tvh->functions->control(tvh->priv,
TVI_CONTROL_IS_VIDEO, 0) == TVI_CONTROL_TRUE)
{
len = tvh->functions->get_video_framesize(tvh->priv);
dp=new_demux_packet(len);
dp->keyframe = true;
dp->pts=tvh->functions->grab_video_frame(tvh->priv, dp->buffer, len);
- ds_add_packet(demux->video,dp);
+ demuxer_add_packet(demux, want_video, dp);
}
if (tvh->tv_param->scan) tv_scan(tvh);
@@ -688,27 +701,31 @@ static int tv_uninit(tvi_handle_t *tvh)
return res;
}
-static demuxer_t* demux_open_tv(demuxer_t *demuxer)
+static int demux_open_tv(demuxer_t *demuxer, enum demux_check check)
{
tvi_handle_t *tvh;
sh_video_t *sh_video;
sh_audio_t *sh_audio = NULL;
const tvi_functions_t *funcs;
+ if (check > DEMUX_CHECK_REQUEST || demuxer->stream->type != STREAMTYPE_TV)
+ return -1;
+
demuxer->priv=NULL;
- if(!(tvh=tv_begin(demuxer->stream->priv))) return NULL;
- if (!tvh->functions->init(tvh->priv)) return NULL;
+ if(!(tvh=tv_begin(demuxer->stream->priv))) return -1;
+ if (!tvh->functions->init(tvh->priv)) return -1;
tvh->demuxer = demuxer;
if (!open_tv(tvh)){
tv_uninit(tvh);
- return NULL;
+ return -1;
}
funcs = tvh->functions;
demuxer->priv=tvh;
- sh_video = new_sh_video(demuxer, 0);
+ struct sh_stream *sh_v = new_sh_stream(demuxer, STREAM_VIDEO);
+ sh_video = sh_v->video;
/* get IMAGE FORMAT */
int fourcc;
@@ -729,8 +746,6 @@ static demuxer_t* demux_open_tv(demuxer_t *demuxer)
if (tvh->tv_param->fps != -1.0f)
sh_video->fps = tvh->tv_param->fps;
- sh_video->frametime = 1.0f/sh_video->fps;
-
/* If playback only mode, go to immediate mode, fail silently */
if(tvh->tv_param->immediate == 1)
{
@@ -738,20 +753,12 @@ static demuxer_t* demux_open_tv(demuxer_t *demuxer)
tvh->tv_param->noaudio = 1;
}
- /* disable TV audio if -nosound is present */
- if (!demuxer->audio || demuxer->audio->id == -2) {
- tvh->tv_param->noaudio = 1;
- }
-
/* set width */
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &sh_video->disp_w);
/* set height */
funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &sh_video->disp_h);
- demuxer->video->sh = sh_video;
- sh_video->ds = demuxer->video;
- demuxer->video->id = 0;
demuxer->seekable = 0;
/* here comes audio init */
@@ -786,7 +793,8 @@ static demuxer_t* demux_open_tv(demuxer_t *demuxer)
goto no_audio;
}
- sh_audio = new_sh_audio(demuxer, 0);
+ struct sh_stream *sh_a = new_sh_stream(demuxer, STREAM_AUDIO);
+ sh_audio = sh_a->audio;
funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLERATE,
&sh_audio->samplerate);
@@ -800,7 +808,7 @@ static demuxer_t* demux_open_tv(demuxer_t *demuxer)
sh_audio->gsh->codec = "mp-pcm";
sh_audio->format = audio_format;
- sh_audio->i_bps = sh_audio->o_bps =
+ sh_audio->i_bps =
sh_audio->samplerate * sh_audio->samplesize *
sh_audio->channels.num;
@@ -816,17 +824,13 @@ static demuxer_t* demux_open_tv(demuxer_t *demuxer)
mp_tmsg(MSGT_DECVIDEO, MSGL_V, " TV audio: %d channels, %d bits, %d Hz\n",
sh_audio->wf->nChannels, sh_audio->wf->wBitsPerSample,
sh_audio->wf->nSamplesPerSec);
-
- demuxer->audio->sh = sh_audio;
- sh_audio->ds = demuxer->audio;
- demuxer->audio->id = 0;
}
no_audio:
if(!(funcs->start(tvh->priv))){
// start failed :(
tv_uninit(tvh);
- return NULL;
+ return -1;
}
/* set color eq */
@@ -839,7 +843,7 @@ no_audio:
if(funcs->control(tvh->priv,TVI_CONTROL_VID_SET_GAIN,&tvh->tv_param->gain)!=TVI_CONTROL_TRUE)
mp_msg(MSGT_TV,MSGL_WARN,"Unable to set gain control!\n");
- return demuxer;
+ return 0;
}
static void demux_close_tv(demuxer_t *demuxer)
@@ -1093,17 +1097,10 @@ int tv_step_chanlist(tvi_handle_t *tvh)
}
demuxer_desc_t demuxer_desc_tv = {
- "Tv card demuxer",
- "tv",
- "TV",
- "Alex Beregszaszi, Charles R. Henrich",
- "?",
- DEMUXER_TYPE_TV,
- 0, // no autodetect
- NULL,
- demux_tv_fill_buffer,
- demux_open_tv,
- demux_close_tv,
- NULL,
- NULL
+ .name = "tv",
+ .desc = "TV card demuxer",
+ .type = DEMUXER_TYPE_TV,
+ .fill_buffer = demux_tv_fill_buffer,
+ .open = demux_open_tv,
+ .close = demux_close_tv,
};
diff --git a/stream/tv.h b/stream/tv.h
index 660a78be7b..ded9ace6c8 100644
--- a/stream/tv.h
+++ b/stream/tv.h
@@ -25,8 +25,6 @@
#ifndef MPLAYER_TV_H
#define MPLAYER_TV_H
-#include "demux/demux.h"
-
typedef struct tv_param_s {
char *freq;
char *channel;
@@ -105,7 +103,7 @@ typedef struct tvi_handle_s {
const tvi_functions_t *functions;
void *priv;
int seq;
- demuxer_t *demuxer;
+ struct demuxer *demuxer;
/* specific */
int norm;
diff --git a/stream/vcd_read.h b/stream/vcd_read.h
index 2d4a88604a..92a9c53b78 100644
--- a/stream/vcd_read.h
+++ b/stream/vcd_read.h
@@ -147,10 +147,12 @@ static mp_vcd_priv_t* vcd_read_toc(int fd){
return vcd;
}
+/*
static int vcd_end_track(mp_vcd_priv_t* vcd)
{
return vcd->tochdr.cdth_trk1;
}
+*/
static int vcd_read(mp_vcd_priv_t* vcd,char *mem){
#ifndef sun