mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 10:40:05 +08:00
修复异步addDelegate导致丢帧的问题
This commit is contained in:
parent
8092cb446e
commit
1df3859c98
@ -1 +1 @@
|
|||||||
Subproject commit ec50224e4094b91be10a40ba221793706676b2b9
|
Subproject commit 03d0953f91e0a75fa8e95fce032ff9d3bef04789
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include "Util/util.h"
|
||||||
#include "Util/logger.h"
|
#include "Util/logger.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "Poller/EventPoller.h"
|
#include "Poller/EventPoller.h"
|
||||||
@ -68,22 +69,27 @@ int main(int argc, char *argv[]) {
|
|||||||
WarnL << "没有视频或者视频不是264编码!";
|
WarnL << "没有视频或者视频不是264编码!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SDLDisplayerHelper::Instance().doTask([viedoTrack]() {
|
|
||||||
std::shared_ptr<H264Decoder> decoder(new H264Decoder);
|
AnyStorage::Ptr storage(new AnyStorage);
|
||||||
std::shared_ptr<YuvDisplayer> displayer(new YuvDisplayer);
|
viedoTrack->addDelegate(std::make_shared<FrameWriterInterfaceHelper>([storage](const Frame::Ptr &frame) {
|
||||||
viedoTrack->addDelegate(std::make_shared<FrameWriterInterfaceHelper>([decoder, displayer](const Frame::Ptr &frame) {
|
SDLDisplayerHelper::Instance().doTask([frame,storage]() {
|
||||||
SDLDisplayerHelper::Instance().doTask([decoder, displayer, frame]() {
|
auto &decoder = (*storage)["decoder"];
|
||||||
AVFrame *pFrame = nullptr;
|
auto &displayer = (*storage)["displayer"];
|
||||||
bool flag = decoder->inputVideo((unsigned char *) frame->data(), frame->size(),
|
if(!decoder){
|
||||||
frame->stamp(), &pFrame);
|
decoder.set<H264Decoder>();
|
||||||
if (flag) {
|
}
|
||||||
displayer->displayYUV(pFrame);
|
if(!displayer){
|
||||||
}
|
displayer.set<YuvDisplayer>();
|
||||||
return true;
|
}
|
||||||
});
|
|
||||||
}));
|
AVFrame *pFrame = nullptr;
|
||||||
return true;
|
bool flag = decoder.get<H264Decoder>().inputVideo((unsigned char *) frame->data(), frame->size(), frame->stamp(), &pFrame);
|
||||||
});
|
if (flag) {
|
||||||
|
displayer.get<YuvDisplayer>().displayYUV(pFrame);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user