gpt4 book ai didi

c - librtmp 免费 () : invalid pointer

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:08:01 27 4
gpt4 key购买 nike

我正在尝试使用 librtmp 处理数据包,但出现“free(): invalid pointer”错误。

#include <stdio.h>
#include <stdlib.h>
#include <librtmp/rtmp.h>
#include <librtmp/log.h>

int main(){
RTMP *r;
RTMPPacket packet;

char uri[] = "rtmp://167.114.171.21:1936/tinyconf app=tinyconf timeout=180000 live=1 conn=S:ROOMNAME swfurl=http://tinychat.com/embed/Tinychat-11.1-1.0.0.0602.swf";

RTMP_LogLevel loglvl=RTMP_LOGDEBUG2;
RTMP_LogSetLevel(loglvl);

r = RTMP_Alloc();
RTMP_Init(r);
RTMP_SetupURL(r, (char*)uri);
RTMP_Connect(r, NULL);

while (RTMP_IsConnected(r)) {
RTMP_ReadPacket(r, &packet);
if (!RTMPPacket_IsReady(&packet))
continue;
RTMP_ClientPacket(r, &packet);
RTMPPacket_Free(&packet);
}

RTMP_Close(r);
RTMP_Free(r);

return 1;
}

Here's a link to the log/backtrace . (因为它很长)

我不确定为什么会这样,这是我的代码还是 librtmp 本身的问题?

最佳答案

使用 RTMPPacket_Alloc(packet, size); 有效,尽管我看到其他代码没有使用它(我认为)。无论如何,这是一个工作示例。

#include <stdio.h>
#include <stdlib.h>
#include <librtmp/rtmp.h>
#include <librtmp/log.h>

int main(){
RTMP *r;
RTMPPacket packet;
RTMPPacket_Alloc(&packet, 4096);

char uri[] = "rtmp://167.114.171.21:1936/tinyconf app=tinyconf timeout=180000 live=1 conn=S:ROOMNAME swfurl=http://tinychat.com/embed/Tinychat-11.1-1.0.0.0602.swf";

RTMP_LogLevel loglvl=RTMP_LOGDEBUG2;
RTMP_LogSetLevel(loglvl);

r = RTMP_Alloc();
RTMP_Init(r);
RTMP_SetupURL(r, (char*)uri);
RTMP_Connect(r, NULL);

while (RTMP_IsConnected(r)) {
RTMP_ReadPacket(r, &packet);
if (!RTMPPacket_IsReady(&packet))
continue;
RTMP_ClientPacket(r, &packet);
RTMPPacket_Free(&packet);
}

RTMP_Close(r);
RTMP_Free(r);

return 1;
}

关于c - librtmp 免费 () : invalid pointer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30068377/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com