PDA

View Full Version : librtmp RTMP_Read is block, can unblock


tigershi2000
04-24-2013, 12:31 AM
debug librtmp:

RTMP_Read-->Read_1_Packet-->RTMP_GetNextMediaPacket
while (!bHasMediaPacket && RTMP_IsConnected(r)
&& RTMP_ReadPacket(r, packet))
{
...
bHasMediaPacket = RTMP_ClientPacket(r, packet);


if (!bHasMediaPacket)
{
RTMPPacket_Free(packet);
}
...
}

there are be block。

can use callback do noblock:


rtmp.h:

typedef struct AVIOInterruptCB {
int (*callback)(void*);
void *opaque;
} AVIOInterruptCB;

typedef struct RTMP
{
...
AVIOInterruptCB interrupt_callback;
...
}

RTMP_Init:
{..
r->interrupt_callback.opaque = NULL;
r->interrupt_callback.callback = NULL;
}



outside use librtmp:
static int decode_interrupt_cb(void *ctx)
{
MYClass *is = (MYClass *)ctx;
return is->abort_request;
}

RTMP* r;
RTMP_Init(r);
r->interrupt_callback.callback = decode_interrupt_cb;
r->interrupt_callback.opaque = this;


if abort_request is true, RTMP_GetNextMediaPacket() break, RTMP_Read is break, can safe exit my application.



I hope it can help you。

gorilla.maguila
04-24-2013, 08:44 AM
Me not understand and why are u mixing aviointerrupt with librtmp. Aviointerrupt makes sense handling callbacks on ffmpeg blocking functions like avformat_find_stream_info not in librtmp