summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authornicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-12-18 20:55:12 +0000
committernicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-12-18 20:55:12 +0000
commitfc2b02cf7eae734aa9892983a75bdd2f903ceb80 (patch)
tree7ed1fb87cf1b195650d4e0c850c62d26999d8566 /stream
parent874627a371f638ac0362eb7c5c98b07e47f4aaf4 (diff)
downloadmpv-fc2b02cf7eae734aa9892983a75bdd2f903ceb80.tar.bz2
mpv-fc2b02cf7eae734aa9892983a75bdd2f903ceb80.tar.xz
implemented STREAM_CTRL_GET_SIZE
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@21674 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'stream')
-rw-r--r--stream/stream_file.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/stream/stream_file.c b/stream/stream_file.c
index a92cc385b8..f2b3ccdf59 100644
--- a/stream/stream_file.c
+++ b/stream/stream_file.c
@@ -68,6 +68,22 @@ static int seek_forward(stream_t *s,off_t newpos) {
return 1;
}
+static int control(stream_t *s, int cmd, void *arg) {
+ switch(cmd) {
+ case STREAM_CTRL_GET_SIZE: {
+ off_t size;
+
+ size = lseek(s->fd, 0, SEEK_END);
+ lseek(s->fd, s->pos, SEEK_SET);
+ if(size != (off_t)-1) {
+ *((off_t*)arg) = size;
+ return 1;
+ }
+ }
+ }
+ return STREAM_UNSUPORTED;
+}
+
static int open_f(stream_t *stream,int mode, void* opts, int* file_format) {
int f;
mode_t m = 0;
@@ -148,6 +164,7 @@ static int open_f(stream_t *stream,int mode, void* opts, int* file_format) {
stream->fd = f;
stream->fill_buffer = fill_buffer;
stream->write_buffer = write_buffer;
+ stream->control = control;
m_struct_free(&stream_opts,opts);
return STREAM_OK;