Skip to content

Commit

Permalink
7.0.110
Browse files Browse the repository at this point in the history
  • Loading branch information
yangrtc committed Feb 1, 2024
1 parent a683ff4 commit 20ad88a
Show file tree
Hide file tree
Showing 49 changed files with 407 additions and 273 deletions.
2 changes: 1 addition & 1 deletion codec/yangwincodec7/codec/YangH264EncoderGpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bool YangH264EncoderGpu::init()
if (nvenc_data_ != nullptr) {
nvenc_config nvenc_config;
nvenc_config.codec = "h264";//
if(m_context->videoEncoderType==Yang_VED_265) nvenc_config.codec = "hevc";
if(m_context->videoEncoderType==Yang_VED_H265) nvenc_config.codec = "hevc";


nvenc_config.format = m_format;//;
Expand Down
1 change: 0 additions & 1 deletion demo/metaplayer7/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ MainWindow::MainWindow(QWidget *parent)

connect(this,SIGNAL(RtcConnectFailure(int)),SLOT(connectFailure(int)));

m_context->avinfo.rtc.enableDatachannel=yangfalse;
m_context->avinfo.rtc.iceCandidateType=YangIceHost;
m_context->avinfo.rtc.turnSocketProtocol=Yang_Socket_Protocol_Udp;

Expand Down
11 changes: 8 additions & 3 deletions demo/metaplayer7/yangplayer/YangRtcReceive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ int32_t YangRtcReceive::init(int32_t puid, char* localIp,
strcpy(m_recv->peer.streamconfig.app,app);
strcpy(m_recv->peer.streamconfig.stream,stream);
m_recv->peer.streamconfig.uid = puid;
m_recv->peer.streamconfig.streamDirection = YangRecvonly;
m_recv->peer.streamconfig.direction = YangRecvonly;

m_recv->peer.streamconfig.recvCallback.context=this;
m_recv->peer.streamconfig.recvCallback.receiveAudio=g_rtcrecv_receiveAudio;
Expand All @@ -131,6 +131,9 @@ int32_t YangRtcReceive::init(int32_t puid, char* localIp,
m_recv->peer.avinfo=&m_context->avinfo;
yang_create_peerConnection(m_recv);
m_recv->init(&m_recv->peer);
m_recv->addAudioTrack(&m_recv->peer,Yang_AED_OPUS);
m_recv->addVideoTrack(&m_recv->peer,Yang_VED_H264);
m_recv->addTransceiver(&m_recv->peer,m_recv->peer.streamconfig.direction);
return Yang_Ok;
}

Expand All @@ -142,7 +145,7 @@ int32_t YangRtcReceive::init(int32_t puid,char* url){
m_recv->peer.streamconfig.localPort = m_context->avinfo.rtc.rtcLocalPort++;

m_recv->peer.streamconfig.uid = puid;
m_recv->peer.streamconfig.streamDirection = YangRecvonly;
m_recv->peer.streamconfig.direction = YangRecvonly;

m_recv->peer.streamconfig.recvCallback.context=this;
m_recv->peer.streamconfig.recvCallback.receiveAudio=g_rtcrecv_receiveAudio;
Expand All @@ -154,7 +157,9 @@ int32_t YangRtcReceive::init(int32_t puid,char* url){
memcpy(&m_recv->peer.streamconfig.rtcCallback,&m_context->rtcCallback,sizeof(YangRtcCallback));
m_recv->peer.avinfo=&m_context->avinfo;
yang_create_peerConnection(m_recv);

m_recv->addAudioTrack(&m_recv->peer,Yang_AED_OPUS);
m_recv->addVideoTrack(&m_recv->peer,Yang_VED_H264);
m_recv->addTransceiver(&m_recv->peer,m_recv->peer.streamconfig.direction);
int len=strlen(url);
if(m_url==NULL) m_url=(char*)yang_malloc(len+1);
memcpy(m_url,url,len);
Expand Down
2 changes: 1 addition & 1 deletion demo/metaplayer7_flutter/metaplayer7/YangMetaplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ YangMetaplayer::YangMetaplayer()

m_context->avinfo.rtc.iceCandidateType=YangIceHost;
m_context->avinfo.rtc.turnSocketProtocol=Yang_Socket_Protocol_Udp;
m_context->avinfo.rtc.enableDatachannel=yangfalse;

m_context->avinfo.rtc.enableAudioBuffer=yangtrue; //use audio buffer
m_context->avinfo.audio.enableAudioFec=yangfalse; //srs not use audio fec

Expand Down
7 changes: 6 additions & 1 deletion demo/metaplayer7_flutter/metaplayer7/YangRtcReceive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ int32_t YangRtcReceive::init(int32_t puid, char* localIp,
m_recv->peer.avinfo=&m_context->avinfo;
yang_create_peerConnection(m_recv);
m_recv->init(&m_recv->peer);
m_recv->addAudioTrack(&m_recv->peer,Yang_AED_OPUS);
m_recv->addVideoTrack(&m_recv->peer,Yang_VED_H264);
m_recv->addTransceiver(&m_recv->peer,m_recv->peer.streamconfig.direction);
return Yang_Ok;
}

Expand All @@ -154,7 +157,9 @@ int32_t YangRtcReceive::init(int32_t puid,char* url){
memcpy(&m_recv->peer.streamconfig.rtcCallback,&m_context->rtcCallback,sizeof(YangRtcCallback));
m_recv->peer.avinfo=&m_context->avinfo;
yang_create_peerConnection(m_recv);

m_recv->addAudioTrack(&m_recv->peer,Yang_AED_OPUS);
m_recv->addVideoTrack(&m_recv->peer,Yang_VED_H264);
m_recv->addTransceiver(&m_recv->peer,m_recv->peer.streamconfig.direction);
int len=strlen(url);
if(m_url==NULL) m_url=(char*)yang_malloc(len+1);
memcpy(m_url,url,len);
Expand Down
1 change: 0 additions & 1 deletion demo/metaplayer7_lvgl/YangMetaplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ YangMetaplayer::YangMetaplayer()

m_isStartplay=false;

m_context->avinfo.rtc.enableDatachannel=yangfalse;
m_context->avinfo.rtc.iceCandidateType=YangIceHost;
m_context->avinfo.rtc.turnSocketProtocol=Yang_Socket_Protocol_Udp;

Expand Down
7 changes: 6 additions & 1 deletion demo/metaplayer7_lvgl/yangplayer/YangRtcReceive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ int32_t YangRtcReceive::init(int32_t puid, char* localIp,
m_recv->peer.avinfo=&m_context->avinfo;
yang_create_peerConnection(m_recv);
m_recv->init(&m_recv->peer);
m_recv->addAudioTrack(&m_recv->peer,Yang_AED_OPUS);
m_recv->addVideoTrack(&m_recv->peer,Yang_VED_H264);
m_recv->addTransceiver(&m_recv->peer,m_recv->peer.streamconfig.direction);
return Yang_Ok;
}

Expand All @@ -154,7 +157,9 @@ int32_t YangRtcReceive::init(int32_t puid,char* url){
memcpy(&m_recv->peer.streamconfig.rtcCallback,&m_context->rtcCallback,sizeof(YangRtcCallback));
m_recv->peer.avinfo=&m_context->avinfo;
yang_create_peerConnection(m_recv);

m_recv->addAudioTrack(&m_recv->peer,Yang_AED_OPUS);
m_recv->addVideoTrack(&m_recv->peer,Yang_VED_H264);
m_recv->addTransceiver(&m_recv->peer,m_recv->peer.streamconfig.direction);
int len=strlen(url);
if(m_url==NULL) m_url=(char*)yang_malloc(len+1);
memcpy(m_url,url,len);
Expand Down
9 changes: 2 additions & 7 deletions demo/metapushstream7/recordmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,8 @@ RecordMainWindow::RecordMainWindow(QWidget *parent)
init();
yang_setLogLevel(m_context->avinfo.sys.logLevel);
yang_setLogFile(m_context->avinfo.sys.enableLogFile);

m_context->avinfo.sys.mediaServer=Yang_Server_Srs;//Yang_Server_Srs/Yang_Server_Zlm/Yang_Server_Whip_Whep
m_context->avinfo.rtc.rtcLocalPort=10000+yang_random()%15000;
//m_showev->event=1;

m_videoType=Yang_VideoSrc_Camera;//Yang_VideoSrc_Camera/Yang_VideoSrc_Screen;

Expand Down Expand Up @@ -79,13 +77,10 @@ RecordMainWindow::RecordMainWindow(QWidget *parent)

m_initRecord=false;

m_context->avinfo.rtc.enableDatachannel=yangfalse;

//using h264 h265
m_context->avinfo.video.videoEncoderType=Yang_VED_264;//Yang_VED_265;
if(m_context->avinfo.video.videoEncoderType==Yang_VED_265){
m_context->avinfo.video.videoEncoderType=Yang_VED_H264;//Yang_VED_265;
if(m_context->avinfo.video.videoEncoderType==Yang_VED_H265){
m_context->avinfo.enc.createMeta=1;
m_context->avinfo.rtc.enableDatachannel=yangfalse;
}
m_context->avinfo.rtc.iceCandidateType=YangIceHost;

Expand Down
16 changes: 11 additions & 5 deletions demo/metapushstream7/yangpush/YangRtcPublish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ int32_t YangRtcPublish::init(int32_t nettype, char* server, int32_t pport,
YangStreamConfig streamconfig;
memset(&streamconfig,0,sizeof(YangStreamConfig));
strcpy(streamconfig.app,app);
streamconfig.streamDirection=YangSendonly;
streamconfig.direction=YangSendonly;

strcpy(streamconfig.remoteIp,server);
streamconfig.remotePort=pport;
Expand All @@ -91,6 +91,9 @@ int32_t YangRtcPublish::init(int32_t nettype, char* server, int32_t pport,

YangPeerConnection2* sh=new YangPeerConnection2(&m_context->avinfo,&streamconfig);
sh->init();
sh->addAudioTrack(Yang_AED_OPUS);
sh->addVideoTrack(Yang_VED_H264);
sh->addTransceiver(streamconfig.direction);
m_pushs.push_back(sh);


Expand All @@ -111,7 +114,7 @@ int32_t YangRtcPublish::init(char* url) {
int32_t ret = 0;
YangStreamConfig streamconfig;
memset(&streamconfig,0,sizeof(YangStreamConfig));
streamconfig.streamDirection=YangSendonly;
streamconfig.direction=YangSendonly;
streamconfig.uid=0;

streamconfig.localPort=m_context->avinfo.rtc.rtcLocalPort;
Expand All @@ -120,6 +123,9 @@ int32_t YangRtcPublish::init(char* url) {

YangPeerConnection2* sh=new YangPeerConnection2(&m_context->avinfo,&streamconfig);
sh->init();
sh->addAudioTrack(Yang_AED_OPUS);
sh->addVideoTrack(Yang_VED_H264);
sh->addTransceiver(streamconfig.direction);
m_pushs.push_back(sh);

ret = m_pushs.back()->connectWhipServer(url);
Expand Down Expand Up @@ -243,12 +249,12 @@ void YangRtcPublish::startLoop() {
//if (ret) continue;
} else {
if (!vmd->isInit) {
if (videoType == Yang_VED_264) {
if (videoType == Yang_VED_H264) {
yang_createH264Meta(vmd, &videoFrame);
yang_getConfig_Flv_H264(&vmd->mp4Meta,
vmd->livingMeta.buffer,
&vmd->livingMeta.bufLen);
} else if (videoType == Yang_VED_265) {
} else if (videoType == Yang_VED_H265) {
yang_createH265Meta(vmd, &videoFrame);
yang_getConfig_Flv_H265(&vmd->mp4Meta,
vmd->livingMeta.buffer,
Expand All @@ -269,7 +275,7 @@ void YangRtcPublish::startLoop() {
if (!m_context->avinfo.enc.createMeta) {

memset(&nalu, 0, sizeof(YangH264NaluData));
if (videoType == Yang_VED_264)
if (videoType == Yang_VED_H264)
yang_parseH264Nalu(&videoFrame, &nalu);
else
yang_parseH265Nalu(&videoFrame, &nalu);
Expand Down
5 changes: 5 additions & 0 deletions include/yangrtc/YangPeerConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ typedef struct {
YangPeer peer;
void (*init)(YangPeer* peer);

int32_t (*addAudioTrack)(YangPeer* peer,YangAudioCodec codec);
int32_t (*addVideoTrack)(YangPeer* peer,YangVideoCodec codec);

int32_t (*addTransceiver)(YangPeer* peer,YangRtcDirection direction);
YangIceCandidateType (*getIceCandidateType)(YangPeer* peer);

int32_t (*createOffer)(YangPeer* peer, char **psdp);
int32_t (*createAnswer)(YangPeer* peer,char* answer);
int32_t (*createHttpAnswer)(YangPeer* peer,char* answer);
int32_t (*createDataChannel)(YangPeer* peer);

int32_t (*setLocalDescription)(YangPeer* peer,char* sdp);
int32_t (*setRemoteDescription)(YangPeer* peer,char* sdp);
int32_t (*connectSfuServer)(YangPeer* peer);//srs zlm
int32_t (*connectWhipWhepServer)(YangPeer* peer,char* url);
Expand Down
8 changes: 5 additions & 3 deletions include/yangrtc/YangPeerConnection2.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ class YangPeerConnection2 {
public:
void init();

//int32_t requestStunServer();
//int32_t requestTurnServer();
int32_t addAudioTrack(YangAudioCodec codec);
int32_t addVideoTrack(YangVideoCodec codec);

int32_t addTransceiver(YangRtcDirection direction);

int32_t createOffer( char **psdp);
int32_t createAnswer(char* answer);
int32_t createHttpAnswer(char* answer);

int32_t createDataChannel();
int32_t setRemoteDescription(char* sdp);
int32_t connectSfuServer();//srs zlm
int32_t connectWhipServer(char* url);
Expand Down
4 changes: 2 additions & 2 deletions include/yangstream/YangStreamManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class YangStreamStateNotify{
public:
YangStreamStateNotify(){};
virtual ~YangStreamStateNotify(){};
virtual void streamStateNotify(int32_t puid,YangStreamDirection opt,bool isConnect)=0;
virtual void streamStateNotify(int32_t puid,YangRtcDirection opt,bool isConnect)=0;
};

class YangStreamManager {
Expand All @@ -26,7 +26,7 @@ class YangStreamManager {

int32_t getPlayOnlineCount();
int32_t getPushOnlineCount();
void connectNotify(int32_t puid,YangStreamDirection opt,bool isConnect);
void connectNotify(int32_t puid,YangRtcDirection opt,bool isConnect);

public:
void setMediaConfig(int32_t puid,YangAudioParam* audio,YangVideoParam* video);
Expand Down
11 changes: 6 additions & 5 deletions include/yangutil/yangavctype.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

typedef enum {
YangRecvonly, YangSendonly, YangSendrecv
}YangStreamDirection;
}YangRtcDirection;

typedef enum {
Yang_Conn_State_New,
Expand All @@ -30,12 +30,13 @@ typedef enum YangAudioCodec{
Yang_AED_MP3,
Yang_AED_SPEEX,
Yang_AED_OPUS,
Yang_AED_G711
Yang_AED_PCMA,
Yang_AED_PCMU
}YangAudioCodec;

typedef enum YangVideoCodec{
Yang_VED_264,
Yang_VED_265,
Yang_VED_H264,
Yang_VED_H265,
Yang_VED_AV1,
Yang_VED_VP8,
Yang_VED_VP9,
Expand Down Expand Up @@ -139,7 +140,7 @@ typedef struct {
int32_t uid;
yangbool isControlled;

YangStreamDirection streamDirection;
YangRtcDirection direction;
YangSslCallback sslCallback;
YangRtcCallback rtcCallback;
YangReceiveCallback recvCallback;
Expand Down
2 changes: 1 addition & 1 deletion include/yangutil/yangavinfotype.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ typedef struct YangRtcInfo {
yangbool enableHttpServerSdp;

int32_t sessionTimeout;
yangbool enableDatachannel;
//yangbool enableDatachannel;
int32_t iceCandidateType;
yangbool iceUsingLocalIp;
int32_t iceServerPort;
Expand Down
8 changes: 4 additions & 4 deletions libmetartc7/src/yangdecoder/YangDecoderFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ YangVideoDecoder* YangDecoderFactory::createVideoDecoder(YangVideoCodec paet,Yan
else
return new YangDecoderMediacodec(pcontext,paet);
#else
if (paet == Yang_VED_264) {
if (paet == Yang_VED_H264) {
if(pcontext->videoDecHwType==0){
#if Yang_Enable_H264Decoder
return new YangH264DecoderSoft();
Expand All @@ -72,13 +72,13 @@ YangVideoDecoder* YangDecoderFactory::createVideoDecoder(YangVideoCodec paet,Yan
}
}
#if Yang_Enable_Ffmpeg_Codec
if (paet == Yang_VED_265) return new YangVideoDecoderFfmpeg(pcontext,paet);
if (paet == Yang_VED_H265) return new YangVideoDecoderFfmpeg(pcontext,paet);
#endif
#endif
return NULL;
}
YangVideoDecoder* YangDecoderFactory::createVideoDecoder(YangVideoInfo *pcontext){
YangVideoCodec maet=Yang_VED_264;
if(pcontext->videoDecoderType==Yang_VED_265) maet=Yang_VED_265;
YangVideoCodec maet=Yang_VED_H264;
if(pcontext->videoDecoderType==Yang_VED_H265) maet=Yang_VED_H265;
return createVideoDecoder(maet,pcontext);
}
4 changes: 2 additions & 2 deletions libmetartc7/src/yangdecoder/YangDecoderMediacodec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ void YangDecoderMediacodec::parseRtmpHeader(uint8_t *p, int32_t pLen, int32_t *p
uint8_t headers[128];
memset(headers, 0, 128);
int32_t headerLen = 0;
if(m_encDecType==Yang_VED_264){
if(m_encDecType==Yang_VED_H264){
uint8_t* sps=NULL;
int32_t spsLen=0;
yang_h264_decode_getH264RtmpHeader(p,&sps,&spsLen);
yang_h264_decode_spspps(sps,spsLen,pwid,phei,pfps);
}else if(m_encDecType==Yang_VED_265) {
}else if(m_encDecType==Yang_VED_H265) {

}
m_width = *pwid;
Expand Down
2 changes: 1 addition & 1 deletion libmetartc7/src/yangdecoder/YangVideoDecoderHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ YangVideoBuffer* YangVideoDecoderHandle::getOutVideoBuffer() {
void YangVideoDecoderHandle::addVideoStream(uint8_t *ps, int32_t puid,
int32_t pisAdd) {
if (pisAdd) {
YangVideoCodec aet = ps[0] == 0x17 ? Yang_VED_264 : Yang_VED_265;
YangVideoCodec aet = ps[0] == 0x17 ? Yang_VED_H264 : Yang_VED_H265;
YangDecoderFactory df;
m_decs=df.createVideoDecoder(aet, &m_context->avinfo.video);
m_decs->m_uid = puid;
Expand Down
2 changes: 1 addition & 1 deletion libmetartc7/src/yangdecoder/YangVideoDecoderHandles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void YangVideoDecoderHandles::removeStream(){
void YangVideoDecoderHandles::addVideoStream(uint8_t *ps, int32_t puid,
int32_t pisAdd) {
if (pisAdd) {
YangVideoCodec aet = ps[0] == 0x17 ? Yang_VED_264 : Yang_VED_265;
YangVideoCodec aet = ps[0] == 0x17 ? Yang_VED_H264 : Yang_VED_H265;
YangDecoderFactory df;
m_decs->push_back(df.createVideoDecoder(aet, &m_context->avinfo.video));
m_decs->back()->m_uid = puid;
Expand Down
Loading

0 comments on commit 20ad88a

Please sign in to comment.