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 void H263plusVideoStreamFramer::doGetNextFrame()
00066 {
00067 fParser->registerReadInterest(fTo, fMaxSize);
00068 continueReadProcessing();
00069 }
00070
00071
00073 Boolean H263plusVideoStreamFramer::isH263plusVideoStreamFramer() const
00074 {
00075 return True;
00076 }
00077
00079 void H263plusVideoStreamFramer::continueReadProcessing(
00080 void* clientData,
00081 unsigned char* , unsigned ,
00082 struct timeval )
00083 {
00084 H263plusVideoStreamFramer* framer = (H263plusVideoStreamFramer*)clientData;
00085 framer->continueReadProcessing();
00086 }
00087
00089 void H263plusVideoStreamFramer::continueReadProcessing()
00090 {
00091 unsigned acquiredFrameSize;
00092
00093 u_int64_t frameDuration;
00094
00095 acquiredFrameSize = fParser->parse(frameDuration);
00096
00097
00098
00099 if (acquiredFrameSize > 0) {
00100
00101
00102 fFrameSize = acquiredFrameSize;
00103
00104
00105 fFrameRate = frameDuration == 0 ? 0.0 : 1000./(long)frameDuration;
00106
00107
00108 if (acquiredFrameSize == 5)
00109 fPresentationTime = fPresentationTimeBase;
00110 else
00111 fPresentationTime.tv_usec += (long) frameDuration*1000;
00112
00113 while (fPresentationTime.tv_usec >= 1000000) {
00114 fPresentationTime.tv_usec -= 1000000;
00115 ++fPresentationTime.tv_sec;
00116 }
00117
00118
00119 fDurationInMicroseconds = (unsigned int) frameDuration*1000;;
00120
00121
00122
00123 afterGetting(this);
00124 } else {
00125
00126
00127
00128 }
00129 }