コード例 #1
0
ファイル: mmst.c プロジェクト: dwlinux/ffmpeg-windows
/** Read ASF data through the protocol. */
static int mms_read(URLContext *h, uint8_t *buf, int size)
{
    /* TODO: see tcp.c:tcp_read() about a possible timeout scheme */
    MMSTContext *mmst = h->priv_data;
    MMSContext *mms   = &mmst->mms;
    int result = 0;

    do
    {
        if(mms->asf_header_read_size < mms->asf_header_size)
        {
            /* Read from ASF header buffer */
            result = ff_mms_read_header(mms, buf, size);
        }
        else if(mms->remaining_in_len)
        {
            /* Read remaining packet data to buffer.
             * the result can not be zero because remaining_in_len is positive.*/
            result = ff_mms_read_data(mms, buf, size);
        }
        else
        {
            /* Read from network */
            int err = mms_safe_send_recv(mmst, NULL, SC_PKT_ASF_MEDIA);
            if (err == 0)
            {
                if(mms->remaining_in_len > mms->asf_packet_len)
                {
                    av_log(NULL, AV_LOG_ERROR,
                           "Incoming pktlen %d is larger than ASF pktsize %d\n",
                           mms->remaining_in_len, mms->asf_packet_len);
                    result = AVERROR(EIO);
                }
                else
                {
                    // copy the data to the packet buffer.
                    result = ff_mms_read_data(mms, buf, size);
                    if (result == 0)
                    {
                        av_dlog(NULL, "read asf media paket size is zero!\n");
                        break;
                    }
                }
            }
            else
            {
                av_dlog(NULL, "read packet error!\n");
                break;
            }
        }
    }
    while(!result);   // only return one packet.
    return result;
}
コード例 #2
0
ファイル: mmsh.c プロジェクト: AndyA/ffmbc
static int mmsh_read(URLContext *h, uint8_t *buf, int size)
{
    int res = 0;
    MMSHContext *mmsh = h->priv_data;
    MMSContext *mms   = &mmsh->mms;
    do {
        if (mms->asf_header_read_size < mms->asf_header_size) {
            // copy asf header into buffer
            res = ff_mms_read_header(mms, buf, size);
        } else {
            if (!mms->remaining_in_len && (res = handle_chunk_type(mmsh)))
                return res;
            res = ff_mms_read_data(mms, buf, size);
        }
    } while (!res);
    return res;
}