Merge branch 'master' of https://gitee.com/xia-chu/ZLMediaKit into dev

This commit is contained in:
xia-chu 2021-04-12 13:48:34 +08:00
commit 46b84fcf39
6 changed files with 29 additions and 9 deletions

View File

@ -13,7 +13,7 @@
## 项目特点 ## 项目特点
- 基于C++11开发避免使用裸指针代码稳定可靠性能优越。 - 基于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模式开发并发性能优越支持海量客户端连接。 - 使用多路复用/多线程/异步网络IO模式开发并发性能优越支持海量客户端连接。
- 代码经过长期大量的稳定性、性能测试,已经在线上商用验证已久。 - 代码经过长期大量的稳定性、性能测试,已经在线上商用验证已久。
- 支持linux、macos、ios、android、windows全平台。 - 支持linux、macos、ios、android、windows全平台。
@ -33,7 +33,7 @@
## 功能清单 ## 功能清单
### 功能一览 ### 功能一览
<img width="800" alt="图片" src="https://user-images.githubusercontent.com/11495632/102689561-09824200-423a-11eb-9cf9-b39d1378ef68.png"> <img width="800" alt="功能一览" src="https://user-images.githubusercontent.com/11495632/114176523-d50fce80-996d-11eb-81f8-0a2e2715ba7b.png">
- RTSP[S] - RTSP[S]
- RTSP[S] 服务器支持RTMP/MP4/HLS转RTSP[S],支持亚马逊echo show这样的设备 - RTSP[S] 服务器支持RTMP/MP4/HLS转RTSP[S],支持亚马逊echo show这样的设备
@ -92,6 +92,10 @@
- RTSP/RTMP/HTTP-FLV/WS-FLV支持MP4文件点播支持seek - RTSP/RTMP/HTTP-FLV/WS-FLV支持MP4文件点播支持seek
- 支持H264/H265/AAC/G711/OPUS编码 - 支持H264/H265/AAC/G711/OPUS编码
- WebRTC(体验,请使用dev分支)
- 支持WebRTC推流支持转其他协议
- 支持WebRTC播放支持其他协议转WebRTC
- 其他 - 其他
- 支持丰富的restful api以及web hook事件 - 支持丰富的restful api以及web hook事件
- 支持简单的telnet调试 - 支持简单的telnet调试

View File

@ -11,7 +11,7 @@
## Why ZLMediaKit? ## 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. - 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 threadextreme performance. - Multiplexing asynchronous network IO based on epoll and multi threadextreme performance.
- Well performance and stable test,can be used commercially. - Well performance and stable test,can be used commercially.
- Support linux, macos, ios, android, Windows Platforms. - Support linux, macos, ios, android, Windows Platforms.
@ -55,6 +55,10 @@
- WebSocket Server and Client. - WebSocket Server and Client.
- File access authentication. - 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 - Others
- Support stream proxy by ffmpeg. - Support stream proxy by ffmpeg.
- RESTful http api and http hook event api. - RESTful http api and http hook event api.

View File

@ -303,7 +303,7 @@ Value makeMediaSourceJson(MediaSource &media){
item["originSock"] = Json::nullValue; item["originSock"] = Json::nullValue;
} }
for(auto &track : media.getTracks()){ for(auto &track : media.getTracks(false)){
Value obj; Value obj;
auto codec_type = track->getTrackType(); auto codec_type = track->getTrackType();
obj["codec_id"] = track->getCodecId(); obj["codec_id"] = track->getCodecId();

View File

@ -301,14 +301,15 @@ void installWebHook(){
return; return;
} }
ArgsType body; ArgsType body;
body["regist"] = bRegist;
if (bRegist) { if (bRegist) {
body = makeMediaSourceJson(sender); body = makeMediaSourceJson(sender);
body["regist"] = bRegist;
} else { } else {
body["schema"] = sender.getSchema(); body["schema"] = sender.getSchema();
body["vhost"] = sender.getVhost(); body["vhost"] = sender.getVhost();
body["app"] = sender.getApp(); body["app"] = sender.getApp();
body["stream"] = sender.getId(); body["stream"] = sender.getId();
body["regist"] = bRegist;
} }
//执行hook //执行hook
do_http_hook(hook_stream_chaned,body, nullptr); do_http_hook(hook_stream_chaned,body, nullptr);

View File

@ -53,12 +53,22 @@ bool RtpReceiver::handleOneRtp(int index, TrackType type, int sample_rate, uint8
auto ssrc = ntohl(header->ssrc); auto ssrc = ntohl(header->ssrc);
if (!_ssrc[index]) { if (!_ssrc[index]) {
//保存SSRC至track对象 //记录并锁定ssrc
_ssrc[index] = 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错误 //ssrc错误
WarnL << "ssrc错误:" << ssrc << " != " << _ssrc[index]; if (_ssrc_alive[index].elapsedTime() < 10 * 1000) {
return false; //接受正确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(); auto rtp = RtpPacket::create();

View File

@ -198,6 +198,7 @@ protected:
private: private:
uint32_t _ssrc[2] = {0, 0}; uint32_t _ssrc[2] = {0, 0};
Ticker _ssrc_alive[2];
//rtp排序缓存根据seq排序 //rtp排序缓存根据seq排序
PacketSortor<RtpPacket::Ptr> _rtp_sortor[2]; PacketSortor<RtpPacket::Ptr> _rtp_sortor[2];
}; };