Determines maximum number of bytes that the plug-in can consume.
#include <npapi.h> int32 NPP_WriteReady(NPP instance, NPStream* stream);
The function has the following parameters:
- Pointer to the current plug-in instance.
- Pointer to the current stream.
Returns the maximum number of bytes that an instance is prepared to accept from the stream.
The browser calls
NPP_WriteReady before each call to NPP_Write to determine whether a plug-in can receive data and how many bytes it can receive. This function allows the browser to send only as much data to the instance as it can handle at one time, making resource use more efficient for both the browser and plug-in.
The NPP_Write function may pass a larger buffer, but the plug-in is required to consume only the amount of data returned by
The browser can write a smaller amount of data if desired or necessary; for example, if only 8K of data is available in a network buffer. If the plug-in is allocating memory for the entire stream at once (an
AS_FILE stream), it can return a very large number. Because it is not processing streaming data, the browser can pass as much data to the instance as necessary in a single NPP_Write.
If the browser receives a value of zero, the data flow temporarily stops. The browser checks to see if the plug-in can receive data again by resending the data at regular intervals.