Refine code

pull/2252/head
winlin 4 years ago
parent edbabf840d
commit 7c6f56affa

@ -942,6 +942,28 @@ char* SrsRtpPacket2::wrap(SrsSharedPtrMessage* msg)
return msg->payload; return msg->payload;
} }
SrsRtpPacket2* SrsRtpPacket2::copy()
{
SrsRtpPacket2* cp = _srs_rtp_cache->allocate();
// We got packet from cache, so we must recycle it.
cp->recycle_payload();
cp->recycle_shared_msg();
cp->header = header;
cp->payload_ = payload_? payload_->copy():NULL;
cp->payload_type_ = payload_type_;
cp->nalu_type = nalu_type;
cp->shared_msg = shared_msg->copy();
cp->frame_type = frame_type;
cp->cached_payload_size = cached_payload_size;
cp->decode_handler = decode_handler;
return cp;
}
void SrsRtpPacket2::set_padding(int size) void SrsRtpPacket2::set_padding(int size)
{ {
header.set_padding(size); header.set_padding(size);
@ -968,28 +990,6 @@ bool SrsRtpPacket2::is_audio()
return frame_type == SrsFrameTypeAudio; return frame_type == SrsFrameTypeAudio;
} }
SrsRtpPacket2* SrsRtpPacket2::copy()
{
SrsRtpPacket2* cp = _srs_rtp_cache->allocate();
// We got packet from cache, so we must recycle it.
cp->recycle_payload();
cp->recycle_shared_msg();
cp->header = header;
cp->payload_ = payload_? payload_->copy():NULL;
cp->payload_type_ = payload_type_;
cp->nalu_type = nalu_type;
cp->shared_msg = shared_msg->copy();
cp->frame_type = frame_type;
cp->cached_payload_size = cached_payload_size;
cp->decode_handler = decode_handler;
return cp;
}
void SrsRtpPacket2::set_extension_types(const SrsRtpExtensionTypes* v) void SrsRtpPacket2::set_extension_types(const SrsRtpExtensionTypes* v)
{ {
return header.set_extensions(v); return header.set_extensions(v);

@ -328,6 +328,8 @@ public:
char* wrap(char* data, int size); char* wrap(char* data, int size);
// Wrap the shared message, we copy it. // Wrap the shared message, we copy it.
char* wrap(SrsSharedPtrMessage* msg); char* wrap(SrsSharedPtrMessage* msg);
// Copy the RTP packet.
virtual SrsRtpPacket2* copy();
public: public:
// Get and set the payload of packet. // Get and set the payload of packet.
void set_payload(ISrsRtpPayloader* p, SrsRtpPacketPayloadType pt) { payload_ = p; payload_type_ = pt; } void set_payload(ISrsRtpPayloader* p, SrsRtpPacketPayloadType pt) { payload_ = p; payload_type_ = pt; }
@ -340,8 +342,6 @@ public:
void set_decode_handler(ISrsRtpPacketDecodeHandler* h); void set_decode_handler(ISrsRtpPacketDecodeHandler* h);
// Whether the packet is Audio packet. // Whether the packet is Audio packet.
bool is_audio(); bool is_audio();
// Copy the RTP packet.
virtual SrsRtpPacket2* copy();
// Set RTP header extensions for encoding or decoding header extension // Set RTP header extensions for encoding or decoding header extension
void set_extension_types(const SrsRtpExtensionTypes* v); void set_extension_types(const SrsRtpExtensionTypes* v);
// interface ISrsEncoder // interface ISrsEncoder

Loading…
Cancel
Save