mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 20:27:34 +08:00
webrtc是否允许发送rtp逻辑移至基类
This commit is contained in:
parent
93c6754fc4
commit
758f1b414e
@ -33,12 +33,6 @@ void WebRtcPlayer::onStartWebRTC() {
|
||||
CHECK(_play_src);
|
||||
WebRtcTransportImp::onStartWebRTC();
|
||||
if (canSendRtp()) {
|
||||
//确保该rtp codec类型对方支持
|
||||
memset(_can_send_rtp, 0, sizeof(_can_send_rtp));
|
||||
for (auto &m : _answer_sdp->media) {
|
||||
_can_send_rtp[m.type] = m.direction == RtpDirection::sendonly || m.direction == RtpDirection::sendrecv;
|
||||
}
|
||||
|
||||
_play_src->pause(false);
|
||||
_reader = _play_src->getRing()->attach(getPoller(), true);
|
||||
weak_ptr<WebRtcPlayer> weak_self = static_pointer_cast<WebRtcPlayer>(shared_from_this());
|
||||
@ -49,7 +43,7 @@ void WebRtcPlayer::onStartWebRTC() {
|
||||
}
|
||||
size_t i = 0;
|
||||
pkt->for_each([&](const RtpPacket::Ptr &rtp) {
|
||||
strongSelf->beforeSendRtp(rtp, ++i == pkt->size());
|
||||
strongSelf->onSendRtp(rtp, ++i == pkt->size());
|
||||
});
|
||||
});
|
||||
_reader->setDetachCB([weak_self]() {
|
||||
@ -91,10 +85,3 @@ void WebRtcPlayer::onRtcConfigure(RtcConfigure &configure) const {
|
||||
configure.audio.direction = configure.video.direction = RtpDirection::sendonly;
|
||||
configure.setPlayRtspInfo(_play_src->getSdp());
|
||||
}
|
||||
|
||||
void WebRtcPlayer::beforeSendRtp(const RtpPacket::Ptr &rtp, bool flush, bool rtx) {
|
||||
if (!_can_send_rtp[rtp->type]) {
|
||||
return;
|
||||
}
|
||||
onSendRtp(rtp, flush, rtx);
|
||||
}
|
||||
|
@ -28,10 +28,8 @@ protected:
|
||||
|
||||
private:
|
||||
WebRtcPlayer(const EventPoller::Ptr &poller, const RtspMediaSource::Ptr &src, const MediaInfo &info);
|
||||
void beforeSendRtp(const RtpPacket::Ptr &rtp, bool flush, bool rtx = false);
|
||||
|
||||
private:
|
||||
bool _can_send_rtp[TrackMax];
|
||||
//媒体相关元数据
|
||||
MediaInfo _media_info;
|
||||
//播放的rtsp源
|
||||
|
@ -372,7 +372,10 @@ void WebRtcTransportImp::onStartWebRTC() {
|
||||
track->rtcp_context_send = std::make_shared<RtcpContextForSend>();
|
||||
|
||||
//rtp track type --> MediaTrack
|
||||
_type_to_track[m_answer.type] = track;
|
||||
if (m_answer.direction == RtpDirection::sendonly || m_answer.direction == RtpDirection::sendrecv) {
|
||||
//该类型的track 才支持发送
|
||||
_type_to_track[m_answer.type] = track;
|
||||
}
|
||||
//send ssrc --> MediaTrack
|
||||
_ssrc_to_track[track->answer_ssrc_rtp] = track;
|
||||
_ssrc_to_track[track->answer_ssrc_rtx] = track;
|
||||
|
Loading…
Reference in New Issue
Block a user