aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmedia/llmediamanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmedia/llmediamanager.cpp')
-rw-r--r--linden/indra/llmedia/llmediamanager.cpp295
1 files changed, 0 insertions, 295 deletions
diff --git a/linden/indra/llmedia/llmediamanager.cpp b/linden/indra/llmedia/llmediamanager.cpp
deleted file mode 100644
index 48da808..0000000
--- a/linden/indra/llmedia/llmediamanager.cpp
+++ /dev/null
@@ -1,295 +0,0 @@
1/**
2 * @file llmediamanager.cpp
3 * @brief Manages instances of media impls
4 *
5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 *
7 * Copyright (c) 2007-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 "llmediamanager.h"
34
35#if LL_WINDOWS
36 // GStreamer 0.10.22 - gstutils.h - conversion from 'guint64' to 'guint8'.
37 // This was an intentional change to make GStreamer more threadsafe, and
38 // is okay. Delete this bit if GStreamer ever gets more VS-friendly -- McCabe
39 #pragma warning(disable : 4244)
40#endif
41#include "llmediaimplgstreamer.h"
42#if LL_WINDOWS
43 #pragma warning(default : 4244)
44#endif
45
46#include "llmediaimplfactory.h"
47
48#include "llmediaimplexample1.h"
49#include "llmediaimplexample2.h"
50#include "llmediaimplquicktime.h"
51
52#if LL_LLMOZLIB_ENABLED
53# include "llmediaimplllmozlib.h"
54#endif
55
56#include "llerror.h"
57LLMediaManager* LLMediaManager::sInstance = 0;
58
59
60////////////////////////////////////////////////////////////////////////////////
61// (private)
62LLMediaManager::LLMediaManager()
63{
64}
65
66////////////////////////////////////////////////////////////////////////////////
67LLMediaManager::~LLMediaManager()
68{
69}
70
71////////////////////////////////////////////////////////////////////////////////
72// Early initialization for web browser for the viewer, so we can show
73// the login screen and defer initialization of QuickTime, etc. JC
74// (static)
75void LLMediaManager::initBrowser( LLMediaManagerData* init_data )
76{
77 if ( ! sInstance )
78 sInstance = new LLMediaManager();
79
80#if LL_LLMOZLIB_ENABLED
81 LLMediaImplLLMozLib::startup( init_data );
82#endif // LL_LLMOZLIB_ENABLED
83}
84
85////////////////////////////////////////////////////////////////////////////////
86// (static)
87void LLMediaManager::initClass( LLMediaManagerData* init_data )
88{
89 if ( ! sInstance )
90 sInstance = new LLMediaManager();
91
92 LL_DEBUGS("MediaManager") << "LLMediaManager::initClass" << LL_ENDL;
93 // Initialize impl classes here - this breaks the encapsulation model
94 // but some of the initialization takes a long time and we only want to
95 // do it once at app startup before any of the impls have been created
96 // Each impl provides a static startup method that does any initialization
97 // which takes a significant amount of time.
98 LLMediaImplExample1::startup( init_data );
99 LLMediaImplExample2::startup( init_data );
100
101#if LL_QUICKTIME_ENABLED
102 LL_DEBUGS("MediaManager") << "LLMediaManager::initClass: starting quicktime." << LL_ENDL;
103 LLMediaImplQuickTime::startup( init_data );
104#endif // LL_QUICKTIME_ENABLED
105
106///#if LL_GSTREAMER_ENABLED
107 LL_DEBUGS("MediaManager") << "LLMediaManager::initClass: starting gstreamer" << LL_ENDL;
108 LLMediaImplGStreamer::startup( init_data );
109///#endif // LL_GSTREAMER_ENABLED
110}
111
112////////////////////////////////////////////////////////////////////////////////
113// (static)
114void LLMediaManager::updateClass()
115{
116 if (!sInstance) return;
117
118 media_impl_container_t::iterator it
119 = sInstance->mMediaImplContainer.begin();
120 media_impl_container_t::iterator end
121 = sInstance->mMediaImplContainer.end();
122 for ( ; it != end; ++it )
123 {
124 LLMediaBase* impl = *it;
125 impl->updateMedia();
126 }
127}
128
129////////////////////////////////////////////////////////////////////////////////
130// (static)
131void LLMediaManager::cleanupClass()
132{
133 // Uninitialize impl classes here - this breaks the encapsulation model
134 // but some of the uninitialization takes a long time and we only want to
135 // do it once at app startup before any of the impls have been created.
136 // Each impl provides a static closedown method that does any uninitialization
137 // which takes a significant amount of time.
138 LLMediaImplExample1::closedown();
139 LLMediaImplExample2::closedown();
140
141#if LL_LLMOZLIB_ENABLED
142 LLMediaImplLLMozLib::closedown();
143#endif // LL_LLMOZLIB_ENABLED
144
145#if LL_QUICKTIME_ENABLED
146 LLMediaImplQuickTime::closedown();
147#endif // LL_QUICKTIME_ENABLED
148
149///#if LL_GSTREAMER_ENABLED
150 LLMediaImplGStreamer::closedown();
151///#endif // LL_QUICKTIME_ENABLED
152
153 if ( sInstance )
154 delete sInstance;
155
156 sInstance = 0;
157}
158
159////////////////////////////////////////////////////////////////////////////////
160// (static)
161LLMediaManager* LLMediaManager::getInstance()
162{
163 return sInstance;
164}
165
166////////////////////////////////////////////////////////////////////////////////
167// (static)
168void LLMediaManager::setBrowserUserAgent(std::string user_agent)
169{
170#if LL_LLMOZLIB_ENABLED
171 // *HACK: Breaks encapsulation model, as initClass does above. JC
172 LLMediaImplLLMozLib::setBrowserUserAgent(user_agent);
173#endif // LL_LLMOZLIB_ENABLED
174}
175
176////////////////////////////////////////////////////////////////////////////////
177//
178LLMediaBase* LLMediaManager::createSourceFromMimeType( std::string scheme, std::string mime_type )
179{
180
181 LLMediaImplMakerBase* impl_maker = LLMediaImplFactory::getInstance()->getImplMaker( scheme, mime_type );
182
183 // If an impl maker is return it means this media type is supported
184 if ( impl_maker )
185 {
186 LLMediaBase* media_impl = impl_maker->create();
187 if( media_impl )
188 {
189 media_impl->setImplMaker( impl_maker );
190 std::pair< media_impl_container_t::iterator, bool > result =
191 mMediaImplContainer.insert( media_impl );
192
193 if ( result.second )
194 {
195 media_impl->setMimeType( mime_type );
196
197 media_impl->init();
198
199 return media_impl;
200 };
201 };
202 };
203
204 return 0;
205}
206
207////////////////////////////////////////////////////////////////////////////////
208//
209bool LLMediaManager::destroySource( LLMediaBase* media_impl )
210{
211 media_impl_container_t::iterator iter =
212 mMediaImplContainer.find( media_impl );
213
214 if ( iter != mMediaImplContainer.end() )
215 {
216 if ( *iter )
217 {
218 ( *iter)->reset();
219
220 delete ( *iter );
221
222 mMediaImplContainer.erase( iter );
223
224 return true;
225 };
226 };
227
228 return false;
229}
230
231////////////////////////////////////////////////////////////////////////////////
232//
233bool LLMediaManager::addMimeTypeImplNameMap( std::string mime_type, std::string impl_name )
234{
235 std::pair< mime_type_impl_name_container_t::iterator, bool > result =
236 mMimeTypeImplNameContainer.insert( std::make_pair( mime_type, impl_name ) );
237
238 return result.second;
239}
240
241////////////////////////////////////////////////////////////////////////////////
242//
243std::string LLMediaManager::getImplNameFromMimeType( std::string mime_type )
244{
245 mime_type_impl_name_container_t::iterator iter =
246 mMimeTypeImplNameContainer.find( mime_type );
247
248 if ( iter != mMimeTypeImplNameContainer.end() )
249 {
250 return ( *iter ).second;
251 }
252 else
253 {
254 return std::string( "" );
255 };
256}
257////////////////////////////////////////////////////////////////////////////////
258//
259bool LLMediaManager::supportsMediaType( const std::string& impl_name, const std::string& scheme, const std::string& mime_type )
260{
261 LLMediaImplMakerBase* impl_maker = LLMediaImplFactory::getInstance()->getImplMaker( impl_name );
262 if( impl_maker )
263 {
264 int idx1 = mime_type.find("/");
265 int len = (idx1 == std::string::npos) ? 0 : idx1;
266 std::string category = mime_type.substr(0,len);
267
268 return impl_maker->supportsScheme(scheme) ||
269 impl_maker->supportsMimeType(mime_type) ||
270 impl_maker->supportsMimeTypeCategory(category);
271 }
272 return false;
273}
274
275// static
276int LLMediaManager::textureWidthFromMediaWidth( int media_width )
277{
278 int texture_width = 1;
279 while ( texture_width < media_width )
280 {
281 texture_width <<= 1;
282 };
283 return texture_width;
284}
285
286// static
287int LLMediaManager::textureHeightFromMediaHeight( int media_height )
288{
289 int texture_height = 1;
290 while ( texture_height < media_height )
291 {
292 texture_height <<= 1;
293 };
294 return texture_height;
295}