metaRTC+ZLMediaKit实现webrtc的推拉流

概述

ZLMediaKit是一个基于C++11的高性能运营级流媒体服务框架,是一个支持webrtc SFU的优秀的流媒体服务器系统。

metaRTC新版本支持whip/whep协议,支持whip/whep协议的ZLMediaKit推拉流。

信令通信

ZLMediaKit新版本支持whip和whep协议,支持两种API。

HTTP API

metaRTC封装了HTTP API,只需将参数mediaServer设置为zlm即可

avinfo.sys.mediaServer=Yang_Server_Zlm;
//zlm 默认端口为80
url="webrtc://192.168.3.85:80/live/test"
  1. index/api/webrtc?app=live&stream=test&type=push
  2. index/api/webrtc?app=live&stream=test&type=play

Whip/Whep API

  1. http://192.168.3.85:80/index/api/whip?app=live&stream=test
  2. http://192.168.3.85:80/index/api/whep?app=live&stream=test

音频参数

ZLMediaKit配置文件config.ini音频编码参数默认排序为PCMU,PCMA,opus,mpeg4-generic

如需用opus可调整其顺序如:opus,PCMU,PCMA,mpeg4-generic

推流

    streamconfig.direction=YangSendonly;	

	conn->addAudioTrack(Yang_AED_OPUS);//Yang_AED_PCMU Yang_AED_PCMA
	conn->addVideoTrack(Yang_VED_H264);
	conn->addTransceiver(streamconfig.direction);

拉流

 m_context->avinfo.audio.audioDecoderType=Yang_AED_PCMU;

     if(m_context->avinfo.audio.audioDecoderType==Yang_AED_PCMU
      ||m_context->avinfo.audio.audioDecoderType==Yang_AED_PCMA){
        m_context->avinfo.audio.sample=8000;
        m_context->avinfo.audio.channel=1;
     }
     streamconfig.direction=YangRecvonly;	

     conn->addAudioTrack(&conn->peer,  (YangAudioCodec)m_context->avinfo.audio.audioDecoderType);
	conn->addVideoTrack(&conn->peer,Yang_VED_H264);
	conn->addTransceiver(&conn->peer,conn->peer.streamconfig.direction);

你可能感兴趣的:(metaRTC,webrtc)