优化代码

This commit is contained in:
xiongziliang
2020-10-24 23:28:25 +08:00
parent 46ee7f369b
commit 02c4aa3f4b
7 changed files with 24 additions and 48 deletions

View File

@@ -183,7 +183,8 @@ public:
}
}
bool is_video = rtp->type == TrackVideo;
PacketCache<RtpPacket>::inputPacket(is_video, std::move(rtp), keyPos);
auto stamp = rtp->timeStamp;
PacketCache<RtpPacket>::inputPacket(stamp, is_video, std::move(rtp), keyPos);
}
void clearCache() override{

View File

@@ -37,17 +37,19 @@ class RtspSession;
class BufferRtp : public Buffer{
public:
typedef std::shared_ptr<BufferRtp> Ptr;
BufferRtp(const RtpPacket::Ptr & pkt,uint32_t offset = 0 ):_rtp(pkt),_offset(offset){}
virtual ~BufferRtp(){}
BufferRtp(Buffer::Ptr pkt, uint32_t offset = 0) : _rtp(std::move(pkt)), _offset(offset) {}
~BufferRtp() override{}
char *data() const override {
return (char *)_rtp->data() + _offset;
}
uint32_t size() const override {
return _rtp->size() - _offset;
}
private:
RtpPacket::Ptr _rtp;
Buffer::Ptr _rtp;
uint32_t _offset;
};