本文整理汇总了C++中VideoFrame::trackFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ VideoFrame::trackFrame方法的具体用法?C++ VideoFrame::trackFrame怎么用?C++ VideoFrame::trackFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VideoFrame
的用法示例。
在下文中一共展示了VideoFrame::trackFrame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stream
/**
* @brief Blocking. Decodes video stream and emits new frames.
* @note Designed to run in its own thread.
*/
void CameraSource::stream()
{
auto streamLoop = [=]() {
AVFrame* frame = av_frame_alloc();
if (!frame)
return;
AVPacket packet;
if (av_read_frame(device->context, &packet) < 0)
return;
// Only keep packets from the right stream;
if (packet.stream_index == videoStreamIndex) {
// Decode video frame
int frameFinished;
avcodec_decode_video2(cctx, frame, &frameFinished, &packet);
if (!frameFinished)
return;
VideoFrame* vframe = new VideoFrame(id, frame);
emit frameAvailable(vframe->trackFrame());
}
// Free the packet that was allocated by av_read_frame
av_packet_unref(&packet);
};
forever
{
QReadLocker locker{&streamMutex};
// Exit if device is no longer valid
if (!device) {
break;
}
streamLoop();
}
}