WebRTC/RTSP/RTMP/HTTP/HLS/HTTP-FLV/WebSocket-FLV/HTTP-TS/HTTP-fMP4/WebSocket-TS/WebSocket-fMP4/GB28181/SRT server and client framework based on C++11
Go to file
2023-03-25 20:40:40 +08:00
.github 修正macos持续集成运行目录 (#2234) 2023-02-12 22:44:37 +08:00
3rdpart 更新三方库 2023-03-12 18:13:27 +08:00
Android 修复Android编译问题 2022-11-13 00:37:45 +08:00
api 修复低版本gcc编译器lambda不支持可变长度模板参数捕获导致的编译问题:#2295 2023-03-12 09:39:49 +08:00
cmake 静态连接到jemalloc库: #1759 2022-06-29 10:59:44 +08:00
conf 新增支持mjpeg es rtp流 2022-12-30 18:04:15 +08:00
docker 添加k8s部署相关说明 2021-09-13 21:16:22 +08:00
package/rpm rpm: 默认不打包 api/cxx-api 2022-08-22 13:18:05 +08:00
player Unified code style (#2137) 2022-12-02 14:43:06 +08:00
postman startSendRtpPassive接口新增连接超时参数:close_delay_ms 2023-02-17 23:02:09 +08:00
server avoid fps too big 2023-03-23 18:14:28 +08:00
src fix direct_proxy is 0 repush not success 2023-03-25 20:40:40 +08:00
srt srt push check audio and video timestamp sync 2023-03-25 20:32:21 +08:00
tests 重写jitter buffer算法,修复seq回环时可能丢包的bug 2023-03-11 10:17:31 +08:00
webrtc 设置webrtc端口缺省配置为0(不开启) 2023-03-13 21:00:00 +08:00
webrtc_player/android android webrtc player 2022-09-25 10:51:43 +08:00
www fix typo 2022-09-22 21:16:56 +08:00
.clang-format 调整switch case代码风格 2022-08-05 17:23:46 +08:00
.gitattributes 去除gfs依赖 2019-10-25 10:46:59 +08:00
.gitignore 更新.gitignore文件,排除out目录。 2022-08-26 10:37:47 +08:00
.gitmodules 使用submodule方式添加jsoncpp源码 2022-10-16 21:10:18 +08:00
.gitmodules_github 使用submodule方式添加jsoncpp源码 2022-10-16 21:10:18 +08:00
AUTHORS 更新作者列表 2023-02-25 00:18:51 +08:00
build_docker_images.sh 使用docker buildx, 用于支持跨平台build 2022-09-14 10:08:18 +08:00
CMakeLists.txt 新增实例上报功能: #2294 2023-03-12 00:14:22 +08:00
default.pem 更新ssl证书 2022-09-18 21:13:01 +08:00
dockerfile 修正docker编译问题 2022-08-01 17:33:58 +08:00
k8s_readme.md 添加k8s部署相关说明 2021-09-13 21:16:22 +08:00
LICENSE 整理授权协议 2020-04-04 20:30:09 +08:00
README_en.md add addDelegate with std::function, remove FrameWriterInterfaceHelper 2022-11-01 12:03:04 +08:00
README.md 更新readme功能描述 2023-03-11 21:24:56 +08:00
sources.list 修改docker镜像为国内源,加快镜像构建速度 2022-01-04 21:13:55 +08:00
version.h.ini 完善版本信息 2022-11-06 00:38:14 +08:00

logo

A lightweight ,high performance and stable stream server and client framework based on C++11.

license C++ platform PRs Welcome Build Status

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/WebRTC),and support Inter-protocol conversion.
  • Multiplexing asynchronous network IO based on epoll and multi threadextreme performance.
  • Well performance and stable test,can be used commercially.
  • Support linux, macos, ios, android, Windows Platforms.
  • Very low latency(lower then one second), video opened immediately.

Features

  • RTSP[S]

    • RTSP[S] server,support rtsp push.
    • RTSP[S] player and pusher.
    • RTP Transport : rtp over udp rtp over tcp rtp over http rtp udp multicast .
    • Basic/Digest/Url Authentication.
    • H265/H264/AAC/G711/OPUS codec.
    • Recorded as mp4.
    • Vod of mp4.
  • RTMP[S]

    • RTMP[S] server,support player and pusher.
    • RTMP[S] player and pusher.
    • Support HTTP-FLV/WebSocket-FLV sever.
    • H265/H264/AAC/G711/OPUS codec.
    • Recorded as flv or mp4.
    • Vod of mp4.
    • support RTMP-H265
  • HLS

    • RTSP RTMP can be converted into HLS,built-in HTTP server.
    • Play authentication based on cookie.
    • Support HLS player, support streaming HLS proxy to RTSP / RTMP / MP4.
  • TS

    • Support HTTP-TS/WebSocket-TS sever.
  • fMP4

    • Support HTTP-fMP4/WebSocket-fMP4 sever.
  • HTTP[S]

    • HTTP server,suppor directory meun、RESTful http api.
    • HTTP client,downloader,uploader,and http api requester.
    • Cookie supported.
    • WebSocket Server and Client.
    • File access authentication.
  • WebRTC(experiential)

    • Support webrtc push stream and transfer to other protocols
    • Support webrtc play, support other protocol to webrtc
    • Support simulcast
    • Support rtx/nack
    • Support transport-cc rtcp/rtp ext
  • SRT support

  • Others

    • Support stream proxy by ffmpeg.
    • RESTful http api and http hook event api.
    • Config file hot loading.
    • Vhost supported.
    • Auto close stream when nobody played.
    • Play and push authentication.
    • Pull stream on Demand.
    • Support TS / PS streaming push through RTP,and it can be converted to RTSP / RTMP / HLS / FLV.
    • Support real-time online screenshot http api.

System Requirements

  • Compiler support c++11GCC4.8/Clang3.3/VC2015 or above.
  • cmake3.1 or above.
  • All Linux , both 32 and 64 bits
  • Apple OSX(Darwin), both 32 and 64bits.
  • All hardware with x86/x86_64/arm/mips cpu.
  • Windows.

How to build

It is recommended to compile on Ubuntu or MacOScompiling on windows is cumbersome, and some features are not compiled by default.

Before build

  • You must use git to clone the complete code. Do not download the source code by downloading zip package. Otherwise, the sub-module code will not be downloaded by default.You can do it like this:
git clone https://github.com/xia-chu/ZLMediaKit.git
cd ZLMediaKit
git submodule update --init

Build on linux

  • My environment

    • Ubuntu16.04 64 bit and gcc5.4
    • cmake 3.5.1
  • Guidance

      # If it is on centos6.x, you need to install the newer version of GCC and cmake first, 
      # and then compile manually according to the script "build_for_linux.sh".
      # If it is on a newer version of a system such as Ubuntu or Debain,
      # step 4 can be manipulated directly.
    
      # 1、Install GCC5.2 (this step can be skipped if the GCC version is higher than 4.7)
      sudo yum install centos-release-scl -y
      sudo yum install devtoolset-4-toolchain -y
      scl enable devtoolset-4 bash
    
      # 2、Install cmake (this step can be skipped if the cmake version is higher than 3.1)
      tar -xvf cmake-3.10.0-rc4.tar.gz #you need download cmake source file manually
      cd cmake-3.10.0-rc4
      ./configure
      make -j4
      sudo make install
    
      # 3、Switch to high version GCC
      scl enable devtoolset-4 bash
    
      # 4、build
      cd ZLMediaKit
      ./build_for_linux.sh
    

Build on macOS

  • My environment

    • macOS Sierra(10.12.1) + xcode8.3.1
    • Homebrew 1.1.3
    • cmake 3.8.0
  • Guidance

    cd ZLMediaKit
    ./build_for_mac.sh
    

Build on iOS

  • You can generate Xcode projects and recompile them , learn more:

    cd ZLMediaKit
    mkdir -p build
    cd build
    # Generate Xcode project, project file is in build directory
    cmake .. -G Xcode -DCMAKE_TOOLCHAIN_FILE=../cmake/ios.toolchain.cmake  -DPLATFORM=OS64COMBINED
    

Build on Android

Now you can open android sudio project in Android folder,this is a aar library and damo project.

  • My environment

    • macOS Sierra(10.12.1) + xcode8.3.1
    • Homebrew 1.1.3
    • cmake 3.8.0
    • android-ndk-r14b
  • Guidance

    cd ZLMediaKit
    export ANDROID_NDK_ROOT=/path/to/ndk
    ./build_for_android.sh
    

Build on Windows

  • My environment

  • Guidance

1 Enter the ZLMediaKit directory and execute git submodule update -- init downloads the code for ZLToolKit
2 Open the project with cmake-gui and generate the vs project file.
3 Find the project file (ZLMediaKit.sln), double-click to open it with vs2017.
4 Choose to compile Release version. Find the target file and run the test case.

Usage

  • As server

    TcpServer::Ptr rtspSrv(new TcpServer());
    TcpServer::Ptr rtmpSrv(new TcpServer());
    TcpServer::Ptr httpSrv(new TcpServer());
    TcpServer::Ptr httpsSrv(new TcpServer());
    
    rtspSrv->start<RtspSession>(mINI::Instance()[Config::Rtsp::kPort]);
    rtmpSrv->start<RtmpSession>(mINI::Instance()[Config::Rtmp::kPort]);
    httpSrv->start<HttpSession>(mINI::Instance()[Config::Http::kPort]);
    httpsSrv->start<HttpsSession>(mINI::Instance()[Config::Http::kSSLPort]);
    
  • As player

    MediaPlayer::Ptr player(new MediaPlayer());
    weak_ptr<MediaPlayer> weakPlayer = player;
    player->setOnPlayResult([weakPlayer](const SockException &ex) {
        InfoL << "OnPlayResult:" << ex.what();
        auto strongPlayer = weakPlayer.lock();
        if (ex || !strongPlayer) {
            return;
        }
    
        auto viedoTrack = strongPlayer->getTrack(TrackVideo);
        if (!viedoTrack) {
            WarnL << "none video Track!";
            return;
        }
        viedoTrack->addDelegate([](const Frame::Ptr &frame) {
            //please decode video here
        });
    });
    
    player->setOnShutdown([](const SockException &ex) {
        ErrorL << "OnShutdown:" << ex.what();
    });
    
    //rtp transport over tcp
    (*player)[Client::kRtpType] = Rtsp::RTP_TCP;
    player->play("rtsp://admin:jzan123456@192.168.0.122/");
    
  • As proxy server

    //support rtmp and rtsp url
    //just support H264+AAC
    auto urlList = {"rtmp://live.hkstv.hk.lxdns.com/live/hks",
    		"rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov"};
    map<string , PlayerProxy::Ptr> proxyMap;
    int i=0;
    for(auto url : urlList){
    	PlayerProxy::Ptr player(new PlayerProxy("live",to_string(i++).data()));
    	player->play(url);
    	proxyMap.emplace(string(url),player);
    }
    
  • As puser

    PlayerProxy::Ptr player(new PlayerProxy("app","stream"));
    player->play("rtmp://live.hkstv.hk.lxdns.com/live/hks");
    
    RtmpPusher::Ptr pusher;
    NoticeCenter::Instance().addListener(nullptr,Config::Broadcast::kBroadcastRtmpSrcRegisted,
    		[&pusher](BroadcastRtmpSrcRegistedArgs){
    	const_cast<RtmpPusher::Ptr &>(pusher).reset(new RtmpPusher(app,stream));
    	pusher->publish("rtmp://jizan.iok.la/live/test");
    });
    
    

Docker Image

You can pull a pre-built docker image from Docker Hub and run with

docker run -id -p 1935:1935 -p 8080:80 -p 8443:443 -p 8554:554 -p 10000:10000 -p 10000:10000/udp -p 8000:8000/udp -p 9000:9000/udp zlmediakit/zlmediakit:master

Dockerfile is also supplied to build images on Ubuntu 16.04

cd docker
docker build -t zlmediakit .

Contact