Пример #1
0
/*
The browser calls the NPP_Write function to deliver the data specified in a previous
NPP_WriteReady call to the plug-in. A plug-in must consume at least as many bytes as indicated in
the NPP_WriteReady call.

After a stream is created by a call to NPP_NewStream, the browser calls NPP_Write either:

    * If the plug-in requested a normal-mode stream, the data in the stream is delivered to the
      plug-in instance in a series of calls to NPP_WriteReady and NPP_Write.
    * If the plug-in requested a seekable stream, the NPN_RequestRead function requests reads of
      a specified byte range that results in a series of calls to NPP_WriteReady and NPP_Write.

The plug-in can use the offset parameter to track the bytes that are written. This gives you
different information depending in the type of stream. In a normal-mode stream., the parameter
value increases as the each buffer is written. The buf parameter is not persistent, so the plug-in
must process data immediately or allocate memory and save a copy of it. In a seekable stream with
byte range requests, you can use this parameter to track NPN_RequestRead requests.
*/
int32_t NpapiPlugin::Write(NPStream* stream, int32_t offset, int32_t len, void* buffer)
{
    NpapiStream* s = static_cast<NpapiStream*>( stream->pdata );
    // check for streams we did not request or create
    if ( !s ) return -1;

    return s->signalDataArrived( buffer, len, offset );
}