本文整理汇总了C++中VideoFrame::IsIntra方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoFrame::IsIntra方法的具体用法?C++ VideoFrame::IsIntra怎么用?C++ VideoFrame::IsIntra使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VideoFrame
的用法示例。
在下文中一共展示了VideoFrame::IsIntra方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: RecVideo
//.........这里部分代码省略.........
continue;
//Get type
VideoCodec::Type type = (VideoCodec::Type)packet->GetCodec();
if ((decoder==NULL) || (type!=decoder->type))
{
//Si habia uno nos lo cargamos
if (decoder!=NULL)
delete decoder;
//Creamos uno dependiendo del tipo
decoder = VideoCodecFactory::CreateDecoder(type);
//Check
if (!decoder)
{
delete(packet);
continue;
}
}
//Lo decodificamos
if(!decoder->DecodePacket(packet->GetMediaData(),packet->GetMediaLength(),0,packet->GetMark()))
{
delete(packet);
continue;
}
//Get mark
bool mark = packet->GetMark();
//Delete packet
delete(packet);
//Check if it is last one
if(!mark)
continue;
//Check size
if (decoder->GetWidth()!=width || decoder->GetHeight()!=height)
{
//Get dimension
width = decoder->GetWidth();
height = decoder->GetHeight();
//Set size
numpixels = width*height*3/2;
//Set also frame rate and bps
encoder->SetFrameRate(25,300,500);
//Set them in the encoder
encoder->SetSize(width,height);
}
//Encode next frame
VideoFrame *encoded = encoder->EncodeFrame(decoder->GetFrame(),numpixels);
//Check
if (!encoded)
break;
//Check size
if (frame.GetMaxMediaSize()<encoded->GetLength())
//Not enougth space
return Error("Not enought space to copy FLV encodec frame [frame:%d,encoded:%d",frame.GetMaxMediaSize(),encoded->GetLength());
//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);
//Let the connection set the timestamp
frame.SetTimestamp(getDifTime(&first)/1000);
//Send it
SendMediaFrame(&frame);
}
//Check
if (decoder)
//Delete
delete(decoder);
//Check
if (encoder)
//Delete
delete(encoder);
Log("<RecVideo\n");
}
示例3: SendVideo
//.........这里部分代码省略.........
QWORD sleep = frameTime;
//Remove extra sleep from prev
if (overslept<sleep)
//Remove it
sleep -= overslept;
else
//Do not overflow
sleep = 1;
//Calculate timeout
calcAbsTimeoutNS(&ts,&prev,sleep);
//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;
//Get differencence
QWORD diff = getDifTime(&prev);
//If it is biffer
if (diff>frameTime)
//Get what we have slept more
overslept = diff-frameTime;
else
//No oversletp (shoulddn't be possible)
overslept = 0;
}
//Increase frame counter
fpsAcu.Update(getTime()/1000,1);
//If first
if (!frameTime)
{
//Set frame time, slower
frameTime = 5*1000000/videoFPS;
//Restore bitrate
videoEncoder->SetFrameRate(videoFPS,current,videoIntraPeriod);
} else {
//Set frame time
frameTime = 1000000/videoFPS;
}
//Add frame size in bits to bitrate calculator
bitrateAcu.Update(getDifTime(&ini)/1000,videoFrame->GetLength()*8);
//Set frame timestamp
videoFrame->SetTimestamp(getDifTime(&ini)/1000);
//Check if we have mediaListener
if (mediaListener)
//Call it
mediaListener->onMediaFrame(*videoFrame);
//Set sending time of previous frame
getUpdDifTime(&prev);
//Calculate sending times based on bitrate
DWORD sendingTime = videoFrame->GetLength()*8/current;
//Adjust to maximum time
if (sendingTime>frameTime/1000)
//Cap it
sendingTime = frameTime/1000;
//If it was a I frame
if (videoFrame->IsIntra())
//Clean rtp rtx buffer
rtp.FlushRTXPackets();
//Send it smoothly
smoother.SendFrame(videoFrame,sendingTime);
//Dump statistics
if (num && ((num%videoFPS*10)==0))
{
Debug("-Send bitrate target=%d current=%d avg=%llf rate=[%llf,%llf] fps=[%llf,%llf] limit=%d\n",target,current,bitrateAcu.GetInstantAvg()/1000,bitrateAcu.GetMinAvg()/1000,bitrateAcu.GetMaxAvg()/1000,fpsAcu.GetMinAvg(),fpsAcu.GetMaxAvg(),videoBitrateLimit);
bitrateAcu.ResetMinMax();
fpsAcu.ResetMinMax();
}
num++;
}
Log("-SendVideo out of loop\n");
//Terminamos de capturar
videoInput->StopVideoCapture();
//Check
if (videoEncoder)
//Borramos el encoder
delete videoEncoder;
//Salimos
Log("<SendVideo [%d]\n",sendingVideo);
return 0;
}