本文整理汇总了C++中VideoFrame::SetLength方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoFrame::SetLength方法的具体用法?C++ VideoFrame::SetLength怎么用?C++ VideoFrame::SetLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VideoFrame
的用法示例。
在下文中一共展示了VideoFrame::SetLength方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNextFrameTime
QWORD MP4RtpTrack::Read(Listener *listener)
{
int last = 0;
uint8_t* data;
bool isSyncSample;
// If it's first packet of a frame
if (!numHintSamples)
{
// Get number of rtp packets for this sample
if (!MP4ReadRtpHint(mp4, hint, sampleId, &numHintSamples))
{
//Print error
Error("Error reading hintt");
//Exit
return MP4_INVALID_TIMESTAMP;
}
// Get number of samples for this sample
frameSamples = MP4GetSampleDuration(mp4, hint, sampleId);
// Get size of sample
frameSize = MP4GetSampleSize(mp4, hint, sampleId);
// Get sample timestamp
frameTime = MP4GetSampleTime(mp4, hint, sampleId);
//Convert to miliseconds
frameTime = MP4ConvertFromTrackTimestamp(mp4, hint, frameTime, 1000);
// Check if it is H264 and it is a Sync frame
if (codec==VideoCodec::H264 && MP4GetSampleSync(mp4,track,sampleId))
// Send SEI info
SendH263SEI(listener);
//Get max data lenght
BYTE *data = NULL;
DWORD dataLen = 0;
MP4Timestamp startTime;
MP4Duration duration;
MP4Duration renderingOffset;
//Get values
data = frame->GetData();
dataLen = frame->GetMaxMediaLength();
// Read next rtp packet
if (!MP4ReadSample(
mp4, // MP4FileHandle hFile
track, // MP4TrackId hintTrackId
sampleId, // MP4SampleId sampleId,
(u_int8_t **) &data, // u_int8_t** ppBytes
(u_int32_t *) &dataLen, // u_int32_t* pNumBytes
&startTime, // MP4Timestamp* pStartTime
&duration, // MP4Duration* pDuration
&renderingOffset, // MP4Duration* pRenderingOffset
&isSyncSample // bool* pIsSyncSample
))
{
Error("Error reading sample");
//Last
return MP4_INVALID_TIMESTAMP;
}
//Check type
if (media == MediaFrame::Video)
{
//Get video frame
VideoFrame *video = (VideoFrame*)frame;
//Set lenght
video->SetLength(dataLen);
//Timestamp
video->SetTimestamp(startTime*90000/timeScale);
//Set intra
video->SetIntra(isSyncSample);
} else {
//Get Audio frame
AudioFrame *audio = (AudioFrame*)frame;
//Set lenght
audio->SetLength(dataLen);
//Timestamp
audio->SetTimestamp(startTime*8000/timeScale);
}
//Check listener
if (listener)
//Frame callback
listener->onMediaFrame(*frame);
}
// if it's the last
if (packetIndex + 1 == numHintSamples)
//Set last mark
last = 1;
// Set mark bit
rtp.SetMark(last);
// Get data pointer
data = rtp.GetMediaData();
//Get max data lenght
//.........这里部分代码省略.........