diff options
Diffstat (limited to 'linden/indra/media_plugins/base/media_plugin_base.h')
-rwxr-xr-x | linden/indra/media_plugins/base/media_plugin_base.h | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/linden/indra/media_plugins/base/media_plugin_base.h b/linden/indra/media_plugins/base/media_plugin_base.h new file mode 100755 index 0000000..efb0629 --- /dev/null +++ b/linden/indra/media_plugins/base/media_plugin_base.h | |||
@@ -0,0 +1,136 @@ | |||
1 | /** | ||
2 | * @file media_plugin_base.h | ||
3 | * @brief Media plugin base class for LLMedia API plugin system | ||
4 | * | ||
5 | * @cond | ||
6 | * $LicenseInfo:firstyear=2008&license=viewergpl$ | ||
7 | * | ||
8 | * Copyright (c) 2008-2010, Linden Research, Inc. | ||
9 | * | ||
10 | * Second Life Viewer Source Code | ||
11 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
12 | * to you under the terms of the GNU General Public License, version 2.0 | ||
13 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
14 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
15 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
16 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
17 | * | ||
18 | * There are special exceptions to the terms and conditions of the GPL as | ||
19 | * it is applied to this Source Code. View the full text of the exception | ||
20 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
21 | * online at | ||
22 | * http://secondlife.com/developers/opensource/flossexception | ||
23 | * | ||
24 | * By copying, modifying or distributing this software, you acknowledge | ||
25 | * that you have read and understood your obligations described above, | ||
26 | * and agree to abide by those obligations. | ||
27 | * | ||
28 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
29 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
30 | * COMPLETENESS OR PERFORMANCE. | ||
31 | * $/LicenseInfo$ | ||
32 | * | ||
33 | * @endcond | ||
34 | */ | ||
35 | |||
36 | #include "linden_common.h" | ||
37 | |||
38 | #include "llplugininstance.h" | ||
39 | #include "llpluginmessage.h" | ||
40 | #include "llpluginmessageclasses.h" | ||
41 | |||
42 | |||
43 | class MediaPluginBase | ||
44 | { | ||
45 | public: | ||
46 | MediaPluginBase(LLPluginInstance::sendMessageFunction host_send_func, void *host_user_data); | ||
47 | /** Media plugin destructor. */ | ||
48 | virtual ~MediaPluginBase() {} | ||
49 | |||
50 | /** Handle received message from plugin loader shell. */ | ||
51 | virtual void receiveMessage(const char *message_string) = 0; | ||
52 | |||
53 | static void staticReceiveMessage(const char *message_string, void **user_data); | ||
54 | |||
55 | protected: | ||
56 | |||
57 | /** Plugin status. */ | ||
58 | typedef enum | ||
59 | { | ||
60 | STATUS_NONE, | ||
61 | STATUS_LOADING, | ||
62 | STATUS_LOADED, | ||
63 | STATUS_ERROR, | ||
64 | STATUS_PLAYING, | ||
65 | STATUS_PAUSED, | ||
66 | STATUS_DONE | ||
67 | } EStatus; | ||
68 | |||
69 | /** Plugin shared memory. */ | ||
70 | class SharedSegmentInfo | ||
71 | { | ||
72 | public: | ||
73 | /** Shared memory address. */ | ||
74 | void *mAddress; | ||
75 | /** Shared memory size. */ | ||
76 | size_t mSize; | ||
77 | }; | ||
78 | |||
79 | void sendMessage(const LLPluginMessage &message); | ||
80 | void sendStatus(); | ||
81 | std::string statusString(); | ||
82 | void setStatus(EStatus status); | ||
83 | |||
84 | /// Note: The quicktime plugin overrides this to add current time and duration to the message. | ||
85 | virtual void setDirty(int left, int top, int right, int bottom); | ||
86 | |||
87 | /** Map of shared memory names to shared memory. */ | ||
88 | typedef std::map<std::string, SharedSegmentInfo> SharedSegmentMap; | ||
89 | |||
90 | |||
91 | /** Function to send message from plugin to plugin loader shell. */ | ||
92 | LLPluginInstance::sendMessageFunction mHostSendFunction; | ||
93 | /** Message data being sent to plugin loader shell by mHostSendFunction. */ | ||
94 | void *mHostUserData; | ||
95 | /** Flag to delete plugin instance (self). */ | ||
96 | bool mDeleteMe; | ||
97 | /** Pixel array to display. TODO:DOC are pixels always 24-bit RGB format, aligned on 32-bit boundary? Also: calling this a pixel array may be misleading since 1 pixel > 1 char. */ | ||
98 | unsigned char* mPixels; | ||
99 | /** TODO:DOC what's this for -- does a texture have its own piece of shared memory? updated on size_change_request, cleared on shm_remove */ | ||
100 | std::string mTextureSegmentName; | ||
101 | /** Width of plugin display in pixels. */ | ||
102 | int mWidth; | ||
103 | /** Height of plugin display in pixels. */ | ||
104 | int mHeight; | ||
105 | /** Width of plugin texture. */ | ||
106 | int mTextureWidth; | ||
107 | /** Height of plugin texture. */ | ||
108 | int mTextureHeight; | ||
109 | /** Pixel depth (pixel size in bytes). */ | ||
110 | int mDepth; | ||
111 | /** Current status of plugin. */ | ||
112 | EStatus mStatus; | ||
113 | /** Map of shared memory segments. */ | ||
114 | SharedSegmentMap mSharedSegments; | ||
115 | |||
116 | }; | ||
117 | |||
118 | /** The plugin <b>must</b> define this function to create its instance. | ||
119 | * It should look something like this: | ||
120 | * @code | ||
121 | * { | ||
122 | * MediaPluginFoo *self = new MediaPluginFoo(host_send_func, host_user_data); | ||
123 | * *plugin_send_func = MediaPluginFoo::staticReceiveMessage; | ||
124 | * *plugin_user_data = (void*)self; | ||
125 | * | ||
126 | * return 0; | ||
127 | * } | ||
128 | * @endcode | ||
129 | */ | ||
130 | int init_media_plugin( | ||
131 | LLPluginInstance::sendMessageFunction host_send_func, | ||
132 | void *host_user_data, | ||
133 | LLPluginInstance::sendMessageFunction *plugin_send_func, | ||
134 | void **plugin_user_data); | ||
135 | |||
136 | |||