diff options
author | wm4 <wm4@nowhere> | 2012-12-01 23:28:58 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-12-03 21:08:51 +0100 |
commit | 6294c785490be5fc31d29758ca592510fd161371 (patch) | |
tree | a03c9135534f28cf7e9a62abcde87c65eb54eeaa /stream/asf_streaming.c | |
parent | 2d58234c86e59298de52fec12d1eb59086d68763 (diff) | |
download | mpv-6294c785490be5fc31d29758ca592510fd161371.tar.bz2 mpv-6294c785490be5fc31d29758ca592510fd161371.tar.xz |
cache: simplify further
This commit is separate from the previous one to separate our own
changes from changes merged from mplayer2 (as far as that was possible).
Make it easier for stream implementations to request being cached. Set
a default cache size in stream.c, and remove them from various stream
implementations. Only MS streaming support sets a meaningful cache size.
Make querying cache size saner. This reduces the amount of #ifdefs
needed.
Diffstat (limited to 'stream/asf_streaming.c')
-rw-r--r-- | stream/asf_streaming.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/stream/asf_streaming.c b/stream/asf_streaming.c index 31e0d71b89..9b6e2e3a64 100644 --- a/stream/asf_streaming.c +++ b/stream/asf_streaming.c @@ -166,7 +166,8 @@ static int max_idx(int s_count, int *s_rates, int bound) { return best; } -static int asf_streaming_parse_header(int fd, streaming_ctrl_t* streaming_ctrl) { +static int asf_streaming_parse_header(stream_t *s, int fd) { + streaming_ctrl_t* streaming_ctrl = s->streaming_ctrl; ASF_stream_chunck_t chunk; asf_http_streaming_ctrl_t* asf_ctrl = streaming_ctrl->data; char* buffer=NULL, *chunk_buffer=NULL; @@ -246,7 +247,9 @@ static int asf_streaming_parse_header(int fd, streaming_ctrl_t* streaming_ctrl) asf_ctrl->packet_size = AV_RL32(&fileh->max_packet_size); // before playing. // preroll: time in ms to bufferize before playing - streaming_ctrl->prebuffer_size = (unsigned int)(((double)fileh->preroll/1000.0)*((double)fileh->max_bitrate/8.0)); + unsigned int preroll = (unsigned int)(((double)fileh->preroll/1000.0)*((double)fileh->max_bitrate/8.0)); + // buffer in KBytes, *5 assuming the prefill is 20% of the buffer. + s->cache_size = preroll / 1024 * 5; } pos = start; @@ -754,7 +757,7 @@ static int asf_http_streaming_start( stream_t *stream, int *demuxer_type ) { if( asf_http_ctrl->request==1 ) { if( asf_http_ctrl->streaming_type!=ASF_PlainText_e ) { // First request, we only got the ASF header. - ret = asf_streaming_parse_header(fd,stream->streaming_ctrl); + ret = asf_streaming_parse_header(stream,fd); if(ret < 0) goto err_out; if(asf_http_ctrl->n_audio == 0 && asf_http_ctrl->n_video == 0) { mp_tmsg(MSGT_NETWORK,MSGL_ERR,"No stream found.\n"); @@ -796,7 +799,7 @@ static int asf_http_streaming_start( stream_t *stream, int *demuxer_type ) { } else { stream->streaming_ctrl->streaming_read = asf_http_streaming_read; stream->streaming_ctrl->streaming_seek = asf_http_streaming_seek; - stream->streaming_ctrl->buffering = 1; + stream->streaming = true; } stream->streaming_ctrl->status = streaming_playing_e; stream->close = close_s; |