在ubuntu16.04中使用"sudo apt-get librtmp-dev".I安装librtmp成功地编译了代码,但我在RTMP_Init()中得到了一个“分割错误”.Here是我的rtmp_test代码:
主要功能:
int main(int argc,char *argv[]){
printf("11111\n");
if (RTMP264_Connect("rtmp://**********") == TRUE){
printf("connect successful");
}
printf("22222222\n");
return 0;
}
RTMP264_Connect函数:
int RTMP264_Connect(const char * url){
printf("~~~~~~~1\n");
RTMP_Init(m_Rtmp);
printf("~~~~~~~2\n");
if(RTMP_SetupURL(m_Rtmp,(char*)url) == FALSE){
RTMP_Free(m_Rtmp);
return FALSE;
}
printf("~~~~~~~3\n");
RTMP_EnableWrite(m_Rtmp);
if(RTMP_Connect(m_Rtmp,NULL)==FALSE){
RTMP_Free(m_Rtmp);
return FALSE;
}
当我运行代码时,我得到了这个错误:
11111
aaaa
~~~~~~~1
Segmentation fault
所以我确定问题出在RTMP_init函数上,我在网上看到有人说可能是socket没有初始化。我找到了一个套接字初始化代码:
int InitSockets()
{
#ifdef WIN32
WORD version;
WSADATA wsaData;
version = MAKEWORD(1, 1);
return (WSAStartup(version, &wsaData) == 0);
#endif
}
void CleanupSockets()
{
#ifdef WIN32
WSACleanup();
#endif
}
但这是针对Windows系统的。如果我在Ubuntu上运行,我会报告一个错误。我不知道我的问题是否与套接字不是initialized.Could有关谁告诉我如何解决我的问题,谢谢!
发布于 2019-12-13 14:43:40
https://stackoverflow.com/questions/59317320
复制相似问题