Skip to content

Commit

Permalink
7.0.020
Browse files Browse the repository at this point in the history
  • Loading branch information
yangrtc committed Aug 10, 2023
1 parent 8663858 commit 6c7c32b
Show file tree
Hide file tree
Showing 14 changed files with 528 additions and 67 deletions.
24 changes: 21 additions & 3 deletions demo/metaplayer7/metaplayer7.pro
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,26 @@ DEFINES += QT_DEPRECATED_WARNINGS
#DEFINES += QT_WIN_MSC
HOME_BASE=../../
INCLUDEPATH += $$HOME_BASE/libmetartc7/src
macx{

unix{
INCLUDEPATH += $$HOME_BASE/include
CONFIG(debug, debug|release) {
LIBS += -L$$HOME_BASE/bin/lib_debug
DESTDIR += $$HOME_BASE/bin/app_debug
}else{
LIBS += -L$$HOME_BASE/bin/lib_release
DESTDIR += $$HOME_BASE/bin/app_release
}
LIBS += -L$$HOME_BASE/thirdparty/lib

LIBS += -lmetartc7 -lmetartccore7 -lyuv -lspeexdsp -lopus -lyangh264decoder -lusrsctp -lpthread -ldl

LIBS += -framework CoreAudio -framework AudioUnit

#openssl
LIBS += -lssl2 -lcrypto2 -lsrtp2
}
unix:!macx{

INCLUDEPATH += $$HOME_BASE/include
CONFIG(debug, debug|release) {
Expand All @@ -29,8 +47,7 @@ unix{
LIBS += -L$$HOME_BASE/thirdparty/lib

LIBS += -lmetartc7 -lmetartccore7 -lyuv -lspeexdsp -lopus -lyangh264decoder -lusrsctp -lpthread -ldl
#mac/ios
#LIBS += -framework CoreAudio -framework AudioUnit

#linux
LIBS += -lasound
#openssl
Expand All @@ -41,6 +58,7 @@ LIBS += -lasound
#gmssl
#LIBS += -lssl_gm -lcrypto_gm -lmetasrtp3
}

win32{
DEFINES += __WIN32__
DEFINES +=_AMD64_
Expand Down
24 changes: 21 additions & 3 deletions demo/metapushstream7/metapushstream7.pro
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,26 @@ HOME_BASE=../../

INCLUDEPATH += $$HOME_BASE/libmetartc7/src
INCLUDEPATH += $$HOME_BASE/thirdparty/include
unix{
macx{

INCLUDEPATH += $$HOME_BASE/include
CONFIG(debug, debug|release) {
LIBS += -L$$HOME_BASE/bin/lib_debug
DESTDIR += $$HOME_BASE/bin/app_debug
}else{
LIBS += -L$$HOME_BASE/bin/lib_release
DESTDIR += $$HOME_BASE/bin/app_release
}

LIBS += -L$$HOME_BASE/thirdparty/lib -lmetartc7 -lmetartccore7 -lyuv -lopenh264 -lspeexdsp -lopus -lusrsctp -lpthread -ldl

LIBS += -framework CoreAudio -framework AudioUnit -framework AVFoundation -framework CoreVideo -framework CoreMedia

#openssl
LIBS += -lssl2 -lcrypto2 -lsrtp2

}
unix:!macx{

INCLUDEPATH += $$HOME_BASE/include
CONFIG(debug, debug|release) {
Expand All @@ -36,8 +55,7 @@ unix{
LIBS += -L$$HOME_BASE/thirdparty/lib -lmetartc7 -lmetartccore7 -lyuv -lopenh264 -lspeexdsp -lopus -lusrsctp -lpthread -ldl
#linux
LIBS += -lasound
#mac/ios
#LIBS += -framework CoreAudio -framework AudioUnit

#openssl
LIBS += -lssl2 -lcrypto2 -lsrtp2
#mbtls
Expand Down
4 changes: 4 additions & 0 deletions demo/metapushstream7/recordmainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ RecordMainWindow::RecordMainWindow(QWidget *parent)
//srs do not use audio fec
m_context->avinfo.audio.enableAudioFec=yangfalse;

#if defined (__APPLE__)
m_context->avinfo.video.videoCaptureFormat=YangNv12;
#endif

}

RecordMainWindow::~RecordMainWindow()
Expand Down
9 changes: 7 additions & 2 deletions libmetartc7/metartc7.pro
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ unix{

DESTDIR += $$HOME_BASE/bin/lib_release
}

}
win32{
DEFINES += _AMD64_
Expand Down Expand Up @@ -82,7 +83,6 @@ SOURCES += \
src/yangcapture/android/YangCameraAndroid.cpp \
src/yangcapture/android/YangVideoCaptureAndroid.cpp \
src/yangcapture/linux/YangVideoCaptureLinux.cpp \
src/yangcapture/mac/YangVideoCaptureMac.cpp \
src/yangcapture/win/YangDXGIManager.cpp \
src/yangcapture/win/YangVideoCaptureWindows.cpp \
src/yangcapture/win/YangVideoSrc.cpp \
Expand Down Expand Up @@ -139,8 +139,12 @@ SOURCES += \
src/yangutil/buffer/YangMediaBuffer.cpp \
src/yangutil/buffer/YangVideoBuffer.cpp \
src/yangutil/buffer/YangVideoDecoderBuffer.cpp \
src/yangutil/buffer/YangVideoEncoderBuffer.cpp
src/yangutil/buffer/YangVideoEncoderBuffer.cpp\
src/yangcapture/mac/YangVideoCaptureMac.cpp \

macx{
SOURCES += src/yangcapture/mac/YangVideoDeviceMac.mm
}


HEADERS += \
Expand Down Expand Up @@ -170,6 +174,7 @@ HEADERS += \
src/yangcapture/android/YangVideoCaptureAndroid.h \
src/yangcapture/linux/YangVideoCaptureLinux.h \
src/yangcapture/mac/YangVideoCaptureMac.h \
src/yangcapture/mac/YangVideoDeviceMac.h \
src/yangcapture/win/YangDXGIManager.h \
src/yangcapture/win/YangVideoCaptureWindows.h \
src/yangcapture/win/YangVideoSrc.h \
Expand Down
5 changes: 4 additions & 1 deletion libmetartc7/src/yangaudiodev/mac/YangAudioDeviceMac.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "YangAudioDeviceMac.h"
//
// Copyright (c) 2019-2023 yanggaofeng
//
#include "YangAudioDeviceMac.h"
#if defined(__APPLE__)
#include <yangutil/sys/YangLog.h>

Expand Down
5 changes: 4 additions & 1 deletion libmetartc7/src/yangaudiodev/mac/YangAudioDeviceMac.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#ifndef YANGAUDIODEVICEMAC_H
//
// Copyright (c) 2019-2023 yanggaofeng
//
#ifndef YANGAUDIODEVICEMAC_H
#define YANGAUDIODEVICEMAC_H

#if defined(__APPLE__)
Expand Down
5 changes: 4 additions & 1 deletion libmetartc7/src/yangaudiodev/mac/YangAudioMac.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include "YangAudioMac.h"
//
// Copyright (c) 2019-2023 yanggaofeng
//
#include "YangAudioMac.h"
#include <yangutil/sys/YangLog.h>
#if defined(__APPLE__)
#include <CoreFoundation/CFString.h>
Expand Down
6 changes: 4 additions & 2 deletions libmetartc7/src/yangaudiodev/mac/YangAudioMac.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#ifndef YANGAUDIOMAC_H
//
// Copyright (c) 2019-2023 yanggaofeng
//
#ifndef YANGAUDIOMAC_H
#define YANGAUDIOMAC_H
#include <yangutil/yangtype.h>
#include <yangutil/yangavctype.h>
Expand Down Expand Up @@ -28,7 +31,6 @@ class YangAudioMac
uint32_t getChannel();
public:
AudioUnit m_unit;

AudioDeviceID m_deviceId;

AudioBufferList* m_bufferList;
Expand Down
24 changes: 20 additions & 4 deletions libmetartc7/src/yangcapture/YangVideoCaptureHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ YangVideoCaptureHandle::~YangVideoCaptureHandle(void) {

}
void YangVideoCaptureHandle::setCaptureFormat(int32_t pformat){
if(pformat==YangYuy2&&!m_buf) m_buf=new uint8_t[m_bufLen];
if((pformat==YangYuy2||pformat==YangNv12)&&!m_buf) m_buf=new uint8_t[m_bufLen];
}
void YangVideoCaptureHandle::setVideoBuffer(YangVideoBuffer *pbuf){
m_out_videoBuffer=pbuf;
Expand Down Expand Up @@ -116,13 +116,29 @@ void YangVideoCaptureHandle::putBuffer(int64_t pstamtime, uint8_t *pBuffer, int3
uint8_t* tmp=NULL;
if(m_buf){
if(m_captureVideoFormat==YangYuy2){

if(m_encoderVideoFormat==YangI420) m_yuv.yuy2toI420(pBuffer,m_buf,m_width,m_height);
if(m_encoderVideoFormat==YangNv12) m_yuv.yuy2tonv12(pBuffer,m_buf,m_width,m_height);
if(m_encoderVideoFormat==YangArgb) m_yuv.yuy2toargb(pBuffer,m_buf,m_width,m_height);
tmp=m_buf;
}else if(m_captureVideoFormat==YangI420){
if(m_encoderVideoFormat==YangI420) tmp=m_buf;
if(m_encoderVideoFormat==YangNv12) m_yuv.i420tonv12(pBuffer,m_buf,m_width,m_height);
}else if(m_captureVideoFormat==YangNv12){

if(m_encoderVideoFormat==YangI420){
m_yuv.nv12toI420(pBuffer,m_buf,m_width,m_height);
tmp=m_buf;

}else if(m_encoderVideoFormat==YangNv12)

tmp=pBuffer;
//if(m_encoderVideoFormat==YangArgb) m_yuv.i420torgba(pBuffer,m_buf,m_width,m_height);
}else if(m_captureVideoFormat==YangI420){

if(m_encoderVideoFormat==YangI420){
tmp=pBuffer;

}else if(m_encoderVideoFormat==YangNv12)
m_yuv.i420tonv12(pBuffer,m_buf,m_width,m_height);
tmp=m_buf;
//if(m_encoderVideoFormat==YangArgb) m_yuv.i420torgba(pBuffer,m_buf,m_width,m_height);
}else if(m_captureVideoFormat==YangArgb){
tmp=pBuffer;
Expand Down
2 changes: 1 addition & 1 deletion libmetartc7/src/yangcapture/linux/YangVideoCaptureLinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#if !defined(_WIN32) && !defined(__APPLE__)
#include <linux/videodev2.h>

#define REQ_BUF_NUM 4 //申请的缓冲区个数,最多5个,缓冲区太少可能会导致图像有间断
#define REQ_BUF_NUM 4
typedef struct buffer_type_r buffer_type;
struct buffer_type_r {
uint8_t *start;
Expand Down
91 changes: 58 additions & 33 deletions libmetartc7/src/yangcapture/mac/YangVideoCaptureMac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,51 @@
#include <yangutil/yangavinfotype.h>

#if defined(__APPLE__)


void yang_macv_on_video(uint8_t* data,uint32_t nb,uint64_t ts,void* user){
YangVideoCaptureMac* mac;
if(data==NULL || user==NULL) return;
mac=(YangVideoCaptureMac*)user;
mac->on_video(data,nb,ts);
}

YangVideoCaptureMac::YangVideoCaptureMac(YangVideoInfo *pcontext) {

m_para = pcontext;

m_vhandle = new YangVideoCaptureHandle(pcontext);
cameraIndex = pcontext->vIndex;
m_width = m_para->width;
m_height = m_para->height;
m_vd_id = 0;

m_isloop = yangfalse;
m_waitState = yangfalse;


YangMacVideoCallback callback;
callback.user=this;
callback.on_video=yang_macv_on_video;

m_device=(YangVideoDeviceMac*)yang_calloc(sizeof(YangVideoDeviceMac),1);

yang_create_macVideo(m_device,(uint32_t)pcontext->width,(uint32_t)pcontext->height,(uint32_t)pcontext->frame,&callback);
yang_thread_mutex_init(&m_lock,NULL);
yang_thread_cond_init(&m_cond_mess,NULL);

m_isloop = 0;
m_isFirstFrame = 0;
m_buffer_count = 0;
m_timestatmp = 0;
m_hasYuy2 = 0, m_hasI420 = 0, m_hasNv12 = 0, m_hasYv12 = 0, m_hasP010 = 0,m_hasP016=0;
m_vhandle->setCaptureFormat(YangNv12);
}

YangVideoCaptureMac::~YangVideoCaptureMac() {
if (m_isloop) {
if (m_isStart) {
stop();
while (m_isStart) {
yang_usleep(1000);
}
}

yang_delete(m_vhandle);
yang_destroy_macVideo(m_device);
yang_free(m_device);
yang_thread_mutex_destroy(&m_lock);
yang_thread_cond_destroy(&m_cond_mess);
}
void YangVideoCaptureMac::setVideoCaptureStart() {
m_vhandle->m_isCapture = 1;
Expand Down Expand Up @@ -82,54 +97,64 @@ void YangVideoCaptureMac::setPreVideoBuffer(YangVideoBuffer *pbuf) {
void YangVideoCaptureMac::initstamp() {
m_vhandle->initstamp();
}
int32_t YangVideoCaptureMac::setPara() {


return Yang_Ok;
}

int32_t YangVideoCaptureMac::init() {



if(m_device&&m_device->init(m_device->session)!=Yang_Ok){
yang_error("mac video capture init fail!");
return 1;
}

return Yang_Ok;
}

void YangVideoCaptureMac::on_video(uint8_t* data,uint32_t nb,uint64_t ts){
if (m_vhandle)
m_vhandle->putBuffer(ts, data,nb);
}


long YangVideoCaptureMac::m_difftime(struct timeval *p_start,
struct timeval *p_end) {
return (p_end->tv_sec - p_start->tv_sec) * 1000000
+ (p_end->tv_usec - p_start->tv_usec);
}

int32_t YangVideoCaptureMac::read_buffer() {



return Yang_Ok;
}
void YangVideoCaptureMac::stopLoop() {
m_isloop = 0;
}

void YangVideoCaptureMac::stop_capturing() {

if(m_device&&m_device->stop(m_device->session)!=Yang_Ok){
yang_error("mac video capture stop fail!");
//return;
}
m_isloop = yangfalse;
if (m_waitState) {
yang_thread_mutex_lock(&m_lock);
yang_thread_cond_signal(&m_cond_mess);
yang_thread_mutex_unlock(&m_lock);

}
}
void YangVideoCaptureMac::uninit_camer_device() {



}

void YangVideoCaptureMac::close_camer_device() {


}

void YangVideoCaptureMac::startLoop() {

m_isloop=yangtrue;
if(m_device&&m_device->start(m_device->session)!=Yang_Ok){
yang_error("mac video capture start fail!");
//return;
}
yang_thread_mutex_lock(&m_lock);
while (m_isloop) {
m_waitState = yangtrue;

yang_thread_cond_wait(&m_cond_mess, &m_lock);
m_waitState = yangfalse;
} //end while


yang_thread_mutex_unlock(&m_lock);
}
#endif
Loading

0 comments on commit 6c7c32b

Please sign in to comment.