ossrs / srs

SRS is a simple, high-efficiency, real-time media server supporting RTMP, WebRTC, HLS, HTTP-FLV, HTTP-TS, SRT, MPEG-DASH, and GB28181.
https://ossrs.io
MIT License
25.47k stars 5.35k forks source link

WebRTC: playing before publishing #3790

Closed w41203208 closed 6 months ago

w41203208 commented 1 year ago

player before publisher in webrtc

Why happen problem when I playing before publishing on Unity platform, but on the website platform don't hanppen

  1. SRS Version: I use development branch

Problem

  1. if streamUrl haven't be used, situation of player before publisher won't show screen at player but I am sure that pkt has passed to player consumer
  2. if streamUrl have be used above situation will not happen and successfully show screen on player
  3. Unity platform will happne this problem but website no.
DannisMa commented 1 year ago

I have same issue,too.

w41203208 commented 1 year ago

I have fixed this problem. Thank you!

winlinvip commented 1 year ago

How did you fix it? Could you share the details?

TRANS_BY_GPT4

w41203208 commented 1 year ago

I find that pkt pt no change to player track pt to in SrsRtcVideoSendTrack and SrsRtcAudioSendTrack on_rtp function, if player before publisher is happened.

Because below condition is no match, I do checking SrsSource and change player track media pt_of_publisher to be SrsSource pulisher's track media pt which is same ssrc with player track. Ensure below condition has excuted.

// Should update PT, because subscriber may use different PT to publisher.
    if (track_desc_->media_ && pkt->header.get_payload_type() == track_desc_->media_->pt_of_publisher_) {
        // If PT is media from publisher, change to PT of media for subscriber.
        pkt->header.set_payload_type(track_desc_->media_->pt_);
    } else if (track_desc_->red_ && pkt->header.get_payload_type() == track_desc_->red_->pt_of_publisher_) {
        // If PT is RED from publisher, change to PT of RED for subscriber.
        pkt->header.set_payload_type(track_desc_->red_->pt_);
    } else {
        // TODO: FIXME: Should update PT for RTX.
    }

This is my temporary solution. And it can work.

SZ937GroupMaster commented 9 months ago

Has this issue been resolved?

winlinvip commented 6 months ago

Should have been fixed.