On Mon, Jun 14, 2010 at 08:12:30PM +0300, Martin Storsjö wrote:
On Mon, 14 Jun 2010, Ronald S. Bultje wrote:
On Mon, Jun 14, 2010 at 12:47 PM, Michael Niedermayer <michaelni@gmx.at> wrote:
add a URLProtocol.priv_data_size this also might simplify existing code by moving allocation of priv_data to a common place
This doesn't solve the problem of fields that should be initialized to a non-zero state in protocol_open(). We really need an API where we have: 1) a function that allocates both URLContext as well as priv_data context (so the type of protocol, e.g. HTTP, is known at this point) 2) a function that initializes these values to a default state; it makes sense that this function is called at the same time as 1. It also might make sense that the URI is known at this point 3) a window here where we can make changes to this context by calling functions or eventually by introducing AVOptions
AVOptions have a field for defaults thus as soon as a struct can be accssed through AVOptions there also are known defaults
Additionally, as far as I've understood AVOptions, they can only set something within one struct, since it simply uses offsets. For this case, we'd need AVOptions that would only apply if the URLContext happens to be a HTTP context, and then set the options within the priv_data, which can't be done as a simple offset (unless the priv_data is tacked on at the end of the context...)
I think we should check the past discussion about using AVOptions and private contexts. but from memory Adding an AVClass pointer to URLProtocol (and a priv_data_size of course too) allows us to allocate and init to defaults the private context in generic code [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Good people do not need laws to tell them to act responsibly, while bad people will find a way around the laws. -- Plato