mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 19:00:01 +08:00
46842e6f29
因WebRtcPlayer中使用RtspMediaSource的共享指针,特定情况下引起媒体注销无法触发的问题。 - 重现步骤 在ZL的webrtc demo页面推流 浏览器打开如下html webrtc.html 关闭推流器页面,推流器停止推流 webrtc.htm浏览器console->network将观察到:即使推流停止,但webrtc sdp请求一直能成功获取sdp,且流媒体一直不注销 - 原因 因为每个WebRtc 播放 SDP请求都会产生 WebRtcPlayer,产生RtspMediaSource的共享指针,产生强引用。 而DTLS超时释放需要一定的时间,WebRtcPlayer销毁需要超时。如果请求sdp的时间足够短,强引用会一直存在。将永远无法触发媒体注销 - 场景 webrtc播放存在重试,但是udp不通。DTLS无法创建 有人对ZLM执行恶意攻击,短时间内不断请求SDP但是不建立WebRTC通信
46 lines
1.5 KiB
C++
46 lines
1.5 KiB
C++
/*
|
|
* Copyright (c) 2016 The ZLMediaKit project authors. All Rights Reserved.
|
|
*
|
|
* This file is part of ZLMediaKit(https://github.com/xia-chu/ZLMediaKit).
|
|
*
|
|
* Use of this source code is governed by MIT license that can be found in the
|
|
* LICENSE file in the root of the source tree. All contributing project authors
|
|
* may be found in the AUTHORS file in the root of the source tree.
|
|
*/
|
|
|
|
#ifndef ZLMEDIAKIT_WEBRTCPLAYER_H
|
|
#define ZLMEDIAKIT_WEBRTCPLAYER_H
|
|
|
|
#include "WebRtcTransport.h"
|
|
#include "Rtsp/RtspMediaSource.h"
|
|
|
|
namespace mediakit {
|
|
|
|
class WebRtcPlayer : public WebRtcTransportImp {
|
|
public:
|
|
using Ptr = std::shared_ptr<WebRtcPlayer>;
|
|
~WebRtcPlayer() override = default;
|
|
static Ptr create(const EventPoller::Ptr &poller, const RtspMediaSource::Ptr &src, const MediaInfo &info, bool preferred_tcp = false);
|
|
|
|
protected:
|
|
///////WebRtcTransportImp override///////
|
|
void onStartWebRTC() override;
|
|
void onDestory() override;
|
|
void onRtcConfigure(RtcConfigure &configure) const override;
|
|
void onRecvRtp(MediaTrack &track, const std::string &rid, RtpPacket::Ptr rtp) override {};
|
|
|
|
private:
|
|
WebRtcPlayer(const EventPoller::Ptr &poller, const RtspMediaSource::Ptr &src, const MediaInfo &info, bool preferred_tcp);
|
|
|
|
private:
|
|
//媒体相关元数据
|
|
MediaInfo _media_info;
|
|
//播放的rtsp源
|
|
std::weak_ptr<RtspMediaSource> _play_src;
|
|
//播放rtsp源的reader对象
|
|
RtspMediaSource::RingType::RingReader::Ptr _reader;
|
|
};
|
|
|
|
}// namespace mediakit
|
|
#endif // ZLMEDIAKIT_WEBRTCPLAYER_H
|