diff --git a/README.md b/README.md index 73ba90eb..1322dfa5 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ ## 项目特点 - 基于C++11开发,避免使用裸指针,代码稳定可靠,性能优越。 -- 支持多种协议(RTSP/RTMP/HLS/HTTP-FLV/WebSocket-FLV/GB28181/HTTP-TS/WebSocket-TS/HTTP-fMP4/WebSocket-fMP4/MP4),支持协议互转。 +- 支持多种协议(RTSP/RTMP/HLS/HTTP-FLV/WebSocket-FLV/GB28181/HTTP-TS/WebSocket-TS/HTTP-fMP4/WebSocket-fMP4/MP4/WebRTC),支持协议互转。 - 使用多路复用/多线程/异步网络IO模式开发,并发性能优越,支持海量客户端连接。 - 代码经过长期大量的稳定性、性能测试,已经在线上商用验证已久。 - 支持linux、macos、ios、android、windows全平台。 @@ -33,7 +33,7 @@ ## 功能清单 ### 功能一览 -图片 +功能一览 - RTSP[S] - RTSP[S] 服务器,支持RTMP/MP4/HLS转RTSP[S],支持亚马逊echo show这样的设备 @@ -92,6 +92,10 @@ - RTSP/RTMP/HTTP-FLV/WS-FLV支持MP4文件点播,支持seek - 支持H264/H265/AAC/G711/OPUS编码 +- WebRTC(体验,请使用dev分支) + - 支持WebRTC推流,支持转其他协议 + - 支持WebRTC播放,支持其他协议转WebRTC + - 其他 - 支持丰富的restful api以及web hook事件 - 支持简单的telnet调试 diff --git a/README_en.md b/README_en.md index a89d0ded..b37074c3 100644 --- a/README_en.md +++ b/README_en.md @@ -11,7 +11,7 @@ ## Why ZLMediaKit? - Developed based on C++ 11, the code is stable and reliable, avoiding the use of raw pointers, cross-platform porting is simple and convenient, and the code is clear and concise. -- Support rich streaming media protocols(`RTSP/RTMP/HLS/HTTP-FLV/WebSocket-flv/HTTP-TS/WebSocket-TS/HTTP-fMP4/Websocket-fMP4/MP4`),and support Inter-protocol conversion. +- Support rich streaming media protocols(`RTSP/RTMP/HLS/HTTP-FLV/WebSocket-flv/HTTP-TS/WebSocket-TS/HTTP-fMP4/Websocket-fMP4/MP4/WebRTC`),and support Inter-protocol conversion. - Multiplexing asynchronous network IO based on epoll and multi thread,extreme performance. - Well performance and stable test,can be used commercially. - Support linux, macos, ios, android, Windows Platforms. @@ -55,6 +55,10 @@ - WebSocket Server and Client. - File access authentication. +- WebRTC(experiential, dev branch) + - Support webrtc push stream and transfer to other protocols + - Support webrtc play, support other protocol to webrtc + - Others - Support stream proxy by ffmpeg. - RESTful http api and http hook event api. diff --git a/server/WebApi.cpp b/server/WebApi.cpp index 7d69df6a..aae6380c 100755 --- a/server/WebApi.cpp +++ b/server/WebApi.cpp @@ -303,7 +303,7 @@ Value makeMediaSourceJson(MediaSource &media){ item["originSock"] = Json::nullValue; } - for(auto &track : media.getTracks()){ + for(auto &track : media.getTracks(false)){ Value obj; auto codec_type = track->getTrackType(); obj["codec_id"] = track->getCodecId(); diff --git a/server/WebHook.cpp b/server/WebHook.cpp index 1bd47ffb..d1df3308 100755 --- a/server/WebHook.cpp +++ b/server/WebHook.cpp @@ -301,14 +301,15 @@ void installWebHook(){ return; } ArgsType body; - body["regist"] = bRegist; if (bRegist) { body = makeMediaSourceJson(sender); + body["regist"] = bRegist; } else { body["schema"] = sender.getSchema(); body["vhost"] = sender.getVhost(); body["app"] = sender.getApp(); body["stream"] = sender.getId(); + body["regist"] = bRegist; } //执行hook do_http_hook(hook_stream_chaned,body, nullptr); diff --git a/src/Rtsp/RtpReceiver.cpp b/src/Rtsp/RtpReceiver.cpp index 711ce9e8..c33c2b5a 100644 --- a/src/Rtsp/RtpReceiver.cpp +++ b/src/Rtsp/RtpReceiver.cpp @@ -53,12 +53,22 @@ bool RtpReceiver::handleOneRtp(int index, TrackType type, int sample_rate, uint8 auto ssrc = ntohl(header->ssrc); if (!_ssrc[index]) { - //保存SSRC至track对象 + //记录并锁定ssrc _ssrc[index] = ssrc; - } else if (_ssrc[index] != ssrc) { + _ssrc_alive[index].resetTime(); + } else if (_ssrc[index] == ssrc) { + //ssrc匹配正确,刷新计时器 + _ssrc_alive[index].resetTime(); + } else { //ssrc错误 - WarnL << "ssrc错误:" << ssrc << " != " << _ssrc[index]; - return false; + if (_ssrc_alive[index].elapsedTime() < 10 * 1000) { + //接受正确ssrc的rtp在10秒内,那么我们认为存在多路rtp,忽略掉ssrc不匹配的rtp + WarnL << "ssrc比匹配,rtp已丢弃:" << ssrc << " != " << _ssrc[index]; + return false; + } + InfoL << "rtp流ssrc切换:" << _ssrc[index] << " -> " << ssrc; + _ssrc[index] = ssrc; + _ssrc_alive[index].resetTime(); } auto rtp = RtpPacket::create(); diff --git a/src/Rtsp/RtpReceiver.h b/src/Rtsp/RtpReceiver.h index 99cba9d3..f8d2fde9 100644 --- a/src/Rtsp/RtpReceiver.h +++ b/src/Rtsp/RtpReceiver.h @@ -198,6 +198,7 @@ protected: private: uint32_t _ssrc[2] = {0, 0}; + Ticker _ssrc_alive[2]; //rtp排序缓存,根据seq排序 PacketSortor _rtp_sortor[2]; };