PageRenderTime 284ms CodeModel.GetById 161ms app.highlight 6ms RepoModel.GetById 115ms app.codeStats 0ms

/indra/media_plugins/base/media_plugin_base.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 129 lines | 52 code | 18 blank | 59 comment | 0 complexity | 748c71ea0f5cc2c5af6b8a2f8a40753d MD5 | raw file
  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=viewerlgpl$
  7 * Second Life Viewer Source Code
  8 * Copyright (C) 2010, Linden Research, Inc.
  9 * 
 10 * This library is free software; you can redistribute it and/or
 11 * modify it under the terms of the GNU Lesser General Public
 12 * License as published by the Free Software Foundation;
 13 * version 2.1 of the License only.
 14 * 
 15 * This library is distributed in the hope that it will be useful,
 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 18 * Lesser General Public License for more details.
 19 * 
 20 * You should have received a copy of the GNU Lesser General Public
 21 * License along with this library; if not, write to the Free Software
 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 23 * 
 24 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 25 * $/LicenseInfo$
 26 * @endcond
 27 */
 28
 29#include "linden_common.h"
 30
 31#include "llplugininstance.h"
 32#include "llpluginmessage.h"
 33#include "llpluginmessageclasses.h"
 34
 35
 36class MediaPluginBase
 37{
 38public:
 39	MediaPluginBase(LLPluginInstance::sendMessageFunction host_send_func, void *host_user_data);
 40   /** Media plugin destructor. */
 41	virtual ~MediaPluginBase() {}
 42
 43   /** Handle received message from plugin loader shell. */
 44	virtual void receiveMessage(const char *message_string) = 0;
 45	
 46	static void staticReceiveMessage(const char *message_string, void **user_data);
 47
 48protected:
 49
 50   /** Plugin status. */
 51	typedef enum 
 52	{
 53		STATUS_NONE,
 54		STATUS_LOADING,
 55		STATUS_LOADED,
 56		STATUS_ERROR,
 57		STATUS_PLAYING,
 58		STATUS_PAUSED,
 59		STATUS_DONE
 60	} EStatus;
 61
 62   /** Plugin shared memory. */
 63	class SharedSegmentInfo
 64	{
 65	public:
 66      /** Shared memory address. */
 67		void *mAddress;
 68      /** Shared memory size. */
 69		size_t mSize;
 70	};
 71
 72	void sendMessage(const LLPluginMessage &message);
 73	void sendStatus();
 74	std::string statusString();
 75	void setStatus(EStatus status);		
 76	
 77	/// Note: The quicktime plugin overrides this to add current time and duration to the message.
 78	virtual void setDirty(int left, int top, int right, int bottom);
 79
 80   /** Map of shared memory names to shared memory. */
 81	typedef std::map<std::string, SharedSegmentInfo> SharedSegmentMap;
 82
 83	
 84   /** Function to send message from plugin to plugin loader shell. */
 85	LLPluginInstance::sendMessageFunction mHostSendFunction;
 86   /** Message data being sent to plugin loader shell by mHostSendFunction. */
 87	void *mHostUserData;
 88   /** Flag to delete plugin instance (self). */
 89	bool mDeleteMe;
 90   /** 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. */
 91	unsigned char* mPixels;
 92   /** 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 */
 93	std::string mTextureSegmentName;
 94   /** Width of plugin display in pixels. */
 95	int mWidth;
 96   /** Height of plugin display in pixels. */
 97	int mHeight;
 98   /** Width of plugin texture. */
 99	int mTextureWidth;
100   /** Height of plugin texture. */
101	int mTextureHeight;
102   /** Pixel depth (pixel size in bytes). */
103	int mDepth;
104   /** Current status of plugin. */
105	EStatus mStatus;
106   /** Map of shared memory segments. */
107	SharedSegmentMap mSharedSegments;
108
109};
110
111/** The plugin <b>must</b> define this function to create its instance.
112 * It should look something like this: 
113 * @code
114 * {  
115 *    MediaPluginFoo *self = new MediaPluginFoo(host_send_func, host_user_data); 
116 *    *plugin_send_func = MediaPluginFoo::staticReceiveMessage; 
117 *    *plugin_user_data = (void*)self; 
118 *    
119 *    return 0; 
120 * }  
121 * @endcode
122 */
123int init_media_plugin(
124	LLPluginInstance::sendMessageFunction host_send_func, 
125	void *host_user_data, 
126	LLPluginInstance::sendMessageFunction *plugin_send_func, 
127	void **plugin_user_data);
128
129