summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-02-02 18:24:27 +0100
committerwm4 <wm4@nowhere>2017-02-02 18:26:58 +0100
commitfb9a32977d6abf4c83a92d993af58e393819c062 (patch)
treedaa8fac391c393560588ce8653943a8259f59815 /stream
parente13a62fc346867450cd41d02cffbdaf477a3fec4 (diff)
downloadmpv-fb9a32977d6abf4c83a92d993af58e393819c062.tar.bz2
mpv-fb9a32977d6abf4c83a92d993af58e393819c062.tar.xz
stream: get rid of streamtype enum
Because it's kind of dumb. (But not sure if it was worth the trouble.) For stream_file.c, we add new explicit fields. The rest are rather special uses and can be killed by comparing the stream impl. name. The changes to DVD/BD/CD/TV are entirely untested.
Diffstat (limited to 'stream')
-rw-r--r--stream/stream.c5
-rw-r--r--stream/stream.h18
-rw-r--r--stream/stream_avdevice.c2
-rw-r--r--stream/stream_bluray.c1
-rw-r--r--stream/stream_cdda.c1
-rw-r--r--stream/stream_dvb.c1
-rw-r--r--stream/stream_dvd.c1
-rw-r--r--stream/stream_dvdnav.c3
-rw-r--r--stream/stream_edl.c2
-rw-r--r--stream/stream_file.c4
-rw-r--r--stream/stream_mf.c1
-rw-r--r--stream/stream_tv.c1
12 files changed, 9 insertions, 31 deletions
diff --git a/stream/stream.c b/stream/stream.c
index 79a51a777f..94b9c44bc4 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -258,8 +258,6 @@ static int open_internal(const stream_info_t *sinfo, const char *url, int flags,
assert(s->seekable == !!s->seek);
- s->uncached_type = s->type;
-
if (s->mime_type)
MP_VERBOSE(s, "Mime-type: '%s'\n", s->mime_type);
@@ -635,7 +633,6 @@ stream_t *open_memory_stream(void *data, int len)
static stream_t *open_cache(stream_t *orig, const char *name)
{
stream_t *cache = new_stream();
- cache->uncached_type = orig->uncached_type;
cache->underlying = orig;
cache->caching = true;
cache->seekable = true;
@@ -648,6 +645,8 @@ static stream_t *open_cache(stream_t *orig, const char *name)
cache->lavf_type = talloc_strdup(cache, orig->lavf_type);
cache->streaming = orig->streaming,
cache->is_network = orig->is_network;
+ cache->is_local_file = orig->is_local_file;
+ cache->is_directory = orig->is_directory;
cache->cancel = orig->cancel;
cache->global = orig->global;
diff --git a/stream/stream.h b/stream/stream.h
index b6fcc3a6fa..cc47184ea6 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -28,20 +28,6 @@
#include "misc/bstr.h"
-enum streamtype {
- STREAMTYPE_GENERIC = 0,
- STREAMTYPE_FILE,
- STREAMTYPE_DIR,
- STREAMTYPE_DVB,
- STREAMTYPE_DVD,
- STREAMTYPE_BLURAY,
- STREAMTYPE_TV,
- STREAMTYPE_MF,
- STREAMTYPE_EDL,
- STREAMTYPE_AVDEVICE,
- STREAMTYPE_CDDA,
-};
-
#define STREAM_BUFFER_SIZE 2048
#define STREAM_MAX_SECTOR_SIZE (8 * 1024)
@@ -178,8 +164,6 @@ typedef struct stream {
// Close
void (*close)(struct stream *s);
- enum streamtype type; // see STREAMTYPE_*
- enum streamtype uncached_type; // if stream is cache, type of wrapped str.
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
unsigned int buf_pos, buf_len;
@@ -198,6 +182,8 @@ typedef struct stream {
bool is_network : 1; // original stream_info_t.is_network flag
bool allow_caching : 1; // stream cache makes sense
bool caching : 1; // is a cache, or accesses a cache
+ bool is_local_file : 1; // from the filesystem
+ bool is_directory : 1; // directory on the filesystem
bool access_references : 1; // open other streams
struct mp_log *log;
struct mpv_global *global;
diff --git a/stream/stream_avdevice.c b/stream/stream_avdevice.c
index 9734b7b6f5..2b132cd1a9 100644
--- a/stream/stream_avdevice.c
+++ b/stream/stream_avdevice.c
@@ -21,8 +21,8 @@
static int open_f(stream_t *stream)
{
- stream->type = STREAMTYPE_AVDEVICE;
stream->demuxer = "lavf";
+ stream->allow_caching = false;
return STREAM_OK;
}
diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c
index e648337b93..07dcc7f69e 100644
--- a/stream/stream_bluray.c
+++ b/stream/stream_bluray.c
@@ -450,7 +450,6 @@ static int bluray_stream_open_internal(stream_t *s)
s->fill_buffer = bluray_stream_fill_buffer;
s->close = bluray_stream_close;
s->control = bluray_stream_control;
- s->type = STREAMTYPE_BLURAY;
s->sector_size = BLURAY_SECTOR_SIZE;
s->priv = b;
s->demuxer = "+disc";
diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c
index df7862cd8f..2a8eb7553f 100644
--- a/stream/stream_cdda.c
+++ b/stream/stream_cdda.c
@@ -383,7 +383,6 @@ static int open_cdda(stream_t *st)
st->streaming = true;
- st->type = STREAMTYPE_CDDA;
st->demuxer = "+disc";
print_cdtext(st, 0);
diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c
index 6e55d8c156..4cdbacc681 100644
--- a/stream/stream_dvb.c
+++ b/stream/stream_dvb.c
@@ -990,7 +990,6 @@ static int dvb_open(stream_t *stream)
return STREAM_ERROR;
}
- stream->type = STREAMTYPE_DVB;
stream->fill_buffer = dvb_streaming_read;
stream->close = dvbin_close;
stream->control = dvbin_stream_control;
diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c
index 338c23633c..fe5796d30d 100644
--- a/stream/stream_dvd.c
+++ b/stream/stream_dvd.c
@@ -904,7 +904,6 @@ static int open_s_internal(stream_t *stream)
// ... (unimplemented)
// return NULL;
- stream->type = STREAMTYPE_DVD;
stream->demuxer = "+disc";
stream->lavf_type = "mpeg";
stream->sector_size = 2048;
diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c
index 1178f50857..21827b6898 100644
--- a/stream/stream_dvdnav.c
+++ b/stream/stream_dvdnav.c
@@ -507,7 +507,6 @@ static int open_s_internal(stream_t *stream)
stream->fill_buffer = fill_buffer;
stream->control = control;
stream->close = stream_dvdnav_close;
- stream->type = STREAMTYPE_DVD;
stream->demuxer = "+disc";
stream->lavf_type = "mpeg";
stream->allow_caching = false;
@@ -596,7 +595,7 @@ unsupported:
}
const stream_info_t stream_info_ifo_dvdnav = {
- .name = "ifo/dvdnav",
+ .name = "ifo_dvdnav",
.open = ifo_dvdnav_stream_open,
.protocols = (const char*const[]){ "file", "", NULL },
};
diff --git a/stream/stream_edl.c b/stream/stream_edl.c
index 4873047cc2..11c149b3ab 100644
--- a/stream/stream_edl.c
+++ b/stream/stream_edl.c
@@ -5,8 +5,8 @@
static int s_open (struct stream *stream)
{
- stream->type = STREAMTYPE_EDL;
stream->demuxer = "edl";
+ stream->allow_caching = false;
return STREAM_OK;
}
diff --git a/stream/stream_file.c b/stream/stream_file.c
index 5d5925ac7c..bfe40429cb 100644
--- a/stream/stream_file.c
+++ b/stream/stream_file.c
@@ -234,7 +234,7 @@ static int open_f(stream_t *stream)
.fd = -1
};
stream->priv = p;
- stream->type = STREAMTYPE_FILE;
+ stream->is_local_file = true;
bool write = stream->mode == STREAM_WRITE;
int m = O_CLOEXEC | (write ? O_RDWR | O_CREAT | O_TRUNC : O_RDONLY);
@@ -281,7 +281,7 @@ static int open_f(stream_t *stream)
if (fstat(p->fd, &st) == 0) {
if (S_ISDIR(st.st_mode)) {
p->use_poll = false;
- stream->type = STREAMTYPE_DIR;
+ stream->is_directory = true;
stream->allow_caching = false;
MP_INFO(stream, "This is a directory - adding to playlist.\n");
}
diff --git a/stream/stream_mf.c b/stream/stream_mf.c
index a027e8b79c..ca6ab6ae88 100644
--- a/stream/stream_mf.c
+++ b/stream/stream_mf.c
@@ -30,7 +30,6 @@
static int
mf_stream_open (stream_t *stream)
{
- stream->type = STREAMTYPE_MF;
stream->demuxer = "mf";
stream->allow_caching = false;
diff --git a/stream/stream_tv.c b/stream/stream_tv.c
index 435e3e7b54..d9acbe4cf4 100644
--- a/stream/stream_tv.c
+++ b/stream/stream_tv.c
@@ -39,7 +39,6 @@ static int
tv_stream_open (stream_t *stream)
{
- stream->type = STREAMTYPE_TV;
stream->close=tv_stream_close;
stream->demuxer = "tv";
stream->allow_caching = false;