summaryrefslogtreecommitdiffstats
path: root/mpeglib/lib/util/timeStampArray.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commite2de64d6f1beb9e492daf5b886e19933c1fa41dd (patch)
tree9047cf9e6b5c43878d5bf82660adae77ceee097a /mpeglib/lib/util/timeStampArray.h
downloadtdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.tar.gz
tdemultimedia-e2de64d6f1beb9e492daf5b886e19933c1fa41dd.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdemultimedia@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'mpeglib/lib/util/timeStampArray.h')
-rw-r--r--mpeglib/lib/util/timeStampArray.h85
1 files changed, 85 insertions, 0 deletions
diff --git a/mpeglib/lib/util/timeStampArray.h b/mpeglib/lib/util/timeStampArray.h
new file mode 100644
index 00000000..8b117652
--- /dev/null
+++ b/mpeglib/lib/util/timeStampArray.h
@@ -0,0 +1,85 @@
+/*
+ class for managing byte positions and associated time positions
+ Copyright (C) 1999 Martin Vogt
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Library General Public License as published by
+ the Free Software Foundation.
+
+ For more information look at the file COPYRIGHT in this package
+
+ */
+
+
+#ifndef __TIMESTAMPARRAY_H
+#define __TIMESTAMPARRAY_H
+
+#include "abstract/abs_thread.h"
+#include "timeStamp.h"
+
+
+/**
+ This class deals with the problem to sync audio and video.
+ Both streams are decoded in different threads, sometimes
+ the video is decoded faster than the audio and sometimes
+ not.
+ <p>
+ You need a general mechanism to decide, which is faster.
+ It works like this:
+ <p>
+ When the mpeg stream is split in video/audio part the split thread
+ writes the video/audio data to the inputInterface.
+ Additionally it writes a timestamp to the interface.
+ The interface counts the bytes and forward the bytes/timeStamp
+ pait to this class.
+ Later when the threads write to the outputInterface the ask
+ this class (with the bytePostions) which timestamp it
+ has and hass the data and the timestamp to the outputInterface.
+ There we can decide what to do with the data.
+ <p>
+ 1) audio faster than video = drop video picture
+ <p>
+ 2) video faster than audio - wait for audio.
+*/
+
+
+
+class TimeStampArray {
+
+ TimeStamp** tStampArray;
+
+ int lastWritePos;
+ int writePos;
+ int readPos;
+ int fillgrade;
+ char* name;
+ int entries;
+
+ abs_thread_mutex_t writeInMut;
+ abs_thread_mutex_t changeMut;
+
+
+ public:
+ TimeStampArray(char* name,int entries);
+ ~TimeStampArray();
+
+
+ int insertTimeStamp(TimeStamp* src,long key,int len);
+ TimeStamp* getReadTimeStamp();
+ TimeStamp* getTimeStamp(long key);
+ int getFillgrade();
+ void forward();
+ void clear();
+
+ int bytesUntilNext(long key);
+
+ private:
+ void lockStampArray();
+ void unlockStampArray();
+ void internalForward();
+
+
+
+};
+#endif
+