aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/media_plugins/base/media_plugin_base.cpp
diff options
context:
space:
mode:
authorArmin Weatherwax2010-06-14 12:04:49 +0200
committerArmin Weatherwax2010-09-23 15:38:25 +0200
commit35df5441d3e2789663532c948731aff3a1e04728 (patch)
treeac7674289784a5f96106ea507637055a8dada78a /linden/indra/media_plugins/base/media_plugin_base.cpp
parentChanged version to Experimental 2010.09.18 (diff)
downloadmeta-impy-35df5441d3e2789663532c948731aff3a1e04728.zip
meta-impy-35df5441d3e2789663532c948731aff3a1e04728.tar.gz
meta-impy-35df5441d3e2789663532c948731aff3a1e04728.tar.bz2
meta-impy-35df5441d3e2789663532c948731aff3a1e04728.tar.xz
llmediaplugins first step
Diffstat (limited to 'linden/indra/media_plugins/base/media_plugin_base.cpp')
-rw-r--r--linden/indra/media_plugins/base/media_plugin_base.cpp155
1 files changed, 155 insertions, 0 deletions
diff --git a/linden/indra/media_plugins/base/media_plugin_base.cpp b/linden/indra/media_plugins/base/media_plugin_base.cpp
new file mode 100644
index 0000000..1919419
--- /dev/null
+++ b/linden/indra/media_plugins/base/media_plugin_base.cpp
@@ -0,0 +1,155 @@
1/**
2 * @file media_plugin_base.cpp
3 * @brief Media plugin base class for LLMedia API plugin system
4 *
5 * $LicenseInfo:firstyear=2008&license=viewergpl$
6 *
7 * Copyright (c) 2008-2009, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
22 *
23 * By copying, modifying or distributing this software, you acknowledge
24 * that you have read and understood your obligations described above,
25 * and agree to abide by those obligations.
26 *
27 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
28 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
29 * COMPLETENESS OR PERFORMANCE.
30 * $/LicenseInfo$
31 */
32
33#include "linden_common.h"
34#include "media_plugin_base.h"
35
36
37// TODO: Make sure that the only symbol exported from this library is LLPluginInitEntryPoint
38////////////////////////////////////////////////////////////////////////////////
39//
40
41MediaPluginBase::MediaPluginBase(
42 LLPluginInstance::sendMessageFunction host_send_func,
43 void *host_user_data )
44{
45 mHostSendFunction = host_send_func;
46 mHostUserData = host_user_data;
47 mDeleteMe = false;
48 mPixels = 0;
49 mWidth = 0;
50 mHeight = 0;
51 mTextureWidth = 0;
52 mTextureHeight = 0;
53 mDepth = 0;
54 mStatus = STATUS_NONE;
55}
56
57std::string MediaPluginBase::statusString()
58{
59 std::string result;
60
61 switch(mStatus)
62 {
63 case STATUS_LOADING: result = "loading"; break;
64 case STATUS_LOADED: result = "loaded"; break;
65 case STATUS_ERROR: result = "error"; break;
66 case STATUS_PLAYING: result = "playing"; break;
67 case STATUS_PAUSED: result = "paused"; break;
68 default:
69 // keep the empty string
70 break;
71 }
72
73 return result;
74}
75
76void MediaPluginBase::setStatus(EStatus status)
77{
78 if(mStatus != status)
79 {
80 mStatus = status;
81 sendStatus();
82 }
83}
84
85
86void MediaPluginBase::staticReceiveMessage(const char *message_string, void **user_data)
87{
88 MediaPluginBase *self = (MediaPluginBase*)*user_data;
89
90 if(self != NULL)
91 {
92 self->receiveMessage(message_string);
93
94 // If the plugin has processed the delete message, delete it.
95 if(self->mDeleteMe)
96 {
97 delete self;
98 *user_data = NULL;
99 }
100 }
101}
102
103void MediaPluginBase::sendMessage(const LLPluginMessage &message)
104{
105 std::string output = message.generate();
106 mHostSendFunction(output.c_str(), &mHostUserData);
107}
108
109void MediaPluginBase::setDirty(int left, int top, int right, int bottom)
110{
111 LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "updated");
112
113 message.setValueS32("left", left);
114 message.setValueS32("top", top);
115 message.setValueS32("right", right);
116 message.setValueS32("bottom", bottom);
117
118 sendMessage(message);
119}
120
121void MediaPluginBase::sendStatus()
122{
123 LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "media_status");
124
125 message.setValue("status", statusString());
126
127 sendMessage(message);
128}
129
130
131#if LL_WINDOWS
132# define LLSYMEXPORT __declspec(dllexport)
133#elif LL_LINUX
134# define LLSYMEXPORT __attribute__ ((visibility("default")))
135#else
136# define LLSYMEXPORT /**/
137#endif
138
139extern "C"
140{
141 LLSYMEXPORT int LLPluginInitEntryPoint(LLPluginInstance::sendMessageFunction host_send_func, void *host_user_data, LLPluginInstance::sendMessageFunction *plugin_send_func, void **plugin_user_data);
142}
143
144LLSYMEXPORT int
145LLPluginInitEntryPoint(LLPluginInstance::sendMessageFunction host_send_func, void *host_user_data, LLPluginInstance::sendMessageFunction *plugin_send_func, void **plugin_user_data)
146{
147 return init_media_plugin(host_send_func, host_user_data, plugin_send_func, plugin_user_data);
148}
149
150#ifdef WIN32
151int WINAPI DllEntryPoint( HINSTANCE hInstance, unsigned long reason, void* params )
152{
153 return 1;
154}
155#endif