Hi All

I have a problem whilst implementing a custom URLProtocol for use with av_open_input_file(...). I am trying to use the protocol so that a custom url_read method will receive data from a callback which the user can supply from the calling application. To illustrate, I have the following methods for the url_open and url_read (which are both static member functions of an unmanaged C++ class)

int BufferProtocol::BufferOpen(URLContext *h, const char *pseudofilename, int flags)
{
    //setup the buffer
    BUFFER *buffer = new BUFFER();
    buffer->buflen = BUFFERLENGTH;
    buffer->offset = 0;
    buffer->buf = new unsigned char[BUFFERLENGTH];
    memset(buffer->buf, 0, BUFFERLENGTH);


    //assign the URLContext's private data to be the buffer
    h->priv_data = buffer;

    return 1;
}

int BufferProtocol::BufferRead(URLContext *h, unsigned char *buf, int size)
{
    BUFFER *buffer = (BUFFER*)h->priv_data;

    int amountRead = 1024;
    unsigned char* data = HELP_HERE_PLEASE
...
...

}

So in the above Read method I want to invoke a callback which will prompt for a certain number of bytes and return the received data (which can be put into *buf). I understand how this would work with a typical callback but I have one more problem - because I am using Class members for the URLProtocol they have to be static, also the application that is going to use this will probably call av_open_input_file(...) more than once (for multiple input buffer sources) and because the methods are all static I will not be able to tell which buffer the callback refers to. This is kind of confusing to describe and I hope that my point is clear enough to understand.

Thanks,
Mark.

_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to