use poller input data avoid throw poll check

This commit is contained in:
xiongguangjie 2023-04-07 23:09:10 +08:00
parent 67d8837442
commit 749ef33965

View File

@ -26,8 +26,10 @@ using namespace std;
using namespace toolkit; using namespace toolkit;
using namespace mediakit; using namespace mediakit;
static semaphore sem;
#if defined(ENABLE_RTPPROXY) #if defined(ENABLE_RTPPROXY)
static bool loadFile(const char *path){ static bool loadFile(const char *path, const EventPoller::Ptr &poller){
FILE *fp = fopen(path, "rb"); FILE *fp = fopen(path, "rb");
if (!fp) { if (!fp) {
WarnL << "open file failed:" << path; WarnL << "open file failed:" << path;
@ -40,7 +42,7 @@ static bool loadFile(const char *path){
struct sockaddr_storage addr; struct sockaddr_storage addr;
memset(&addr, 0, sizeof(addr)); memset(&addr, 0, sizeof(addr));
addr.ss_family = AF_INET; addr.ss_family = AF_INET;
auto sock = Socket::createSocket(); auto sock = Socket::createSocket(poller);
size_t total_size = 0; size_t total_size = 0;
RtpProcess::Ptr process; RtpProcess::Ptr process;
uint32_t ssrc = 0; uint32_t ssrc = 0;
@ -108,8 +110,14 @@ int main(int argc,char *argv[]) {
//此处选择是否导出调试文件 //此处选择是否导出调试文件
// mINI::Instance()[RtpProxy::kDumpDir] = "/Users/xzl/Desktop/"; // mINI::Instance()[RtpProxy::kDumpDir] = "/Users/xzl/Desktop/";
if (argc == 2) if (argc == 2){
loadFile(argv[1]); auto poller = EventPollerPool::Instance().getPoller();
poller->async_first([poller,argv](){
loadFile(argv[1],poller);
sem.post();
});
sem.wait();
}
else else
ErrorL << "parameter error."; ErrorL << "parameter error.";
#else #else