Skip to content
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

WebRTC: Fix no audio and video issue for Firefox. #3079

Merged
merged 6 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions trunk/src/app/srs_app_rtc_source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,17 @@ srs_error_t SrsRtcSource::on_timer(srs_utime_t interval)
}

#ifdef SRS_FFMPEG_FIT

inline uint8_t srs_parse_video_payload_type_from(const std::vector<SrsRtcTrackDescription*>& descs) {
if (descs.empty()) {
return kVideoPayloadType;
}

SrsCodecPayload* media_ = descs.front()->media_;
assert(media_->pt_ == media_->pt_of_publisher_);
winlinvip marked this conversation as resolved.
Show resolved Hide resolved
return media_->pt_;
}

SrsRtcFromRtmpBridge::SrsRtcFromRtmpBridge(SrsRtcSource* source)
{
req = NULL;
Expand Down Expand Up @@ -737,6 +748,9 @@ SrsRtcFromRtmpBridge::SrsRtcFromRtmpBridge(SrsRtcSource* source)
if (!descs.empty()) {
video_ssrc = descs.at(0)->ssrc_;
}

// Note we must use the PT of source, see https://github.com/ossrs/srs/pull/3079
video_payload_type_ = srs_parse_video_payload_type_from(descs);
}
}

Expand Down Expand Up @@ -1054,7 +1068,7 @@ srs_error_t SrsRtcFromRtmpBridge::package_stap_a(SrsRtcSource* source, SrsShared
return srs_error_new(ERROR_RTC_RTP_MUXER, "sps/pps empty");
}

pkt->header.set_payload_type(kVideoPayloadType);
pkt->header.set_payload_type(video_payload_type_);
pkt->header.set_ssrc(video_ssrc);
pkt->frame_type = SrsFrameTypeVideo;
pkt->nalu_type = (SrsAvcNaluType)kStapA;
Expand Down Expand Up @@ -1136,7 +1150,7 @@ srs_error_t SrsRtcFromRtmpBridge::package_nalus(SrsSharedPtrMessage* msg, const
SrsRtpPacket* pkt = new SrsRtpPacket();
pkts.push_back(pkt);

pkt->header.set_payload_type(kVideoPayloadType);
pkt->header.set_payload_type(video_payload_type_);
pkt->header.set_ssrc(video_ssrc);
pkt->frame_type = SrsFrameTypeVideo;
pkt->nalu_type = (SrsAvcNaluType)first_nalu_type;
Expand Down Expand Up @@ -1170,7 +1184,7 @@ srs_error_t SrsRtcFromRtmpBridge::package_nalus(SrsSharedPtrMessage* msg, const
SrsRtpPacket* pkt = new SrsRtpPacket();
pkts.push_back(pkt);

pkt->header.set_payload_type(kVideoPayloadType);
pkt->header.set_payload_type(video_payload_type_);
pkt->header.set_ssrc(video_ssrc);
pkt->frame_type = SrsFrameTypeVideo;
pkt->nalu_type = (SrsAvcNaluType)kFuA;
Expand Down Expand Up @@ -1200,7 +1214,7 @@ srs_error_t SrsRtcFromRtmpBridge::package_single_nalu(SrsSharedPtrMessage* msg,
SrsRtpPacket* pkt = new SrsRtpPacket();
pkts.push_back(pkt);

pkt->header.set_payload_type(kVideoPayloadType);
pkt->header.set_payload_type(video_payload_type_);
pkt->header.set_ssrc(video_ssrc);
pkt->frame_type = SrsFrameTypeVideo;
pkt->header.set_sequence(video_sequence++);
Expand Down Expand Up @@ -1233,7 +1247,7 @@ srs_error_t SrsRtcFromRtmpBridge::package_fu_a(SrsSharedPtrMessage* msg, SrsSamp
SrsRtpPacket* pkt = new SrsRtpPacket();
pkts.push_back(pkt);

pkt->header.set_payload_type(kVideoPayloadType);
pkt->header.set_payload_type(video_payload_type_);
pkt->header.set_ssrc(video_ssrc);
pkt->frame_type = SrsFrameTypeVideo;
pkt->header.set_sequence(video_sequence++);
Expand Down
2 changes: 2 additions & 0 deletions trunk/src/app/srs_app_rtc_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ class SrsRtcFromRtmpBridge : public ISrsLiveSourceBridge
uint16_t video_sequence;
uint32_t audio_ssrc;
uint32_t video_ssrc;

uint8_t video_payload_type_;
public:
SrsRtcFromRtmpBridge(SrsRtcSource* source);
virtual ~SrsRtcFromRtmpBridge();
Expand Down