mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-06 03:28:09 +08:00
无音频时生成静音音频,防止播放器加载画面太慢
修复MAC下SDL必须在主线程渲染的问题
This commit is contained in:
@@ -11,7 +11,7 @@ find_package(AVUTIL QUIET)
|
||||
if(AVUTIL_FOUND)
|
||||
include_directories(${AVUTIL_INCLUDE_DIR})
|
||||
list(APPEND LINK_LIB_LIST ${AVUTIL_LIBRARIES})
|
||||
message(STATUS " found libutil")
|
||||
message(STATUS "found libutil ${AVUTIL_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
#查找ffmpeg/libavcodec是否安装
|
||||
@@ -19,7 +19,7 @@ find_package(AVCODEC QUIET)
|
||||
if(AVCODEC_FOUND)
|
||||
include_directories(${AVCODEC_INCLUDE_DIR})
|
||||
list(APPEND LINK_LIB_LIST ${AVCODEC_LIBRARIES})
|
||||
message(STATUS " found libavcodec")
|
||||
message(STATUS "found libavcodec ${AVCODEC_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
aux_source_directory(. TEST_SRC_LIST)
|
||||
|
||||
@@ -42,6 +42,8 @@ using namespace ZL::Util;
|
||||
|
||||
#define REFRESH_EVENT (SDL_USEREVENT + 1)
|
||||
|
||||
|
||||
#ifndef __MACH__
|
||||
class SDLDisplayerHelper
|
||||
{
|
||||
public:
|
||||
@@ -104,6 +106,8 @@ private:
|
||||
|
||||
};
|
||||
|
||||
#endif //__MACH__
|
||||
|
||||
class YuvDisplayer {
|
||||
public:
|
||||
YuvDisplayer(void *hwnd = nullptr,const char *title = "untitled"){
|
||||
@@ -121,7 +125,9 @@ public:
|
||||
},nullptr);
|
||||
InfoL << "SDL_Init";
|
||||
}, []() {
|
||||
#ifndef __MACH__
|
||||
SDLDisplayerHelper::Destory();
|
||||
#endif
|
||||
SDL_Quit();
|
||||
});
|
||||
|
||||
|
||||
@@ -73,16 +73,29 @@ int main(int argc, char *argv[]) {
|
||||
H264Decoder decoder;
|
||||
YuvDisplayer displayer;
|
||||
player->setOnVideoCB([&](const H264Frame &frame) {
|
||||
#ifndef __MACH__
|
||||
SDLDisplayerHelper::Instance().doTask([&, frame]() {
|
||||
AVFrame *pFrame = nullptr;
|
||||
bool flag = decoder.inputVideo((unsigned char *) frame.data.data(), frame.data.size(), frame.timeStamp,
|
||||
&pFrame);
|
||||
if (flag) {
|
||||
//DebugL << pFrame->pkt_pts;
|
||||
displayer.displayYUV(pFrame);
|
||||
EventPoller::Instance().sync([&](){
|
||||
displayer.displayYUV(pFrame);
|
||||
});
|
||||
}
|
||||
return true;
|
||||
});
|
||||
#else
|
||||
AVFrame *pFrame = nullptr;
|
||||
bool flag = decoder.inputVideo((unsigned char *) frame.data.data(), frame.data.size(), frame.timeStamp,
|
||||
&pFrame);
|
||||
if (flag) {
|
||||
//DebugL << pFrame->pkt_pts;
|
||||
displayer.displayYUV(pFrame);
|
||||
}
|
||||
#endif
|
||||
|
||||
});
|
||||
|
||||
EventPoller::Instance().runLoop();
|
||||
|
||||
Reference in New Issue
Block a user