Skip to content

RTC: audio packet jitter buffer. #4295

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

chundonglinlin
Copy link
Member

Rtp packets may be retransmitted, disordered, jittery, delayed, etc.There may be abnormalities when converting to rtmp.

@winlinvip winlinvip added the EnglishNative This issue is conveyed exclusively in English. label Feb 22, 2025
// If packet is beyond window end, stop processing
srs_warn("Audio packet beyond window end, seq=%u, window_end=%u", next_seq, window_end);
break;
} else if (srs_rtp_seq_distance(last_audio_seq_num_, next_seq) > 1) {// If there's a gap and we haven't exceeded wait time, wait for missing packets
Copy link
Member

@duiniuluantanqin duiniuluantanqin Feb 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// If there's a gap and we haven't exceeded wait time, wait for missing packets
This comment has been duplicated.

TRANS_BY_GPT4

@@ -335,6 +342,13 @@ class SrsRtcFrameBuilder
uint16_t header_sn_;
uint16_t lost_sn_;
int64_t rtp_key_frame_ts_;

// Audio jitter buffer, map sequence number to packet
std::map<uint16_t, SrsRtpPacket*> audio_buffer_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obviously, the audio jitter buffer should be a class with its own fields and behaviors, rather than being directly exposed and mixed with the SrsRtcFrameBuilder code.

    // Audio jitter buffer, map sequence number to packet
    std::map<uint16_t, SrsRtpPacket*> audio_buffer_;
    // Last processed sequence number
    uint16_t last_audio_seq_num_;
    // Last time we processed the jitter buffer
    int64_t last_audio_process_time_ms_;

@@ -335,6 +342,13 @@ class SrsRtcFrameBuilder
uint16_t header_sn_;
uint16_t lost_sn_;
int64_t rtp_key_frame_ts_;

// Audio jitter buffer, map sequence number to packet
std::map<uint16_t, SrsRtpPacket*> audio_buffer_;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that the audio buffer is similar to SrsRtpRingBuffer; please consider whether you can use it directly.

@winlinvip winlinvip force-pushed the develop branch 2 times, most recently from 195435d to 97e2b64 Compare July 1, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EnglishNative This issue is conveyed exclusively in English.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants