整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
126
video/core/Packet.h
Normal file
126
video/core/Packet.h
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
#ifndef AE3F35DC_04CA_417F_8D57_CADC8913678F
|
||||
#define AE3F35DC_04CA_417F_8D57_CADC8913678F
|
||||
/*
|
||||
*******************************************************************************
|
||||
* INCLUDE
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "NotificationQueue.h"
|
||||
#include <Poco/SharedPtr.h>
|
||||
#include "SerialCode.h"
|
||||
#if defined(USING_FFMPEG)
|
||||
extern "C"
|
||||
{
|
||||
#include <libavcodec/packet.h>
|
||||
#include <libavutil/mem.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace Video
|
||||
{
|
||||
namespace Core
|
||||
{
|
||||
/*
|
||||
*******************************************************************************
|
||||
* CLASS DECLARE
|
||||
*******************************************************************************
|
||||
*/
|
||||
class Packet
|
||||
{
|
||||
public:
|
||||
using Ptr = Poco::SharedPtr<Packet>;
|
||||
|
||||
static const uint32_t FLAG_IS_VIDEO;
|
||||
static const uint32_t FLAG_IS_KEY;
|
||||
static const uint32_t FLAG_IS_AAC_HEADER;
|
||||
static const uint32_t FLAG_IS_SEI;
|
||||
|
||||
public:
|
||||
Packet();
|
||||
Packet(const SerialCode& code, uint32_t flags, uint8_t* data, uint32_t length, int64_t pts, int64_t dts);
|
||||
#if defined(USING_FFMPEG)
|
||||
Packet(const SerialCode& code, bool isVideo, AVPacket** packet);
|
||||
#endif
|
||||
Packet(const Packet& other);
|
||||
virtual ~Packet();
|
||||
|
||||
virtual void moveTo(AVPacket** packet);
|
||||
bool isVideo() const;
|
||||
bool isKeyFrame() const;
|
||||
Ptr clone();
|
||||
|
||||
const SerialCode& serialCode();
|
||||
const uint8_t* data();
|
||||
uint32_t length();
|
||||
uint64_t pts();
|
||||
uint64_t dts();
|
||||
uint32_t flags();
|
||||
|
||||
Poco::SharedPtr<uint8_t>& sharedData();
|
||||
|
||||
protected:
|
||||
#if defined(USING_FFMPEG)
|
||||
AVPacket* buildAVPacket();
|
||||
virtual void convertToAVPacket(AVPacket* pPacket);
|
||||
#endif
|
||||
|
||||
private:
|
||||
SerialCode _code;
|
||||
uint32_t _flags;
|
||||
int64_t _pts, _dts;
|
||||
Poco::SharedPtr<uint8_t> _pData;
|
||||
uint32_t _length;
|
||||
#if defined(USING_FFMPEG)
|
||||
AVPacket* _pAVPacket;
|
||||
#endif
|
||||
};
|
||||
|
||||
using PacketQueue = NotificationQueue<Packet>;
|
||||
|
||||
inline bool Packet::isVideo() const
|
||||
{
|
||||
return (_flags & FLAG_IS_VIDEO) > 0;
|
||||
}
|
||||
|
||||
inline bool Packet::isKeyFrame() const
|
||||
{
|
||||
return (_flags & FLAG_IS_KEY) > 0;
|
||||
}
|
||||
|
||||
inline Packet::Ptr Packet::clone()
|
||||
{
|
||||
return new Packet(*this);
|
||||
}
|
||||
|
||||
inline uint32_t Packet::length()
|
||||
{
|
||||
return _length;
|
||||
}
|
||||
|
||||
inline uint64_t Packet::pts()
|
||||
{
|
||||
return _pts;
|
||||
}
|
||||
|
||||
inline uint64_t Packet::dts()
|
||||
{
|
||||
return _dts;
|
||||
}
|
||||
|
||||
inline uint32_t Packet::flags()
|
||||
{
|
||||
return _flags;
|
||||
}
|
||||
|
||||
inline const SerialCode& Packet::serialCode()
|
||||
{
|
||||
return _code;
|
||||
}
|
||||
|
||||
inline Poco::SharedPtr<uint8_t>& Packet::sharedData()
|
||||
{
|
||||
return _pData;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue