Hello Sir
i asked live media people the following ques:-
Is there any way in testMPEG2TransportStreamer.cpp to know the frame
> rate of the file it is streaming????
Try subclassing MPEG2TransportStreamFramer, and keeping track when its
getNextFrame() method is called. Between that and gettimeofday(), you
should be able to calculate this
i implemented this as follows:-
#include "FramedSource.hh"
#include <stdlib.h>
#include "GroupsockHelper.hh"
#include<math.h>
static int Framek=0;
double t1,t2,T;
float F;
struct timeval timeNow;
FramedSource::FramedSource(UsageEnvironment& env)
: MediaSource(env),
fAfterGettingFunc(NULL), fAfterGettingClientData(NULL),
fOnCloseFunc(NULL), fOnCloseClientData(NULL),
fIsCurrentlyAwaitingData(False) {
fPresentationTime.tv_sec = fPresentationTime.tv_usec = 0; }
FramedSource::~FramedSource() {
}
Boolean FramedSource::isFramedSource() const {
return True;
}
Boolean FramedSource::lookupByName(UsageEnvironment& env, char const* sourceName,
FramedSource*& resultSource) {
resultSource = NULL;
MediaSource* source;
if (!MediaSource::lookupByName(env, sourceName, source)) return False;
if (!source->isFramedSource()) {
env.setResultMsg(sourceName, " is not a framed source");
return False;
}
resultSource = (FramedSource*)source;
return True;
}
void FramedSource::getNextFrame(unsigned char* to, unsigned maxSize,
afterGettingFunc* afterGettingFunc,
void* afterGettingClientData,
onCloseFunc* onCloseFunc,
void* onCloseClientData) {
if(Framek == 0)
{
gettimeofday(&timeNow, NULL);
t1=timeNow.tv_sec+(timeNow.tv_usec/1000000.0);
printf("value of t1 is %.6lf\t Framek %d \n",t1,Framek);
Framek++;
}
else
{
if(Framek == 1)
{
gettimeofday(&timeNow, NULL);
t2=timeNow.tv_sec+(timeNow.tv_usec/1000000.0);
printf("value of t2 is %.6lf Framek = %d\n",t2,Framek);
Framek++;
}
else
{
Framek =0;
T=t2-t1;
printf("\nFramek = %d\t t1= %.6lf\t t2= %.6lf\t T = %.6lf\t\n",Framek,t1,t2,T);
F=(float)(1/T);
printf("Framerate is %f\n",F);
}
}
if (fIsCurrentlyAwaitingData) {
envir() << "FramedSource[" << this << "]::getNextFrame(): attempting to read more than once at the same time!\n";
envir().internalError();
}
fTo = to;
fMaxSize = maxSize;
fNumTruncatedBytes = 0; fDurationInMicroseconds = 0; fAfterGettingFunc = afterGettingFunc;
fAfterGettingClientData = afterGettingClientData;
fOnCloseFunc = onCloseFunc;
fOnCloseClientData = onCloseClientData;
fIsCurrentlyAwaitingData = True;
doGetNextFrame();
}
void FramedSource::afterGetting(FramedSource* source) {
source->fIsCurrentlyAwaitingData = False;
if (source->fAfterGettingFunc != NULL) {
(*(source->fAfterGettingFunc))(source->fAfterGettingClientData,
source->fFrameSize, source->fNumTruncatedBytes,
source->fPresentationTime,
source->fDurationInMicroseconds);
}
}
void FramedSource::handleClosure(void* clientData) {
FramedSource* source = (FramedSource*)clientData;
source->fIsCurrentlyAwaitingData = False; if (source->fOnCloseFunc != NULL) {
(*(source->fOnCloseFunc))(source->fOnCloseClientData);
}
}
void FramedSource::stopGettingFrames() {
fIsCurrentlyAwaitingData = False;
doStopGettingFrames();
}
void FramedSource::doStopGettingFrames() {
}
unsigned FramedSource::maxFrameSize() const {
return 0;
}
If anyone knows the problem solution do mail me on **@***.***