Skip to content

Commit

Permalink
7.0.072
Browse files Browse the repository at this point in the history
  • Loading branch information
yangrtc committed Oct 28, 2023
1 parent 290f2d8 commit 3aeab1a
Show file tree
Hide file tree
Showing 195 changed files with 10,379 additions and 2 deletions.
35 changes: 35 additions & 0 deletions demo/metaplayer7_flutter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 2.8)
project(metaplayer7)

add_definitions(-D__STDC_FORMAT_MACROS)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -std=gnu11 ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -std=gnu++11 ")
set(HOME_BASE_REL "../../")
get_filename_component(HOME_BASE ${HOME_BASE_REL} REALPATH)
set(Yang_3RD_DIR ${HOME_BASE}/thirdparty/lib/pic/)
set(Yang_Lib_DIR ${HOME_BASE}/bin/lib_debug)
# 头文件目录
include_directories(${HOME_BASE}/include)
include_directories(${HOME_BASE}/thirdparty/include)
include_directories(${HOME_BASE}/thirdparty/user_include)
include_directories(${HOME_BASE}/thirdparty/user_include/ffmpeg)
include_directories(${HOME_BASE}/libmetartc7/src)
include_directories(${HOME_BASE}/demo/libmetaApp/src)


aux_source_directory(./metaplayer7 DIR_SRCS)

#set(CMAKE_POSITION_INDEPENDENT_CODE ON)

add_library(metaplayer7 SHARED ${DIR_SRCS})

target_link_libraries(metaplayer7
${Yang_Lib_DIR}/libmetartc7.a ${Yang_Lib_DIR}/libmetartccore7.a
${Yang_3RD_DIR}/libsrtp2.a ${Yang_3RD_DIR}/libssl2.a ${Yang_3RD_DIR}/libcrypto2.a
${Yang_3RD_DIR}/libspeexdsp.a ${Yang_3RD_DIR}/libyuv.a
${Yang_3RD_DIR}/libyangh264decoder.a ${Yang_3RD_DIR}/libopus.a
asound pthread dl
)


25 changes: 25 additions & 0 deletions demo/metaplayer7_flutter/cmake_x64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

cd metaplayer7_flutter
flutter build linux --debug

cd ..
rm -rf ../../bin/app_debug/flutter
cp -r ./metaplayer7_flutter/build/linux/x64/debug/bundle ../../bin/app_debug/
mv ../../bin/app_debug/bundle ../../bin/app_debug/flutter

rm -rf build
mkdir build
cd build
#cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..
cmake -DCMAKE_BUILD_TYPE=Release ..
make

cd ..

if [ ! -d "../../bin/app_debug/flutter/lib" ] ; then
mkdir -p ../../bin/app_debug/flutter/lib
fi

cp ./build/libmetaplayer7.so ../../bin/app_debug/flutter/lib/
cp ./yang_config.ini ../../bin/app_debug/flutter/

170 changes: 170 additions & 0 deletions demo/metaplayer7_flutter/metaplayer7/YangMetaplayer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
//
// Copyright (c) 2019-2023 yanggaofeng
//

#include "YangMetaplayer.h"
#include <yangutil/sys/YangSocket.h>
#include <yangutil/sys/YangLog.h>
#include <yangutil/sys/YangMath.h>
#include "YangPlayDef.h"

extern "C"{
#include <libyuv.h>
}
void* yang_create_player(){
return new YangMetaplayer();
}
void yang_destroy_player(void* user){
YangMetaplayer* player=(YangMetaplayer*)user;
yang_delete(player);
}
int32_t yang_player_playRtc(void* user,char* url){
if(user==NULL) return 1;
YangMetaplayer* player=(YangMetaplayer*)user;
player->playRtc(url);
return 0;
}
int32_t yang_player_close(void* user){
if(user==NULL) return 1;
YangMetaplayer* player=(YangMetaplayer*)user;
player->close();
return 0;
}
uint8_t* yang_player_get_buffer(void* user,int32_t dstWidth,int32_t dstHeight){
YangMetaplayer* player=(YangMetaplayer*)user;
uint8_t* buffer=NULL;
int32_t width=0;
int32_t height=0;
if(user==NULL) return NULL;
buffer=player->m_context->synMgr.session->playBuffer->getVideoRef(
player->m_context->synMgr.session->playBuffer->session,&player->m_frame);
if(buffer==NULL) return NULL;
width=player->m_context->synMgr.session->playBuffer->width(player->m_context->synMgr.session->playBuffer->session);
height=player->m_context->synMgr.session->playBuffer->height(player->m_context->synMgr.session->playBuffer->session);
if(width!=player->m_srcWidth&&height!=player->m_srcHeight){
yang_free(player->m_rgbaBuffer);
player->m_rgbaBuffer=(uint8_t*)malloc(width*height*4);
player->m_srcWidth=width;
player->m_srcHeight=height;
}
if(player->m_dstWidth!=dstWidth&&player->m_dstHeight!=dstHeight){
yang_free(player->m_buffer);
player->m_dstWidth=dstWidth;
player->m_dstHeight=dstHeight;
player->m_buffer=(uint8_t*)malloc(dstWidth*dstHeight*4);
}
//I420ToABGR I420ToARGB
libyuv::I420ToABGR((const uint8_t*) buffer, width,
(const uint8_t*) (buffer + (width * height)), (width >> 1),
(const uint8_t*) (buffer + (width * height) + (int) (width * height / 4)),width >> 1,
(uint8_t*)player->m_rgbaBuffer,width * 4,
width, height);
if(width!=dstWidth){
libyuv::ARGBScale((const uint8_t*)player->m_rgbaBuffer,width*4,
width,height,
player->m_buffer,dstWidth*4,
dstWidth,dstHeight,
libyuv::kFilterNone
);
return player->m_buffer;
}

return player->m_rgbaBuffer;



}
YangMetaplayer::YangMetaplayer()

{

m_context=new YangContext();
m_context->init();

m_context->synMgr.session->playBuffer=(YangSynBuffer*)yang_calloc(sizeof(YangSynBuffer),1);
yang_create_synBuffer(m_context->synMgr.session->playBuffer);

m_context->avinfo.sys.mediaServer=Yang_Server_Srs;//Yang_Server_Srs/Yang_Server_Zlm
m_context->avinfo.rtc.rtcSocketProtocol=Yang_Socket_Protocol_Udp;//

m_context->avinfo.rtc.rtcLocalPort=10000+yang_random()%15000;
memset(m_context->avinfo.rtc.localIp,0,sizeof(m_context->avinfo.rtc.localIp));
yang_getLocalInfo(m_context->avinfo.sys.familyType,m_context->avinfo.rtc.localIp);
m_player= YangPlayerHandle::createPlayerHandle(m_context,this);
yang_setLogLevel(5);
yang_setLogFile(1);
m_srcWidth=640;
m_srcHeight=480;
m_dstWidth=640;
m_dstHeight=480;
m_buffer=(uint8_t*)yang_malloc(m_dstWidth*m_dstHeight*4);
m_rgbaBuffer=(uint8_t*)yang_malloc(m_srcWidth*m_srcHeight*4);;

//char s[128]={0};

//sprintf(s,"webrtc://%s:1985/live/livestream",m_context->avinfo.rtc.localIp);
//yang_trace("\nurl===%s",s);
//yang_lvgl_setUrlText(s);

m_isStartplay=false;


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


memset(&m_frame,0,sizeof(m_frame));

}

YangMetaplayer::~YangMetaplayer()
{
yang_delete(m_player);
yang_closeLogFile();
yang_delete(m_context);
yang_free(m_buffer);
yang_free(m_rgbaBuffer);

}


void YangMetaplayer::success(){

}
void YangMetaplayer::failure(int32_t errcode){



}


void YangMetaplayer::close(){

yang_usleep(50 * 1000);
if (m_player)
m_player->stopPlay();

m_isStartplay = !m_isStartplay;
}
void YangMetaplayer::playRtc(char* url)
{
m_context->synMgr.session->playBuffer->resetVideoClock(m_context->synMgr.session->playBuffer->session);
int32_t err = Yang_Ok;

err = m_player->play(url);

if (err)
{
yang_error("play url error!");

}
}






40 changes: 40 additions & 0 deletions demo/metaplayer7_flutter/metaplayer7/YangMetaplayer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// Copyright (c) 2019-2023 yanggaofeng
//

#ifndef SRC_YANGMETAPLAYER_H_
#define SRC_YANGMETAPLAYER_H_

#include "yangplayer/YangPlayerHandle.h"
#include "yangstream/YangStreamType.h"

#include <yangutil/yangavinfotype.h>
#include <yangutil/sys/YangSysMessageI.h>
class YangMetaplayer:public YangSysMessageI {
public:
YangMetaplayer();
virtual ~YangMetaplayer();
YangContext* m_context;
uint8_t* m_buffer;
uint8_t* m_rgbaBuffer;
YangPlayerHandle *m_player;
YangStreamConfig m_conf;
YangFrame m_frame;
int32_t m_srcWidth,m_dstWidth;
int32_t m_srcHeight,m_dstHeight;

void success();
void failure(int32_t errcode);
void playRtc(char* url);
void close();
void setSize(int32_t width,int32_t height);
protected:

private:
bool m_isStartplay;



};

#endif /* SRC_YANGMETAPLAYER_H_ */
19 changes: 19 additions & 0 deletions demo/metaplayer7_flutter/metaplayer7/YangPlayDef.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//
// Copyright (c) 2019-2023 yanggaofeng
//

#ifndef SRC_YANGPlayerDEF_H_
#define SRC_YANGPlayerDEF_H_
#include <stdint.h>
extern "C"{

void* yang_create_player();
void yang_destroy_player(void* user);
int32_t yang_player_playRtc(void* user,char* url);
int32_t yang_player_close(void* user);
uint8_t* yang_player_get_buffer(void* user,int32_t width,int32_t height);
}



#endif
30 changes: 30 additions & 0 deletions demo/metaplayer7_flutter/metaplayer7/YangPlayFactory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// Copyright (c) 2019-2022 yanggaofeng
//


#include <yangplayer/YangPlayFactory.h>


YangPlayFactory::YangPlayFactory() {


}

YangPlayFactory::~YangPlayFactory() {

}

YangAudioPlay* YangPlayFactory::createAudioPlay(YangAudioInfo *pcontext){
#if !Yang_OS_WIN
return NULL;//if(pcontext->audioPlayType==1) return new YangAudioPlayAlsa(pcontext);
#endif
return NULL;// new YangAudioPlaySdl(pcontext);
}

YangAudioPlay *YangPlayFactory::createAudioPlay(YangAudioPlayType paet,YangAudioInfo *pcontext){
#if !Yang_OS_WIN
return NULL;//if(paet==Yang_AP_ALSA) return new YangAudioPlayAlsa(pcontext);
#endif
return NULL;//new YangAudioPlaySdl(pcontext);
}
64 changes: 64 additions & 0 deletions demo/metaplayer7_flutter/metaplayer7/YangPlayerBase.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// Copyright (c) 2019-2022 yanggaofeng
//
#include <yangplayer/YangPlayerBase.h>

YangPlayerBase::YangPlayerBase()
{

m_ydb=NULL;
m_ypb=NULL;

}

YangPlayerBase::~YangPlayerBase()
{

yang_delete(m_ydb);
yang_delete(m_ypb);
}

void YangPlayerBase::stopAll(){
if(m_ydb) m_ydb->stopAll();
if(m_ypb) m_ypb->stopAll();
}


void YangPlayerBase::init(YangContext* pcontext){
//YangAudioInfo* audio=&pcontext->audio;
if(m_ydb==NULL) {
m_ydb=new YangPlayerDecoder(pcontext);

m_ydb->initAudioDecoder();
m_ydb->initVideoDecoder();
}

if(m_ypb==NULL) {
m_ypb=new YangPlayerPlay();
m_ypb->initAudioPlay(pcontext);

m_ypb->setInAudioList(m_ydb->getOutAudioBuffer());
;
}

}

void YangPlayerBase::startAudioDecoder(YangAudioEncoderBuffer *prr){
m_ydb->setInAudioBuffer(prr);
m_ydb->startAudioDecoder();
}
void YangPlayerBase::startVideoDecoder(YangVideoDecoderBuffer *prr){
m_ydb->setInVideoBuffer(prr);
m_ydb->startVideoDecoder();
}

void YangPlayerBase::startAudioPlay(YangContext* paudio) {

if(m_ypb){
m_ypb->initAudioPlay(paudio);
m_ypb->startAudioPlay();
}
}



Loading

0 comments on commit 3aeab1a

Please sign in to comment.