mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Perf: Refine copy RTP header.
This commit is contained in:
parent
81dddcbd93
commit
b1457dfc16
2 changed files with 55 additions and 6 deletions
|
@ -218,6 +218,13 @@ void SrsRtpExtensionTwcc::reset()
|
|||
sn_ = 0;
|
||||
}
|
||||
|
||||
void SrsRtpExtensionTwcc::assign(const SrsRtpExtensionTwcc& h)
|
||||
{
|
||||
has_twcc_ = h.has_twcc_;
|
||||
id_ = h.id_;
|
||||
sn_ = h.sn_;
|
||||
}
|
||||
|
||||
bool SrsRtpExtensionTwcc::has_twcc_ext()
|
||||
{
|
||||
return has_twcc_;
|
||||
|
@ -311,6 +318,13 @@ void SrsRtpExtensionOneByte::reset()
|
|||
value_ = 0;
|
||||
}
|
||||
|
||||
void SrsRtpExtensionOneByte::assign(const SrsRtpExtensionOneByte& h)
|
||||
{
|
||||
has_ext_ = h.has_ext_;
|
||||
id_ = h.id_;
|
||||
value_ = h.value_;
|
||||
}
|
||||
|
||||
void SrsRtpExtensionOneByte::set_id(int id)
|
||||
{
|
||||
id_ = id;
|
||||
|
@ -370,10 +384,21 @@ SrsRtpExtensions::~SrsRtpExtensions()
|
|||
|
||||
void SrsRtpExtensions::reset()
|
||||
{
|
||||
has_ext_ = false;
|
||||
types_ = NULL;
|
||||
twcc_.reset();
|
||||
audio_level_.reset();
|
||||
has_ext_ = false;
|
||||
}
|
||||
|
||||
void SrsRtpExtensions::assign(const SrsRtpExtensions& h)
|
||||
{
|
||||
has_ext_ = h.has_ext_;
|
||||
types_ = h.types_;
|
||||
|
||||
if (has_ext_) {
|
||||
twcc_.assign(h.twcc_);
|
||||
audio_level_.assign(h.audio_level_);
|
||||
}
|
||||
}
|
||||
|
||||
srs_error_t SrsRtpExtensions::decode(SrsBuffer* buf)
|
||||
|
@ -583,6 +608,27 @@ void SrsRtpHeader::reset()
|
|||
//memset(csrc, 0, sizeof(csrc));
|
||||
}
|
||||
|
||||
void SrsRtpHeader::assign(const SrsRtpHeader& h)
|
||||
{
|
||||
// Reset the fields in protocol.
|
||||
cc = h.cc;
|
||||
marker = h.marker;
|
||||
payload_type = h.payload_type;
|
||||
sequence = h.sequence;
|
||||
timestamp = h.timestamp;
|
||||
ssrc = h.ssrc;
|
||||
|
||||
// Reset the parsed fields.
|
||||
padding_length = h.padding_length;
|
||||
extensions_.assign(h.extensions_);
|
||||
|
||||
// Reset other fields.
|
||||
ignore_padding_ = h.ignore_padding_;
|
||||
|
||||
// The CSRC is not used yet, so we never reset it.
|
||||
//memcpy(csrc, h.csrc, sizeof(csrc));
|
||||
}
|
||||
|
||||
srs_error_t SrsRtpHeader::decode(SrsBuffer* buf)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
@ -948,7 +994,7 @@ SrsRtpPacket2* SrsRtpPacket2::copy()
|
|||
cp->recycle_shared_msg();
|
||||
}
|
||||
|
||||
cp->header = header;
|
||||
cp->header.assign(header);
|
||||
cp->payload_ = payload_? payload_->copy():NULL;
|
||||
cp->payload_type_ = payload_type_;
|
||||
|
||||
|
|
|
@ -140,13 +140,13 @@ public:
|
|||
public:
|
||||
// Reset the object to reuse it.
|
||||
void reset();
|
||||
|
||||
void assign(const SrsRtpExtensionTwcc& h);
|
||||
public:
|
||||
bool has_twcc_ext();
|
||||
uint8_t get_id();
|
||||
void set_id(uint8_t id);
|
||||
uint16_t get_sn();
|
||||
void set_sn(uint16_t sn);
|
||||
|
||||
public:
|
||||
// ISrsCodec
|
||||
virtual srs_error_t decode(SrsBuffer* buf);
|
||||
|
@ -166,7 +166,8 @@ public:
|
|||
public:
|
||||
// Reset the object to reuse it.
|
||||
void reset();
|
||||
|
||||
void assign(const SrsRtpExtensionOneByte& h);
|
||||
public:
|
||||
bool exists() { return has_ext_; }
|
||||
int get_id() { return id_; }
|
||||
uint8_t get_value() { return value_; }
|
||||
|
@ -197,6 +198,7 @@ public:
|
|||
public:
|
||||
// Reset the object to reuse it.
|
||||
void reset();
|
||||
void assign(const SrsRtpExtensions& h);
|
||||
public:
|
||||
bool exists();
|
||||
void set_types_(SrsRtpExtensionTypes* types);
|
||||
|
@ -234,6 +236,7 @@ public:
|
|||
public:
|
||||
// Reset the object to reuse it.
|
||||
void reset();
|
||||
void assign(const SrsRtpHeader& h);
|
||||
public:
|
||||
virtual srs_error_t decode(SrsBuffer* buf);
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue