Home | History | Annotate | Download | only in plugins
      1 /*
      2  * Copyright 2011, The Android Open Source Project
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  *  * Redistributions of source code must retain the above copyright
      8  *    notice, this list of conditions and the following disclaimer.
      9  *  * Redistributions in binary form must reproduce the above copyright
     10  *    notice, this list of conditions and the following disclaimer in the
     11  *    documentation and/or other materials provided with the distribution.
     12  *
     13  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
     14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
     20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
     21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24  */
     25 
     26 #ifndef ANPVideo_npapi_h
     27 #define ANPVideo_npapi_h
     28 
     29 #include "android_npapi.h"
     30 #include <android/native_window.h>
     31 
     32 struct ANPVideoInterfaceV0 : ANPInterface {
     33 
     34     /**
     35      * Constructs a new native window to be used for rendering video content.
     36      *
     37      * Subsequent calls will produce new windows, but may also return NULL after
     38      * n attempts if the browser has reached it's limit. Further, if the browser
     39      * is unable to acquire the window quickly it may also return NULL in order
     40      * to not prevent the plugin from executing. A subsequent call will then
     41      * return the window if it is avaiable.
     42      *
     43      * NOTE: The hardware may fail if you try to decode more than the allowable
     44      * number of videos supported on that device.
     45      */
     46     ANativeWindow* (*acquireNativeWindow)(NPP instance);
     47 
     48     /**
     49      * Sets the rectangle that specifies where the video content is to be drawn.
     50      * The dimensions are in document space. Further, if the rect is NULL the
     51      * browser will not attempt to draw the window, therefore do not set the
     52      * dimensions until you queue the first buffer in the window.
     53      */
     54     void (*setWindowDimensions)(NPP instance, const ANativeWindow* window, const ANPRectF* dimensions);
     55 
     56     /**
     57      */
     58     void (*releaseNativeWindow)(NPP instance, ANativeWindow* window);
     59 };
     60 
     61 /** Called to notify the plugin that a video frame has been composited by the
     62  *  browser for display.  This will be called in a separate thread and as such
     63  *  you cannot call releaseNativeWindow from the callback.
     64  *
     65  *  The timestamp is in nanoseconds, and is monotonically increasing.
     66  */
     67 typedef void (*ANPVideoFrameCallbackProc)(ANativeWindow* window, int64_t timestamp);
     68 
     69 struct ANPVideoInterfaceV1 : ANPVideoInterfaceV0 {
     70     /** Set a callback to be notified when an ANativeWindow is composited by
     71      *  the browser.
     72      */
     73     void (*setFramerateCallback)(NPP instance, const ANativeWindow* window, ANPVideoFrameCallbackProc);
     74 };
     75 
     76 #endif // ANPVideo_npapi_h
     77