本文整理汇总了C++中VideoFrame::GetTimeStamp方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoFrame::GetTimeStamp方法的具体用法?C++ VideoFrame::GetTimeStamp怎么用?C++ VideoFrame::GetTimeStamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VideoFrame
的用法示例。
在下文中一共展示了VideoFrame::GetTimeStamp方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EncodeVideo
//.........这里部分代码省略.........
}
//Check
if (frameTime)
{
timespec ts;
//Lock
pthread_mutex_lock(&mutex);
//Calculate timeout
calcAbsTimeout(&ts,&prev,frameTime);
//Wait next or stopped
int canceled = !pthread_cond_timedwait(&cond,&mutex,&ts);
//Unlock
pthread_mutex_unlock(&mutex);
//Check if we have been canceled
if (canceled)
//Exit
break;
}
//Set sending time of previous frame
getUpdDifTime(&prev);
//Set timestamp
encoded->SetTimestamp(getDifTime(&first)/1000);
//Set next one
frameTime = 1000/fps;
//Set duration
encoded->SetDuration(frameTime);
//Get full frame
frame.SetVideoFrame(encoded->GetData(),encoded->GetLength());
//Set buffer size
frame.SetMediaSize(encoded->GetLength());
//Check type
if (encoded->IsIntra())
//Set type
frame.SetFrameType(RTMPVideoFrame::INTRA);
else
//Set type
frame.SetFrameType(RTMPVideoFrame::INTER);
//If we need desc but yet not have it
if (!frameDesc && encoded->IsIntra() && videoCodec==VideoCodec::H264)
{
//Create new description
AVCDescriptor desc;
//Set values
desc.SetConfigurationVersion(1);
desc.SetAVCProfileIndication(0x42);
desc.SetProfileCompatibility(0x80);
desc.SetAVCLevelIndication(0x0C);
desc.SetNALUnitLength(3);
//Get encoded data
BYTE *data = encoded->GetData();
//Get size
DWORD size = encoded->GetLength();
//get from frame
desc.AddParametersFromFrame(data,size);
//Crete desc frame
frameDesc = new RTMPVideoFrame(getDifTime(&first)/1000,desc);
//Lock
pthread_mutex_lock(&mutex);
//Send it
SendMediaFrame(frameDesc);
//unlock
pthread_mutex_unlock(&mutex);
}
//Lock
pthread_mutex_lock(&mutex);
//Set timestamp
frame.SetTimestamp(encoded->GetTimeStamp());
//Publish it
SendMediaFrame(&frame);
//For each listener
for(MediaFrameListeners::iterator it = mediaListeners.begin(); it!=mediaListeners.end(); ++it)
//Send it
(*it)->onMediaFrame(RTMPMediaStream::id,*encoded);
//unlock
pthread_mutex_unlock(&mutex);
}
Log("-FLVEncoder encode video end of loop\n");
//Stop the capture
videoInput->StopVideoCapture();
//Check
if (encoder)
//Exit
delete(encoder);
Log("<FLVEncoder encode vide\n");
//Exit
return 1;
}