Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include <android/log.h>
6 #include "AndroidBridge.h"
7 #include "ANPBase.h"
8 #include "nsIPluginInstanceOwner.h"
9 #include "nsPluginInstanceOwner.h"
10 #include "nsNPAPIPluginInstance.h"
11 #include "gfxRect.h"
13 #define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
14 #define ASSIGN(obj, name) (obj)->name = anp_video_##name
16 using namespace mozilla;
18 typedef nsNPAPIPluginInstance::VideoInfo VideoInfo;
20 static ANPNativeWindow anp_video_acquireNativeWindow(NPP instance) {
21 nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
23 return pinst->AcquireVideoWindow();
24 }
26 static void anp_video_setWindowDimensions(NPP instance, const ANPNativeWindow window,
27 const ANPRectF* dimensions) {
28 nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
30 gfxRect rect(dimensions->left, dimensions->top,
31 dimensions->right - dimensions->left,
32 dimensions->bottom - dimensions->top);
34 pinst->SetVideoDimensions(window, rect);
35 pinst->RedrawPlugin();
36 }
38 static void anp_video_releaseNativeWindow(NPP instance, ANPNativeWindow window) {
39 nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata);
40 pinst->ReleaseVideoWindow(window);
41 pinst->RedrawPlugin();
42 }
44 static void anp_video_setFramerateCallback(NPP instance, const ANPNativeWindow window, ANPVideoFrameCallbackProc callback) {
45 // Bug 722682
46 NOT_IMPLEMENTED();
47 }
49 ///////////////////////////////////////////////////////////////////////////////
51 void InitVideoInterfaceV0(ANPVideoInterfaceV0* i) {
52 ASSIGN(i, acquireNativeWindow);
53 ASSIGN(i, setWindowDimensions);
54 ASSIGN(i, releaseNativeWindow);
55 }
57 void InitVideoInterfaceV1(ANPVideoInterfaceV1* i) {
58 ASSIGN(i, acquireNativeWindow);
59 ASSIGN(i, setWindowDimensions);
60 ASSIGN(i, releaseNativeWindow);
61 ASSIGN(i, setFramerateCallback);
62 }