framedsource.cpp

来自「rtsp协议的主要实现代码.对开发流媒体」· C++ 代码 · 共 53 行

CPP
53
字号
// FramedSource.cpp: implementation of the FramedSource class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "FramedSource.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

FramedSource::FramedSource() :
	fIsCurrentlyAwaitingData(FALSE)
{

}

FramedSource::~FramedSource()
{

}
void FramedSource::getNextFrame(unsigned char* to, unsigned maxSize,afterGettingFunc* afterGettingFunc,
								void* afterGettingClientData)
{
	if(fIsCurrentlyAwaitingData)
	{
		cout << "FramedSource[" << this << "]::getNextFrame(): attempting to read more than once at the same time!\n";
		exit(1);		
	}
	fTo = to;
	fMaxSize = maxSize;
	fNumTruncatedBytes = 0; // by default; could be changed by doGetNextFrame()
	fDurationInMicroseconds = 0; // by default; could be changed by doGetNextFrame()
	fAfterGettingFunc = afterGettingFunc;
	fAfterGettingClientData = afterGettingClientData;
	
	fIsCurrentlyAwaitingData = TRUE;
	doGetNextFrame();
}

void FramedSource::afterGetting(FramedSource* source) {
	source->fIsCurrentlyAwaitingData = False;
	// indicates that we can be read again
	// Note that this needs to be done here, in case the "fAfterFunc"
	// called below tries to read another frame (which it usually will)
	
	if (source->fAfterGettingFunc != NULL) {
		(*(source->fAfterGettingFunc))(source->fAfterGettingClientData,
			source->fFrameSize, source->fNumTruncatedBytes,
			source->fPresentationTime,
			source->fDurationInMicroseconds);
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?