NPP_WriteReady

« Gecko Plugin API Reference « Plug-in Side Plug-in API

Summary

Determines maximum number of bytes that the plug-in can consume.

Syntax

#include <npapi.h>

int32 NPP_WriteReady(NPP instance, NPStream* stream);

Parameters

The function has the following parameters:

instance
Pointer to the current plug-in instance.
stream
Pointer to the current stream.

Returns

Returns the maximum number of bytes that an instance is prepared to accept from the stream.

Description

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 NPP_WriteReady.

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.

See Also

NPP_Write, NPStream, NPP