00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "H263plusVideoStreamFramer.hh"
00023 #include "H263plusVideoStreamParser.hh"
00024
00025 #include <string.h>
00026 #include <GroupsockHelper.hh>
00027
00028
00031
00032 H263plusVideoStreamFramer* H263plusVideoStreamFramer::createNew(
00033 UsageEnvironment& env,
00034 FramedSource* inputSource)
00035 {
00036
00037 H263plusVideoStreamFramer* fr;
00038 fr = new H263plusVideoStreamFramer(env, inputSource);
00039 return fr;
00040 }
00041
00042
00044 H263plusVideoStreamFramer::H263plusVideoStreamFramer(
00045 UsageEnvironment& env,
00046 FramedSource* inputSource,
00047 Boolean createParser)
00048 : FramedFilter(env, inputSource),
00049 fFrameRate(0.0),
00050 fPictureEndMarker(False)
00051 {
00052
00053 gettimeofday(&fPresentationTimeBase, NULL);
00054 fParser = createParser ? new H263plusVideoStreamParser(this, inputSource) : NULL;
00055 }
00056
00058 H263plusVideoStreamFramer::~H263plusVideoStreamFramer()
00059 {
00060 delete fParser;
00061 }
00062
00063
00065 #ifdef DEBUG
00066 static struct timeval firstPT;
00067 #endif
00068
00069
00071 void H263plusVideoStreamFramer::doGetNextFrame()
00072 {
00073 fParser->registerReadInterest(fTo, fMaxSize);
00074 continueReadProcessing();
00075 }
00076
00077
00079 Boolean H263plusVideoStreamFramer::isH263plusVideoStreamFramer() const
00080 {
00081 return True;
00082 }
00083
00085 void H263plusVideoStreamFramer::continueReadProcessing(
00086 void* clientData,
00087 unsigned char* , unsigned ,
00088 struct timeval )
00089 {
00090 H263plusVideoStreamFramer* framer = (H263plusVideoStreamFramer*)clientData;
00091 framer->continueReadProcessing();
00092 }
00093
00095 void H263plusVideoStreamFramer::continueReadProcessing()
00096 {
00097 unsigned acquiredFrameSize;
00098
00099 u_int64_t frameDuration;
00100
00101 acquiredFrameSize = fParser->parse(frameDuration);
00102
00103
00104
00105 if (acquiredFrameSize > 0) {
00106
00107
00108 fFrameSize = acquiredFrameSize;
00109
00110
00111 fFrameRate = frameDuration == 0 ? 0.0 : 1000./(long)frameDuration;
00112
00113
00114 if (acquiredFrameSize == 5)
00115 fPresentationTime = fPresentationTimeBase;
00116 else
00117 fPresentationTime.tv_usec += (long) frameDuration*1000;
00118
00119 while (fPresentationTime.tv_usec >= 1000000) {
00120 fPresentationTime.tv_usec -= 1000000;
00121 ++fPresentationTime.tv_sec;
00122 }
00123
00124
00125 fDurationInMicroseconds = (unsigned int) frameDuration*1000;;
00126
00127
00128
00129 afterGetting(this);
00130 } else {
00131
00132
00133
00134 }
00135 }