callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time)

{

    AVFormatContext *s = priv_data;

    struct dshow_ctx *ctx = s->priv_data;

    AVPacketList **ppktl, *pktl_next;



//    dump_videohdr(s, vdhdr);



    WaitForSingleObject(ctx->mutex, INFINITE);



    if(shall_we_drop(s))

        goto fail;



    pktl_next = av_mallocz(sizeof(AVPacketList));

    if(!pktl_next)

        goto fail;



    if(av_new_packet(&pktl_next->pkt, buf_size) < 0) {

        av_free(pktl_next);

        goto fail;

    }



    pktl_next->pkt.stream_index = index;

    pktl_next->pkt.pts = time;

    memcpy(pktl_next->pkt.data, buf, buf_size);



    for(ppktl = &ctx->pktl ; *ppktl ; ppktl = &(*ppktl)->next);

    *ppktl = pktl_next;



    ctx->curbufsize += buf_size;



    SetEvent(ctx->event);

    ReleaseMutex(ctx->mutex);



    return;

fail:

    ReleaseMutex(ctx->mutex);

    return;

}

callback(void *priv_data, int index, uint8_t *buf, int buf_size, int64_t time)

{

    AVFormatContext *s = priv_data;

    struct dshow_ctx *ctx = s->priv_data;

    AVPacketList **ppktl, *pktl_next;







    WaitForSingleObject(ctx->mutex, INFINITE);



    if(shall_we_drop(s))

        goto fail;



    pktl_next = av_mallocz(sizeof(AVPacketList));

    if(!pktl_next)

        goto fail;



    if(av_new_packet(&pktl_next->pkt, buf_size) < 0) {

        av_free(pktl_next);

        goto fail;

    }



    pktl_next->pkt.stream_index = index;

    pktl_next->pkt.pts = time;

    memcpy(pktl_next->pkt.data, buf, buf_size);



    for(ppktl = &ctx->pktl ; *ppktl ; ppktl = &(*ppktl)->next);

    *ppktl = pktl_next;



    ctx->curbufsize += buf_size;



    SetEvent(ctx->event);

    ReleaseMutex(ctx->mutex);



    return;

fail:

    ReleaseMutex(ctx->mutex);

    return;

}

FUNC_0(void *VAR_0, int VAR_1, uint8_t *VAR_2, int VAR_3, int64_t VAR_4)

{

    AVFormatContext *s = VAR_0;

    struct dshow_ctx *VAR_5 = s->VAR_0;

    AVPacketList **ppktl, *pktl_next;







    WaitForSingleObject(VAR_5->mutex, INFINITE);



    if(shall_we_drop(s))

        goto fail;



    pktl_next = av_mallocz(sizeof(AVPacketList));

    if(!pktl_next)

        goto fail;



    if(av_new_packet(&pktl_next->pkt, VAR_3) < 0) {

        av_free(pktl_next);

        goto fail;

    }



    pktl_next->pkt.stream_index = VAR_1;

    pktl_next->pkt.pts = VAR_4;

    memcpy(pktl_next->pkt.data, VAR_2, VAR_3);



    for(ppktl = &VAR_5->pktl ; *ppktl ; ppktl = &(*ppktl)->next);

    *ppktl = pktl_next;



    VAR_5->curbufsize += VAR_3;



    SetEvent(VAR_5->event);

    ReleaseMutex(VAR_5->mutex);



    return;

fail:

    ReleaseMutex(VAR_5->mutex);

    return;

}

FUNC_0(void *VAR_0, int VAR_1, uint8_t *VAR_2, int VAR_3, int64_t VAR_4)
{ AVFormatContext *s = VAR_0; struct dshow_ctx *VAR_5 = s->VAR_0; AVPacketList **ppktl, *pktl_next; WaitForSingleObject(VAR_5->mutex, INFINITE); if(shall_we_drop(s))
goto fail; pktl_next = av_mallocz(sizeof(AVPacketList)); if(!pktl_next)
goto fail; if(av_new_packet(&pktl_next->pkt, VAR_3) < 0) { av_free(pktl_next); goto fail; } pktl_next->pkt.stream_index = VAR_1; pktl_next->pkt.pts = VAR_4; memcpy(pktl_next->pkt.data, VAR_2, VAR_3); for(ppktl = &VAR_5->pktl ; *ppktl ; ppktl = &(*ppktl)->next); *ppktl = pktl_next; VAR_5->curbufsize += VAR_3; SetEvent(VAR_5->event); ReleaseMutex(VAR_5->mutex); return; fail:
ReleaseMutex(VAR_5->mutex); return; }