summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-12-21 12:27:38 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2004-12-21 12:27:38 +0000
commit12067f7a97c2d8ed825d4c69b46376647043d47b (patch)
tree755eb291c74f04f1b52ace66daf02fbab75d58f7
parent3426117ee8ce21e81dd8ec8a87d6e1ef7b7871db (diff)
downloadmpv-12067f7a97c2d8ed825d4c69b46376647043d47b.tar.bz2
mpv-12067f7a97c2d8ed825d4c69b46376647043d47b.tar.xz
fix position bar and length display for mov files
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14199 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r--ChangeLog1
-rw-r--r--libmpdemux/demux_mov.c56
2 files changed, 51 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index f2ae93d06a..bdf9d6524c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -78,6 +78,7 @@ MPlayer (1.0)
* improved seeking precision in MPEG files
* better subtitle language code handling for MKV files
* support DVHS files and H.264 over MPEG-TS
+ * display length and position (in the seekbar) for mov files
Streaming:
* -cache-min and -cache-prefill options added
diff --git a/libmpdemux/demux_mov.c b/libmpdemux/demux_mov.c
index b819309f40..3a186f8b95 100644
--- a/libmpdemux/demux_mov.c
+++ b/libmpdemux/demux_mov.c
@@ -1696,6 +1696,18 @@ int mov_read_header(demuxer_t* demuxer){
return 1;
}
+/**
+ * \brief return the mov track that belongs to a demuxer stream
+ * \param ds the demuxer stream, may be NULL
+ * \return the mov track info structure belonging to the stream,
+ * NULL if not found
+ */
+static mov_track_t *stream_track(mov_priv_t *priv, demux_stream_t *ds) {
+ if (ds && (ds->id >= 0) && (ds->id < priv->track_db))
+ return priv->tracks[ds->id];
+ return NULL;
+}
+
// return value:
// 0 = EOF or no stream found
// 1 = successfully read a packet
@@ -1706,8 +1718,8 @@ int demux_mov_fill_buffer(demuxer_t *demuxer,demux_stream_t* ds){
int x;
off_t pos;
- if(ds->id<0 || ds->id>=priv->track_db) return 0;
- trak=priv->tracks[ds->id];
+ trak = stream_track(priv, ds);
+ if (!trak) return 0;
if(trak->samplesize){
// read chunk:
@@ -1835,12 +1847,13 @@ return pts;
void demux_seek_mov(demuxer_t *demuxer,float pts,int flags){
mov_priv_t* priv=demuxer->priv;
demux_stream_t* ds;
+ mov_track_t* trak;
// printf("MOV seek called %5.3f flag=%d \n",pts,flags);
ds=demuxer->video;
- if(ds && ds->id>=0 && ds->id<priv->track_db){
- mov_track_t* trak=priv->tracks[ds->id];
+ trak = stream_track(priv, ds);
+ if (trak) {
//if(flags&2) pts*=(float)trak->length/(float)trak->timescale;
//if(!(flags&1)) pts+=ds->pts;
pts=ds->pts=mov_seek_track(trak,pts,flags);
@@ -1848,8 +1861,8 @@ void demux_seek_mov(demuxer_t *demuxer,float pts,int flags){
}
ds=demuxer->audio;
- if(ds && ds->id>=0 && ds->id<priv->track_db){
- mov_track_t* trak=priv->tracks[ds->id];
+ trak = stream_track(priv, ds);
+ if (trak) {
//if(flags&2) pts*=(float)trak->length/(float)trak->timescale;
//if(!(flags&1)) pts+=ds->pts;
ds->pts=mov_seek_track(trak,pts,flags);
@@ -1857,3 +1870,34 @@ void demux_seek_mov(demuxer_t *demuxer,float pts,int flags){
}
+int demux_mov_control(demuxer_t *demuxer, int cmd, void *arg){
+ mov_track_t* track;
+
+ // try the video track
+ track = stream_track(demuxer->priv, demuxer->video);
+ if (!track || !track->length)
+ // otherwise try to get the info from the audio track
+ track = stream_track(demuxer->priv, demuxer->audio);
+
+ if (!track || !track->length)
+ return DEMUXER_CTRL_DONTKNOW;
+
+ switch(cmd) {
+ case DEMUXER_CTRL_GET_TIME_LENGTH:
+ if (!track->timescale)
+ return DEMUXER_CTRL_DONTKNOW;
+ *((unsigned long *)arg) = track->length / track->timescale;
+ return DEMUXER_CTRL_OK;
+
+ case DEMUXER_CTRL_GET_PERCENT_POS:
+ {
+ off_t pos = track->pos;
+ if (track->durmap_size >= 1)
+ pos *= track->durmap[0].dur;
+ *((int *)arg) = (int)(100 * pos / track->length);
+ return DEMUXER_CTRL_OK;
+ }
+ }
+ return DEMUXER_CTRL_NOTIMPL;
+}
+