mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 20:27:34 +08:00
修复webrtc纯音频推流时不能注册流的bug:#963
This commit is contained in:
parent
039be5444e
commit
6220db77e8
@ -1034,15 +1034,17 @@ string RtcSession::toRtspSdp() const{
|
|||||||
switch (m.type) {
|
switch (m.type) {
|
||||||
case TrackAudio:
|
case TrackAudio:
|
||||||
case TrackVideo: {
|
case TrackVideo: {
|
||||||
copy.media.emplace_back(m);
|
if (m.direction != RtpDirection::inactive) {
|
||||||
copy.media.back().plan.resize(1);
|
copy.media.emplace_back(m);
|
||||||
|
copy.media.back().plan.resize(1);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default: continue;
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CHECK(!copy.media.empty());
|
||||||
auto sdp = copy.toRtcSessionSdp();
|
auto sdp = copy.toRtcSessionSdp();
|
||||||
toRtsp(sdp->items);
|
toRtsp(sdp->items);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -1368,6 +1370,18 @@ bool RtcSession::supportRtcpFb(const string &name, TrackType type) const {
|
|||||||
return ref.find(name) != ref.end();
|
return ref.find(name) != ref.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RtcSession::supportSimulcast() const {
|
||||||
|
for (auto &m : media) {
|
||||||
|
if (!m.rtp_rids.empty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!m.rtp_ssrc_sim.empty()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
string const SdpConst::kTWCCRtcpFb = "transport-cc";
|
string const SdpConst::kTWCCRtcpFb = "transport-cc";
|
||||||
string const SdpConst::kRembRtcpFb = "goog-remb";
|
string const SdpConst::kRembRtcpFb = "goog-remb";
|
||||||
|
|
||||||
|
@ -673,6 +673,7 @@ public:
|
|||||||
const RtcMedia *getMedia(TrackType type) const;
|
const RtcMedia *getMedia(TrackType type) const;
|
||||||
bool haveSSRC() const;
|
bool haveSSRC() const;
|
||||||
bool supportRtcpFb(const string &name, TrackType type = TrackType::TrackVideo) const;
|
bool supportRtcpFb(const string &name, TrackType type = TrackType::TrackVideo) const;
|
||||||
|
bool supportSimulcast() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RtcSessionSdp::Ptr toRtcSessionSdp() const;
|
RtcSessionSdp::Ptr toRtcSessionSdp() const;
|
||||||
|
@ -448,6 +448,7 @@ void WebRtcTransportImp::onStartWebRTC() {
|
|||||||
|
|
||||||
if (canRecvRtp()) {
|
if (canRecvRtp()) {
|
||||||
_push_src->setSdp(getSdp(SdpType::answer).toRtspSdp());
|
_push_src->setSdp(getSdp(SdpType::answer).toRtspSdp());
|
||||||
|
_simulcast = getSdp(SdpType::answer).supportSimulcast();
|
||||||
}
|
}
|
||||||
if (canSendRtp()) {
|
if (canSendRtp()) {
|
||||||
_reader = _play_src->getRing()->attach(getPoller(), true);
|
_reader = _play_src->getRing()->attach(getPoller(), true);
|
||||||
@ -794,25 +795,29 @@ void WebRtcTransportImp::onSortedRtp(MediaTrack &track, const string &rid, RtpPa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_push_src) {
|
if (!_simulcast) {
|
||||||
if (rtp->type == TrackAudio) {
|
assert(_push_src);
|
||||||
//音频
|
_push_src->onWrite(rtp, false);
|
||||||
for (auto &pr : _push_src_simulcast) {
|
return;
|
||||||
pr.second->onWrite(rtp, false);
|
}
|
||||||
}
|
|
||||||
} else {
|
if (rtp->type == TrackAudio) {
|
||||||
//视频
|
//音频
|
||||||
auto &src = _push_src_simulcast[rid];
|
for (auto &pr : _push_src_simulcast) {
|
||||||
if (!src) {
|
pr.second->onWrite(rtp, false);
|
||||||
auto stream_id = rid.empty() ? _push_src->getId() : _push_src->getId() + "_" + rid;
|
|
||||||
auto src_imp = std::make_shared<RtspMediaSourceImp>(_push_src->getVhost(), _push_src->getApp(), stream_id);
|
|
||||||
src_imp->setSdp(_push_src->getSdp());
|
|
||||||
src_imp->setProtocolTranslation(_push_src->isRecording(Recorder::type_hls),_push_src->isRecording(Recorder::type_mp4));
|
|
||||||
src_imp->setListener(shared_from_this());
|
|
||||||
src = src_imp;
|
|
||||||
}
|
|
||||||
src->onWrite(std::move(rtp), false);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
//视频
|
||||||
|
auto &src = _push_src_simulcast[rid];
|
||||||
|
if (!src) {
|
||||||
|
auto stream_id = rid.empty() ? _push_src->getId() : _push_src->getId() + "_" + rid;
|
||||||
|
auto src_imp = std::make_shared<RtspMediaSourceImp>(_push_src->getVhost(), _push_src->getApp(), stream_id);
|
||||||
|
src_imp->setSdp(_push_src->getSdp());
|
||||||
|
src_imp->setProtocolTranslation(_push_src->isRecording(Recorder::type_hls),_push_src->isRecording(Recorder::type_mp4));
|
||||||
|
src_imp->setListener(shared_from_this());
|
||||||
|
src = src_imp;
|
||||||
|
}
|
||||||
|
src->onWrite(std::move(rtp), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -901,7 +906,7 @@ int WebRtcTransportImp::totalReaderCount(MediaSource &sender) {
|
|||||||
for (auto &src : _push_src_simulcast) {
|
for (auto &src : _push_src_simulcast) {
|
||||||
total_count += src.second->totalReaderCount();
|
total_count += src.second->totalReaderCount();
|
||||||
}
|
}
|
||||||
return total_count;
|
return total_count + _push_src->totalReaderCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaOriginType WebRtcTransportImp::getOriginType(MediaSource &sender) const {
|
MediaOriginType WebRtcTransportImp::getOriginType(MediaSource &sender) const {
|
||||||
|
@ -219,6 +219,7 @@ private:
|
|||||||
void createRtpChannel(const string &rid, uint32_t ssrc, const MediaTrack::Ptr &track);
|
void createRtpChannel(const string &rid, uint32_t ssrc, const MediaTrack::Ptr &track);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool _simulcast = false;
|
||||||
uint16_t _rtx_seq[2] = {0, 0};
|
uint16_t _rtx_seq[2] = {0, 0};
|
||||||
//用掉的总流量
|
//用掉的总流量
|
||||||
uint64_t _bytes_usage = 0;
|
uint64_t _bytes_usage = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user