summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
Diffstat (limited to 'stream')
-rw-r--r--stream/asf_streaming.c1
-rw-r--r--stream/cache2.c10
-rw-r--r--stream/http.c1
-rw-r--r--stream/network.c16
-rw-r--r--stream/network.h1
-rw-r--r--stream/stream.c14
-rw-r--r--stream/stream.h7
-rw-r--r--stream/stream_udp.c1
8 files changed, 24 insertions, 27 deletions
diff --git a/stream/asf_streaming.c b/stream/asf_streaming.c
index e3bfbe9019..31e0d71b89 100644
--- a/stream/asf_streaming.c
+++ b/stream/asf_streaming.c
@@ -839,7 +839,6 @@ static int open_s(stream_t *stream,int mode, void* opts, int* file_format) {
if (*file_format != DEMUXER_TYPE_PLAYLIST)
*file_format = DEMUXER_TYPE_ASF;
stream->type = STREAMTYPE_STREAM;
- fixup_network_stream_cache(stream);
return STREAM_OK;
}
diff --git a/stream/cache2.c b/stream/cache2.c
index d547f9e5ea..27147d00fb 100644
--- a/stream/cache2.c
+++ b/stream/cache2.c
@@ -452,7 +452,14 @@ int stream_enable_cache_percent(stream_t *stream, int64_t stream_cache_size,
/**
* \return 1 on success, 0 if the function was interrupted and -1 on error
*/
-int stream_enable_cache(stream_t *stream,int64_t size,int64_t min,int64_t seek_limit){
+int stream_enable_cache(stream_t *stream,int64_t size,int64_t min,int64_t seek_limit)
+{
+ if (size < 0)
+ size = stream->cache_size * 1024;
+ if (!size)
+ return 1;
+ mp_tmsg(MSGT_NETWORK,MSGL_INFO,"Cache size set to %"PRId64" KiB\n", size / 1024);
+
int ss = stream->sector_size ? stream->sector_size : STREAM_BUFFER_SIZE;
int res = -1;
cache_vars_t* s;
@@ -521,6 +528,7 @@ int stream_enable_cache(stream_t *stream,int64_t size,int64_t min,int64_t seek_l
}
}
mp_msg(MSGT_CACHE,MSGL_STATUS,"\n");
+ stream->cached = true;
return 1; // parent exits
err_out:
diff --git a/stream/http.c b/stream/http.c
index 1638d80790..c77e7e05c5 100644
--- a/stream/http.c
+++ b/stream/http.c
@@ -880,7 +880,6 @@ static int fixup_open(stream_t *stream,int seekable) {
return STREAM_UNSUPPORTED;
}
- fixup_network_stream_cache(stream);
return STREAM_OK;
}
diff --git a/stream/network.c b/stream/network.c
index fb432d47c0..56e5a1b5e1 100644
--- a/stream/network.c
+++ b/stream/network.c
@@ -461,19 +461,3 @@ int
nop_streaming_seek( int fd, int64_t pos, streaming_ctrl_t *stream_ctrl ) {
return -1;
}
-
-
-void fixup_network_stream_cache(stream_t *stream) {
- struct MPOpts *opts = stream->opts;
- if(!opts)
- return;
- if(stream->streaming_ctrl->buffering) {
- if(opts->stream_cache_size<0) {
- // cache option not set, will use our computed value.
- // buffer in KBytes, *5 because the prefill is 20% of the buffer.
- opts->stream_cache_size = (stream->streaming_ctrl->prebuffer_size/1024)*5;
- if( opts->stream_cache_size<64 ) opts->stream_cache_size = 64; // 16KBytes min buffer
- }
- mp_tmsg(MSGT_NETWORK,MSGL_INFO,"Cache size set to %d KBytes\n", opts->stream_cache_size);
- }
-}
diff --git a/stream/network.h b/stream/network.h
index ee6a940c99..6e21453b16 100644
--- a/stream/network.h
+++ b/stream/network.h
@@ -77,7 +77,6 @@ int http_authenticate(HTTP_header_t *http_hdr, URL_t *url, int *auth_retry);
URL_t* check4proxies(const URL_t *url);
URL_t *url_new_with_proxy(const char *urlstr);
-void fixup_network_stream_cache(stream_t *stream);
int http_seek(stream_t *stream, int64_t pos);
#endif /* MPLAYER_NETWORK_H */
diff --git a/stream/stream.c b/stream/stream.c
index 94a7c4cf6d..bd87448fac 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -182,6 +182,16 @@ static stream_t *open_stream_plugin(const stream_info_t *sinfo,
free(s);
return NULL;
}
+
+ s->cache_size = 0;
+ if (s->streaming_ctrl && s->streaming_ctrl->buffering) {
+ // Set default cache size to use if user does not specify it.
+ // buffer in KBytes, *5 assuming the prefill is 20% of the buffer.
+ s->cache_size = s->streaming_ctrl->prebuffer_size / 1024 * 5;
+ if (s->cache_size < 64)
+ s->cache_size = 64;
+ }
+
if(s->type <= -2)
mp_msg(MSGT_OPEN,MSGL_WARN, "Warning streams need a type !!!!\n");
if(s->flags & MP_STREAM_SEEK && !s->seek)
@@ -200,8 +210,8 @@ static stream_t *open_stream_plugin(const stream_info_t *sinfo,
}
-stream_t *open_stream_full(const char *filename, int mode,
- struct MPOpts *options, int *file_format)
+static stream_t *open_stream_full(const char *filename, int mode,
+ struct MPOpts *options, int *file_format)
{
int i,j,l,r;
const stream_info_t* sinfo;
diff --git a/stream/stream.h b/stream/stream.h
index 28557e8c6e..dd092ddaec 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -22,6 +22,7 @@
#include "config.h"
#include "core/mp_msg.h"
#include "url.h"
+#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
@@ -166,15 +167,15 @@ typedef struct stream {
int64_t pos,start_pos,end_pos;
int eof;
int mode; //STREAM_READ or STREAM_WRITE
+ int cache_size; // cache size to use if enabled
+ bool cached;
unsigned int cache_pid;
void* cache_data;
void* priv; // used for DVD, TV, RTSP etc
char* url; // strdup() of filename/url
char *lavf_type; // name of expected demuxer type for lavf
struct MPOpts *opts;
-#ifdef CONFIG_NETWORKING
streaming_ctrl_t *streaming_ctrl;
-#endif
unsigned char buffer[STREAM_BUFFER_SIZE>STREAM_MAX_SECTOR_SIZE?STREAM_BUFFER_SIZE:STREAM_MAX_SECTOR_SIZE];
} stream_t;
@@ -356,8 +357,6 @@ void free_stream(stream_t *s);
stream_t* new_memory_stream(unsigned char* data,int len);
stream_t *open_stream(const char *filename, struct MPOpts *options,
int *file_format);
-stream_t *open_stream_full(const char *filename,int mode,
- struct MPOpts *options, int *file_format);
stream_t *open_output_stream(const char *filename, struct MPOpts *options);
struct demux_stream;
struct stream *new_ds_stream(struct demux_stream *ds);
diff --git a/stream/stream_udp.c b/stream/stream_udp.c
index 2654a01577..22b9cefc57 100644
--- a/stream/stream_udp.c
+++ b/stream/stream_udp.c
@@ -91,7 +91,6 @@ udp_stream_open (stream_t *stream, int mode, void *opts, int *file_format)
}
stream->type = STREAMTYPE_STREAM;
- fixup_network_stream_cache (stream);
return STREAM_OK;
}