Skip to content

Commit

Permalink
update main.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
babosa committed Aug 30, 2019
1 parent 635dc26 commit d3c47d7
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions EasyRTMP_Demo/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,16 @@ int main(int argc, char * argv[])
bool bSuc = InitCfgInfo();
if (!bSuc)
{
printf("配置文件easyrtmp.ini 读取失败,请检查配置项是否正确!\n");

return 0;
printf("read config easyrtmp.ini fail£¬plz check file!\n");
goto end;
}

fES = fopen(g_cfgInfo.srcFilePath, "rb");
if (NULL == fES) return 0;
if (NULL == fES)
{
printf("read H.264 file:%s error!\n",g_cfgInfo.srcFilePath);
goto end;
}

isActivated = EasyRTMP_Activate(KEY);
switch(isActivated)
Expand All @@ -228,13 +231,19 @@ int main(int argc, char * argv[])
break;
}

if( isActivated<=0)
return -1;
if(isActivated<=0)
{
printf("EasyRTMP License key error,plz confirm!\n");
goto end;
}

fPusherHandle = EasyRTMP_Create();

if(fPusherHandle == NULL)
{
printf("create EasyRTMP push handle error,exit!\n");
return -2;
}

EasyRTMP_SetCallback(fPusherHandle, __EasyRTMP_Callback, NULL);

Expand Down Expand Up @@ -274,7 +283,6 @@ int main(int argc, char * argv[])

if(!b_init)
{

get_h264_sps_and_pps(pbuf, framesize, sps, &sps_len, pps, &pps_len );
if (sps_len>0 && pps_len>0)
{
Expand Down Expand Up @@ -323,7 +331,6 @@ int main(int argc, char * argv[])
nOffSet = framesize;
}


memset(&avFrame, 0x00, sizeof(EASY_AV_Frame));
avFrame.u32AVFrameLen = nOffSet;
avFrame.pBuffer = (unsigned char*)pSendBuf;
Expand All @@ -333,18 +340,17 @@ int main(int argc, char * argv[])
avFrame.u32VFrameType = EASY_SDK_VIDEO_FRAME_I;
}
avFrame.u32AVFrameFlag = EASY_SDK_VIDEO_FRAME_FLAG;
// avFrame.u32TimestampSec = timestamp/1000;
// avFrame.u32TimestampUsec = (timestamp%1000)*1000;
//avFrame.u32TimestampSec = timestamp/1000;
//avFrame.u32TimestampUsec = (timestamp%1000)*1000;
EasyRTMP_SendPacket(fPusherHandle, &avFrame);
timestamp += 1000/mediainfo.u32VideoFps;
#ifndef _WIN32
usleep(30*1000);
#else
Sleep(30);
#endif
#endif
}


memmove(pbuf, pbuf+position-5, 5);
position = 5;

Expand All @@ -356,6 +362,7 @@ int main(int argc, char * argv[])
}
}

end:
_TRACE("Press Enter exit...\n");
getchar();

Expand Down

0 comments on commit d3c47d7

Please sign in to comment.