From b180ea060900f463c23077cba55d2605b9e3c526 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Fri, 9 Apr 2021 20:42:05 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/main.cpp | 148 ------------------------------------------------ 1 file changed, 148 deletions(-) diff --git a/server/main.cpp b/server/main.cpp index fdba471d..4bbf189f 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -210,153 +210,6 @@ static void inline listen_shell_input(){ //全局变量,在WebApi中用于保存配置文件用 string g_ini_file; - -void test_sdp(){ - char str1[] = "v=0\n" - "o=- 380154348540553537 2 IN IP4 127.0.0.1\n" - "s=-\n" - "b=CT:1900\n" - "t=0 0\n" - "a=group:BUNDLE video\n" - "a=msid-semantic: WMS\n" - "m=video 9 RTP/SAVPF 96\n" - "c=IN IP4 0.0.0.0\n" - "a=rtcp:9 IN IP4 0.0.0.0\n" - "a=ice-ufrag:1ZFN\n" - "a=ice-pwd:70P3H0jPlGz1fiJl5XZfXMZH\n" - "a=ice-options:trickle\n" - "a=fingerprint:sha-256 3E:10:35:6B:9A:9E:B0:55:AC:2A:88:F5:74:C1:70:32:B5:8D:88:1D:37:B0:9C:69:A6:DD:07:10:73:27:1A:16\n" - "a=setup:active\n" - "a=mid:video\n" - "a=recvonly\n" - "a=rtcp-mux\n" - "a=rtpmap:96 H264/90000\n" - "a=fmtp:96 level-asymmetry-allowed=1;packetization-mode=0;profile-level-id=42e01f"; - char str2[] = "v=0\n" - "o=- 2584450093346841581 2 IN IP4 127.0.0.1\n" - "s=-\n" - "t=0 0\n" - "a=group:BUNDLE audio video data\n" - "a=msid-semantic: WMS 616cfbb1-33a3-4d8c-8275-a199d6005549\n" - "m=audio 9 UDP/TLS/RTP/SAVPF 111 103 104 9 0 8 106 105 13 110 112 113 126\n" - "c=IN IP4 0.0.0.0\n" - "a=rtcp:9 IN IP4 0.0.0.0\n" - "a=ice-ufrag:sXJ3\n" - "a=ice-pwd:yEclOTrLg1gEubBFefOqtmyV\n" - "a=fingerprint:sha-256 22:14:B5:AF:66:12:C7:C7:8D:EF:4B:DE:40:25:ED:5D:8F:17:54:DD:88:33:C0:13:2E:FD:1A:FA:7E:7A:1B:79\n" - "a=setup:actpass\n" - "a=mid:audio\n" - "a=extmap:1/sendonly urn:ietf:params:rtp-hdrext:ssrc-audio-level\n" - "a=sendrecv\n" - "a=rtcp-mux\n" - "a=rtpmap:111 opus/48000/2\n" - "a=rtcp-fb:111 transport-cc\n" - "a=fmtp:111 minptime=10;useinbandfec=1\n" - "a=rtpmap:103 ISAC/16000\n" - "a=rtpmap:104 ISAC/32000\n" - "a=rtpmap:9 G722/8000\n" - "a=rtpmap:0 PCMU/8000\n" - "a=rtpmap:8 PCMA/8000\n" - "a=rtpmap:106 CN/32000\n" - "a=rtpmap:105 CN/16000\n" - "a=rtpmap:13 CN/8000\n" - "a=rtpmap:110 telephone-event/48000\n" - "a=rtpmap:112 telephone-event/32000\n" - "a=rtpmap:113 telephone-event/16000\n" - "a=rtpmap:126 telephone-event/8000\n" - "a=ssrc:120276603 cname:iSkJ2vn5cYYubTve\n" - "a=ssrc:120276603 msid:616cfbb1-33a3-4d8c-8275-a199d6005549 1da3d329-7399-4fe9-b20f-69606bebd363\n" - "a=ssrc:120276603 mslabel:616cfbb1-33a3-4d8c-8275-a199d6005549\n" - "a=ssrc:120276603 label:1da3d329-7399-4fe9-b20f-69606bebd363\n" - "m=video 9 UDP/TLS/RTP/SAVPF 96 98 100 102 127 97 99 101 125\n" - "c=IN IP4 0.0.0.0\n" - "a=rtcp:9 IN IP4 0.0.0.0\n" - "a=ice-ufrag:sXJ3\n" - "a=ice-pwd:yEclOTrLg1gEubBFefOqtmyV\n" - "a=fingerprint:sha-256 22:14:B5:AF:66:12:C7:C7:8D:EF:4B:DE:40:25:ED:5D:8F:17:54:DD:88:33:C0:13:2E:FD:1A:FA:7E:7A:1B:79\n" - "a=setup:actpass\n" - "a=mid:video\n" - "a=extmap:2 urn:ietf:params:rtp-hdrext:toffset\n" - "a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\n" - "a=extmap:4 urn:3gpp:video-orientation\n" - "a=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01\n" - "a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay\n" - "a=sendrecv\n" - "a=rtcp-mux\n" - "a=rtcp-rsize\n" - "a=rtpmap:96 VP8/90000\n" - "a=rtcp-fb:96 ccm fir\n" - "a=rtcp-fb:96 nack\n" - "a=rtcp-fb:96 nack pli\n" - "a=rtcp-fb:96 goog-remb\n" - "a=rtcp-fb:96 transport-cc\n" - "a=rtpmap:98 VP9/90000\n" - "a=rtcp-fb:98 ccm fir\n" - "a=rtcp-fb:98 nack\n" - "a=rtcp-fb:98 nack pli\n" - "a=rtcp-fb:98 goog-remb\n" - "a=rtcp-fb:98 transport-cc\n" - "a=rtpmap:100 H264/90000\n" - "a=rtcp-fb:100 ccm fir\n" - "a=rtcp-fb:100 nack\n" - "a=rtcp-fb:100 nack pli\n" - "a=rtcp-fb:100 goog-remb\n" - "a=rtcp-fb:100 transport-cc\n" - "a=fmtp:100 level-asymmetry-allowed=1;packetization-mode=1;profile-level-id=42e01f\n" - "a=rtpmap:102 red/90000\n" - "a=rtpmap:127 ulpfec/90000\n" - "a=rtpmap:97 rtx/90000\n" - "a=fmtp:97 apt=96\n" - "a=rtpmap:99 rtx/90000\n" - "a=fmtp:99 apt=98\n" - "a=rtpmap:101 rtx/90000\n" - "a=fmtp:101 apt=100\n" - "a=rtpmap:125 rtx/90000\n" - "a=fmtp:125 apt=102\n" - "a=ssrc-group:FID 2580761338 611523443\n" - "a=ssrc:2580761338 cname:iSkJ2vn5cYYubTve\n" - "a=ssrc:2580761338 msid:616cfbb1-33a3-4d8c-8275-a199d6005549 bf270496-a23e-47b5-b901-ef23096cd961\n" - "a=ssrc:2580761338 mslabel:616cfbb1-33a3-4d8c-8275-a199d6005549\n" - "a=ssrc:2580761338 label:bf270496-a23e-47b5-b901-ef23096cd961\n" - "a=ssrc:611523443 cname:iSkJ2vn5cYYubTve\n" - "a=ssrc:611523443 msid:616cfbb1-33a3-4d8c-8275-a199d6005549 bf270496-a23e-47b5-b901-ef23096cd961\n" - "a=ssrc:611523443 mslabel:616cfbb1-33a3-4d8c-8275-a199d6005549\n" - "a=ssrc:611523443 label:bf270496-a23e-47b5-b901-ef23096cd961\n" - "a=candidate:3575467457 1 udp 2113937151 10.15.83.23 57857 typ host generation 0 ufrag 6R0z network-cost 999\n" - "m=application 9 DTLS/SCTP 5000\n" - "c=IN IP4 0.0.0.0\n" - "a=ice-ufrag:sXJ3\n" - "a=ice-pwd:yEclOTrLg1gEubBFefOqtmyV\n" - "a=fingerprint:sha-256 22:14:B5:AF:66:12:C7:C7:8D:EF:4B:DE:40:25:ED:5D:8F:17:54:DD:88:33:C0:13:2E:FD:1A:FA:7E:7A:1B:79\n" - "a=setup:actpass\n" - "a=mid:data\n" - "a=sctpmap:5000 webrtc-datachannel 1024\n" - "a=sctp-port:5000"; - - RtcSessionSdp sdp1; - sdp1.parse(str1); - - RtcSessionSdp sdp2; - sdp2.parse(str2); - - for (auto media : sdp1.medias) { - InfoL << getRtpDirectionString(media.getDirection()); - } - for (auto media : sdp2.medias) { - InfoL << getRtpDirectionString(media.getDirection()); - } - InfoL << sdp1.toString(); - InfoL << sdp2.toString(); - - RtcSession session1; - session1.loadFrom(str1); - - RtcSession session2; - session2.loadFrom(str2); - DebugL << session1.toString(); - DebugL << session2.toString(); -} - int start_main(int argc,char *argv[]) { { CMD_main cmd_main; @@ -414,7 +267,6 @@ int start_main(int argc,char *argv[]) { }); } -// test_sdp(); uint16_t shellPort = mINI::Instance()[Shell::kPort]; uint16_t rtspPort = mINI::Instance()[Rtsp::kPort]; uint16_t rtspsPort = mINI::Instance()[Rtsp::kSSLPort]; From 5b7974a522abceba6bc7760ea33de3b94ef04434 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Fri, 9 Apr 2021 20:42:36 +0800 Subject: [PATCH 02/11] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=89=88=E6=9D=83?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AUTHORS | 3 ++- webrtc/DtlsTransport.cpp | 20 +++++++++++++++++++- webrtc/DtlsTransport.hpp | 20 +++++++++++++++++++- webrtc/IceServer.cpp | 20 +++++++++++++++++++- webrtc/IceServer.hpp | 20 +++++++++++++++++++- webrtc/Sdp.cpp | 12 +++++++++--- webrtc/Sdp.h | 12 +++++++++--- webrtc/SrtpSession.cpp | 20 +++++++++++++++++++- webrtc/SrtpSession.hpp | 20 +++++++++++++++++++- webrtc/StunPacket.cpp | 20 +++++++++++++++++++- webrtc/StunPacket.hpp | 20 +++++++++++++++++++- webrtc/Utils.hpp | 20 +++++++++++++++++++- webrtc/WebRtcTransport.cpp | 12 +++++++++++- webrtc/WebRtcTransport.h | 12 +++++++++++- webrtc/readme.md | 37 +++++++++++++++++++++++++++++++++++++ www/webrtc/readme.txt | 2 ++ 16 files changed, 252 insertions(+), 18 deletions(-) create mode 100644 webrtc/readme.md create mode 100644 www/webrtc/readme.txt diff --git a/AUTHORS b/AUTHORS index 2fbea1c9..3456f103 100644 --- a/AUTHORS +++ b/AUTHORS @@ -31,4 +31,5 @@ Luke 大裤衩 <3503207480@qq.com> droid.chow [陈晓林](https://github.com/musicwood) -[老衲不出家](https://github.com/monktan89) \ No newline at end of file +[老衲不出家](https://github.com/monktan89) +[big panda](<2381267071@qq.com>) \ No newline at end of file diff --git a/webrtc/DtlsTransport.cpp b/webrtc/DtlsTransport.cpp index 0dd9492c..8abb2a21 100644 --- a/webrtc/DtlsTransport.cpp +++ b/webrtc/DtlsTransport.cpp @@ -1,4 +1,22 @@ -#define MS_CLASS "RTC::DtlsTransport" +/** +ISC License + +Copyright © 2015, Iñaki Baz Castillo + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#define MS_CLASS "RTC::DtlsTransport" // #define MS_LOG_DEV_LEVEL 3 #include "DtlsTransport.hpp" diff --git a/webrtc/DtlsTransport.hpp b/webrtc/DtlsTransport.hpp index 2d324441..fb28a6a4 100644 --- a/webrtc/DtlsTransport.hpp +++ b/webrtc/DtlsTransport.hpp @@ -1,4 +1,22 @@ -#ifndef MS_RTC_DTLS_TRANSPORT_HPP +/** +ISC License + +Copyright © 2015, Iñaki Baz Castillo + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef MS_RTC_DTLS_TRANSPORT_HPP #define MS_RTC_DTLS_TRANSPORT_HPP #include "SrtpSession.hpp" diff --git a/webrtc/IceServer.cpp b/webrtc/IceServer.cpp index 15aeb0bd..c976bcf0 100644 --- a/webrtc/IceServer.cpp +++ b/webrtc/IceServer.cpp @@ -1,4 +1,22 @@ -#define MS_CLASS "RTC::IceServer" +/** +ISC License + +Copyright © 2015, Iñaki Baz Castillo + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#define MS_CLASS "RTC::IceServer" // #define MS_LOG_DEV_LEVEL 3 #include diff --git a/webrtc/IceServer.hpp b/webrtc/IceServer.hpp index 49045f43..8b9742ad 100644 --- a/webrtc/IceServer.hpp +++ b/webrtc/IceServer.hpp @@ -1,4 +1,22 @@ -#ifndef MS_RTC_ICE_SERVER_HPP +/** +ISC License + +Copyright © 2015, Iñaki Baz Castillo + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef MS_RTC_ICE_SERVER_HPP #define MS_RTC_ICE_SERVER_HPP #include "StunPacket.hpp" diff --git a/webrtc/Sdp.cpp b/webrtc/Sdp.cpp index 410f6c53..89065ecc 100644 --- a/webrtc/Sdp.cpp +++ b/webrtc/Sdp.cpp @@ -1,6 +1,12 @@ -// -// Created by xzl on 2021/3/27. -// +/* + * 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. + */ #include "Sdp.h" #include "Common/Parser.h" diff --git a/webrtc/Sdp.h b/webrtc/Sdp.h index 2a9eb6ee..9247018a 100644 --- a/webrtc/Sdp.h +++ b/webrtc/Sdp.h @@ -1,6 +1,12 @@ -// -// Created by xzl on 2021/3/27. -// +/* + * 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_SDP_H #define ZLMEDIAKIT_SDP_H diff --git a/webrtc/SrtpSession.cpp b/webrtc/SrtpSession.cpp index a73c5aaa..cf359b7e 100644 --- a/webrtc/SrtpSession.cpp +++ b/webrtc/SrtpSession.cpp @@ -1,4 +1,22 @@ -#define MS_CLASS "RTC::SrtpSession" +/** +ISC License + +Copyright © 2015, Iñaki Baz Castillo + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#define MS_CLASS "RTC::SrtpSession" // #define MS_LOG_DEV_LEVEL 3 #include "SrtpSession.hpp" diff --git a/webrtc/SrtpSession.hpp b/webrtc/SrtpSession.hpp index 988d730b..d9d73fbe 100644 --- a/webrtc/SrtpSession.hpp +++ b/webrtc/SrtpSession.hpp @@ -1,4 +1,22 @@ -#ifndef MS_RTC_SRTP_SESSION_HPP +/** +ISC License + +Copyright © 2015, Iñaki Baz Castillo + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef MS_RTC_SRTP_SESSION_HPP #define MS_RTC_SRTP_SESSION_HPP #include "Utils.hpp" diff --git a/webrtc/StunPacket.cpp b/webrtc/StunPacket.cpp index 223d3f57..50120a70 100644 --- a/webrtc/StunPacket.cpp +++ b/webrtc/StunPacket.cpp @@ -1,4 +1,22 @@ -#define MS_CLASS "RTC::StunPacket" +/** +ISC License + +Copyright © 2015, Iñaki Baz Castillo + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#define MS_CLASS "RTC::StunPacket" // #define MS_LOG_DEV_LEVEL 3 #include "StunPacket.hpp" diff --git a/webrtc/StunPacket.hpp b/webrtc/StunPacket.hpp index ebd1b1d0..a6b2c940 100644 --- a/webrtc/StunPacket.hpp +++ b/webrtc/StunPacket.hpp @@ -1,4 +1,22 @@ -#ifndef MS_RTC_STUN_PACKET_HPP +/** +ISC License + +Copyright © 2015, Iñaki Baz Castillo + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef MS_RTC_STUN_PACKET_HPP #define MS_RTC_STUN_PACKET_HPP diff --git a/webrtc/Utils.hpp b/webrtc/Utils.hpp index 0b1b66ad..1692ff50 100644 --- a/webrtc/Utils.hpp +++ b/webrtc/Utils.hpp @@ -1,4 +1,22 @@ -#ifndef MS_UTILS_HPP +/** +ISC License + +Copyright © 2015, Iñaki Baz Castillo + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#ifndef MS_UTILS_HPP #define MS_UTILS_HPP #if defined(_WIN32) diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index 4084c610..342dabc0 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -1,4 +1,14 @@ -#include "WebRtcTransport.h" +/* + * 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. + */ + +#include "WebRtcTransport.h" #include #include "Rtcp/Rtcp.h" #include "Rtsp/RtpReceiver.h" diff --git a/webrtc/WebRtcTransport.h b/webrtc/WebRtcTransport.h index e418cdf8..2b8f8a2c 100644 --- a/webrtc/WebRtcTransport.h +++ b/webrtc/WebRtcTransport.h @@ -1,4 +1,14 @@ -#pragma once +/* + * 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. + */ + +#pragma once #include #include diff --git a/webrtc/readme.md b/webrtc/readme.md new file mode 100644 index 00000000..ff832278 --- /dev/null +++ b/webrtc/readme.md @@ -0,0 +1,37 @@ +# 致谢与声明 +本文件夹下部分文件提取自[MediaSoup](https://github.com/versatica/mediasoup) ,分别为: + +- ice相关功能: + - IceServer.cpp + - IceServer.hpp + - StunPacket.cpp + - StunPacket.hpp + - Utils.hpp + +- dtls相关功能: + - DtlsTransport.cpp + - DtlsTransport.hpp + +- srtp相关功能: + - SrtpSession.cpp + - SrtpSession.hpp + + +以上源码有一定的修改和裁剪,感谢MediaSoup开源项目及作者, +用户在使用本项目的同时,应该同时遵循MediaSoup的开源协议。 + +同时,在此也感谢开源项目[easy_webrtc_server](https://github.com/Mihawk086/easy_webrtc_server) 及作者, +在集成MediaSoup相关代码前期,主要参考这个项目。 + +另外,感谢[big panda](<2381267071@qq.com>) 开发并贡献的webrtc js测试客户端(www/webrtc目录下文件), +其开源项目地址为:https://gitee.com/xiongguangjie/zlmrtcclient.js + +# 现状与规划 +ZLMediaKit的WebRTC相关功能目前仅供测试与开发,现在还不成熟,后续主要工作有: + +- 1、完善webrtc rtcp相关功能,包括丢包重传、带宽检测等功能。 +- 2、实现rtp重传等相关功能。 +- 3、实现simulecast相关功能。 +- 4、fec、rtp扩展等其他功能。 +- 5、如果精力允许,逐步替换MediaSoup相关代码,改用自有版权代码。 + diff --git a/www/webrtc/readme.txt b/www/webrtc/readme.txt new file mode 100644 index 00000000..ba651b40 --- /dev/null +++ b/www/webrtc/readme.txt @@ -0,0 +1,2 @@ +感谢[big panda](<2381267071@qq.com>) 开发并贡献此webrtc js测试客户端, +其开源项目地址为:https://gitee.com/xiongguangjie/zlmrtcclient.js \ No newline at end of file From e495dfca64027e25dbb81746dc1ff7d1867453fe Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sat, 10 Apr 2021 21:58:27 +0800 Subject: [PATCH 03/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BF=BD=E7=95=A5g711a?= =?UTF-8?q?(pt=3D0)=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/WebRtcTransport.cpp | 2 +- webrtc/WebRtcTransport.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/webrtc/WebRtcTransport.cpp b/webrtc/WebRtcTransport.cpp index 342dabc0..9a58fb21 100644 --- a/webrtc/WebRtcTransport.cpp +++ b/webrtc/WebRtcTransport.cpp @@ -593,7 +593,7 @@ void WebRtcTransportImp::onBeforeSortedRtp(const RtpPayloadInfo &info, const Rtp void WebRtcTransportImp::onSendRtp(const RtpPacket::Ptr &rtp, bool flush){ auto &pt = _send_rtp_pt[rtp->type]; - if (!pt) { + if (pt == 0xFF) { //忽略,对方不支持该编码类型 return; } diff --git a/webrtc/WebRtcTransport.h b/webrtc/WebRtcTransport.h index 2b8f8a2c..50f45604 100644 --- a/webrtc/WebRtcTransport.h +++ b/webrtc/WebRtcTransport.h @@ -212,7 +212,7 @@ private: //rtc rtp推流的视频ssrc uint32_t _recv_video_ssrc; //记录协商的rtp的pt类型 - uint8_t _send_rtp_pt[2] = {0, 0}; + uint8_t _send_rtp_pt[2] = {0xFF, 0xFF}; //复合udp端口,接收一切rtp与rtcp Socket::Ptr _socket; //推流的rtsp源 From ebf650cf4fc018948fd1619159ced5932b827ba9 Mon Sep 17 00:00:00 2001 From: xgj Date: Sat, 10 Apr 2021 22:24:26 +0800 Subject: [PATCH 04/11] fix static library link order --- server/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 6e0af5e1..bf59de98 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -48,4 +48,4 @@ else() install(TARGETS MediaServer DESTINATION ${INSTALL_PATH_EXECUTABLE}) endif() -target_link_libraries(MediaServer jsoncpp ${LINK_LIB_LIST}) +target_link_libraries(MediaServer -Wl,--start-group jsoncpp ${LINK_LIB_LIST} -Wl,--end-group) From 33da2e28ec3a6e4421602cf6c4c326037a57a975 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 11 Apr 2021 01:14:41 +0800 Subject: [PATCH 05/11] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dpt=E8=A6=86=E7=9B=96?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webrtc/SrtpSession.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webrtc/SrtpSession.cpp b/webrtc/SrtpSession.cpp index cf359b7e..4591e466 100644 --- a/webrtc/SrtpSession.cpp +++ b/webrtc/SrtpSession.cpp @@ -244,7 +244,7 @@ namespace RTC } std::memcpy(EncryptBuffer, *data, *len); - EncryptBuffer[1] |= (pt & 0x7F); + EncryptBuffer[1] = (pt & 0x7F) | (EncryptBuffer[1] & 0x80); srtp_err_status_t err = srtp_protect(this->session, static_cast(EncryptBuffer), reinterpret_cast(len)); From 012f58d27c07446d6f6464d32e98cbeea62730ba Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 11 Apr 2021 01:15:02 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E6=B7=BB=E5=8A=A0rtp=20=E8=B0=83?= =?UTF-8?q?=E8=AF=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtsp/Rtsp.cpp | 4 ++++ src/Rtsp/Rtsp.h | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Rtsp/Rtsp.cpp b/src/Rtsp/Rtsp.cpp index 492eb644..73f84434 100644 --- a/src/Rtsp/Rtsp.cpp +++ b/src/Rtsp/Rtsp.cpp @@ -521,6 +521,10 @@ RtpHeader* RtpPacket::getHeader(){ return (RtpHeader*)(data() + RtpPacket::kRtpTcpHeaderSize); } +string RtpPacket::dumpString() const{ + return ((RtpPacket *) this)->getHeader()->dumpString(size() - RtpPacket::kRtpTcpHeaderSize); +} + uint16_t RtpPacket::getSeq(){ return ntohs(getHeader()->seq); } diff --git a/src/Rtsp/Rtsp.h b/src/Rtsp/Rtsp.h index 884176e1..20307f45 100644 --- a/src/Rtsp/Rtsp.h +++ b/src/Rtsp/Rtsp.h @@ -150,7 +150,11 @@ public: kRtpTcpHeaderSize = 4 }; + //获取rtp头 RtpHeader* getHeader(); + //打印调试信息 + string dumpString() const; + //主机字节序的seq uint16_t getSeq(); //主机字节序的时间戳,已经转换为毫秒 From 5fadd2665df9921a1921b5af8a2f1508a8a89f11 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 11 Apr 2021 11:44:16 +0800 Subject: [PATCH 07/11] =?UTF-8?q?=E9=9D=9Ewindows=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=EF=BC=8C=E6=89=8D=E5=BF=BD=E7=95=A5=E9=9D=99=E6=80=81=E5=BA=93?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index bf59de98..2e11813c 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -48,4 +48,8 @@ else() install(TARGETS MediaServer DESTINATION ${INSTALL_PATH_EXECUTABLE}) endif() -target_link_libraries(MediaServer -Wl,--start-group jsoncpp ${LINK_LIB_LIST} -Wl,--end-group) +if (WIN32) + target_link_libraries(MediaServer jsoncpp ${LINK_LIB_LIST}) +else () + target_link_libraries(MediaServer -Wl,--start-group jsoncpp ${LINK_LIB_LIST} -Wl,--end-group) +endif () From 9e93561c7741032d3156f1af59ef0c0fd9dc7ebb Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 11 Apr 2021 11:53:05 +0800 Subject: [PATCH 08/11] =?UTF-8?q?=E5=8F=AA=E6=9C=89linux=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E6=89=93=E5=BC=80=E9=93=BE=E6=8E=A5=E9=A1=BA=E5=BA=8F=E6=97=A0?= =?UTF-8?q?=E5=85=B3=E9=80=89=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt index 2e11813c..8ae6ff28 100644 --- a/server/CMakeLists.txt +++ b/server/CMakeLists.txt @@ -48,8 +48,8 @@ else() install(TARGETS MediaServer DESTINATION ${INSTALL_PATH_EXECUTABLE}) endif() -if (WIN32) - target_link_libraries(MediaServer jsoncpp ${LINK_LIB_LIST}) -else () +if (CMAKE_SYSTEM_NAME MATCHES "Linux") target_link_libraries(MediaServer -Wl,--start-group jsoncpp ${LINK_LIB_LIST} -Wl,--end-group) +else () + target_link_libraries(MediaServer jsoncpp ${LINK_LIB_LIST}) endif () From 8b7289a689b530a0000b0dd0b9c949a2ed5cb8f9 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 11 Apr 2021 12:06:40 +0800 Subject: [PATCH 09/11] =?UTF-8?q?rtsp=E6=8E=A8=E6=B5=81=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E7=9B=B4=E6=8E=A5=E4=BB=A3=E7=90=86=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Rtsp/RtspMediaSourceImp.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Rtsp/RtspMediaSourceImp.h b/src/Rtsp/RtspMediaSourceImp.h index 4ecc93b7..8401d4b8 100644 --- a/src/Rtsp/RtspMediaSourceImp.h +++ b/src/Rtsp/RtspMediaSourceImp.h @@ -56,7 +56,11 @@ public: //需要解复用rtp key_pos = _demuxer->inputRtp(rtp); } - RtspMediaSource::onWrite(std::move(rtp), key_pos); + GET_CONFIG(bool, directProxy, Rtsp::kDirectProxy); + if (directProxy) { + //直接代理模式才直接使用原始rtp + RtspMediaSource::onWrite(std::move(rtp), key_pos); + } } /** @@ -72,8 +76,10 @@ public: * @param enableMP4 是否mp4录制 */ void setProtocolTranslation(bool enableHls,bool enableMP4){ - //不重复生成rtsp - _muxer = std::make_shared(getVhost(), getApp(), getId(), _demuxer->getDuration(), false, true, enableHls, enableMP4); + GET_CONFIG(bool, directProxy, Rtsp::kDirectProxy); + //开启直接代理模式时,rtsp直接代理,不重复产生;但是有些rtsp推流端,由于sdp中已有sps pps,rtp中就不再包括sps pps, + //导致rtc无法播放,所以在rtsp推流rtc播放时,建议关闭直接代理模式 + _muxer = std::make_shared(getVhost(), getApp(), getId(), _demuxer->getDuration(), !directProxy, true, enableHls, enableMP4); _muxer->setMediaListener(getListener()); _muxer->setTrackListener(static_pointer_cast(shared_from_this())); //让_muxer对象拦截一部分事件(比如说录像相关事件) From fbe8beb3648b4cb1f91d0837c5534ab4fc7a3863 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 11 Apr 2021 12:06:55 +0800 Subject: [PATCH 10/11] =?UTF-8?q?=E6=B7=BB=E5=8A=A0rtc=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=8E=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- conf/config.ini | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/conf/config.ini b/conf/config.ini index 904cc57a..c7330ed2 100644 --- a/conf/config.ini +++ b/conf/config.ini @@ -206,13 +206,21 @@ port=10000 #rtp超时时间,单位秒 timeoutSec=15 +[rtc] +#rtc播放推流、播放超时时间 +timeoutSec=15 +#本机对rtc客户端的可见ip,作为服务器时一般为公网ip,置空时,会自动获取网卡ip +externIP= + [rtsp] #rtsp专有鉴权方式是采用base64还是md5方式 authBasic=0 -#rtsp拉流代理是否是直接代理模式 +#rtsp拉流、推流代理是否是直接代理模式 #直接代理后支持任意编码格式,但是会导致GOP缓存无法定位到I帧,可能会导致开播花屏 #并且如果是tcp方式拉流,如果rtp大于mtu会导致无法使用udp方式代理 #假定您的拉流源地址不是264或265或AAC,那么你可以使用直接代理的方式来支持rtsp代理 +#如果你是rtsp推拉流,但是rtc播放,也建议关闭直接代理模式, +#因为直接代理时,rtp中可能没有sps pps,会导致rtc无法播放 #默认开启rtsp直接代理,rtmp由于没有这些问题,是强制开启直接代理的 directProxy=1 #rtsp必须在此时间内完成握手,否则服务器会断开链接,单位秒 From 753fe05813b114ac99b46cbb614a1e9121ca001a Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 11 Apr 2021 12:07:04 +0800 Subject: [PATCH 11/11] =?UTF-8?q?=E9=87=87=E7=94=A8pts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Extension/CommonRtp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Extension/CommonRtp.cpp b/src/Extension/CommonRtp.cpp index 039bf93d..e009816a 100644 --- a/src/Extension/CommonRtp.cpp +++ b/src/Extension/CommonRtp.cpp @@ -69,7 +69,7 @@ CommonRtpEncoder::CommonRtpEncoder(CodecId codec, uint32_t ssrc, uint32_t mtu_si } void CommonRtpEncoder::inputFrame(const Frame::Ptr &frame){ - auto stamp = frame->dts(); + auto stamp = frame->pts(); auto ptr = frame->data() + frame->prefixSize(); auto len = frame->size() - frame->prefixSize(); auto remain_size = len;