完善对pts的支持

This commit is contained in:
xiongziliang
2019-07-03 16:22:12 +08:00
parent f6ff2172bd
commit e36194aec3
8 changed files with 56 additions and 46 deletions

View File

@@ -109,11 +109,11 @@ class AACFrameNoCopyAble : public FrameNoCopyAble {
public:
typedef std::shared_ptr<AACFrameNoCopyAble> Ptr;
AACFrameNoCopyAble(char *ptr,uint32_t size,uint32_t stamp,int prefixeSize = 7){
buffer_ptr = ptr;
buffer_size = size;
timeStamp = stamp;
iPrefixSize = prefixeSize;
AACFrameNoCopyAble(char *ptr,uint32_t size,uint32_t dts,int prefixeSize = 7){
_ptr = ptr;
_size = size;
_dts = dts;
_prefixSize = prefixeSize;
}
TrackType getTrackType() const override{

View File

@@ -285,22 +285,33 @@ class FrameNoCopyAble : public Frame{
public:
typedef std::shared_ptr<FrameNoCopyAble> Ptr;
char *data() const override{
return buffer_ptr;
return _ptr;
}
uint32_t size() const override {
return buffer_size;
return _size;
}
uint32_t dts() const override {
return timeStamp;
return _dts;
}
uint32_t pts() const override{
if(_pts){
return _pts;
}
return dts();
}
uint32_t prefixSize() const override{
return iPrefixSize;
return _prefixSize;
}
public:
char *buffer_ptr;
uint32_t buffer_size;
uint32_t timeStamp;
uint32_t iPrefixSize;
protected:
char *_ptr;
uint32_t _size;
uint32_t _dts;
uint32_t _pts = 0;
uint32_t _prefixSize;
};

View File

@@ -96,11 +96,12 @@ class H264FrameNoCopyAble : public FrameNoCopyAble {
public:
typedef std::shared_ptr<H264FrameNoCopyAble> Ptr;
H264FrameNoCopyAble(char *ptr,uint32_t size,uint32_t stamp,int prefixeSize = 4){
buffer_ptr = ptr;
buffer_size = size;
timeStamp = stamp;
iPrefixSize = prefixeSize;
H264FrameNoCopyAble(char *ptr,uint32_t size,uint32_t dts , uint32_t pts ,int prefixeSize = 4){
_ptr = ptr;
_size = size;
_dts = dts;
_pts = pts;
_prefixSize = prefixeSize;
}
TrackType getTrackType() const override{
@@ -112,19 +113,17 @@ public:
}
bool keyFrame() const override {
return H264_TYPE(buffer_ptr[iPrefixSize]) == H264Frame::NAL_IDR;
return H264_TYPE(_ptr[_prefixSize]) == H264Frame::NAL_IDR;
}
};
class H264FrameSubFrame : public H264FrameNoCopyAble{
public:
typedef std::shared_ptr<H264FrameSubFrame> Ptr;
H264FrameSubFrame(const Frame::Ptr &strongRef,
char *ptr,
uint32_t size,
uint32_t stamp,
int prefixeSize) : H264FrameNoCopyAble(ptr,size,stamp,prefixeSize){
char *ptr,
uint32_t size,
int prefixeSize) : H264FrameNoCopyAble(ptr,size,strongRef->dts(),strongRef->pts(),prefixeSize){
_strongRef = strongRef;
}
private:
@@ -234,7 +233,6 @@ public:
H264FrameSubFrame::Ptr sub_frame = std::make_shared<H264FrameSubFrame>(frame,
frame->data(),
len + frame->prefixSize(),
frame->stamp(),
frame->prefixSize());
inputFrame_l(sub_frame);
first_frame = false;
@@ -242,7 +240,6 @@ public:
H264FrameSubFrame::Ptr sub_frame = std::make_shared<H264FrameSubFrame>(frame,
(char *)ptr,
len ,
frame->stamp(),
3);
inputFrame_l(sub_frame);
}

View File

@@ -125,11 +125,12 @@ class H265FrameNoCopyAble : public FrameNoCopyAble {
public:
typedef std::shared_ptr<H265FrameNoCopyAble> Ptr;
H265FrameNoCopyAble(char *ptr, uint32_t size, uint32_t stamp, int prefixeSize = 4) {
buffer_ptr = ptr;
buffer_size = size;
timeStamp = stamp;
iPrefixSize = prefixeSize;
H265FrameNoCopyAble(char *ptr, uint32_t size, uint32_t dts,uint32_t pts, int prefixeSize = 4) {
_ptr = ptr;
_size = size;
_dts = dts;
_pts = pts;
_prefixSize = prefixeSize;
}
TrackType getTrackType() const override {
@@ -141,7 +142,7 @@ public:
}
bool keyFrame() const override {
int type = H265_TYPE(((uint8_t *) buffer_ptr)[iPrefixSize]);
int type = H265_TYPE(((uint8_t *) _ptr)[_prefixSize]);
return H265Frame::isKeyFrame(type);
}
};