|
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/. */ |
|
4 |
|
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" |
|
12 |
|
13 #define LOG(args...) __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args) |
|
14 #define ASSIGN(obj, name) (obj)->name = anp_video_##name |
|
15 |
|
16 using namespace mozilla; |
|
17 |
|
18 typedef nsNPAPIPluginInstance::VideoInfo VideoInfo; |
|
19 |
|
20 static ANPNativeWindow anp_video_acquireNativeWindow(NPP instance) { |
|
21 nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata); |
|
22 |
|
23 return pinst->AcquireVideoWindow(); |
|
24 } |
|
25 |
|
26 static void anp_video_setWindowDimensions(NPP instance, const ANPNativeWindow window, |
|
27 const ANPRectF* dimensions) { |
|
28 nsNPAPIPluginInstance* pinst = static_cast<nsNPAPIPluginInstance*>(instance->ndata); |
|
29 |
|
30 gfxRect rect(dimensions->left, dimensions->top, |
|
31 dimensions->right - dimensions->left, |
|
32 dimensions->bottom - dimensions->top); |
|
33 |
|
34 pinst->SetVideoDimensions(window, rect); |
|
35 pinst->RedrawPlugin(); |
|
36 } |
|
37 |
|
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 } |
|
43 |
|
44 static void anp_video_setFramerateCallback(NPP instance, const ANPNativeWindow window, ANPVideoFrameCallbackProc callback) { |
|
45 // Bug 722682 |
|
46 NOT_IMPLEMENTED(); |
|
47 } |
|
48 |
|
49 /////////////////////////////////////////////////////////////////////////////// |
|
50 |
|
51 void InitVideoInterfaceV0(ANPVideoInterfaceV0* i) { |
|
52 ASSIGN(i, acquireNativeWindow); |
|
53 ASSIGN(i, setWindowDimensions); |
|
54 ASSIGN(i, releaseNativeWindow); |
|
55 } |
|
56 |
|
57 void InitVideoInterfaceV1(ANPVideoInterfaceV1* i) { |
|
58 ASSIGN(i, acquireNativeWindow); |
|
59 ASSIGN(i, setWindowDimensions); |
|
60 ASSIGN(i, releaseNativeWindow); |
|
61 ASSIGN(i, setFramerateCallback); |
|
62 } |