aboutsummaryrefslogtreecommitdiffhomepage
path: root/libmpdemux
diff options
context:
space:
mode:
authorGravatar nicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-11-07 22:55:49 +0000
committerGravatar nicodvb <nicodvb@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-11-07 22:55:49 +0000
commit6200940dcbb147f229b3055cae6fe03c4a42fc5a (patch)
tree2186c3f65391d769f98afea1c481d75d5d2f29ca /libmpdemux
parent0fa1a3e4c67e7b0783cf359e65911e67d4ea7728 (diff)
added demuxer_get_current_time() to get the current playtime (possibly aided by the stream layer)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@20765 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/demuxer.c17
-rw-r--r--libmpdemux/demuxer.h1
2 files changed, 18 insertions, 0 deletions
diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c
index ce8e96eead..e39099a30e 100644
--- a/libmpdemux/demuxer.c
+++ b/libmpdemux/demuxer.c
@@ -1023,6 +1023,23 @@ double demuxer_get_time_length(demuxer_t *demuxer){
return get_time_ans;
}
+/**
+ * \brief demuxer_get_current_time() returns the time of the current play in three possible ways:
+ * either when the stream reader satisfies STREAM_CTRL_GET_CURRENT_TIME (e.g. dvd)
+ * or using sh_video->pts when the former method fails
+ * 0 otherwise
+ * \return the current play time
+ */
+int demuxer_get_current_time(demuxer_t *demuxer){
+ double get_time_ans = 0;
+ unsigned tm;
+ sh_video_t *sh_video = demuxer->video->sh;
+ if(stream_control(demuxer->stream, STREAM_CTRL_GET_CURRENT_TIME,(void *)&tm)!=STREAM_UNSUPORTED) {
+ get_time_ans = (double) tm / 1000.0f;
+ } else if(sh_video) get_time_ans = sh_video->pts;
+ return (int) get_time_ans;
+}
+
int demuxer_get_percent_pos(demuxer_t *demuxer){
int ans = 0;
int res = demux_control(demuxer, DEMUXER_CTRL_GET_PERCENT_POS, &ans);
diff --git a/libmpdemux/demuxer.h b/libmpdemux/demuxer.h
index e731d03b34..bc2c79cff8 100644
--- a/libmpdemux/demuxer.h
+++ b/libmpdemux/demuxer.h
@@ -373,6 +373,7 @@ char *demux_ogg_sub_lang(demuxer_t *demuxer, int index);
#endif
+extern int demuxer_get_current_time(demuxer_t *demuxer);
extern double demuxer_get_time_length(demuxer_t *demuxer);
extern int demuxer_get_percent_pos(demuxer_t *demuxer);
extern int demuxer_switch_audio(demuxer_t *demuxer, int index);