From 71174f906b61e22ea72e3a50ab6e76efc165534c Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Tue, 17 Apr 2018 21:44:18 +0800 Subject: [PATCH] bug fixed --- tests/YuvDisplayer.h | 1 - tests/test_player.cpp | 59 +++++++++++++++++++++---------------------- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/tests/YuvDisplayer.h b/tests/YuvDisplayer.h index 22f41898..3dabc93f 100644 --- a/tests/YuvDisplayer.h +++ b/tests/YuvDisplayer.h @@ -123,7 +123,6 @@ public: }, []() { SDLDisplayerHelper::Destory(); SDL_Quit(); - InfoL << "SDL_Quit"; }); _title = title; diff --git a/tests/test_player.cpp b/tests/test_player.cpp index 9ce06563..1534bf5f 100644 --- a/tests/test_player.cpp +++ b/tests/test_player.cpp @@ -59,39 +59,38 @@ int main(int argc, char *argv[]) { } - MediaPlayer::Ptr player(new MediaPlayer()); - player->setOnPlayResult([](const SockException &ex) { - InfoL << "OnPlayResult:" << ex.what(); - }); - player->setOnShutdown([](const SockException &ex) { - ErrorL << "OnShutdown:" << ex.what(); - }); - (*player)[RtspPlayer::kRtpType] = atoi(argv[2]); - player->play(argv[1]); - - H264Decoder decoder; - YuvDisplayer displayer; - player->setOnVideoCB([&](const H264Frame &frame) { - 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); - } - return true; + { + MediaPlayer::Ptr player(new MediaPlayer()); + player->setOnPlayResult([](const SockException &ex) { + InfoL << "OnPlayResult:" << ex.what(); }); - }); + player->setOnShutdown([](const SockException &ex) { + ErrorL << "OnShutdown:" << ex.what(); + }); + (*player)[RtspPlayer::kRtpType] = atoi(argv[2]); + player->play(argv[1]); - EventPoller::Instance().runLoop(); + H264Decoder decoder; + YuvDisplayer displayer; + player->setOnVideoCB([&](const H264Frame &frame) { + 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); + } + return true; + }); + }); - - static onceToken token(nullptr, []() { - UDPServer::Destory(); - EventPoller::Destory(); - AsyncTaskThread::Destory(); - Logger::Destory(); - }); + EventPoller::Instance().runLoop(); + } + UDPServer::Destory(); + EventPoller::Destory(); + AsyncTaskThread::Destory(); + Logger::Destory(); return 0; }