本文整理汇总了C++中PacketPtr::isKeyFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketPtr::isKeyFrame方法的具体用法?C++ PacketPtr::isKeyFrame怎么用?C++ PacketPtr::isKeyFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketPtr
的用法示例。
在下文中一共展示了PacketPtr::isKeyFrame方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processPacket
/***
* this function packetizes the GOPs in chunks between the IFrames
* i normal cases the order of the Pictures are
* here will be each group of Picture be chunked, all of them cutted in the position of an I-Frame
* IPPPPPPPPIPPPPPPPPIPPPPPPPP
* IPPPPPPPP
* IPPPPPPPP
* IPPPPPPPP
*
* in a MPeg Stream there is a reorder with BFrames
* each group will be also chunked in the position of the I-Frame, but in the case of the delay from the Decoder
* we will append the next packets until a P-Frame arrived.
* IPBBPBBPBBIBBPBBPBBIBBPBBPBBIBBP
* IPBBPBBPBBIBB
* I PBBPBBIBB
* I PBBPBBIBB
*
*
*/
bool Packetizer::processPacket(PacketPtr ptr) {
bool result = false;
int stream_idx = ptr->getStreamIndex();
if (_streams[stream_idx].state == STATE_NOP && (ptr->isKeyFrame() || _streams[stream_idx].decoder->getCodecType() == AVMEDIA_TYPE_AUDIO)) {
_streams[stream_idx].state = STATE_START_I_FRAME;
}
if (_streams[stream_idx].state == STATE_START_I_FRAME && _streams[stream_idx].packets.size() >= _streams[stream_idx].min_packet_count && ptr->isKeyFrame()) {
_streams[stream_idx].state = STATE_END_I_FRAME;
}
if (_streams[stream_idx].state == STATE_START_I_FRAME) {
_streams[stream_idx].packets.push_back(ptr);
}
if (_streams[stream_idx].state == STATE_END_I_FRAME) {
_overlap_queue[stream_idx].push_back(ptr);
}
/**
* case handling for mpeg2 video packets(formaly streams with b frames)
* */
if (_streams[stream_idx].state == STATE_END_I_FRAME && (_streams[stream_idx].decoder->getCodecId() == CODEC_ID_MPEG2VIDEO && ptr->_pict_type == AV_PICTURE_TYPE_P)) {
/*in the first roundtrip the stream packets look like this, the first B Frames are not removed*/
/*_streams[stream_idx].packets =IBBPBBPBBPBB*/
/*in the following roundtrip the stream packets look like this*/
/*_streams[stream_idx].packets =IPBBPBBPBB*/
/*_overlap_queue[stream_idx] =IBBP*/
_streams[stream_idx].state = STATE_START_I_FRAME;
/**
* appending the next IBB from the IBBP order to the actual packet_list
* */
_streams[stream_idx].packets.insert(_streams[stream_idx].packets.end(), _overlap_queue[stream_idx].begin(), _overlap_queue[stream_idx].end() - 1);
/*_streams[stream_idx].packets =IBBPBBPBBPBBIBB*/
/*_overlap_queue[stream_idx] =IBBP*/
_packet_list.push_back(_streams[stream_idx].packets);
_streams[stream_idx].packets.clear();
/*_streams[stream_idx].packets = */
/*_overlap_queue[stream_idx] =IBBP*/
/**
* appending the IP frames from the IBBP order to the actual packet_list
* that are the first and the last entries in the overlap queue
* */
_streams[stream_idx].packets.insert(_streams[stream_idx].packets.end(), _overlap_queue[stream_idx].begin(), _overlap_queue[stream_idx].begin() + 1);
_streams[stream_idx].packets.insert(_streams[stream_idx].packets.end(), _overlap_queue[stream_idx].end() - 1, _overlap_queue[stream_idx].end());
// _streams[stream_idx].packets.insert(_streams[stream_idx].packets.end(), _overlap_queue[stream_idx].begin(), _overlap_queue[stream_idx].end());
/*_streams[stream_idx].packets =IP */
/*_overlap_queue[stream_idx] =IBBP*/
_overlap_queue[stream_idx].clear();
/*_streams[stream_idx].packets =IP */
/*_overlap_queue[stream_idx] = */
result = true;
} else if (_streams[stream_idx].state == STATE_END_I_FRAME && _streams[stream_idx].decoder->getCodecType() == AVMEDIA_TYPE_AUDIO) {
/**************************************
* this is used for all audio streams
**************************************/
_streams[stream_idx].state = STATE_START_I_FRAME;
/**copying all Packets into the actual ProcessUnit*/
_packet_list.push_back(_streams[stream_idx].packets);
/**clear out the PacketList, because they are in the ProcessUnit*/
_streams[stream_idx].packets.clear();
/**bring in the first I-Frame for the next Process Unit*/
_streams[stream_idx].packets.insert(_streams[stream_idx].packets.end(), _overlap_queue[stream_idx].begin(), _overlap_queue[stream_idx].end());
/**clear out the overlap queue, because there is only an I-Frame packet and this is now in the next ProcessUnit*/
_overlap_queue[stream_idx].clear();
result = true;
} else if (_streams[stream_idx].state == STATE_END_I_FRAME && _streams[stream_idx].decoder->getCodecId() != CODEC_ID_MPEG2VIDEO) {
/**********************************************************************
* this is used for all video stream types except MPEG2 Video Streams
**********************************************************************/
_streams[stream_idx].state = STATE_START_I_FRAME;
/**copying all Packets into the actual ProcessUnit*/
_packet_list.push_back(_streams[stream_idx].packets);
/**clear out the PacketList, because they are in the ProcessUnit*/
//.........这里部分代码省略.........