From 19f08e982ed90aa2a7b8d30208540b12b59546be Mon Sep 17 00:00:00 2001 From: a7458969 <290198252@qq.com> Date: Thu, 14 May 2020 01:06:27 +0800 Subject: [PATCH] no message --- client/qt_gl_render/yuvgl/inc/Base64.h | 8 +- client/qt_gl_render/yuvgl/inc/utils.h | 6 - .../qt_gl_render/yuvgl/media/AudioPlayer.cpp | 2 +- client/qt_gl_render/yuvgl/utils/Base64.cpp | 121 ++++++++++++++++++ client/qt_gl_render/yuvgl/utils/Debuger.cpp | 25 ++++ client/qt_gl_render/yuvgl/utils/utils.cpp | 17 +++ client/qt_gl_render/yuvgl/yuvgl.pro | 27 +++- 7 files changed, 194 insertions(+), 12 deletions(-) create mode 100644 client/qt_gl_render/yuvgl/utils/Base64.cpp create mode 100644 client/qt_gl_render/yuvgl/utils/Debuger.cpp create mode 100644 client/qt_gl_render/yuvgl/utils/utils.cpp diff --git a/client/qt_gl_render/yuvgl/inc/Base64.h b/client/qt_gl_render/yuvgl/inc/Base64.h index d08bc8b..9c1ead1 100644 --- a/client/qt_gl_render/yuvgl/inc/Base64.h +++ b/client/qt_gl_render/yuvgl/inc/Base64.h @@ -1,5 +1,5 @@ -const BYTE Base64IdxTab[128] = +const unsigned char Base64IdxTab[128] = { 255,255,255,255, 255,255,255,255, 255,255,255,255, 255,255,255,255, 255,255,255,255, 255,255,255,255, 255,255,255,255, 255,255,255,255, @@ -15,11 +15,11 @@ const BYTE Base64IdxTab[128] = int DecodeBase64(char * pInput, char * pOutput); -const BYTE Base64ValTab[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +const char Base64ValTab[65] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; #define AVal(x) Base64ValTab[x] -int EncodeBase64(BYTE * pInput, int iInputLen, BYTE * pOutput); +int EncodeBase64(unsigned char * pInput, int iInputLen, unsigned char * pOutput); #define DCD_ONCE_LEN 400*1024 -#define CDC_ONCE_LEN 300*1024 \ No newline at end of file +#define CDC_ONCE_LEN 300*1024 diff --git a/client/qt_gl_render/yuvgl/inc/utils.h b/client/qt_gl_render/yuvgl/inc/utils.h index e2ed6e9..dc34076 100644 --- a/client/qt_gl_render/yuvgl/inc/utils.h +++ b/client/qt_gl_render/yuvgl/inc/utils.h @@ -3,9 +3,3 @@ #include using namespace std; - -string GetGUID(); -std::wstring s2ws(const std::string& s); -string WideCharToMultiChar(wstring str); -string Utf8ToAnsi(const char *UTF8); -wstring char2wchar(const char* cchar); \ No newline at end of file diff --git a/client/qt_gl_render/yuvgl/media/AudioPlayer.cpp b/client/qt_gl_render/yuvgl/media/AudioPlayer.cpp index cc0493a..6300a72 100644 --- a/client/qt_gl_render/yuvgl/media/AudioPlayer.cpp +++ b/client/qt_gl_render/yuvgl/media/AudioPlayer.cpp @@ -64,7 +64,7 @@ vector AudioPlayer::EnumSpeakers() const PaDeviceInfo *deviceInfo = Pa_GetDeviceInfo(i); if(nullptr != deviceInfo) if (deviceInfo->maxOutputChannels > 0) { - ins.name = char2wchar(deviceInfo->name); + //ins.name = char2wchar(deviceInfo->name); ret.push_back(ins); } } diff --git a/client/qt_gl_render/yuvgl/utils/Base64.cpp b/client/qt_gl_render/yuvgl/utils/Base64.cpp new file mode 100644 index 0000000..2288f3a --- /dev/null +++ b/client/qt_gl_render/yuvgl/utils/Base64.cpp @@ -0,0 +1,121 @@ +#include "Base64.h" +#include "stdio.h" +#include "string.h" +int DecodeBase64(char * pInput, char * pOutput) +{ + int i = 0; + int iCnt = 0; + int iSrcLen = (int)strlen(pInput); + + char * p = pOutput; + + for (i=0; i 127) continue; + if (pInput[i] == '=') return p-pOutput+1; + + char a = BVal(pInput[i]); + if (a == 255) continue; + + switch (iCnt) + { + case 0: + { + *p = a << 2; + iCnt++; + } + break; + + case 1: + { + *p++ |= a >> 4; + *p = a << 4; + iCnt++; + } + break; + + case 2: + { + *p++ |= a >> 2; + *p = a << 6; + iCnt++; + } + break; + + case 3: + { + *p++ |= a; + iCnt = 0; + } + break; + } + } + + *p = 0x00; + return p-pOutput; +} + +int EncodeBase64(char * pInput,int iInputLen,char * pOutput) +{ + int i = 0; + int loop = 0; + int remain = 0; + int iDstLen = 0; + int iSrcLen = iInputLen; + + loop = iSrcLen/3; + remain = iSrcLen%3; + + // also can encode native char one by one as decode method + // but because all of char in native string is to be encoded so encode 3-chars one time is easier. + + for (i=0; i> 2); + char a2 = ( ((pInput[i*3] & 0x03) << 4) | (pInput[i*3+1] >> 4) ); + char a3 = ( ((pInput[i*3+1] & 0x0F) << 2) | ((pInput[i*3+2] & 0xC0) >> 6) ); + char a4 = (pInput[i*3+2] & 0x3F); + + pOutput[i*4] = AVal(a1); + pOutput[i*4+1] = AVal(a2); + pOutput[i*4+2] = AVal(a3); + pOutput[i*4+3] = AVal(a4); + } + + iDstLen = i*4; + + if (remain == 1) + { + // should pad two equal sign + i = iSrcLen-1; + char a1 = (pInput[i] >> 2); + char a2 = ((pInput[i] & 0x03) << 4); + + pOutput[iDstLen++] = AVal(a1); + pOutput[iDstLen++] = AVal(a2); + pOutput[iDstLen++] = '='; + pOutput[iDstLen++] = '='; + pOutput[iDstLen] = 0x00; + } + else if (remain == 2) + { + // should pad one equal sign + i = iSrcLen-2; + char a1 = (pInput[i] >> 2); + char a2 = ( ((pInput[i] & 0x03) << 4) | (pInput[i+1] >> 4)); + char a3 = ( (pInput[i+1] & 0x0F) << 2); + + pOutput[iDstLen++] = AVal(a1); + pOutput[iDstLen++] = AVal(a2); + pOutput[iDstLen++] = AVal(a3); + pOutput[iDstLen++] = '='; + pOutput[iDstLen] = 0x00; + } + else + { + // just division by 3 + pOutput[iDstLen] = 0x00; + } + + return iDstLen; +} diff --git a/client/qt_gl_render/yuvgl/utils/Debuger.cpp b/client/qt_gl_render/yuvgl/utils/Debuger.cpp new file mode 100644 index 0000000..86eed67 --- /dev/null +++ b/client/qt_gl_render/yuvgl/utils/Debuger.cpp @@ -0,0 +1,25 @@ +#include "Debuger.h" + + +Debuger::Debuger() +{ +} + +Debuger::~Debuger() +{ +} + +int Debuger::Debug(wstring log) +{ + return 0; +} + +int Debuger::Debug(string log) +{ + return 0; +} + +int Debuger::Debug(const wchar_t *format, ...) { + + return 0; +} diff --git a/client/qt_gl_render/yuvgl/utils/utils.cpp b/client/qt_gl_render/yuvgl/utils/utils.cpp new file mode 100644 index 0000000..cb5c4fd --- /dev/null +++ b/client/qt_gl_render/yuvgl/utils/utils.cpp @@ -0,0 +1,17 @@ +#include "utils.h" + + +wstring char2wchar(const char* cchar) +{ + /* + wchar_t m_wchar[2000]; + int len = MultiByteToWideChar(CP_ACP, 0, cchar, strlen(cchar), NULL, 0); + if (len > 0) + { + MultiByteToWideChar(CP_ACP, 0, cchar, strlen(cchar), m_wchar, len); + m_wchar[len] = L'\0'; + return std::wstring(m_wchar); + }*/ + return wstring(L""); +} + diff --git a/client/qt_gl_render/yuvgl/yuvgl.pro b/client/qt_gl_render/yuvgl/yuvgl.pro index aecedc2..c012898 100644 --- a/client/qt_gl_render/yuvgl/yuvgl.pro +++ b/client/qt_gl_render/yuvgl/yuvgl.pro @@ -37,7 +37,12 @@ SOURCES += \ media/ImageUtil.cpp \ media/SdlPlayer.cpp \ media/VideoCoder.cpp \ - media/sps_decode.cpp + media/sps_decode.cpp \ + utils/Base64.cpp \ + utils/Debuger.cpp \ + utils/utils.cpp + +CXXFLAGS += -std=c++0x HEADERS += \ mainwindow.h \ @@ -47,6 +52,26 @@ HEADERS += \ FORMS += \ mainwindow.ui INCLUDEPATH += media/ third/ffmpeg/include/ inc/ third/ +message($$PWD/third/libs/) +LIBS += -L$$PWD/third/libs/ +LIBS += -lm +win32: LIBS += -llibavcodec +win32: LIBS += -llibrtmp +win32: LIBS += -llibswscale +win32: LIBS += -llibavresample +win32: LIBS += -llibavformat +win32: LIBS += -llibavdevice +win32: LIBS += -llibavfilter +win32: LIBS += -lSecur32 +win32: LIBS += -llibavutil +win32: LIBS += -lSDL2 +win32: LIBS += -lSDL2main +win32: LIBS += -lportaudio_x86 +win32: LIBS += -llibx264 +win32: LIBS += -lOle32 +win32: LIBS += -lOleAut32 +win32: LIBS += $$PWD/third/libs/chkstk.obj + # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin