mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Refactor for performance
This commit is contained in:
parent
cac5bbddf6
commit
54b6a9faa7
1 changed files with 8 additions and 2 deletions
|
@ -885,6 +885,9 @@ srs_error_t SrsRtcSenderThread::send_packets(SrsRtcPackets& packets)
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// Cache the encrypt flag.
|
||||
bool encrypt = rtc_session->encrypt;
|
||||
|
||||
int nn_packets = packets.size();
|
||||
for (int i = 0; i < nn_packets; i++) {
|
||||
SrsRtpPacket2* packet = packets.at(i);
|
||||
|
@ -915,7 +918,7 @@ srs_error_t SrsRtcSenderThread::send_packets(SrsRtcPackets& packets)
|
|||
}
|
||||
|
||||
// Whether encrypt the RTP bytes.
|
||||
if (rtc_session->encrypt) {
|
||||
if (encrypt) {
|
||||
int nn_encrypt = (int)iov->iov_len;
|
||||
if ((err = rtc_session->dtls_session->protect_rtp2(iov->iov_base, &nn_encrypt)) != srs_success) {
|
||||
return srs_error_wrap(err, "srtp protect");
|
||||
|
@ -947,6 +950,9 @@ srs_error_t SrsRtcSenderThread::send_packets_gso(SrsRtcPackets& packets)
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// Cache the encrypt flag.
|
||||
bool encrypt = rtc_session->encrypt;
|
||||
|
||||
// Previous handler, if has the same size, we can use GSO.
|
||||
mmsghdr* gso_mhdr = NULL; int gso_size = 0; int gso_encrypt = 0; int gso_cursor = 0;
|
||||
// GSO, N packets has same length, the final one may not.
|
||||
|
@ -1056,7 +1062,7 @@ srs_error_t SrsRtcSenderThread::send_packets_gso(SrsRtcPackets& packets)
|
|||
}
|
||||
|
||||
// Whether encrypt the RTP bytes.
|
||||
if (rtc_session->encrypt) {
|
||||
if (encrypt) {
|
||||
int nn_encrypt = (int)iov->iov_len;
|
||||
if ((err = rtc_session->dtls_session->protect_rtp2(iov->iov_base, &nn_encrypt)) != srs_success) {
|
||||
return srs_error_wrap(err, "srtp protect");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue