diff options
author | albeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-04-23 15:39:51 +0000 |
---|---|---|
committer | albeu <albeu@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-04-23 15:39:51 +0000 |
commit | 44e9960dd02e5cc66c7b9f393e3fc5d16201bb6b (patch) | |
tree | cf2bbffca87741c75a0d31cdd4356ac8733a0871 /mplayer.c | |
parent | 152d7ed02c15a8ea5685b155fc175837d1b7a5e6 (diff) | |
download | mpv-44e9960dd02e5cc66c7b9f393e3fc5d16201bb6b.tar.bz2 mpv-44e9960dd02e5cc66c7b9f393e3fc5d16201bb6b.tar.xz |
Add properties to get/set the stream position and get the stream
start pos, end pos and length. Based on Reimar's patch.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18227 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'mplayer.c')
-rw-r--r-- | mplayer.c | 53 |
1 files changed, 53 insertions, 0 deletions
@@ -1361,6 +1361,51 @@ static int mp_property_demuxer(m_option_t* prop,int action,void* arg) { return m_property_string_ro(prop,action,arg,(char*)demuxer->desc->name); } +static int mp_property_stream_pos(m_option_t* prop,int action,void* arg) { + if (!demuxer || !demuxer->stream) return M_PROPERTY_UNAVAILABLE; + if (!arg) return M_PROPERTY_ERROR; + switch (action) { + case M_PROPERTY_GET: + *(off_t*)arg = stream_tell(demuxer->stream); + return M_PROPERTY_OK; + case M_PROPERTY_SET: + M_PROPERTY_CLAMP(prop,*(off_t*)arg); + stream_seek(demuxer->stream, *(off_t*)arg); + return M_PROPERTY_OK; + } + return M_PROPERTY_NOT_IMPLEMENTED; +} + +static int mp_property_stream_start(m_option_t* prop,int action,void* arg) { + if (!demuxer || !demuxer->stream) return M_PROPERTY_UNAVAILABLE; + switch (action) { + case M_PROPERTY_GET: + *(off_t*)arg = demuxer->stream->start_pos; + return M_PROPERTY_OK; + } + return M_PROPERTY_NOT_IMPLEMENTED; +} + +static int mp_property_stream_end(m_option_t* prop,int action,void* arg) { + if (!demuxer || !demuxer->stream) return M_PROPERTY_UNAVAILABLE; + switch (action) { + case M_PROPERTY_GET: + *(off_t*)arg = demuxer->stream->end_pos; + return M_PROPERTY_OK; + } + return M_PROPERTY_NOT_IMPLEMENTED; +} + +static int mp_property_stream_length(m_option_t* prop,int action,void* arg) { + if (!demuxer || !demuxer->stream) return M_PROPERTY_UNAVAILABLE; + switch (action) { + case M_PROPERTY_GET: + *(off_t*)arg = demuxer->stream->end_pos - demuxer->stream->start_pos; + return M_PROPERTY_OK; + } + return M_PROPERTY_NOT_IMPLEMENTED; +} + static int mp_property_length(m_option_t* prop,int action,void* arg) { double len; @@ -2009,6 +2054,14 @@ static m_option_t mp_properties[] = { 0, 0, 0, NULL }, { "demuxer", mp_property_demuxer, CONF_TYPE_STRING, 0, 0, 0, NULL }, + { "stream_pos", mp_property_stream_pos, CONF_TYPE_POSITION, + M_OPT_MIN, 0, 0, NULL }, + { "stream_start", mp_property_stream_start, CONF_TYPE_POSITION, + M_OPT_MIN, 0, 0, NULL }, + { "stream_end", mp_property_stream_end, CONF_TYPE_POSITION, + M_OPT_MIN, 0, 0, NULL }, + { "stream_length", mp_property_stream_length, CONF_TYPE_POSITION, + M_OPT_MIN, 0, 0, NULL }, { "length", mp_property_length, CONF_TYPE_DOUBLE, 0, 0, 0, NULL }, |