aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmedia
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmedia')
-rw-r--r--linden/indra/llmedia/CMakeLists.txt79
-rw-r--r--linden/indra/llmedia/llgstplaythread.cpp54
-rw-r--r--linden/indra/llmedia/llgstplaythread.h62
-rw-r--r--linden/indra/llmedia/llmediabase.h265
-rw-r--r--linden/indra/llmedia/llmediaemitter.h104
-rw-r--r--linden/indra/llmedia/llmediaimplcommon.cpp552
-rw-r--r--linden/indra/llmedia/llmediaimplcommon.h164
-rw-r--r--linden/indra/llmedia/llmediaimplexample1.cpp231
-rw-r--r--linden/indra/llmedia/llmediaimplexample1.h73
-rw-r--r--linden/indra/llmedia/llmediaimplexample2.cpp198
-rw-r--r--linden/indra/llmedia/llmediaimplexample2.h76
-rw-r--r--linden/indra/llmedia/llmediaimplfactory.cpp105
-rw-r--r--linden/indra/llmedia/llmediaimplfactory.h100
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.h164
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamervidplug.cpp448
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamervidplug.h106
-rw-r--r--linden/indra/llmedia/llmediaimplllmozlib.cpp624
-rw-r--r--linden/indra/llmedia/llmediaimplllmozlib.h127
-rw-r--r--linden/indra/llmedia/llmediaimplquicktime.cpp657
-rw-r--r--linden/indra/llmedia/llmediaimplquicktime.h112
-rw-r--r--linden/indra/llmedia/llmediaimplregister.h60
-rw-r--r--linden/indra/llmedia/llmediamanager.cpp295
-rw-r--r--linden/indra/llmedia/llmediamanager.h127
-rw-r--r--linden/indra/llmedia/llmediaobserver.h116
24 files changed, 0 insertions, 4899 deletions
diff --git a/linden/indra/llmedia/CMakeLists.txt b/linden/indra/llmedia/CMakeLists.txt
deleted file mode 100644
index c7b5cd1..0000000
--- a/linden/indra/llmedia/CMakeLists.txt
+++ /dev/null
@@ -1,79 +0,0 @@
1# -*- cmake -*-
2
3project(llmedia)
4
5include(00-Common)
6include(LLAudio)
7include(LLCommon)
8include(LLImage)
9include(LLMath)
10include(LLMedia)
11include(LLMessage)
12include(LLWindow)
13include(Mozlib)
14
15include_directories(
16 ${GSTREAMER_INCLUDE_DIRS}
17 ${GSTREAMER_PLUGINS_BASE_INCLUDE_DIRS}
18 ${LLAUDIO_INCLUDE_DIRS}
19 ${LLCOMMON_INCLUDE_DIRS}
20 ${LLIMAGE_INCLUDE_DIRS}
21 ${LLMATH_INCLUDE_DIRS}
22 ${LLMESSAGE_INCLUDE_DIRS}
23 ${LLWINDOW_INCLUDE_DIRS}
24 )
25
26set(llmedia_SOURCE_FILES
27 llmediaimplcommon.cpp
28 llmediaimplexample1.cpp
29 llmediaimplexample2.cpp
30 llmediaimplfactory.cpp
31 llmediamanager.cpp
32 llmediaimplgstreamer.cpp
33 llmediaimplgstreamervidplug.cpp
34 llgstplaythread.cpp
35 )
36
37set(llmedia_HEADER_FILES
38 CMakeLists.txt
39
40 llmediabase.h
41 llmediaemitter.h
42 llmediaimplcommon.h
43 llmediaimplexample1.h
44 llmediaimplexample2.h
45 llmediaimplfactory.h
46 llmediaimplregister.h
47 llmediamanager.h
48 llmediaobserver.h
49 llmediaimplgstreamer.h
50 llmediaimplgstreamervidplug.h
51 llgstplaythread.h
52 )
53
54 # Work around a bad interaction between broken gstreamer headers and
55 # g++ 4.3's increased strictness.
56
57 if (${CXX_VERSION} MATCHES "4.[23]")
58 set_source_files_properties(llmediaimplgstreamervidplug.cpp PROPERTIES
59 COMPILE_FLAGS -Wno-error=write-strings)
60 endif (${CXX_VERSION} MATCHES "4.[23]")
61
62if (MOZLIB)
63 list(APPEND llmedia_SOURCE_FILES llmediaimplllmozlib.cpp)
64
65 list(APPEND llmedia_HEADER_FILES llmediaimplllmozlib.h)
66endif (MOZLIB)
67
68set_source_files_properties(${llmedia_HEADER_FILES}
69 PROPERTIES HEADER_FILE_ONLY TRUE)
70
71list(APPEND llmedia_SOURCE_FILES ${llmedia_HEADER_FILES})
72
73add_library (llmedia ${llmedia_SOURCE_FILES})
74target_link_libraries(
75 llmedia
76 ${GSTREAMER_LIBRARIES}
77 ${GSTREAMER_PLUGINS_BASE_LIBRARIES}
78 ${QUICKTIME_LIBRARY}
79 )
diff --git a/linden/indra/llmedia/llgstplaythread.cpp b/linden/indra/llmedia/llgstplaythread.cpp
deleted file mode 100644
index 152f9d9..0000000
--- a/linden/indra/llmedia/llgstplaythread.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
1/**
2 * @file llgstplaythread.cpp
3 * @author Jacek Antonelli
4 * @brief GStreamer playback management thread class
5 *
6 * $LicenseInfo:firstyear=2009&license=viewergpl$
7 *
8 * Copyright (c) 2009, Jacek Antonelli
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation. Terms of
13 * the GPL can be found in doc/GPL-license.txt in this distribution, or
14 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
15 *
16 * There are special exceptions to the terms and conditions of the GPL as
17 * it is applied to this Source Code. View the full text of the exception
18 * in the file doc/FLOSS-exception.txt in this software distribution, or
19 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 *
30 * $/LicenseInfo$
31 */
32
33#include "llgstplaythread.h"
34#include "llmediaimplgstreamer.h"
35
36LLGstPlayThread::
37LLGstPlayThread( LLMediaImplCommon *impl,
38 const std::string& name, apr_pool_t *poolp ):
39 LLThread( name, poolp ),
40 mMediaImpl( impl )
41{
42}
43
44
45LLGstPlayThread::~LLGstPlayThread()
46{
47}
48
49
50// virtual
51void LLGstPlayThread::run()
52{
53 ((LLMediaImplGStreamer *)mMediaImpl)->startPlay();
54}
diff --git a/linden/indra/llmedia/llgstplaythread.h b/linden/indra/llmedia/llgstplaythread.h
deleted file mode 100644
index c3c36a7..0000000
--- a/linden/indra/llmedia/llgstplaythread.h
+++ /dev/null
@@ -1,62 +0,0 @@
1/**
2 * @file llgstplaythread.h
3 * @author Jacek Antonelli
4 * @brief GStreamer playback management thread class
5 *
6 * $LicenseInfo:firstyear=2009&license=viewergpl$
7 *
8 * Copyright (c) 2009, Jacek Antonelli
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation. Terms of
13 * the GPL can be found in doc/GPL-license.txt in this distribution, or
14 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
15 *
16 * There are special exceptions to the terms and conditions of the GPL as
17 * it is applied to this Source Code. View the full text of the exception
18 * in the file doc/FLOSS-exception.txt in this software distribution, or
19 * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception
20 *
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * You should have received a copy of the GNU General Public License along
27 * with this program; if not, write to the Free Software Foundation, Inc.,
28 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 *
30 * $/LicenseInfo$
31 */
32
33
34#ifndef LL_LLGSTPLAYTHREAD_H
35#define LL_LLGSTPLAYTHREAD_H
36
37#include "linden_common.h"
38
39#include "llthread.h"
40#include "llmediaimplcommon.h"
41
42class LLGstPlayThread: public LLThread
43{
44 public:
45
46 LLGstPlayThread( LLMediaImplCommon *impl,
47 const std::string& name, apr_pool_t *poolp );
48
49 ~LLGstPlayThread();
50
51 virtual void run();
52
53 private:
54
55 // Actually, this will really only be an LLMediaImplGStreamer.
56 // But we have to jump through some hoops to mutual pointer-holding.
57 // There may be a better way, but I don't have the motivation to find it.
58 LLMediaImplCommon *mMediaImpl;
59};
60
61
62#endif // LL_LLGSTPLAYTHREAD_H
diff --git a/linden/indra/llmedia/llmediabase.h b/linden/indra/llmedia/llmediabase.h
deleted file mode 100644
index 3bcee4e..0000000
--- a/linden/indra/llmedia/llmediabase.h
+++ /dev/null
@@ -1,265 +0,0 @@
1/**
2 * @file llmediabase.h
3 * @author Callum Prentice
4 * @date 2007-10-22 00:00:00
5 * @brief Abstract class that defines LLMedia public interface
6 *
7 * $LicenseInfo:firstyear=2005&license=viewergpl$
8 *
9 * Copyright (c) 2005-2009, Linden Research, Inc.
10 *
11 * Second Life Viewer Source Code
12 * The source code in this file ("Source Code") is provided by Linden Lab
13 * to you under the terms of the GNU General Public License, version 2.0
14 * ("GPL"), unless you have obtained a separate licensing agreement
15 * ("Other License"), formally executed by you and Linden Lab. Terms of
16 * the GPL can be found in doc/GPL-license.txt in this distribution, or
17 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
18 *
19 * There are special exceptions to the terms and conditions of the GPL as
20 * it is applied to this Source Code. View the full text of the exception
21 * in the file doc/FLOSS-exception.txt in this software distribution, or
22 * online at
23 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
24 *
25 * By copying, modifying or distributing this software, you acknowledge
26 * that you have read and understood your obligations described above,
27 * and agree to abide by those obligations.
28 *
29 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
30 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
31 * COMPLETENESS OR PERFORMANCE.
32 * $/LicenseInfo$
33 */
34
35#ifndef LLMEDIABASE_H
36#define LLMEDIABASE_H
37
38#if LL_LLMOZLIB_ENABLED && !defined ( MOZILLA_INTERNAL_API )
39 // Without this, nsTAString.h errors out with:
40 // "Cannot use internal string classes without MOZILLA_INTERNAL_API defined. Use the frozen header nsStringAPI.h instead."
41 // It might be worth our while to figure out if we can use the frozen apis at some point...
42 #define MOZILLA_INTERNAL_API 1
43#endif
44
45#include <string>
46
47class LLMediaObserver;
48class LLMediaImplMakerBase;
49
50class LLMediaBase
51{
52 public:
53 LLMediaBase() {};
54 virtual ~LLMediaBase() {};
55
56 ////////////////////////////////////////////////////////////////////////////////
57 // housekeeping
58
59 // local initialization, called by the media manager when creating a source
60 virtual bool init() = 0;
61
62 // undoes everything init() didm called by the media manager when destroying a source
63 virtual bool reset() = 0;
64
65
66 /* Mirrors GStreamer debug levels. */
67 enum EDebugLevel {
68 DEBUG_LEVEL_NONE = 0,
69 DEBUG_LEVEL_ERROR,
70 DEBUG_LEVEL_WARNING,
71 DEBUG_LEVEL_INFO,
72 DEBUG_LEVEL_DEBUG,
73 DEBUG_LEVEL_LOG,
74 DEBUG_LEVEL_COUNT,
75 };
76
77 /* Set the debug verbosity level. Only implemented for GStreamer. */
78 virtual bool setDebugLevel( EDebugLevel level ) = 0;
79
80 // accessor for MIME type
81 virtual bool setMimeType( const std::string mime_type ) = 0;
82 virtual std::string getMimeType() const = 0;
83
84 // accessor for intial URL. Note that this may have changed under the hood
85 // so pass back the original URL seeded to this impl
86 virtual std::string getMediaURL() const = 0;
87
88 // ask impl for version string
89 virtual std::string getVersion() = 0;
90
91 // set/clear URL to visit when a 404 page is reached
92 virtual bool set404RedirectUrl( std::string redirect_url ) = 0;
93 virtual bool clr404RedirectUrl() = 0;
94
95 // sets the background color of the browser window
96 virtual bool setBackgroundColor( unsigned int red, unsigned int green, unsigned int blue ) const = 0;
97
98 // sets the color of the caret in media impls that have one
99 virtual bool setCaretColor( unsigned int red, unsigned int green, unsigned int blue ) const = 0;
100
101 ////////////////////////////////////////////////////////////////////////////////
102 // media management
103
104 // needs to be called regularly to make media stream update itself
105 virtual bool updateMedia() = 0;
106
107 // allows you to request a change in media width, height - may fail if media doesn't support size change
108 virtual bool setRequestedMediaSize( int media_width, int media_height ) = 0;
109
110 // gets media width (may change throughout lifetime of media stream) - event emitted when media size changed too
111 virtual int getMediaWidth() const = 0;
112
113 // gets media height (may change throughout lifetime of media stream) - event emitted when media size changed too
114 virtual int getMediaHeight() const = 0;
115
116 // allows you to try to explicitly change media depth - may fail if media doesn't support depth change
117 virtual bool setMediaDepth( int media_depth ) = 0;
118
119 // gets media depth (may change throughout lifetime of media stream) - event emitted when media depth changed too
120 virtual int getMediaDepth() const = 0;
121
122 // gets size of media buffer for current frame (might NOT be the same as media width * height * depth)
123 virtual int getMediaBufferSize() const = 0;
124
125 // returns pointer to raw media pixels
126 virtual unsigned char* getMediaData() = 0;
127
128 // returns the size of the data, which may be different that the size of the media
129 virtual int getMediaDataWidth() const = 0;
130 virtual int getMediaDataHeight() const = 0;
131
132 ////////////////////////////////////////////////////////////////////////////////
133 // texture management
134
135 // gets internal format to use for OpenGL texture
136 virtual int getTextureFormatInternal() const = 0;
137
138 // gets primary format to use for OpenGL texture
139 virtual int getTextureFormatPrimary() const = 0;
140
141 // gets format type to use for OpenGL texture
142 virtual int getTextureFormatType() const = 0;
143
144
145
146
147 ////////////////////////////////////////////////////////////////////////////////
148 // audio
149
150 // set/get control volume from media stream if present
151 virtual bool setVolume( float volume ) = 0;
152 virtual float getVolume() const = 0;
153
154
155 ////////////////////////////////////////////////////////////////////////////////
156 // transport control etc.
157 enum ECommand {
158 COMMAND_NONE = 0,
159 COMMAND_STOP = 1,
160 COMMAND_START = 2,
161 COMMAND_PAUSE = 4,
162 COMMAND_BACK = 5,
163 COMMAND_FORWARD = 6
164 };
165 enum EStatus {
166 STATUS_UNKNOWN = 0,
167 STATUS_INITIALIZING = 1,
168 STATUS_NAVIGATING = 2,
169 STATUS_STARTED = 3,
170 STATUS_STOPPED = 4,
171 STATUS_PAUSED = 6,
172 STATUS_RESETTING = 7,
173 STATUS_DEAD = 8
174 };
175 virtual bool addCommand( ECommand cmd ) = 0;
176 virtual bool clearCommand() = 0;
177 virtual bool updateCommand() = 0;
178 virtual EStatus getStatus() = 0;
179 virtual bool seek( double time ) = 0;
180 virtual bool setLooping( bool enable) = 0;
181 virtual bool isLooping() = 0;
182
183 ////////////////////////////////////////////////////////////////////////////////
184 // scaling
185
186 // autoscale means try to scale media to size of texture - may fail if media doesn't support size change
187 virtual bool setAutoScaled( bool auto_scaled ) = 0;
188 virtual bool isAutoScaled() const = 0;
189
190
191 ////////////////////////////////////////////////////////////////////////////////
192 // mouse and keyboard interaction
193 virtual bool mouseDown( int x_pos, int y_pos ) = 0;
194 virtual bool mouseUp( int x_pos, int y_pos ) = 0;
195 virtual bool mouseMove( int x_pos, int y_pos ) = 0;
196 virtual bool keyPress( int key_code ) = 0;
197 virtual bool scrollByLines( int lines ) = 0;
198 virtual bool focus( bool focus ) = 0;
199 virtual bool unicodeInput( unsigned long uni_char ) = 0;
200 virtual bool mouseLeftDoubleClick( int x_pos, int y_pos ) = 0;
201
202
203 ////////////////////////////////////////////////////////////////////////////////
204 // navigation
205 virtual bool navigateTo( const std::string url ) = 0;
206 virtual bool navigateForward() = 0;
207 virtual bool navigateBack() = 0;
208 virtual bool canNavigateForward() = 0;
209 virtual bool canNavigateBack() = 0;
210
211 ////////////////////////////////////////////////////////////////////////////////
212 // caching/cookies
213 virtual bool enableCookies( bool enable ) = 0;
214 virtual bool clearCache() = 0;
215 virtual bool clearCookies() = 0;
216
217 ////////////////////////////////////////////////////////////////////////////////
218 // proxy
219 virtual bool enableProxy(bool enable, std::string proxy_host_name, int proxy_port) = 0;
220
221 ////////////////////////////////////////////////////////////////////////////////
222 // observer interface
223 virtual bool addObserver( LLMediaObserver* subject ) = 0;
224 virtual bool remObserver( LLMediaObserver* subject ) = 0;
225
226 ////////////////////////////////////////////////////////////////////////////////
227 // factory interface
228 virtual void setImplMaker(LLMediaImplMakerBase* impl_maker) = 0;
229
230 ////////////////////////////////////////////////////////////////////////////////
231 // type registry interface
232 virtual bool supportsMediaType(std::string scheme, std::string type) = 0;
233};
234
235//////////////////////////////////////////////////////////////
236// media key codes - (mirroring mozilla's values)
237const unsigned long LL_MEDIA_KEY_BACKSPACE = 0x08;
238const unsigned long LL_MEDIA_KEY_TAB = 0x09;
239const unsigned long LL_MEDIA_KEY_RETURN = 0x0D;
240const unsigned long LL_MEDIA_KEY_PAD_RETURN = 0x0E;
241const unsigned long LL_MEDIA_KEY_ESCAPE = 0x1B;
242const unsigned long LL_MEDIA_KEY_PAGE_UP = 0x21;
243const unsigned long LL_MEDIA_KEY_PAGE_DOWN = 0x22;
244const unsigned long LL_MEDIA_KEY_END = 0x23;
245const unsigned long LL_MEDIA_KEY_HOME = 0x24;
246const unsigned long LL_MEDIA_KEY_LEFT = 0x25;
247const unsigned long LL_MEDIA_KEY_UP = 0x26;
248const unsigned long LL_MEDIA_KEY_RIGHT = 0x27;
249const unsigned long LL_MEDIA_KEY_DOWN = 0x28;
250const unsigned long LL_MEDIA_KEY_INSERT = 0x2D;
251const unsigned long LL_MEDIA_KEY_DELETE = 0x2E;
252
253//////////////////////////////////////////////////////////////
254// media frame buffer types - (mirroring GL values)
255const int LL_MEDIA_UNSIGNED_BYTE = 0x1401;
256const int LL_MEDIA_RGB = 0x1907;
257const int LL_MEDIA_RGBA = 0x1908;
258const int LL_MEDIA_RGB8 = 0x8051;
259const int LL_MEDIA_UNSIGNED_INT_8_8_8_8 = 0x8035;
260const int LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV = 0x8367;
261const int LL_MEDIA_BGR = 0x80E0;
262const int LL_MEDIA_BGRA = 0x80E1;
263
264
265#endif // LLMEDIABASE_H
diff --git a/linden/indra/llmedia/llmediaemitter.h b/linden/indra/llmedia/llmediaemitter.h
deleted file mode 100644
index ef3caeb..0000000
--- a/linden/indra/llmedia/llmediaemitter.h
+++ /dev/null
@@ -1,104 +0,0 @@
1/**
2 * @file llmediaemitter.h
3 * @author Callum Prentice
4 * @date 2007-10-22 00:00:00
5 * @brief Manages and emits events to observers
6 *
7 * $LicenseInfo:firstyear=2005&license=viewergpl$
8 *
9 * Copyright (c) 2005-2009, Linden Research, Inc.
10 *
11 * Second Life Viewer Source Code
12 * The source code in this file ("Source Code") is provided by Linden Lab
13 * to you under the terms of the GNU General Public License, version 2.0
14 * ("GPL"), unless you have obtained a separate licensing agreement
15 * ("Other License"), formally executed by you and Linden Lab. Terms of
16 * the GPL can be found in doc/GPL-license.txt in this distribution, or
17 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
18 *
19 * There are special exceptions to the terms and conditions of the GPL as
20 * it is applied to this Source Code. View the full text of the exception
21 * in the file doc/FLOSS-exception.txt in this software distribution, or
22 * online at
23 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
24 *
25 * By copying, modifying or distributing this software, you acknowledge
26 * that you have read and understood your obligations described above,
27 * and agree to abide by those obligations.
28 *
29 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
30 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
31 * COMPLETENESS OR PERFORMANCE.
32 * $/LicenseInfo$
33 */
34
35#ifndef LLMEDIAEMITTER_H
36#define LLMEDIAEMITTER_H
37
38#include <list>
39#include <algorithm>
40#include <typeinfo>
41
42///////////////////////////////////////////////////////////////////////////////
43//
44template< class T >
45class LLMediaEmitter
46{
47 public:
48 LLMediaEmitter() { };
49 ~LLMediaEmitter() { };
50
51 typedef typename T::EventType EventType;
52 typedef std::list< T* > ObserverContainer;
53 typedef void( T::*observerMethod )( const EventType& );
54
55 ///////////////////////////////////////////////////////////////////////////////
56 //
57 bool addObserver( T* observer_in )
58 {
59 if ( ! observer_in )
60 return false;
61
62 if ( std::find( observers.begin(), observers.end(), observer_in) != observers.end() )
63 return false;
64
65 observers.push_back( observer_in );
66
67 return true;
68 };
69
70 ///////////////////////////////////////////////////////////////////////////////
71 //
72 bool remObserver( T* observer_in )
73 {
74 if ( ! observer_in )
75 return false;
76
77 observers.remove( observer_in );
78 observers.remove( observer_in );
79 observers.remove( observer_in );
80
81
82
83 return true;
84 };
85
86 ///////////////////////////////////////////////////////////////////////////////
87 //
88 void update( observerMethod method, const EventType& msgIn )
89 {
90 typename std::list< T* >::iterator iter = observers.begin();
91
92 while( iter != observers.end() )
93 {
94 ( ( *iter )->*method )( msgIn );
95
96 ++iter;
97 };
98 };
99
100 protected:
101 ObserverContainer observers;
102};
103
104#endif // LLMEDIAEMITTER_H
diff --git a/linden/indra/llmedia/llmediaimplcommon.cpp b/linden/indra/llmedia/llmediaimplcommon.cpp
deleted file mode 100644
index 166e86d..0000000
--- a/linden/indra/llmedia/llmediaimplcommon.cpp
+++ /dev/null
@@ -1,552 +0,0 @@
1/**
2 * @file llmediaimplcommon.cpp
3 * @brief Common impl functionality
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 "llmediaimplcommon.h"
34#include "llmediaemitter.h"
35#include "llmediaimplfactory.h"
36#include "llmediaobserver.h"
37
38#ifdef WIN32
39 // platform specific includes needed before OpenGL header
40 #include <windows.h>
41 #include <GL/gl.h>
42#elif defined(__APPLE__)
43 // framework-style include path when building on the Mac.
44 #include <OpenGL/gl.h>
45#else // Assume this is linux
46 // Linux, MESA headers, but not necessarily assuming MESA runtime.
47 // quotes so we get libraries/.../GL/ version
48 #include "GL/gl.h"
49#endif
50
51////////////////////////////////////////////////////////////////////////////////
52// virtual (derives from LLMediaBase)
53LLMediaImplCommon::LLMediaImplCommon() :
54 mMimeType( std::string() ),
55 mInitialURL( std::string() ),
56 mImplMaker( NULL ),
57 mAutoScaled( false ),
58 mMediaWidth( 0 ),
59 mMediaPrevWidth( 0 ),
60 mMediaHeight( 0 ),
61 mMediaPrevHeight( 0 ),
62 mMediaDepth( 0 ),
63 mMediaPrevDepth( 0 ),
64 mMediaRowSpan( 0 ),
65 mMediaRequestedWidth( 0 ),
66 mMediaRequestedHeight( 0 ),
67 mCommand( LLMediaBase::COMMAND_NONE ),
68 mStatus( LLMediaBase::STATUS_UNKNOWN ),
69 mVolume( 0 ),
70 mLooping( false ),
71 mDebugLevel( LLMediaBase::DEBUG_LEVEL_NONE )
72{
73}
74
75////////////////////////////////////////////////////////////////////////////////
76// virtual (derives from LLMediaBase)
77LLMediaImplCommon::~LLMediaImplCommon()
78{
79}
80
81////////////////////////////////////////////////////////////////////////////////
82// virtual (derives from LLMediaBase)
83bool LLMediaImplCommon::init()
84{
85 return false;
86}
87
88////////////////////////////////////////////////////////////////////////////////
89// virtual (derives from LLMediaBase)
90bool LLMediaImplCommon::reset()
91{
92 return false;
93}
94
95////////////////////////////////////////////////////////////////////////////////
96// virtual (derives from LLMediaBase)
97bool LLMediaImplCommon::setDebugLevel( LLMediaBase::EDebugLevel level )
98{
99 mDebugLevel = level;
100
101 return true;
102}
103
104////////////////////////////////////////////////////////////////////////////////
105// virtual (derives from LLMediaBase)
106bool LLMediaImplCommon::setMimeType( const std::string mime_type )
107{
108 mMimeType = mime_type;
109
110 return true;
111}
112
113////////////////////////////////////////////////////////////////////////////////
114// virtual (derives from LLMediaBase)
115std::string LLMediaImplCommon::getMimeType() const
116{
117 return mMimeType;
118}
119
120////////////////////////////////////////////////////////////////////////////////
121// virtual (derives from LLMediaBase)
122std::string LLMediaImplCommon::getMediaURL() const
123{
124 return mInitialURL;
125}
126
127////////////////////////////////////////////////////////////////////////////////
128// virtual (derives from LLMediaBase)
129std::string LLMediaImplCommon::getVersion()
130{
131 return std::string( "" );
132}
133
134////////////////////////////////////////////////////////////////////////////////
135// virtual (derives from LLMediaBase)
136bool LLMediaImplCommon::set404RedirectUrl( std::string redirect_url )
137{
138 return true;
139}
140
141////////////////////////////////////////////////////////////////////////////////
142// virtual (derives from LLMediaBase)
143bool LLMediaImplCommon::clr404RedirectUrl()
144{
145 return true;
146}
147
148////////////////////////////////////////////////////////////////////////////////
149// virtual (derives from LLMediaBase)
150bool LLMediaImplCommon::setBackgroundColor( unsigned int red, unsigned int green, unsigned int blue ) const
151{
152 return true;
153}
154
155////////////////////////////////////////////////////////////////////////////////
156// virtual (derives from LLMediaBase)
157bool LLMediaImplCommon::setCaretColor( unsigned int red, unsigned int green, unsigned int blue ) const
158{
159 return true;
160}
161
162////////////////////////////////////////////////////////////////////////////////
163// virtual (derives from LLMediaBase)
164bool LLMediaImplCommon::updateMedia()
165{
166 return false;
167}
168
169////////////////////////////////////////////////////////////////////////////////
170// virtual (derives from LLMediaBase)
171unsigned char* LLMediaImplCommon::getMediaData()
172{
173 return 0;
174}
175
176////////////////////////////////////////////////////////////////////////////////
177// virtual (derives from LLMediaBase)
178int LLMediaImplCommon::getMediaDataWidth() const
179{
180 return getMediaWidth();
181}
182
183////////////////////////////////////////////////////////////////////////////////
184// virtual (derives from LLMediaBase)
185int LLMediaImplCommon::getMediaDataHeight() const
186{
187 return getMediaHeight();
188}
189
190
191////////////////////////////////////////////////////////////////////////////////
192// virtual (derives from LLMediaBase)
193bool LLMediaImplCommon::setMediaSize( int media_width, int media_height )
194{
195 // if nothing changed, don't do anything
196 if ( ( mMediaWidth == media_width ) &&
197 ( mMediaHeight == media_height ) )
198 return false;
199
200 // save old values so we can tell elsewhere if media size has changed
201 mMediaPrevWidth = mMediaWidth;
202 mMediaPrevHeight = mMediaHeight;
203
204 mMediaWidth = media_width;
205 mMediaHeight = media_height;
206
207 // only fire an event if the width changed
208 LLMediaEvent event( this );
209 mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event );
210
211 return true;
212}
213
214////////////////////////////////////////////////////////////////////////////////
215// virtual (derives from LLMediaBase)
216int LLMediaImplCommon::getMediaWidth() const
217{
218 return mMediaWidth;
219}
220
221
222////////////////////////////////////////////////////////////////////////////////
223// virtual (derives from LLMediaBase)
224int LLMediaImplCommon::getMediaHeight() const
225{
226 return mMediaHeight;
227}
228
229////////////////////////////////////////////////////////////////////////////////
230// virtual (derives from LLMediaBase)
231bool LLMediaImplCommon::setRequestedMediaSize(int width, int height)
232{
233 mMediaRequestedWidth = width;
234 mMediaRequestedHeight = height;
235
236 return true;
237}
238
239////////////////////////////////////////////////////////////////////////////////
240// virtual (derives from LLMediaBase)
241bool LLMediaImplCommon::setMediaDepth( int media_depth )
242{
243 // if nothing changed, don't do anything
244 if ( mMediaDepth == media_depth )
245 return false;
246
247 // save old values so we can tell elsewhere if media size has changed
248 mMediaPrevDepth = mMediaDepth;
249 mMediaDepth = media_depth;
250
251 // update value of rowspan too since it's based on media width & depth
252 mMediaRowSpan = mMediaWidth * mMediaDepth;
253
254 // only fire an event if the depth changed
255 //LLMediaEvent event( this );
256 //mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event );
257
258 return true;
259}
260
261////////////////////////////////////////////////////////////////////////////////
262// virtual (derives from LLMediaBase)
263int LLMediaImplCommon::getMediaDepth() const
264{
265 return mMediaDepth;
266}
267
268////////////////////////////////////////////////////////////////////////////////
269// virtual (derives from LLMediaBase)
270int LLMediaImplCommon::getMediaBufferSize() const
271{
272 return mMediaRowSpan * mMediaHeight;
273}
274
275////////////////////////////////////////////////////////////////////////////////
276// virtual (derives from LLMediaBase)
277int LLMediaImplCommon::getTextureFormatInternal() const
278{
279 return LL_MEDIA_RGB;
280}
281
282////////////////////////////////////////////////////////////////////////////////
283// virtual (derives from LLMediaBase)
284int LLMediaImplCommon::getTextureFormatPrimary() const
285{
286 return LL_MEDIA_RGB;
287}
288
289////////////////////////////////////////////////////////////////////////////////
290// virtual (derives from LLMediaBase)
291int LLMediaImplCommon::getTextureFormatType() const
292{
293 return LL_MEDIA_UNSIGNED_BYTE;
294}
295
296////////////////////////////////////////////////////////////////////////////////
297// virtual (derives from LLMediaBase)
298bool LLMediaImplCommon::setVolume( float volume )
299{
300 mVolume = volume;
301
302 return true;
303}
304
305////////////////////////////////////////////////////////////////////////////////
306// virtual (derives from LLMediaBase)
307float LLMediaImplCommon::getVolume() const
308{
309 return mVolume;
310}
311
312////////////////////////////////////////////////////////////////////////////////
313// virtual (derives from LLMediaBase)
314bool LLMediaImplCommon::addCommand( LLMediaBase::ECommand cmd )
315{
316 // eventually will be a std::queue so you can add multiple commands
317 mCommand = cmd;
318
319 return true;
320}
321
322////////////////////////////////////////////////////////////////////////////////
323// virtual (derives from LLMediaBase)
324bool LLMediaImplCommon::clearCommand()
325{
326 // eventually will be a std::queue so you can add multiple commands
327 mCommand = LLMediaBase::COMMAND_NONE;
328
329 return true;
330}
331
332////////////////////////////////////////////////////////////////////////////////
333// virtual (derives from LLMediaBase)
334bool LLMediaImplCommon::updateCommand()
335{
336 if ( nextCommand() == LLMediaBase::COMMAND_START )
337 {
338 setStatus( LLMediaBase::STATUS_STARTED );
339 clearCommand();
340 };
341
342 if ( nextCommand() == LLMediaBase::COMMAND_STOP )
343 {
344 setStatus( LLMediaBase::STATUS_STOPPED );
345 clearCommand();
346 };
347
348 if ( nextCommand() == LLMediaBase::COMMAND_PAUSE )
349 {
350 setStatus( LLMediaBase::STATUS_PAUSED );
351 clearCommand();
352 };
353
354 return true;
355}
356
357////////////////////////////////////////////////////////////////////////////////
358// non-virtual (only impls use this)
359LLMediaBase::ECommand LLMediaImplCommon::nextCommand()
360{
361 return mCommand;
362}
363
364////////////////////////////////////////////////////////////////////////////////
365// virtual (derives from LLMediaBase)
366LLMediaBase::EStatus LLMediaImplCommon::getStatus()
367{
368 return mStatus;
369}
370
371////////////////////////////////////////////////////////////////////////////////
372// non-virtual (only impls set this)
373bool LLMediaImplCommon::setStatus( LLMediaBase::EStatus status )
374{
375 mStatus = status;
376
377 return true;
378}
379
380////////////////////////////////////////////////////////////////////////////////
381// virtual (derives from LLMediaBase)
382bool LLMediaImplCommon::seek( double time )
383{
384 return false;
385}
386
387////////////////////////////////////////////////////////////////////////////////
388// virtual (derives from LLMediaBase)
389bool LLMediaImplCommon::navigateTo( const std::string url )
390{
391 return false;
392}
393
394////////////////////////////////////////////////////////////////////////////////
395// virtual (derives from LLMediaBase)
396bool LLMediaImplCommon::setAutoScaled( bool auto_scaled )
397{
398 mAutoScaled = auto_scaled;
399
400 return true;
401}
402
403////////////////////////////////////////////////////////////////////////////////
404// virtual (derives from LLMediaBase)
405bool LLMediaImplCommon::isAutoScaled() const
406{
407 return mAutoScaled;
408}
409
410////////////////////////////////////////////////////////////////////////////////
411// virtual (derives from LLMediaBase)
412bool LLMediaImplCommon::mouseDown( int x_pos, int y_pos )
413{
414 return false;
415}
416
417////////////////////////////////////////////////////////////////////////////////
418// virtual (derives from LLMediaBase)
419bool LLMediaImplCommon::mouseUp( int x_pos, int y_pos )
420{
421 return false;
422}
423
424////////////////////////////////////////////////////////////////////////////////
425// virtual (derives from LLMediaBase)
426bool LLMediaImplCommon::mouseMove( int x_pos, int y_pos )
427{
428 return false;
429}
430
431////////////////////////////////////////////////////////////////////////////////
432// virtual (derives from LLMediaBase)
433bool LLMediaImplCommon::keyPress( int key_code )
434{
435 return false;
436}
437
438////////////////////////////////////////////////////////////////////////////////
439// virtual (derives from LLMediaBase)
440bool LLMediaImplCommon::scrollByLines( int lines )
441{
442 return false;
443}
444
445////////////////////////////////////////////////////////////////////////////////
446// virtual (derives from LLMediaBase)
447bool LLMediaImplCommon::focus( bool focus )
448{
449 return false;
450}
451
452////////////////////////////////////////////////////////////////////////////////
453// virtual (derives from LLMediaBase)
454bool LLMediaImplCommon::unicodeInput( unsigned long uni_char )
455{
456 return false;
457}
458
459////////////////////////////////////////////////////////////////////////////////
460// virtual (derives from LLMediaBase)
461bool LLMediaImplCommon::mouseLeftDoubleClick( int x_pos, int y_pos )
462{
463 return false;
464}
465
466////////////////////////////////////////////////////////////////////////////////
467// virtual (derives from LLMediaBase)
468bool LLMediaImplCommon::navigateForward()
469{
470 return false;
471}
472
473////////////////////////////////////////////////////////////////////////////////
474// virtual (derives from LLMediaBase)
475bool LLMediaImplCommon::navigateBack()
476{
477 return false;
478}
479
480////////////////////////////////////////////////////////////////////////////////
481// virtual (derives from LLMediaBase)
482bool LLMediaImplCommon::canNavigateForward()
483{
484 return false;
485}
486
487////////////////////////////////////////////////////////////////////////////////
488// virtual (derives from LLMediaBase)
489bool LLMediaImplCommon::canNavigateBack()
490{
491 return false;
492}
493
494////////////////////////////////////////////////////////////////////////////////
495// virtual (derives from LLMediaBase)
496bool LLMediaImplCommon::enableCookies( bool enable )
497{
498 return false;
499}
500
501////////////////////////////////////////////////////////////////////////////////
502// virtual (derives from LLMediaBase)
503bool LLMediaImplCommon::clearCache()
504{
505 return false;
506}
507
508////////////////////////////////////////////////////////////////////////////////
509// virtual (derives from LLMediaBase)
510bool LLMediaImplCommon::clearCookies()
511{
512 return false;
513}
514
515////////////////////////////////////////////////////////////////////////////////
516// virtual (derives from LLMediaBase)
517bool LLMediaImplCommon::enableProxy(bool enable, std::string proxy_host_name, int proxy_port)
518{
519 return false;
520}
521////////////////////////////////////////////////////////////////////////////////
522//
523bool LLMediaImplCommon::addObserver( LLMediaObserver* subject )
524{
525 return mEventEmitter.addObserver( subject );
526}
527
528////////////////////////////////////////////////////////////////////////////////
529//
530bool LLMediaImplCommon::remObserver( LLMediaObserver* subject )
531{
532 return mEventEmitter.remObserver( subject );
533}
534
535////////////////////////////////////////////////////////////////////////////////
536//
537void LLMediaImplCommon::setImplMaker(LLMediaImplMakerBase* impl_maker)
538{
539 mImplMaker = impl_maker;
540}
541////////////////////////////////////////////////////////////////////////////////
542//
543bool LLMediaImplCommon::supportsMediaType(std::string scheme, std::string type)
544{
545 int idx1 = type.find("/");
546 int len = (idx1 == std::string::npos) ? 0 : idx1;
547 std::string category = type.substr(0,len);
548
549 return mImplMaker->supportsScheme(scheme) ||
550 mImplMaker->supportsMimeType(type) ||
551 mImplMaker->supportsMimeTypeCategory(category);
552}
diff --git a/linden/indra/llmedia/llmediaimplcommon.h b/linden/indra/llmedia/llmediaimplcommon.h
deleted file mode 100644
index 845429c..0000000
--- a/linden/indra/llmedia/llmediaimplcommon.h
+++ /dev/null
@@ -1,164 +0,0 @@
1/**
2 * @file llmediaimplcommon.h
3 * @brief Common impl functionality
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#ifndef LLMEDIAIMPLCOMMON_H
34#define LLMEDIAIMPLCOMMON_H
35
36#include "llmediabase.h"
37#include "llmediaemitter.h"
38#include "llmediaobserver.h"
39
40#include <string>
41
42class LLMediaImplMakerBase;
43
44class LLMediaImplCommon :
45 public LLMediaBase
46{
47 public:
48 LLMediaImplCommon();
49 virtual ~LLMediaImplCommon();
50
51 ////////////////////////////////////////////////////////////////////////////////
52 // begin: default implementation of the abstract interface
53 // see llmediabase.h for documentation
54
55 // housekeeping
56 virtual bool init();
57 virtual bool reset();
58 virtual bool setDebugLevel( LLMediaBase::EDebugLevel level );
59 virtual bool setMimeType( const std::string url );
60 virtual std::string getMimeType() const;
61 virtual std::string getMediaURL() const;
62 virtual std::string getVersion();
63 virtual bool set404RedirectUrl( std::string redirect_url );
64 virtual bool clr404RedirectUrl();
65 virtual bool setBackgroundColor( unsigned int red, unsigned int green, unsigned int blue ) const;
66 virtual bool setCaretColor( unsigned int red, unsigned int green, unsigned int blue ) const;
67
68 // media management
69 virtual bool updateMedia();
70 virtual bool setRequestedMediaSize( int width, int height );
71 virtual int getMediaWidth() const;
72 virtual int getMediaHeight() const;
73 virtual int getMediaDepth() const;
74 virtual int getMediaBufferSize() const;
75 virtual unsigned char* getMediaData();
76 virtual int getMediaDataWidth() const;
77 virtual int getMediaDataHeight() const;
78
79 // texture management
80 virtual int getTextureFormatInternal() const;
81 virtual int getTextureFormatPrimary() const;
82 virtual int getTextureFormatType() const;
83
84 // audio
85 virtual bool setVolume( float volume );
86 virtual float getVolume() const;
87
88 // transport control
89 virtual bool addCommand( ECommand cmd );
90 virtual bool clearCommand();
91 virtual bool updateCommand();
92 LLMediaBase::ECommand nextCommand();
93 virtual LLMediaBase::EStatus getStatus();
94 bool setStatus( LLMediaBase::EStatus status );
95
96 virtual bool seek( double time );
97 virtual bool setLooping(bool enable) { mLooping = enable; return true; }
98 virtual bool isLooping() { return mLooping; }
99 virtual bool navigateTo( const std::string url );
100
101 // scaling
102 virtual bool setAutoScaled( bool auto_scaled );
103 virtual bool isAutoScaled() const;
104
105 // mouse and keyboard interaction
106 virtual bool mouseDown( int x_pos, int y_pos );
107 virtual bool mouseUp( int x_pos, int y_pos );
108 virtual bool mouseMove( int x_pos, int y_pos );
109 virtual bool keyPress( int key_code );
110 virtual bool scrollByLines( int lines );
111 virtual bool focus( bool focus );
112 virtual bool unicodeInput( unsigned long uni_char );
113 virtual bool mouseLeftDoubleClick( int x_pos, int y_pos );
114
115 // navigation
116 virtual bool navigateForward();
117 virtual bool navigateBack();
118 virtual bool canNavigateForward();
119 virtual bool canNavigateBack();
120
121 // caching/cookies
122 virtual bool enableCookies( bool enable );
123 virtual bool clearCache();
124 virtual bool clearCookies();
125
126 virtual bool enableProxy(bool enable, std::string proxy_host_name, int proxy_port);
127
128 // observer interface
129 bool addObserver( LLMediaObserver* subject );
130 bool remObserver( LLMediaObserver* subject );
131
132 // type registry interface
133 void setImplMaker(LLMediaImplMakerBase* impl_maker);
134 bool supportsMediaType(std::string scheme, std::string type);
135
136 protected:
137 virtual bool setMediaSize( int width, int height );
138 virtual bool setMediaDepth( int media_depth );
139
140 LLMediaEmitter< LLMediaObserver > mEventEmitter;
141
142 // Back pointer to the construction object, which is used to discover types handled
143 // by the Impl, and meta data associated with the Impl.
144 LLMediaImplMakerBase* mImplMaker;
145 std::string mMimeType;
146 std::string mInitialURL;
147 bool mAutoScaled;
148 int mMediaWidth;
149 int mMediaPrevWidth;
150 int mMediaHeight;
151 int mMediaPrevHeight;
152 int mMediaDepth;
153 int mMediaPrevDepth;
154 int mMediaRowSpan;
155 int mMediaRequestedWidth;
156 int mMediaRequestedHeight;
157 float mVolume;
158 LLMediaBase::ECommand mCommand;
159 LLMediaBase::EStatus mStatus;
160 bool mLooping;
161 LLMediaBase::EDebugLevel mDebugLevel;
162};
163
164#endif // LLMEDIAIMPLCOMMON_H
diff --git a/linden/indra/llmedia/llmediaimplexample1.cpp b/linden/indra/llmedia/llmediaimplexample1.cpp
deleted file mode 100644
index fe7b7e2..0000000
--- a/linden/indra/llmedia/llmediaimplexample1.cpp
+++ /dev/null
@@ -1,231 +0,0 @@
1/**
2 * @file llmediaimplexample1.cpp
3 * @brief Example 1 of a media impl concrete class
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 "llmediaimplexample1.h"
34#include "llmediaimplregister.h"
35
36#include <cstring>
37
38// register this impl with media manager factory
39static LLMediaImplRegister sLLMediaImplExample1Reg( "LLMediaImplExample1", new LLMediaImplExample1Maker() );
40
41#include <iostream>
42
43#include <time.h>
44
45///////////////////////////////////////////////////////////////////////////////
46//
47LLMediaImplExample1Maker::LLMediaImplExample1Maker()
48{
49 // Register to handle the scheme
50 mSchema.push_back( "example1" );
51}
52
53///////////////////////////////////////////////////////////////////////////////
54//
55LLMediaImplExample1::LLMediaImplExample1() :
56 mMediaPixels( 0 )
57{
58 setRequestedMediaSize( 400, 200 );
59 setMediaDepth( 3 );
60
61 srand( (unsigned int)(time( NULL )) );
62}
63
64////////////////////////////////////////////////////////////////////////////////
65// (static) super-initialization - called once at application startup
66bool LLMediaImplExample1::startup( LLMediaManagerData* init_data )
67{
68 return true;
69}
70
71////////////////////////////////////////////////////////////////////////////////
72// (static) super-uninitialization - called once at application closedown
73bool LLMediaImplExample1::closedown()
74{
75 return true;
76}
77
78////////////////////////////////////////////////////////////////////////////////
79// virtual
80bool LLMediaImplExample1::init()
81{
82 int buffer_size = getMediaBufferSize();
83
84 mMediaPixels = new unsigned char[ buffer_size ];
85
86 memset( mMediaPixels, 0xAA, buffer_size );
87
88 return true;
89}
90
91////////////////////////////////////////////////////////////////////////////////
92// virtual
93bool LLMediaImplExample1::navigateTo( const std::string url )
94{
95 std::cout << "LLMediaImplExample1::navigateTo" << std::endl;
96
97 setStatus( LLMediaBase::STATUS_NAVIGATING );
98
99 // force a size change event for new URL
100 LLMediaEvent event( this );
101 mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event );
102
103 return true;
104}
105
106////////////////////////////////////////////////////////////////////////////////
107// virtual
108std::string LLMediaImplExample1::getVersion()
109{
110 std::string version_string = "[" + sLLMediaImplExample1Reg.getImplName() + "] - " + "1.0.0.0";
111
112 return version_string;
113}
114
115////////////////////////////////////////////////////////////////////////////////
116// virtual
117bool LLMediaImplExample1::updateMedia()
118{
119 if ( mMediaPixels && getStatus() == LLMediaBase::STATUS_STARTED )
120 {
121 // first time - make sure it's a few seconds back so first update happens immediately
122 static time_t t = time( 0 ) - 4;
123
124 // selected time period elapsed (1 second)
125 if ( time( 0 ) - t > 1 )
126 {
127 // display checkerboard
128 const int num_squares = rand() % 20 + 4;
129 int sqr1_r = rand() % 0x80;
130 int sqr1_g = rand() % 0x80;
131 int sqr1_b = rand() % 0x80;
132 int sqr2_r = rand() % 0x80;
133 int sqr2_g = rand() % 0x80;
134 int sqr2_b = rand() % 0x80;
135
136 for ( int y1 = 0; y1 < num_squares; ++y1 )
137 {
138 for ( int x1 = 0; x1 < num_squares; ++x1 )
139 {
140 int px_start = getMediaWidth() * x1 / num_squares;
141 int px_end = ( getMediaWidth() * ( x1 + 1 ) ) / num_squares;
142 int py_start = getMediaHeight() * y1 / num_squares;
143 int py_end = ( getMediaHeight() * ( y1 + 1 ) ) / num_squares;
144
145 for( int y2 = py_start; y2 < py_end; ++y2 )
146 {
147 for( int x2 = px_start; x2 < px_end; ++x2 )
148 {
149 int rowspan = getMediaWidth() * getMediaDepth();
150
151 if ( ( y1 % 2 ) ^ ( x1 % 2 ) )
152 {
153 mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 0 ] = sqr1_r;
154 mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 1 ] = sqr1_g;
155 mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 2 ] = sqr1_b;
156 }
157 else
158 {
159 mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 0 ] = sqr2_r;
160 mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 1 ] = sqr2_g;
161 mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 2 ] = sqr2_b;
162 };
163 };
164 };
165 };
166 };
167
168 // emit an event to say that something in the media stream changed
169 LLMediaEvent event( this );
170 mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event );
171
172 // reset time
173 t = time( 0 );
174
175 return true;
176 };
177 };
178
179 // update the command (e.g. transport controls) state
180 updateCommand();
181
182 return false;
183}
184
185////////////////////////////////////////////////////////////////////////////////
186// virtual
187unsigned char* LLMediaImplExample1::getMediaData()
188{
189 return mMediaPixels;
190}
191
192////////////////////////////////////////////////////////////////////////////////
193// virtual
194bool LLMediaImplExample1::reset()
195{
196 if ( mMediaPixels )
197 {
198 delete [] mMediaPixels;
199 };
200
201 return true;
202}
203
204////////////////////////////////////////////////////////////////////////////////
205// virtual
206bool LLMediaImplExample1::mouseMove( int x_pos, int y_pos )
207{
208 if ( mMediaPixels && getStatus() == LLMediaBase::STATUS_STARTED )
209 {
210 int base_pos = x_pos * getMediaDepth() + y_pos * getMediaDepth() * getMediaWidth();
211 // example: write a bright pixel to the display when we move the mouse
212 mMediaPixels[ base_pos + 0 ] = rand() % 0x80 + 0x80;
213 mMediaPixels[ base_pos + 1 ] = rand() % 0x80 + 0x80;
214 mMediaPixels[ base_pos + 2 ] = rand() % 0x80 + 0x80;
215
216 // emit an event to say that something in the media stream changed
217 LLMediaEvent event( this );
218 mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event );
219 };
220
221 return true;
222}
223
224
225////////////////////////////////////////////////////////////////////////////////
226// virtual
227bool LLMediaImplExample1::setRequestedMediaSize( int width, int height )
228{
229 // we accept any size:
230 return setMediaSize(width, height);
231}
diff --git a/linden/indra/llmedia/llmediaimplexample1.h b/linden/indra/llmedia/llmediaimplexample1.h
deleted file mode 100644
index 1b90e93..0000000
--- a/linden/indra/llmedia/llmediaimplexample1.h
+++ /dev/null
@@ -1,73 +0,0 @@
1/**
2 * @file llmediaimplexample1.h
3 * @brief Example 1 of a media impl concrete class
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#ifndef LLMEDIAIMPLEXAMPLE1_H
34#define LLMEDIAIMPLEXAMPLE1_H
35
36#include "llmediaimplcommon.h"
37#include "llmediaimplfactory.h"
38
39class LLMediaManagerData;
40
41class LLMediaImplExample1 :
42 public LLMediaImplCommon
43{
44 public:
45 LLMediaImplExample1();
46
47 static bool startup( LLMediaManagerData* init_data );
48 static bool closedown();
49
50 /* virtual */ bool init();
51 /* virtual */ bool navigateTo( const std::string url );
52 /* virtual */ bool updateMedia();
53 /* virtual */ std::string getVersion();
54 /* virtual */ unsigned char* getMediaData();
55 /* virtual */ bool reset();
56 /* virtual */ bool mouseMove( int x_pos, int y_pos );
57 /* virtual */ bool setRequestedMediaSize( int width, int height );
58
59 private:
60 unsigned char* mMediaPixels;
61};
62
63class LLMediaImplExample1Maker : public LLMediaImplMaker
64{
65 public:
66 LLMediaImplExample1Maker();
67 LLMediaImplExample1* create()
68 {
69 return new LLMediaImplExample1();
70 }
71};
72
73#endif // LLMEDIAIMPLEXAMPLE1_H
diff --git a/linden/indra/llmedia/llmediaimplexample2.cpp b/linden/indra/llmedia/llmediaimplexample2.cpp
deleted file mode 100644
index 7590e19..0000000
--- a/linden/indra/llmedia/llmediaimplexample2.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
1/**
2 * @file llmediaimplexample2.cpp
3 * @brief Example 2 of a media impl concrete class
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 "llmediaimplexample2.h"
34#include "llmediaimplregister.h"
35
36#include <cstring>
37
38// register this impl with media manager factory
39static LLMediaImplRegister sLLMediaImplExample2Reg( "LLMediaImplExample2", new LLMediaImplExample2Maker() );
40
41#include <iostream>
42#include <time.h>
43
44///////////////////////////////////////////////////////////////////////////////
45//
46LLMediaImplExample2Maker::LLMediaImplExample2Maker()
47{
48 // Register to handle the scheme
49 mSchema.push_back( "example2." );
50}
51
52///////////////////////////////////////////////////////////////////////////////
53//
54LLMediaImplExample2::LLMediaImplExample2() :
55 mMediaPixels( 0 )
56{
57 setRequestedMediaSize( 500, 500 );
58 setMediaDepth( 3 );
59
60 mXpos = ( getMediaWidth() / 2 ) + rand() % ( getMediaWidth() / 16 ) - ( getMediaWidth() / 32 );
61 mYpos = ( getMediaHeight() / 2 ) + rand() % ( getMediaHeight() / 16 ) - ( getMediaHeight() / 32 );
62
63 srand( (unsigned int)(time( NULL )) );
64}
65
66////////////////////////////////////////////////////////////////////////////////
67// (static) super-initialization - called once at application startup
68bool LLMediaImplExample2::startup( LLMediaManagerData* init_data )
69{
70 return true;
71}
72
73////////////////////////////////////////////////////////////////////////////////
74// (static) super-uninitialization - called once at application closedown
75bool LLMediaImplExample2::closedown()
76{
77 return true;
78}
79
80////////////////////////////////////////////////////////////////////////////////
81// virtual
82bool LLMediaImplExample2::init()
83{
84 int buffer_size = getMediaBufferSize();
85
86 mMediaPixels = new unsigned char[ buffer_size ];
87
88 memset( mMediaPixels, 0x00, buffer_size );
89
90 return true;
91}
92
93////////////////////////////////////////////////////////////////////////////////
94// virtual
95bool LLMediaImplExample2::navigateTo( const std::string url )
96{
97 std::cout << "LLMediaImplExample2::navigateTo" << std::endl;
98
99 setStatus( LLMediaBase::STATUS_NAVIGATING );
100
101 // force a size change event for new URL
102 LLMediaEvent event( this );
103 mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event );
104
105 return true;
106}
107
108////////////////////////////////////////////////////////////////////////////////
109// virtual
110std::string LLMediaImplExample2::getVersion()
111{
112 std::string version_string = "[" + sLLMediaImplExample2Reg.getImplName() + "] - " + "1.0.0.0";
113
114 return version_string;
115}
116
117////////////////////////////////////////////////////////////////////////////////
118// virtual
119bool LLMediaImplExample2::updateMedia()
120{
121 if ( mMediaPixels && getStatus() == LLMediaBase::STATUS_STARTED )
122 {
123 static int x_inc = rand() % 5 + 2;
124 static int y_inc = rand() % 5 + 2;
125 int block_size = 32;
126
127 for( int y = 0; y < block_size; ++y )
128 {
129 for( int x = 0; x < block_size; ++x )
130 {
131 int rowspan = getMediaWidth() * getMediaDepth();
132 mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 0 ] = 0;
133 mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 1 ] = 0;
134 mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 2 ] = 0;
135 };
136 };
137
138 if ( mXpos + x_inc < 0 || mXpos + x_inc >= getMediaWidth() - block_size )
139 x_inc =- x_inc;
140
141 if ( mYpos + y_inc < 0 || mYpos + y_inc >= getMediaHeight() - block_size )
142 y_inc =- y_inc;
143
144 mXpos += x_inc;
145 mYpos += y_inc;
146
147 unsigned char col_r = rand() % 0xff;
148 unsigned char col_g = rand() % 0xff;
149 unsigned char col_b = rand() % 0xff;
150
151 for( int y = 0; y < block_size; ++y )
152 {
153 for( int x = 0; x < block_size; ++x )
154 {
155 int rowspan = getMediaWidth() * getMediaDepth();
156 mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 0 ] = col_r;
157 mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 1 ] = col_g;
158 mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 2 ] = col_b;
159 };
160 };
161
162 // emit an event to say that something in the media stream changed
163 LLMediaEvent event( this );
164 mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event );
165 };
166
167 // update the command (e.g. transport controls) state
168 updateCommand();
169
170 return false;
171}
172
173////////////////////////////////////////////////////////////////////////////////
174// virtual
175unsigned char* LLMediaImplExample2::getMediaData()
176{
177 return mMediaPixels;
178}
179
180////////////////////////////////////////////////////////////////////////////////
181// virtual
182bool LLMediaImplExample2::reset()
183{
184 if ( mMediaPixels )
185 {
186 delete [] mMediaPixels;
187 };
188
189 return true;
190}
191
192////////////////////////////////////////////////////////////////////////////////
193// virtual
194bool LLMediaImplExample2::setRequestedMediaSize( int width, int height )
195{
196 // we accept any size:
197 return setMediaSize(width, height);
198}
diff --git a/linden/indra/llmedia/llmediaimplexample2.h b/linden/indra/llmedia/llmediaimplexample2.h
deleted file mode 100644
index 6a4f80b..0000000
--- a/linden/indra/llmedia/llmediaimplexample2.h
+++ /dev/null
@@ -1,76 +0,0 @@
1/**
2 * @file llmediaimplexample2.h
3 * @brief Example 2 of a media impl concrete class
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#ifndef LLMEDIAIMPLEXAMPLE2_H
34#define LLMEDIAIMPLEXAMPLE2_H
35
36#include "llmediaimplcommon.h"
37#include "llmediaimplfactory.h"
38
39class LLMediaManagerData;
40class LLMediaImplMaker;
41
42class LLMediaImplExample2 :
43 public LLMediaImplCommon
44{
45 public:
46 LLMediaImplExample2();
47
48 static bool startup( LLMediaManagerData* init_data );
49 static bool closedown();
50
51 /* virtual */ bool init();
52 /* virtual */ bool navigateTo( const std::string url );
53 /* virtual */ bool load( const std::string url );
54 /* virtual */ std::string getVersion();
55 /* virtual */ bool updateMedia();
56 /* virtual */ unsigned char* getMediaData();
57 /* virtual */ bool reset();
58 /* virtual */ bool setRequestedMediaSize( int width, int height );
59
60 private:
61 unsigned char* mMediaPixels;
62 int mXpos;
63 int mYpos;
64};
65
66class LLMediaImplExample2Maker : public LLMediaImplMaker
67{
68 public:
69 LLMediaImplExample2Maker();
70 LLMediaImplExample2* create()
71 {
72 return new LLMediaImplExample2();
73 }
74};
75
76#endif // LLMEDIAIMPLEXAMPLE2_H
diff --git a/linden/indra/llmedia/llmediaimplfactory.cpp b/linden/indra/llmedia/llmediaimplfactory.cpp
deleted file mode 100644
index c5d098f..0000000
--- a/linden/indra/llmedia/llmediaimplfactory.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
1/**
2 * @file llmediaimplfactory.cpp
3 * @brief Creates media impls that have registered themselves with LLMediaRegster
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 "llmediaimplfactory.h"
34
35#include <iostream>
36
37LLMediaImplFactory* LLMediaImplFactory::sInstance = NULL;
38
39///////////////////////////////////////////////////////////////////////////////
40// static
41LLMediaImplFactory* LLMediaImplFactory::getInstance()
42{
43 if ( ! sInstance )
44 sInstance = new LLMediaImplFactory();
45
46 return sInstance;
47}
48
49///////////////////////////////////////////////////////////////////////////////
50//
51void LLMediaImplFactory::registerImpl( const std::string& impl_name, LLMediaImplMakerBase* impl_maker )
52{
53 mNameImplMakerContainer.insert( name_impl_maker_container_t::value_type( impl_name, impl_maker ) );
54}
55
56///////////////////////////////////////////////////////////////////////////////
57//
58LLMediaImplMakerBase* LLMediaImplFactory::getImplMaker( const std::string& scheme, const std::string& type )
59{
60 name_impl_maker_container_t::const_iterator iter;
61 name_impl_maker_container_t::const_iterator begin = mNameImplMakerContainer.begin();
62 name_impl_maker_container_t::const_iterator end = mNameImplMakerContainer.end();
63
64 for(iter = begin; iter != end; ++iter)
65 {
66 if(( *iter->second ).supportsScheme(scheme))
67 {
68 return ( iter->second );
69 }
70 }
71
72 for(iter = begin; iter != end; ++iter)
73 {
74 if(( *iter->second ).supportsMimeType(type))
75 {
76 return ( iter->second );
77 }
78 }
79 int idx1 = type.find("/");
80 int len = (idx1 == std::string::npos) ? 0 : idx1;
81 std::string category = type.substr(0,len);
82 for(iter = begin; iter != end; ++iter)
83 {
84 if(( *iter->second ).supportsMimeTypeCategory(category))
85 {
86 return ( iter->second );
87 }
88 }
89
90 return NULL;
91};
92
93///////////////////////////////////////////////////////////////////////////////
94//
95LLMediaImplMakerBase* LLMediaImplFactory::getImplMaker( const std::string& impl_name )
96{
97 name_impl_maker_container_t::const_iterator found = mNameImplMakerContainer.find( impl_name );
98
99 if ( found == mNameImplMakerContainer.end() )
100 {
101 return NULL;
102 };
103
104 return found->second;
105}
diff --git a/linden/indra/llmedia/llmediaimplfactory.h b/linden/indra/llmedia/llmediaimplfactory.h
deleted file mode 100644
index 93a7cc1..0000000
--- a/linden/indra/llmedia/llmediaimplfactory.h
+++ /dev/null
@@ -1,100 +0,0 @@
1/**
2 * @file llmediaimplfactory.h
3 * @brief Creates media impls that have registered themselves with LLMediaRegster
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#ifndef LLMEDIAIMPLFACTORY_H
34#define LLMEDIAIMPLFACTORY_H
35
36#include <algorithm>
37#include <map>
38#include <string>
39#include <vector>
40
41#include "llmediabase.h"
42
43///////////////////////////////////////////////////////////////////////////////
44//
45class LLMediaImplMakerBase
46{
47 public:
48 virtual bool supportsScheme(std::string scheme) = 0;
49 virtual bool supportsMimeType(std::string type) = 0;
50 virtual bool supportsMimeTypeCategory(std::string category) = 0;
51 virtual LLMediaBase* create() = 0;
52 virtual ~LLMediaImplMakerBase() {};
53
54 protected:
55 typedef std::vector <std::string> vector_impl_registry_t;
56 vector_impl_registry_t mSchema;
57 vector_impl_registry_t mMimeTypes;
58 vector_impl_registry_t mMimeTypeCategories;
59};
60
61///////////////////////////////////////////////////////////////////////////////
62//
63class LLMediaImplMaker : public LLMediaImplMakerBase
64{
65 public:
66 bool supportsScheme(std::string scheme)
67 {
68 vector_impl_registry_t::iterator found = std::find(mSchema.begin(), mSchema.end(), scheme);
69 return found != mSchema.end();
70 }
71 bool supportsMimeType(std::string type)
72 {
73 vector_impl_registry_t::iterator found = std::find(mMimeTypes.begin(), mMimeTypes.end(), type);
74 return found != mMimeTypes.end();
75 }
76 bool supportsMimeTypeCategory(std::string category)
77 {
78 vector_impl_registry_t::iterator found = std::find(mMimeTypeCategories.begin(), mMimeTypeCategories.end(), category);
79 return found != mMimeTypeCategories.end();
80 }
81};
82
83///////////////////////////////////////////////////////////////////////////////
84//
85class LLMediaImplFactory
86{
87 public:
88 static LLMediaImplFactory* getInstance();
89 void registerImpl( const std::string& impl_name, LLMediaImplMakerBase* impl_maker );
90 LLMediaImplMakerBase* getImplMaker( const std::string& scheme, const std::string& type );
91 LLMediaImplMakerBase* getImplMaker( const std::string& impl_name);
92
93 private:
94 typedef std::map< std::string, LLMediaImplMakerBase* > name_impl_maker_container_t;
95 name_impl_maker_container_t mNameImplMakerContainer;
96
97 static LLMediaImplFactory* sInstance;
98};
99
100#endif // LLMEDIAIMPLFACTORY_H
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.h b/linden/indra/llmedia/llmediaimplgstreamer.h
deleted file mode 100644
index 8d2e756..0000000
--- a/linden/indra/llmedia/llmediaimplgstreamer.h
+++ /dev/null
@@ -1,164 +0,0 @@
1/**
2 * @file llmediaimplgstreamer.h
3 * @author Tofu Linden
4 * @brief implementation that supports media playback via GStreamer.
5 *
6 * $LicenseInfo:firstyear=2007&license=viewergpl$
7 *
8 * Copyright (c) 2007-2009, 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://secondlifegrid.net/programs/open_source/licensing/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 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// header guard
34#ifndef llmediaimplgstreamer_h
35#define llmediaimplgstreamer_h
36
37#include "llmediaimplcommon.h"
38#include "llmediaimplfactory.h"
39
40///#if LL_GSTREAMER_ENABLED
41
42extern "C" {
43#include <gst/gst.h>
44}
45
46#include <stdio.h>
47#include "apr_pools.h"
48#include "apr_dso.h"
49
50
51#include "llmediaimplgstreamervidplug.h"
52#include "llgstplaythread.h"
53
54class LLMediaManagerData;
55class LLMediaImplMaker;
56
57///////////////////////////////////////////////////////////////////////////
58class LLMediaImplGStreamer:
59 public LLMediaImplCommon
60{
61 friend class LLGstPlayThread;
62
63 public:
64 LLMediaImplGStreamer ();
65 virtual ~LLMediaImplGStreamer ();
66
67 ////////////////////////////////////////////////////////
68 // implementation of the media public interface
69
70 static bool startup( LLMediaManagerData* init_data );
71 static bool closedown();
72
73 // Sets GST_PLUGIN_PATH env var for GStreamer.
74 static void set_gst_plugin_path();
75
76 /* virtual */ bool setDebugLevel( LLMediaBase::EDebugLevel level );
77
78 // Function given to GStreamer for handling debug messages
79 static void gstreamer_log(GstDebugCategory *category,
80 GstDebugLevel level,
81 const gchar *file,
82 const gchar *function,
83 gint line,
84 GObject *object,
85 GstDebugMessage *message,
86 gpointer data)
87#if __GNUC__
88 // recommended by the gstreamer docs
89 G_GNUC_NO_INSTRUMENT
90#endif
91 ;
92
93 /* virtual */ std::string getVersion();
94 /* virtual */ bool navigateTo( const std::string url );
95 /* virtual */ bool updateMedia();
96 /* virtual */ unsigned char* getMediaData();
97 /* virtual */ int getTextureFormatPrimary() const;
98 /* virtual */ int getTextureFormatType() const;
99 /* virtual */ int getTextureFormatInternal() const;
100 /* virtual */ bool seek( double time );
101 /* virtual */ bool setVolume( float volume );
102
103 LLMediaEmitter< LLMediaObserver > getEventEmitter() const {return mEventEmitter;};
104
105 protected:
106
107 void startPlay();
108
109
110 private:
111
112 // misc
113 bool unload();
114 bool pause();
115 bool stop();
116 bool play();
117
118 static gboolean bus_callback (GstBus *bus,
119 GstMessage *message,
120 gpointer data);
121
122 unsigned char* mediaData;
123 int mMediaRowbytes;
124 int mTextureFormatPrimary;
125 int mTextureFormatType;
126
127 // GStreamer-specific
128 GMainLoop *mPump; // event pump for this media
129 GstElement *mPlaybin;
130 GstSLVideo *mVideoSink;
131 std::string mLastTitle;
132 GstState mState;
133 GstState getState() const { return mState; }
134
135 LLGstPlayThread *mPlayThread;
136};
137
138class LLMediaImplGStreamerMaker : public LLMediaImplMaker
139{
140 public:
141 LLMediaImplGStreamerMaker();
142 LLMediaImplGStreamer* create()
143 {
144 return new LLMediaImplGStreamer();
145 }
146};
147
148/////////////////////////////////////////////////////////////////////////
149// Debug/Info/Warning macros.
150#define STDERRMSG(...) do{\
151 fprintf(stderr, "%s:%d: ", __FUNCTION__, __LINE__);\
152 fprintf(stderr, __VA_ARGS__);\
153 fputc('\n',stderr);\
154 }while(0)
155#define NULLMSG(...) do{}while(0)
156
157#define DEBUGMSG NULLMSG
158#define INFOMSG STDERRMSG
159#define WARNMSG STDERRMSG
160/////////////////////////////////////////////////////////////////////////
161
162///#endif // LL_GSTREAMER_ENABLED
163
164#endif // llmediaimplgstreamer_h
diff --git a/linden/indra/llmedia/llmediaimplgstreamervidplug.cpp b/linden/indra/llmedia/llmediaimplgstreamervidplug.cpp
deleted file mode 100644
index f2c0e88..0000000
--- a/linden/indra/llmedia/llmediaimplgstreamervidplug.cpp
+++ /dev/null
@@ -1,448 +0,0 @@
1/**
2 * @file llmediaimplgstreamervidplug.h
3 * @brief Video-consuming static GStreamer plugin for gst-to-LLMediaImpl
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///#if LL_GSTREAMER_ENABLED
34
35#include "linden_common.h"
36
37#include <gst/gst.h>
38#include <gst/video/video.h>
39#include <gst/video/gstvideosink.h>
40
41#include "llthread.h"
42
43#include "llmediaimplgstreamervidplug.h"
44
45GST_DEBUG_CATEGORY_STATIC (gst_slvideo_debug);
46#define GST_CAT_DEFAULT gst_slvideo_debug
47
48/* Filter signals and args */
49enum
50{
51 /* FILL ME */
52 LAST_SIGNAL
53};
54
55enum
56{
57 ARG_0
58};
59
60#define SLV_SIZECAPS ", width=(int){1,2,4,8,16,32,64,128,256,512,1024}, height=(int){1,2,4,8,16,32,64,128,256,512,1024} "
61#define SLV_ALLCAPS GST_VIDEO_CAPS_RGBx SLV_SIZECAPS ";" GST_VIDEO_CAPS_BGRx SLV_SIZECAPS
62
63static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE (
64 "sink",
65 GST_PAD_SINK,
66 GST_PAD_ALWAYS,
67 GST_STATIC_CAPS (SLV_ALLCAPS)
68 );
69
70GST_BOILERPLATE (GstSLVideo, gst_slvideo, GstVideoSink,
71 GST_TYPE_VIDEO_SINK);
72
73static void gst_slvideo_set_property (GObject * object, guint prop_id,
74 const GValue * value,
75 GParamSpec * pspec);
76static void gst_slvideo_get_property (GObject * object, guint prop_id,
77 GValue * value, GParamSpec * pspec);
78
79static void
80gst_slvideo_base_init (gpointer gclass)
81{
82 static GstElementDetails element_details = {
83 (gchar*)"PluginTemplate",
84 (gchar*)"Generic/PluginTemplate",
85 (gchar*)"Generic Template Element",
86 (gchar*)"Linden Lab"
87 };
88 GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
89
90 gst_element_class_add_pad_template (element_class,
91 gst_static_pad_template_get (&sink_factory));
92 gst_element_class_set_details (element_class, &element_details);
93}
94
95
96static void
97gst_slvideo_finalize (GObject * object)
98{
99 GstSLVideo *slvideo;
100 slvideo = GST_SLVIDEO (object);
101 if (slvideo->caps)
102 {
103 gst_caps_unref(slvideo->caps);
104 }
105
106 G_OBJECT_CLASS(parent_class)->finalize (object);
107}
108
109
110static GstFlowReturn
111gst_slvideo_show_frame (GstBaseSink * bsink, GstBuffer * buf)
112{
113 GstSLVideo *slvideo;
114 g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
115
116 slvideo = GST_SLVIDEO(bsink);
117
118#if 0
119 fprintf(stderr, "\n\ntransferring a frame of %dx%d <- %p (%d)\n\n",
120 slvideo->width, slvideo->height, GST_BUFFER_DATA(buf),
121 slvideo->format);
122#endif
123 if (GST_BUFFER_DATA(buf))
124 {
125 // copy frame and frame info into neutral territory
126 GST_OBJECT_LOCK(slvideo);
127 slvideo->retained_frame_ready = TRUE;
128 slvideo->retained_frame_width = slvideo->width;
129 slvideo->retained_frame_height = slvideo->height;
130 slvideo->retained_frame_format = slvideo->format;
131 int rowbytes =
132 SLVPixelFormatBytes[slvideo->retained_frame_format] *
133 slvideo->retained_frame_width;
134 int needbytes = rowbytes * slvideo->retained_frame_width;
135 // resize retained frame hunk only if necessary
136 if (needbytes != slvideo->retained_frame_allocbytes)
137 {
138 delete[] slvideo->retained_frame_data;
139 slvideo->retained_frame_data = new unsigned char[needbytes];
140 slvideo->retained_frame_allocbytes = needbytes;
141
142 }
143 // copy the actual frame data to neutral territory -
144 // flipped, for GL reasons
145 for (int ypos=0; ypos<slvideo->height; ++ypos)
146 {
147 memcpy(&slvideo->retained_frame_data[(slvideo->height-1-ypos)*rowbytes],
148 &(((unsigned char*)GST_BUFFER_DATA(buf))[ypos*rowbytes]),
149 rowbytes);
150 }
151 // done with the shared data
152 GST_OBJECT_UNLOCK(slvideo);
153 }
154
155 return GST_FLOW_OK;
156}
157
158
159static GstStateChangeReturn
160gst_slvideo_change_state(GstElement * element, GstStateChange transition)
161{
162 GstSLVideo *slvideo;
163 GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
164
165 slvideo = GST_SLVIDEO (element);
166
167 switch (transition) {
168 case GST_STATE_CHANGE_NULL_TO_READY:
169 break;
170 case GST_STATE_CHANGE_READY_TO_PAUSED:
171 break;
172 case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
173 break;
174 default:
175 break;
176 }
177
178 ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
179 if (ret == GST_STATE_CHANGE_FAILURE)
180 return ret;
181
182 switch (transition) {
183 case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
184 break;
185 case GST_STATE_CHANGE_PAUSED_TO_READY:
186 slvideo->fps_n = 0;
187 slvideo->fps_d = 1;
188 GST_VIDEO_SINK_WIDTH(slvideo) = 0;
189 GST_VIDEO_SINK_HEIGHT(slvideo) = 0;
190 break;
191 case GST_STATE_CHANGE_READY_TO_NULL:
192 break;
193 default:
194 break;
195 }
196
197 return ret;
198}
199
200
201static GstCaps *
202gst_slvideo_get_caps (GstBaseSink * bsink)
203{
204 GstSLVideo *slvideo;
205 slvideo = GST_SLVIDEO(bsink);
206
207 return gst_caps_ref (slvideo->caps);
208}
209
210
211/* this function handles the link with other elements */
212static gboolean
213gst_slvideo_set_caps (GstBaseSink * bsink, GstCaps * caps)
214{
215 GstSLVideo *filter;
216 GstStructure *structure;
217 GstCaps *intersection;
218
219 GST_DEBUG ("set caps with %" GST_PTR_FORMAT, caps);
220
221 filter = GST_SLVIDEO(bsink);
222
223 intersection = gst_caps_intersect (filter->caps, caps);
224 if (gst_caps_is_empty (intersection))
225 {
226 // no overlap between our caps and requested caps
227 return FALSE;
228 }
229 gst_caps_unref(intersection);
230
231 int width = 0;
232 int height = 0;
233 gboolean ret;
234 const GValue *fps;
235 const GValue *par;
236 structure = gst_caps_get_structure (caps, 0);
237 ret = gst_structure_get_int (structure, "width", &width);
238 ret = ret && gst_structure_get_int (structure, "height", &height);
239 fps = gst_structure_get_value (structure, "framerate");
240 ret = ret && (fps != NULL);
241 par = gst_structure_get_value (structure, "pixel-aspect-ratio");
242 if (!ret)
243 return FALSE;
244
245 filter->width = width;
246 filter->height = height;
247 filter->fps_n = gst_value_get_fraction_numerator(fps);
248 filter->fps_d = gst_value_get_fraction_denominator(fps);
249 if (par)
250 {
251 filter->par_n = gst_value_get_fraction_numerator(par);
252 filter->par_d = gst_value_get_fraction_denominator(par);
253 }
254 else
255 {
256 filter->par_n = 1;
257 filter->par_d = 1;
258 }
259 GST_VIDEO_SINK_WIDTH(filter) = width;
260 GST_VIDEO_SINK_HEIGHT(filter) = height;
261
262 filter->format = SLV_PF_UNKNOWN;
263 if (0 == strcmp(gst_structure_get_name(structure),
264 "video/x-raw-rgb"))
265 {
266 int red_mask;
267 int green_mask;
268 int blue_mask;
269 gst_structure_get_int(structure, "red_mask", &red_mask);
270 gst_structure_get_int(structure, "green_mask", &green_mask);
271 gst_structure_get_int(structure, "blue_mask", &blue_mask);
272 if ((unsigned int)red_mask == 0xFF000000 &&
273 (unsigned int)green_mask == 0x00FF0000 &&
274 (unsigned int)blue_mask == 0x0000FF00)
275 {
276 filter->format = SLV_PF_RGBX;
277 //fprintf(stderr, "\n\nPIXEL FORMAT RGB\n\n");
278 } else if ((unsigned int)red_mask == 0x0000FF00 &&
279 (unsigned int)green_mask == 0x00FF0000 &&
280 (unsigned int)blue_mask == 0xFF000000)
281 {
282 filter->format = SLV_PF_BGRX;
283 //fprintf(stderr, "\n\nPIXEL FORMAT BGR\n\n");
284 }
285 }
286
287 return TRUE;
288}
289
290
291static gboolean
292gst_slvideo_start (GstBaseSink * bsink)
293{
294 GstSLVideo *slvideo;
295 gboolean ret = TRUE;
296
297 slvideo = GST_SLVIDEO(bsink);
298
299 return ret;
300}
301
302static gboolean
303gst_slvideo_stop (GstBaseSink * bsink)
304{
305 GstSLVideo *slvideo;
306 slvideo = GST_SLVIDEO(bsink);
307
308 // free-up retained frame buffer
309 GST_OBJECT_LOCK(slvideo);
310 slvideo->retained_frame_ready = FALSE;
311 delete[] slvideo->retained_frame_data;
312 slvideo->retained_frame_data = NULL;
313 slvideo->retained_frame_allocbytes = 0;
314 GST_OBJECT_UNLOCK(slvideo);
315
316 return TRUE;
317}
318
319
320/* initialize the plugin's class */
321static void
322gst_slvideo_class_init (GstSLVideoClass * klass)
323{
324 GObjectClass *gobject_class;
325 GstElementClass *gstelement_class;
326 GstBaseSinkClass *gstbasesink_class;
327
328 gobject_class = (GObjectClass *) klass;
329 gstelement_class = (GstElementClass *) klass;
330 gstbasesink_class = (GstBaseSinkClass *) klass;
331
332 gobject_class->finalize = gst_slvideo_finalize;
333 gobject_class->set_property = gst_slvideo_set_property;
334 gobject_class->get_property = gst_slvideo_get_property;
335
336 gstelement_class->change_state = gst_slvideo_change_state;
337
338#define LLGST_DEBUG_FUNCPTR(p) (p)
339 gstbasesink_class->get_caps = LLGST_DEBUG_FUNCPTR (gst_slvideo_get_caps);
340 gstbasesink_class->set_caps = LLGST_DEBUG_FUNCPTR( gst_slvideo_set_caps);
341 //gstbasesink_class->buffer_alloc=LLGST_DEBUG_FUNCPTR(gst_slvideo_buffer_alloc);
342 //gstbasesink_class->get_times = LLGST_DEBUG_FUNCPTR (gst_slvideo_get_times);
343 gstbasesink_class->preroll = LLGST_DEBUG_FUNCPTR (gst_slvideo_show_frame);
344 gstbasesink_class->render = LLGST_DEBUG_FUNCPTR (gst_slvideo_show_frame);
345
346 gstbasesink_class->start = LLGST_DEBUG_FUNCPTR (gst_slvideo_start);
347 gstbasesink_class->stop = LLGST_DEBUG_FUNCPTR (gst_slvideo_stop);
348
349 // gstbasesink_class->unlock = LLGST_DEBUG_FUNCPTR (gst_slvideo_unlock);
350#undef LLGST_DEBUG_FUNCPTR
351}
352
353
354static void
355gst_slvideo_update_caps (GstSLVideo * slvideo)
356{
357 GstCaps *caps;
358
359 // GStreamer will automatically convert colourspace if necessary.
360 // GStreamer will automatically resize media to one of these enumerated
361 // powers-of-two that we ask for (yay GStreamer!)
362 caps = gst_caps_from_string (SLV_ALLCAPS);
363
364 gst_caps_replace (&slvideo->caps, caps);
365}
366
367
368/* initialize the new element
369 * instantiate pads and add them to element
370 * set functions
371 * initialize structure
372 */
373static void
374gst_slvideo_init (GstSLVideo * filter,
375 GstSLVideoClass * gclass)
376{
377 filter->width = -1;
378 filter->height = -1;
379
380 // this is the info we share with the client app
381 GST_OBJECT_LOCK(filter);
382 filter->retained_frame_ready = FALSE;
383 filter->retained_frame_data = NULL;
384 filter->retained_frame_allocbytes = 0;
385 filter->retained_frame_width = filter->width;
386 filter->retained_frame_height = filter->height;
387 filter->retained_frame_format = SLV_PF_UNKNOWN;
388 GST_OBJECT_UNLOCK(filter);
389
390 gst_slvideo_update_caps(filter);
391}
392
393static void
394gst_slvideo_set_property (GObject * object, guint prop_id,
395 const GValue * value, GParamSpec * pspec)
396{
397 g_return_if_fail (GST_IS_SLVIDEO (object));
398
399 if (prop_id) {
400 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
401 }
402}
403
404static void
405gst_slvideo_get_property (GObject * object, guint prop_id,
406 GValue * value, GParamSpec * pspec)
407{
408 g_return_if_fail (GST_IS_SLVIDEO (object));
409
410 if (prop_id) {
411 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
412 }
413}
414
415
416/* entry point to initialize the plug-in
417 * initialize the plug-in itself
418 * register the element factories and pad templates
419 * register the features
420 */
421static gboolean
422plugin_init (GstPlugin * plugin)
423{
424 //fprintf(stderr, "\n\n\nPLUGIN INIT\n\n\n");
425
426 GST_DEBUG_CATEGORY_INIT (gst_slvideo_debug, (gchar*)"private-slvideo-plugin",
427 0, (gchar*)"Second Life Video Sink");
428
429 return gst_element_register (plugin, "private-slvideo",
430 GST_RANK_NONE, GST_TYPE_SLVIDEO);
431}
432
433
434void gst_slvideo_init_class (void)
435{
436 gst_plugin_register_static( GST_VERSION_MAJOR,
437 GST_VERSION_MINOR,
438 (const gchar *)"private-slvideoplugin",
439 (gchar *)"SL Video sink plugin",
440 plugin_init,
441 (const gchar *)"0.1",
442 GST_LICENSE_UNKNOWN,
443 (const gchar *)"Second Life",
444 (const gchar *)"Second Life",
445 (const gchar *)"http://www.secondlife.com/" );
446}
447
448///#endif // LL_GSTREAMER_ENABLED
diff --git a/linden/indra/llmedia/llmediaimplgstreamervidplug.h b/linden/indra/llmedia/llmediaimplgstreamervidplug.h
deleted file mode 100644
index 3a984a9..0000000
--- a/linden/indra/llmedia/llmediaimplgstreamervidplug.h
+++ /dev/null
@@ -1,106 +0,0 @@
1/**
2 * @file llmediaimplgstreamervidplug.h
3 * @brief Video-consuming static GStreamer plugin for gst-to-LLMediaImpl
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#ifndef __GST_SLVIDEO_H__
34#define __GST_SLVIDEO_H__
35
36///#if LL_GSTREAMER_ENABLED
37
38extern "C" {
39#include <gst/gst.h>
40#include <gst/video/video.h>
41#include <gst/video/gstvideosink.h>
42#include <glib/gthread.h>
43}
44
45G_BEGIN_DECLS
46
47/* #defines don't like whitespacey bits */
48#define GST_TYPE_SLVIDEO \
49 (gst_slvideo_get_type())
50#define GST_SLVIDEO(obj) \
51 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_SLVIDEO,GstSLVideo))
52#define GST_SLVIDEO_CLASS(klass) \
53 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_SLVIDEO,GstSLVideoClass))
54#define GST_IS_SLVIDEO(obj) \
55 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_SLVIDEO))
56#define GST_IS_SLVIDEO_CLASS(klass) \
57 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_SLVIDEO))
58
59typedef struct _GstSLVideo GstSLVideo;
60typedef struct _GstSLVideoClass GstSLVideoClass;
61
62typedef enum {
63 SLV_PF_UNKNOWN = 0,
64 SLV_PF_RGBX = 1,
65 SLV_PF_BGRX = 2,
66 SLV__END = 3
67} SLVPixelFormat;
68const int SLVPixelFormatBytes[SLV__END] = {1, 4, 4};
69
70struct _GstSLVideo
71{
72 GstVideoSink video_sink;
73
74 GstCaps *caps;
75
76 int fps_n, fps_d;
77 int par_n, par_d;
78 int height, width;
79 SLVPixelFormat format;
80
81 // SHARED WITH APPLICATION:
82 // Access to the following should be protected by GST_OBJECT_LOCK() on
83 // the GstSLVideo object, and should be totally consistent upon UNLOCK
84 // (i.e. all written at once to reflect the current retained frame info
85 // when the retained frame is updated.)
86 bool retained_frame_ready; // new frame ready since flag last reset. (*TODO: could get the writer to wait on a semaphore instead of having the reader poll, potentially making dropped frames somewhat cheaper.)
87 unsigned char* retained_frame_data;
88 int retained_frame_allocbytes;
89 int retained_frame_width, retained_frame_height;
90 SLVPixelFormat retained_frame_format;
91};
92
93struct _GstSLVideoClass
94{
95 GstVideoSinkClass parent_class;
96};
97
98GType gst_slvideo_get_type (void);
99
100void gst_slvideo_init_class (void);
101
102G_END_DECLS
103
104///#endif // LL_GSTREAMER_ENABLED
105
106#endif /* __GST_SLVIDEO_H__ */
diff --git a/linden/indra/llmedia/llmediaimplllmozlib.cpp b/linden/indra/llmedia/llmediaimplllmozlib.cpp
deleted file mode 100644
index 5b4b02e..0000000
--- a/linden/indra/llmedia/llmediaimplllmozlib.cpp
+++ /dev/null
@@ -1,624 +0,0 @@
1/**
2 * @file llmediaimplllmozlib.cpp
3 * @brief Example 2 of a media impl concrete class
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 "llmediaimplllmozlib.h"
34
35#if LL_LLMOZLIB_ENABLED
36
37#include "llmediaimplregister.h"
38#include "llmediamanager.h"
39
40#ifdef WIN32
41 // platform specific includes needed before OpenGL header
42 #include <windows.h>
43 #include <GL/gl.h>
44#elif defined(__APPLE__)
45 // framework-style include path when building on the Mac.
46 #include <OpenGL/gl.h>
47#else // Assume this is linux
48 // Linux, MESA headers, but not necessarily assuming MESA runtime.
49 // quotes so we get libraries/.../GL/ version
50 #include "GL/gl.h"
51#endif
52
53
54#include <locale.h>
55
56
57#include <iostream>
58
59// register this impl with media manager factory
60static LLMediaImplRegister sLLMediaImplLLMozLibReg( "LLMediaImplLLMozLib", new LLMediaImplLLMozLibMaker() );
61
62///////////////////////////////////////////////////////////////////////////////
63//
64LLMediaImplLLMozLibMaker::LLMediaImplLLMozLibMaker()
65{
66 // Register to handle the mime category
67 mMimeTypes.push_back( "image/svg+xml" );
68 mMimeTypeCategories.push_back( "text" );
69#if !LL_QUICKTIME_ENABLED
70 mMimeTypeCategories.push_back( "image" );
71#endif
72}
73
74///////////////////////////////////////////////////////////////////////////////
75//
76LLMediaImplLLMozLib::LLMediaImplLLMozLib() :
77 mBrowserWindowWidth( 800 ),
78 mBrowserWindowHeight( 600 ),
79 mMediaDataWidth( 0 ),
80 mMediaDataHeight( 0 ),
81 mWindowId( 0 ),
82 mNeedsUpdate( false )
83{
84 setRequestedMediaSize( mBrowserWindowWidth, mBrowserWindowHeight );
85
86 setMediaDepth( 4 );
87}
88
89////////////////////////////////////////////////////////////////////////////////
90// (static) super-initialization - called once at application startup
91bool LLMediaImplLLMozLib::startup( LLMediaManagerData* init_data )
92{
93
94 // Yuck, Mozilla's GTK callbacks play with the locale - push/pop
95 // the locale to protect it, as exotic/non-C locales
96 // causes our code lots of general critical weirdness
97 // and crashness. (SL-35450)
98 static std::string saved_locale;
99 saved_locale = setlocale(LC_ALL, NULL);
100
101
102 bool result = LLMozLib::getInstance()->init( init_data->getBrowserApplicationDir(),
103 init_data->getBrowserComponentDir(),
104 init_data->getBrowserProfileDir(),
105 init_data->getBrowserParentWindow() );
106
107
108 setlocale(LC_ALL, saved_locale.c_str() );
109
110
111 return result;
112}
113
114////////////////////////////////////////////////////////////////////////////////
115// (static) super-uninitialization - called once at application closedown
116bool LLMediaImplLLMozLib::closedown()
117{
118 // name discrepancy - this reset actually shuts down LLMozLib
119 LLMozLib::getInstance()->reset();
120
121 return true;
122}
123
124////////////////////////////////////////////////////////////////////////////////
125// (static)
126bool LLMediaImplLLMozLib::setBrowserUserAgent(std::string user_agent)
127{
128 // append special string to the embedded browser user agent string
129 LLMozLib::getInstance()->setBrowserAgentId(user_agent);
130 return true;
131}
132
133////////////////////////////////////////////////////////////////////////////////
134// virtual
135bool LLMediaImplLLMozLib::init()
136{
137 // if mWindowId is non-0, it's we already called init() and shouldn't call it again
138 // (::reset() will zero this value)
139 if ( mWindowId )
140 return false;
141
142#if defined(LL_LINUX) || defined(WIN32)
143 static std::string saved_locale;
144 saved_locale = setlocale(LC_ALL, NULL);
145#endif // defined(LL_LINUX) || defined(WIN32)
146
147 mWindowId = LLMozLib::getInstance()->createBrowserWindow( mBrowserWindowWidth, mBrowserWindowHeight );
148
149 LLMozLib::getInstance()->setSize( mWindowId, mBrowserWindowWidth, mBrowserWindowHeight );
150
151 LLMozLib::getInstance()->setBackgroundColor( mWindowId, 0x00, 0x00, 0x00 );
152
153 LLMozLib::getInstance()->addObserver( mWindowId, this );
154
155 // plugins only work with some client-side hackery and they cause
156 // exception handling issues (DEV-10020) so we turn them off
157 LLMozLib::getInstance()->enablePlugins( false );
158
159 // second life client needs the bitmap flipped
160 LLMozLib::getInstance()->flipWindow( mWindowId, true );
161
162 // set media depth now we have created a browser window and know what it is
163 setMediaDepth( LLMozLib::getInstance()->getBrowserDepth( mWindowId ) );
164
165#if defined(LL_LINUX) || defined(WIN32)
166 setlocale(LC_ALL, saved_locale.c_str() );
167#endif // defined(LL_LINUX) || defined(WIN32)
168
169 return true;
170}
171
172////////////////////////////////////////////////////////////////////////////////
173// virtual
174std::string LLMediaImplLLMozLib::getVersion()
175{
176 std::string version_string = "[" + sLLMediaImplLLMozLibReg.getImplName() + "] - " + LLMozLib::getInstance()->getVersion();
177
178 return version_string;
179}
180
181////////////////////////////////////////////////////////////////////////////////
182// virtual
183bool LLMediaImplLLMozLib::set404RedirectUrl( std::string redirect_url )
184{
185 return LLMozLib::getInstance()->set404RedirectUrl( mWindowId, redirect_url );
186}
187
188////////////////////////////////////////////////////////////////////////////////
189// virtual
190
191bool LLMediaImplLLMozLib::clr404RedirectUrl()
192{
193 return LLMozLib::getInstance()->clr404RedirectUrl( mWindowId );
194}
195
196////////////////////////////////////////////////////////////////////////////////
197// virtual
198bool LLMediaImplLLMozLib::setBackgroundColor( unsigned int red, unsigned int green, unsigned int blue ) const
199{
200 return LLMozLib::getInstance()->setBackgroundColor( mWindowId, red, green, blue );
201}
202
203////////////////////////////////////////////////////////////////////////////////
204// virtual
205bool LLMediaImplLLMozLib::setCaretColor( unsigned int red, unsigned int green, unsigned int blue ) const
206{
207 return LLMozLib::getInstance()->setCaretColor( mWindowId, red, green, blue );
208}
209
210////////////////////////////////////////////////////////////////////////////////
211// virtual
212bool LLMediaImplLLMozLib::navigateTo( const std::string url )
213{
214 // pass url to llmozlib
215 LLMozLib::getInstance()->navigateTo( mWindowId, url );
216
217 // emit event with size change to kick things off
218 LLMediaEvent event( this );
219 mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event );
220
221 // not that useful right now but maybe later
222 return true;
223}
224
225////////////////////////////////////////////////////////////////////////////////
226// virtual
227bool LLMediaImplLLMozLib::updateMedia()
228{
229 if ( getStatus() == LLMediaBase::STATUS_STARTED )
230 {
231 // if flag set, the page changed and we need to update
232 if ( mNeedsUpdate )
233 {
234 // snap browser pixels
235 LLMozLib::getInstance()->grabBrowserWindow( mWindowId );
236
237 // update media width - rendering the page can change it
238 mMediaDataWidth = LLMozLib::getInstance()->getBrowserRowSpan( mWindowId ) / getMediaDepth();
239 mMediaDataHeight = LLMozLib::getInstance()->getBrowserHeight( mWindowId );
240
241 // emit an event to say that something in the media stream changed
242 LLMediaEvent event( this );
243 mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event );
244
245 // flag that we've done the update and one isn't needed next frame
246 mNeedsUpdate = false;
247 };
248 };
249
250 // update the state (e.g. transport controls) state
251 updateState();
252
253 return false;
254}
255
256////////////////////////////////////////////////////////////////////////////////
257//
258bool LLMediaImplLLMozLib::updateState()
259{
260 if ( nextCommand() == LLMediaBase::COMMAND_START )
261 {
262 setStatus( LLMediaBase::STATUS_STARTED );
263 clearCommand();
264 };
265
266 if ( nextCommand() == LLMediaBase::COMMAND_STOP )
267 {
268 setStatus( LLMediaBase::STATUS_STOPPED );
269 clearCommand();
270 };
271
272 if ( nextCommand() == LLMediaBase::COMMAND_BACK )
273 {
274 setStatus( LLMediaBase::STATUS_STARTED );
275 LLMozLib::getInstance()->navigateBack( mWindowId );
276 clearCommand();
277 };
278
279 if ( nextCommand() == LLMediaBase::COMMAND_FORWARD )
280 {
281 setStatus( LLMediaBase::STATUS_STARTED );
282 LLMozLib::getInstance()->navigateForward( mWindowId );
283 clearCommand();
284 };
285
286 return true;
287}
288
289////////////////////////////////////////////////////////////////////////////////
290// virtual
291void LLMediaImplLLMozLib::onPageChanged( const EventType& eventIn )
292{
293 // force an update when the contents of the page changes
294 mNeedsUpdate = true;
295}
296
297////////////////////////////////////////////////////////////////////////////////
298// virtual
299void LLMediaImplLLMozLib::onClickLinkHref( const EventType& eventIn )
300{
301 LLMediaEvent event( this, eventIn.getStringValue(), eventIn.getStringValue2() );
302 mEventEmitter.update( &LLMediaObserver::onClickLinkHref, event );
303}
304
305////////////////////////////////////////////////////////////////////////////////
306// virtual
307void LLMediaImplLLMozLib::onClickLinkNoFollow( const EventType& eventIn )
308{
309 LLMediaEvent event( this, eventIn.getStringValue() );
310 mEventEmitter.update( &LLMediaObserver::onClickLinkNoFollow, event );
311}
312
313////////////////////////////////////////////////////////////////////////////////
314// virtual
315void LLMediaImplLLMozLib::onUpdateProgress( const EventType& eventIn )
316{
317 LLMediaEvent event( this, eventIn.getIntValue() );
318 mEventEmitter.update( &LLMediaObserver::onUpdateProgress, event );
319}
320
321////////////////////////////////////////////////////////////////////////////////
322// virtual
323void LLMediaImplLLMozLib::onStatusTextChange( const EventType& eventIn )
324{
325 LLMediaEvent event( this, eventIn.getStringValue() );
326 mEventEmitter.update( &LLMediaObserver::onStatusTextChange, event );
327}
328
329////////////////////////////////////////////////////////////////////////////////
330// virtual
331void LLMediaImplLLMozLib::onLocationChange( const EventType& eventIn )
332{
333 LLMediaEvent event( this, eventIn.getEventUri() );
334 mEventEmitter.update( &LLMediaObserver::onLocationChange, event );
335}
336
337////////////////////////////////////////////////////////////////////////////////
338// virtual
339void LLMediaImplLLMozLib::onNavigateBegin( const EventType& eventIn )
340{
341 LLMediaEvent event( this, eventIn.getEventUri() );
342 mEventEmitter.update( &LLMediaObserver::onNavigateBegin, event );
343}
344
345////////////////////////////////////////////////////////////////////////////////
346// virtual
347void LLMediaImplLLMozLib::onNavigateComplete( const EventType& eventIn )
348{
349 // force an update when the page is finished
350 mNeedsUpdate = true;
351
352 // pass in url and HTML response code (200/404 etc.)
353 LLMediaEvent event( this, eventIn.getEventUri(), eventIn.getIntValue() );
354 mEventEmitter.update( &LLMediaObserver::onNavigateComplete, event );
355}
356
357////////////////////////////////////////////////////////////////////////////////
358// virtual
359unsigned char* LLMediaImplLLMozLib::getMediaData()
360{
361 return (unsigned char*)LLMozLib::getInstance()->getBrowserWindowPixels( mWindowId );
362}
363
364// helper func to compute size of media data
365bool LLMediaImplLLMozLib::recomputeSizes()
366{
367 int new_width = mMediaRequestedWidth;
368 int new_height = mMediaRequestedHeight;
369
370 if (new_width < 0)
371 new_width = 512;
372
373 if (new_height < 0)
374 new_height = 512;
375
376 if (mAutoScaled)
377 {
378 new_width = LLMediaManager::textureWidthFromMediaWidth( new_width );
379 new_height = LLMediaManager::textureHeightFromMediaHeight( new_height );
380 }
381
382 bool status = LLMozLib::getInstance()->setSize( mWindowId, new_width, new_height );
383
384 if (status)
385 setMediaSize(new_width, new_height);
386
387 return status;
388}
389
390
391////////////////////////////////////////////////////////////////////////////////
392// virtual
393int LLMediaImplLLMozLib::getMediaDataWidth() const
394{
395 return mMediaDataWidth;
396}
397
398////////////////////////////////////////////////////////////////////////////////
399// virtual
400int LLMediaImplLLMozLib::getMediaDataHeight() const
401{
402 return mMediaDataHeight;
403}
404
405////////////////////////////////////////////////////////////////////////////////
406// virtual
407bool LLMediaImplLLMozLib::setRequestedMediaSize(int width, int height)
408{
409 LLMediaImplCommon::setRequestedMediaSize(width, height);
410
411 return recomputeSizes();
412}
413
414////////////////////////////////////////////////////////////////////////////////
415// virtual
416bool LLMediaImplLLMozLib::setAutoScaled( bool auto_scaled )
417{
418 LLMediaImplCommon::setAutoScaled(auto_scaled);
419
420 return recomputeSizes();
421}
422
423
424////////////////////////////////////////////////////////////////////////////////
425// virtual
426int LLMediaImplLLMozLib::getTextureFormatPrimary() const
427{
428#if defined(__APPLE__) || defined(MACOSX)
429 return GL_BGRA_EXT;
430#else
431 return LLMozLib::getInstance()->getBrowserDepth( mWindowId ) == 3 ? GL_BGR_EXT : GL_BGRA_EXT;
432#endif
433}
434
435////////////////////////////////////////////////////////////////////////////////
436// virtual
437int LLMediaImplLLMozLib::getTextureFormatType() const
438{
439#if defined(__APPLE__) || defined(MACOSX)
440 #ifdef __BIG_ENDIAN__
441 return GL_UNSIGNED_INT_8_8_8_8_REV;
442 #else
443 return GL_UNSIGNED_INT_8_8_8_8;
444 #endif
445#else
446 return GL_UNSIGNED_BYTE;
447#endif
448}
449
450////////////////////////////////////////////////////////////////////////////////
451// virtual
452bool LLMediaImplLLMozLib::mouseDown( int x_pos, int y_pos )
453{
454 return LLMozLib::getInstance()->mouseDown( mWindowId, x_pos, y_pos );
455}
456
457////////////////////////////////////////////////////////////////////////////////
458// virtual
459bool LLMediaImplLLMozLib::mouseUp( int x_pos, int y_pos )
460{
461 LLMozLib::getInstance()->mouseUp( mWindowId, x_pos, y_pos );
462
463 // this seems better than sending focus on mouse down (still need to improve this)
464 LLMozLib::getInstance()->focusBrowser( mWindowId, true );
465
466 return true;
467}
468
469////////////////////////////////////////////////////////////////////////////////
470// virtual
471bool LLMediaImplLLMozLib::mouseMove( int x_pos, int y_pos )
472{
473 return LLMozLib::getInstance()->mouseMove( mWindowId, x_pos, y_pos );
474}
475
476////////////////////////////////////////////////////////////////////////////////
477// virtual
478bool LLMediaImplLLMozLib::keyPress( int key_code )
479{
480 // We don't have to deal with printable characters here - they should
481 // go through handleUnicodeChar(). This table could be more complete
482 // than it is, but I think this covers all of the important
483 // non-printables.
484
485 unsigned long moz_key;
486
487 switch(key_code)
488 {
489 case LL_MEDIA_KEY_BACKSPACE:
490 moz_key = LL_DOM_VK_BACK_SPACE; break;
491 case LL_MEDIA_KEY_TAB:
492 moz_key = LL_DOM_VK_TAB; break;
493 case LL_MEDIA_KEY_RETURN:
494 moz_key = LL_DOM_VK_RETURN; break;
495 case LL_MEDIA_KEY_PAD_RETURN:
496 moz_key = LL_DOM_VK_ENTER; break;
497 case LL_MEDIA_KEY_ESCAPE:
498 moz_key = LL_DOM_VK_ESCAPE; break;
499 case LL_MEDIA_KEY_PAGE_UP:
500 moz_key = LL_DOM_VK_PAGE_UP; break;
501 case LL_MEDIA_KEY_PAGE_DOWN:
502 moz_key = LL_DOM_VK_PAGE_DOWN; break;
503 case LL_MEDIA_KEY_END:
504 moz_key = LL_DOM_VK_END; break;
505 case LL_MEDIA_KEY_HOME:
506 moz_key = LL_DOM_VK_HOME; break;
507 case LL_MEDIA_KEY_LEFT:
508 moz_key = LL_DOM_VK_LEFT; break;
509 case LL_MEDIA_KEY_UP:
510 moz_key = LL_DOM_VK_UP; break;
511 case LL_MEDIA_KEY_RIGHT:
512 moz_key = LL_DOM_VK_RIGHT; break;
513 case LL_MEDIA_KEY_DOWN:
514 moz_key = LL_DOM_VK_DOWN; break;
515 case LL_MEDIA_KEY_INSERT:
516 moz_key = LL_DOM_VK_INSERT; break;
517 case LL_MEDIA_KEY_DELETE:
518 moz_key = LL_DOM_VK_DELETE; break;
519
520 default:
521 return false; // don't know how to map this key.
522 }
523
524 return LLMozLib::getInstance()->keyPress( mWindowId, moz_key );
525}
526
527////////////////////////////////////////////////////////////////////////////////
528// virtual
529bool LLMediaImplLLMozLib::scrollByLines( int lines )
530{
531 return LLMozLib::getInstance()->scrollByLines(mWindowId, lines);
532}
533
534////////////////////////////////////////////////////////////////////////////////
535// virtual
536bool LLMediaImplLLMozLib::focus( bool focus )
537{
538 return LLMozLib::getInstance()->focusBrowser(mWindowId, focus);
539}
540
541////////////////////////////////////////////////////////////////////////////////
542// virtual
543bool LLMediaImplLLMozLib::unicodeInput( unsigned long uni_char )
544{
545 return LLMozLib::getInstance()->unicodeInput(mWindowId, uni_char);
546}
547
548////////////////////////////////////////////////////////////////////////////////
549// virtual
550bool LLMediaImplLLMozLib::mouseLeftDoubleClick( int x_pos, int y_pos )
551{
552 return LLMozLib::getInstance()->mouseLeftDoubleClick( mWindowId, x_pos, y_pos );
553}
554
555////////////////////////////////////////////////////////////////////////////////
556// virtual
557bool LLMediaImplLLMozLib::navigateForward()
558{
559 return LLMozLib::getInstance()->navigateForward(mWindowId);
560}
561
562////////////////////////////////////////////////////////////////////////////////
563// virtual
564bool LLMediaImplLLMozLib::navigateBack()
565{
566 return LLMozLib::getInstance()->navigateBack(mWindowId);
567}
568
569////////////////////////////////////////////////////////////////////////////////
570// virtual
571bool LLMediaImplLLMozLib::canNavigateForward()
572{
573 return LLMozLib::getInstance()->canNavigateForward(mWindowId);
574}
575
576////////////////////////////////////////////////////////////////////////////////
577// virtual
578bool LLMediaImplLLMozLib::canNavigateBack()
579{
580 return LLMozLib::getInstance()->canNavigateBack(mWindowId);
581}
582
583////////////////////////////////////////////////////////////////////////////////
584// virtual
585bool LLMediaImplLLMozLib::enableCookies(bool enable)
586{
587 return LLMozLib::getInstance()->enableCookies(enable);
588}
589
590////////////////////////////////////////////////////////////////////////////////
591// virtual
592bool LLMediaImplLLMozLib::enableProxy(bool enable, std::string proxy_host_name, int proxy_port)
593{
594 return LLMozLib::getInstance()->enableProxy(enable, proxy_host_name, proxy_port);
595}
596
597////////////////////////////////////////////////////////////////////////////////
598// virtual
599bool LLMediaImplLLMozLib::clearCache()
600{
601 return LLMozLib::getInstance()->clearCache();
602}
603
604////////////////////////////////////////////////////////////////////////////////
605// virtual
606bool LLMediaImplLLMozLib::clearCookies()
607{
608 return LLMozLib::getInstance()->clearAllCookies();
609}
610
611////////////////////////////////////////////////////////////////////////////////
612// virtual
613bool LLMediaImplLLMozLib::reset()
614{
615 LLMozLib::getInstance()->remObserver( mWindowId, this );
616
617 LLMozLib::getInstance()->destroyBrowserWindow( mWindowId );
618
619 mWindowId = 0;
620
621 return true;
622}
623
624#endif // LL_LLMOZLIB_ENABLED
diff --git a/linden/indra/llmedia/llmediaimplllmozlib.h b/linden/indra/llmedia/llmediaimplllmozlib.h
deleted file mode 100644
index f71300e..0000000
--- a/linden/indra/llmedia/llmediaimplllmozlib.h
+++ /dev/null
@@ -1,127 +0,0 @@
1/**
2 * @file llmediaimplllmozlib.cpp
3 * @brief Example 2 of a media impl concrete class
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#ifndef LLMEDIAIMPLLLMOZLIB_H
34#define LLMEDIAIMPLLLMOZLIB_H
35
36#include "llmediaimplcommon.h"
37#include "llmediaimplfactory.h"
38
39#if LL_LLMOZLIB_ENABLED
40
41#include "llmozlib2.h"
42
43class LLMediaManagerData;
44
45class LLMediaImplLLMozLib :
46 public LLMediaImplCommon,
47 public LLEmbeddedBrowserWindowObserver
48{
49 public:
50 LLMediaImplLLMozLib();
51
52 static bool startup( LLMediaManagerData* init_data );
53 static bool closedown();
54
55 // Update the user-agent string reported when the browser requests
56 // web page, because we need to include the Second Life version
57 // and skin name (which can change without restarts).
58 // Must be called after startup().
59 static bool setBrowserUserAgent(std::string user_agent);
60
61 /* virtual */ bool init();
62 /* virtual */ std::string getVersion();
63 /* virtual */ bool set404RedirectUrl( std::string redirect_url );
64 /* virtual */ bool clr404RedirectUrl();
65 /* virtual */ bool setBackgroundColor( unsigned int red, unsigned int green, unsigned int blue ) const;
66 /* virtual */ bool setCaretColor( unsigned int red, unsigned int green, unsigned int blue ) const;
67 /* virtual */ bool navigateTo( const std::string url );
68 /* virtual */ bool updateMedia();
69 /* virtual */ unsigned char* getMediaData();
70 /* virtual */ int getMediaDataWidth() const;
71 /* virtual */ int getMediaDataHeight() const;
72 /* virtual */ bool setRequestedMediaSize(int width, int height);
73 /* virtual */ bool setAutoScaled( bool auto_scaled );
74 /* virtual */ int getTextureFormatPrimary() const;
75 /* virtual */ int getTextureFormatType() const;
76 /* virtual */ bool mouseDown( int x_pos, int y_pos );
77 /* virtual */ bool mouseUp( int x_pos, int y_pos );
78 /* virtual */ bool mouseMove( int x_pos, int y_pos );
79 /* virtual */ bool keyPress( int key_code );
80 /* virtual */ bool scrollByLines( int lines );
81 /* virtual */ bool focus( bool focus );
82 /* virtual */ bool unicodeInput( unsigned long uni_char );
83 /* virtual */ bool mouseLeftDoubleClick( int x_pos, int y_pos );
84 /* virtual */ bool navigateForward();
85 /* virtual */ bool navigateBack();
86 /* virtual */ bool canNavigateForward();
87 /* virtual */ bool canNavigateBack();
88 /* virtual */ bool enableCookies(bool enable);
89 /* virtual */ bool enableProxy(bool enable, std::string proxy_host_name, int proxy_port);
90 /* virtual */ bool clearCache();
91 /* virtual */ bool clearCookies();
92 /* virtual */ bool reset();
93
94 // LLMozLib observerables
95 virtual void onNavigateBegin( const EventType& eventIn );
96 virtual void onNavigateComplete( const EventType& eventIn );
97 virtual void onUpdateProgress( const EventType& eventIn );
98 virtual void onPageChanged( const EventType& eventIn );
99 virtual void onStatusTextChange( const EventType& eventIn );
100 virtual void onLocationChange( const EventType& eventIn );
101 virtual void onClickLinkHref( const EventType& eventIn );
102 virtual void onClickLinkNoFollow( const EventType& eventIn );
103
104 private:
105 bool recomputeSizes();
106 int mWindowId;
107 int mBrowserWindowWidth;
108 int mBrowserWindowHeight;
109 int mMediaDataWidth;
110 int mMediaDataHeight;
111 bool mNeedsUpdate;
112 bool updateState();
113};
114
115// The maker class
116class LLMediaImplLLMozLibMaker : public LLMediaImplMaker
117{
118 public:
119 LLMediaImplLLMozLibMaker();
120 LLMediaImplLLMozLib* create()
121 {
122 return new LLMediaImplLLMozLib();
123 }
124};
125#endif // LL_LLMOZLIB_ENABLED
126
127#endif // LLMEDIAIMPLLLMOZLIB_H
diff --git a/linden/indra/llmedia/llmediaimplquicktime.cpp b/linden/indra/llmedia/llmediaimplquicktime.cpp
deleted file mode 100644
index 76cacee..0000000
--- a/linden/indra/llmedia/llmediaimplquicktime.cpp
+++ /dev/null
@@ -1,657 +0,0 @@
1/**
2 * @file llmediaimplquicktime.cpp
3 * @brief QuickTime media impl concrete class
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 "llmediaimplquicktime.h"
34
35#if LL_QUICKTIME_ENABLED
36
37#include "llmediamanager.h"
38#include "llmediaimplregister.h"
39
40#if LL_WINDOWS
41#include <windows.h>
42#endif
43
44#include <iostream>
45#include <sstream>
46
47// register this impl with media manager factory
48static LLMediaImplRegister sLLMediaImplQuickTimeReg( "LLMediaImplQuickTime", new LLMediaImplQuickTimeMaker() );
49
50///////////////////////////////////////////////////////////////////////////////
51//
52LLMediaImplQuickTimeMaker::LLMediaImplQuickTimeMaker()
53{
54 // Register to handle the scheme
55 mSchema.push_back( "rtsp" );
56
57 // Register to handle the category
58 mMimeTypeCategories.push_back( "video" );
59 mMimeTypeCategories.push_back( "audio" );
60 mMimeTypeCategories.push_back( "image" );
61}
62
63///////////////////////////////////////////////////////////////////////////////
64//
65LLMediaImplQuickTime::LLMediaImplQuickTime() :
66 mMovieHandle( 0 ),
67 mGWorldHandle( 0 ),
68 mMovieController( 0 ),
69 mMinWidth( 32 ),
70 mMaxWidth( 2048 ),
71 mMinHeight( 32 ),
72 mMaxHeight( 2048 ),
73 mCurVolume( 0 )
74{
75}
76
77///////////////////////////////////////////////////////////////////////////////
78//
79LLMediaImplQuickTime::~LLMediaImplQuickTime()
80{
81 unload();
82}
83
84////////////////////////////////////////////////////////////////////////////////
85// (static) super-initialization - called once at application startup
86bool LLMediaImplQuickTime::startup( LLMediaManagerData* init_data )
87{
88#ifdef WIN32
89 if ( InitializeQTML( 0L ) != noErr )
90 {
91 return false;
92 };
93#endif
94
95 EnterMovies();
96
97 return true;
98}
99
100////////////////////////////////////////////////////////////////////////////////
101// (static) super-uninitialization - called once at application closedown
102bool LLMediaImplQuickTime::closedown()
103{
104 ExitMovies();
105
106#ifdef WIN32
107 TerminateQTML();
108#endif
109
110 return true;
111}
112
113////////////////////////////////////////////////////////////////////////////////
114// private
115bool LLMediaImplQuickTime::load( const std::string url )
116{
117 if ( url.empty() )
118 return false;
119
120 //In case std::string::c_str() makes a copy of the url data,
121 //make sure there is memory to hold it before allocating memory for handle.
122 //if fails, NewHandleClear(...) should return NULL.
123 const char* url_string = url.c_str() ;
124 Handle handle = NewHandleClear( ( Size )( url.length() + 1 ) );
125 if ( NULL == handle )
126 return false;
127 if(noErr != MemError() || NULL == *handle)
128 {
129 return false ;
130 }
131
132 BlockMove( url_string, *handle, ( Size )( url.length() + 1 ) );
133
134 //std::cout << "LLMediaImplQuickTime::load( " << url << " )" << std::endl;
135
136 // TODO: supposed to use NewMovieFromDataParams now
137 OSErr err = NewMovieFromDataRef( &mMovieHandle, newMovieActive | newMovieDontInteractWithUser | newMovieAsyncOK | newMovieIdleImportOK, nil, handle, URLDataHandlerSubType );
138 DisposeHandle( handle );
139 if ( noErr != err )
140 return false;
141
142 // do pre-roll actions (typically fired for streaming movies but not always)
143 PrePrerollMovie( mMovieHandle, 0, GetMoviePreferredRate( mMovieHandle ), moviePrePrerollCompleteCallback, ( void * )this );
144
145 // get movie rect (and check for min/max)
146 Rect movie_rect;
147 setMovieBoxEnhanced( &movie_rect );
148
149 // make a new movie controller
150 mMovieController = NewMovieController( mMovieHandle, &movie_rect, mcNotVisible | mcTopLeftMovie );
151
152#if defined(__APPLE__) || defined(MACOSX)
153 setMediaDepth( 4 );
154#else
155 setMediaDepth( 3 );
156#endif
157
158 // tell manager about the media size
159 setMediaSize( movie_rect.right - movie_rect.left, movie_rect.bottom - movie_rect.top);
160
161 // movie controller
162 MCSetActionFilterWithRefCon( mMovieController, mcActionFilterCallBack, ( long )this );
163
164 SetMoviePlayHints( mMovieHandle, hintsAllowDynamicResize, hintsAllowDynamicResize );
165
166 // function that gets called when a frame is drawn
167 SetMovieDrawingCompleteProc( mMovieHandle, movieDrawingCallWhenChanged, movieDrawingCompleteCallback, ( long )this );
168
169 // emit an event to say that a media source was loaded
170 LLMediaEvent event( this );
171 mEventEmitter.update( &LLMediaObserver::onMediaLoaded, event );
172
173 // set up inital state
174 sizeChanged();
175
176 return true;
177}
178
179////////////////////////////////////////////////////////////////////////////////
180// virtual
181std::string LLMediaImplQuickTime::getVersion()
182{
183 long version;
184 Gestalt( gestaltQuickTimeVersion, &version );
185
186 std::ostringstream codec( "" );
187 codec << "[";
188 codec << sLLMediaImplQuickTimeReg.getImplName();
189 codec << "] - ";
190 codec << "QuickTime: " << std::hex << version;
191
192 return codec.str();
193}
194
195////////////////////////////////////////////////////////////////////////////////
196// virtual
197bool LLMediaImplQuickTime::navigateTo( const std::string url )
198{
199 // tell engine what we're doing
200 setStatus( LLMediaBase::STATUS_NAVIGATING );
201
202 // remove the movie we were looking at
203 unload();
204
205 // load the new one (no real 'go to this url' function in QT)
206 load( url );
207
208 return true;
209}
210
211////////////////////////////////////////////////////////////////////////////////
212// virtual
213bool LLMediaImplQuickTime::sizeChanged()
214{
215 if ( ! mMovieHandle )
216 return false;
217
218 // sanitize size of movie
219 Rect movie_rect;
220 setMovieBoxEnhanced( &movie_rect );
221
222 // we need this later
223 int width = ( movie_rect.right - movie_rect.left );
224 int height = ( movie_rect.bottom - movie_rect.top );
225
226 std::cout << "LLMEDIA> size changed to " << width << " x " << height << std::endl;
227
228 setMediaSize( width, height );
229
230 // media depth won't change
231 int depth_bits = getMediaDepth() * 8;
232
233 GWorldPtr old_gworld_handle = mGWorldHandle;
234
235 if (old_gworld_handle)
236 {
237 GWorldFlags result = UpdateGWorld( &mGWorldHandle, depth_bits, &movie_rect, NULL, NULL, 0 );
238 if ( gwFlagErr == result )
239 {
240 // TODO: unrecoverable?? throw exception? return something?
241 return false;
242 }
243 }
244 else
245 {
246 OSErr result = NewGWorld( &mGWorldHandle, depth_bits, &movie_rect, NULL, NULL, keepLocal | pixelsLocked );
247 if ( noErr != result )
248 {
249 // ATODO: unrecoverable?? throw exception? return something?
250 return false;
251 }
252
253 // clear memory in GWorld to avoid random screen visual fuzz from uninitialized texture data
254 if ( mGWorldHandle )
255 {
256 PixMapHandle pix_map_handle = GetGWorldPixMap( mGWorldHandle );
257 unsigned char* ptr = ( unsigned char* )GetPixBaseAddr( pix_map_handle );
258 memset( ptr, 0x00, height * QTGetPixMapHandleRowBytes( pix_map_handle ) );
259 }
260 }
261
262 // point movie at GWorld if it's new
263 if ( mMovieHandle && ! old_gworld_handle )
264 {
265 SetMovieGWorld( mMovieHandle, mGWorldHandle, GetGWorldDevice ( mGWorldHandle ) );
266 }
267
268 // update movie controller
269 if ( mMovieController )
270 {
271 MCSetControllerPort( mMovieController, mGWorldHandle );
272 MCPositionController( mMovieController, &movie_rect, &movie_rect,
273 mcTopLeftMovie | mcPositionDontInvalidate );
274 MCMovieChanged( mMovieController, mMovieHandle );
275 }
276
277 // Emit event with size change so the calling app knows about it too
278 LLMediaEvent event( this );
279 mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event );
280
281 return true;
282}
283
284////////////////////////////////////////////////////////////////////////////////
285// static
286Boolean LLMediaImplQuickTime::mcActionFilterCallBack( MovieController mc, short action, void *params, long ref )
287{
288 Boolean result = false;
289
290 LLMediaImplQuickTime* self = ( LLMediaImplQuickTime* )ref;
291
292 switch( action )
293 {
294 // handle window resizing
295 case mcActionControllerSizeChanged:
296 self->sizeChanged();
297 break;
298
299 // Block any movie controller actions that open URLs.
300 case mcActionLinkToURL:
301 case mcActionGetNextURL:
302 case mcActionLinkToURLExtended:
303 // Prevent the movie controller from handling the message
304 result = true;
305 break;
306
307 default:
308 break;
309 };
310
311 return result;
312}
313
314////////////////////////////////////////////////////////////////////////////////
315// private
316bool LLMediaImplQuickTime::unload()
317{
318 if ( mMovieHandle )
319 {
320 StopMovie( mMovieHandle );
321 if ( mMovieController )
322 {
323 MCMovieChanged( mMovieController, mMovieHandle );
324 };
325 };
326
327 if ( mMovieController )
328 {
329 MCSetActionFilterWithRefCon( mMovieController, NULL, (long)this );
330 DisposeMovieController( mMovieController );
331 mMovieController = NULL;
332 };
333
334 if ( mMovieHandle )
335 {
336 SetMovieDrawingCompleteProc( mMovieHandle, movieDrawingCallWhenChanged, nil, ( long )this );
337 DisposeMovie ( mMovieHandle );
338 mMovieHandle = NULL;
339 };
340
341 if ( mGWorldHandle )
342 {
343 DisposeGWorld( mGWorldHandle );
344 mGWorldHandle = NULL;
345 };
346
347 return true;
348}
349
350////////////////////////////////////////////////////////////////////////////////
351// static
352OSErr LLMediaImplQuickTime::movieDrawingCompleteCallback( Movie call_back_movie, long ref )
353{
354 LLMediaImplQuickTime* self = ( LLMediaImplQuickTime* )ref;
355
356 // IMPORTANT: typically, a consumer who is observing this event will set a flag
357 // when this event is fired then render later. Be aware that the media stream
358 // can change during this period - dimensions, depth, format etc.
359 LLMediaEvent event( self );
360 self->mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event );
361
362 return noErr;
363}
364
365////////////////////////////////////////////////////////////////////////////////
366// static
367void LLMediaImplQuickTime::moviePrePrerollCompleteCallback( Movie movie, OSErr preroll_err, void *ref )
368{
369 LLMediaImplQuickTime* self = ( LLMediaImplQuickTime* )ref;
370
371 LLMediaEvent event( self );
372 self->mEventEmitter.update( &LLMediaObserver::onMediaPreroll, event );
373}
374
375///////////////////////////////////////////////////////////////////////////////
376// used for stop / loop
377void LLMediaImplQuickTime::rewind()
378{
379 GoToBeginningOfMovie ( mMovieHandle );
380
381 MCMovieChanged( mMovieController, mMovieHandle );
382}
383
384////////////////////////////////////////////////////////////////////////////////
385//
386bool LLMediaImplQuickTime::processState()
387{
388 // start stream
389 if ( nextCommand() == LLMediaBase::COMMAND_START )
390 {
391 // valid when we are in these states
392 if ( getStatus() == LLMediaBase::STATUS_NAVIGATING|| getStatus() == LLMediaBase::STATUS_STOPPED || getStatus() == LLMediaBase::STATUS_PAUSED )
393 {
394 // it appears that the movie must be in a loaded state before we do this command
395 if ( GetMovieLoadState( mMovieHandle ) >= kMovieLoadStatePlaythroughOK )
396 {
397 MCDoAction( mMovieController, mcActionPrerollAndPlay, (void*)GetMoviePreferredRate( mMovieHandle ) );
398
399 MCDoAction( mMovieController, mcActionSetVolume, (void*)mCurVolume );
400
401 setStatus( LLMediaBase::STATUS_STARTED );
402
403 clearCommand();
404 }
405 }
406 }
407 else
408 if ( nextCommand() == LLMediaBase::COMMAND_STOP )
409 {
410 // valid when we are in these states
411 if ( getStatus() == LLMediaBase::STATUS_NAVIGATING || getStatus() == LLMediaBase::STATUS_STARTED || getStatus() == LLMediaBase::STATUS_PAUSED )
412 {
413 // it appears that the movie must be in a loaded state before we do this command
414 if ( GetMovieLoadState( mMovieHandle ) >= kMovieLoadStatePlaythroughOK )
415 {
416 // stop playing
417 Fixed rate = X2Fix( 0.0 );
418 MCDoAction( mMovieController, mcActionPlay, (void*)rate );
419
420 // go back to start
421 rewind();
422
423 setStatus( LLMediaBase::STATUS_STOPPED );
424 clearCommand();
425 };
426 };
427 }
428 else
429 if ( nextCommand() == LLMediaBase::COMMAND_PAUSE )
430 {
431 // valid when we are in these states
432 if ( getStatus() == LLMediaBase::STATUS_NAVIGATING || getStatus() == LLMediaBase::STATUS_STARTED || getStatus() == LLMediaBase::STATUS_STOPPED )
433 {
434 // it appears that the movie must be in a loaded state before we do this command
435 if ( GetMovieLoadState( mMovieHandle ) >= kMovieLoadStatePlaythroughOK )
436 {
437 // stop playing
438 Fixed rate = X2Fix( 0.0 );
439 MCDoAction( mMovieController, mcActionPlay, (void*)rate );
440
441 setStatus( LLMediaBase::STATUS_PAUSED );
442 clearCommand();
443 };
444 };
445 };
446
447 return true;
448}
449
450////////////////////////////////////////////////////////////////////////////////
451// virtual
452bool LLMediaImplQuickTime::setMovieBoxEnhanced( Rect* rect )
453{
454 // get movie rect
455 GetMovieNaturalBoundsRect( mMovieHandle, rect );
456
457 int natural_width = ( rect->right - rect->left );
458 int natural_height = ( rect->bottom - rect->top );
459
460 int width = natural_width;
461 int height = natural_height;
462
463 // if the user has requested a specific size, use it:
464 if ((mMediaRequestedWidth != 0) && (mMediaRequestedHeight != 0))
465 {
466 width = mMediaRequestedWidth;
467 height = mMediaRequestedHeight;
468 }
469
470 // if the user has requested, resize media to exactly fit texture
471 if (mAutoScaled)
472 {
473 width = LLMediaManager::textureWidthFromMediaWidth( width );
474 height = LLMediaManager::textureHeightFromMediaHeight( height );
475 }
476
477 // make sure it falls in valid range
478 if ( width < mMinWidth )
479 width = mMinWidth;
480
481 if ( width > mMaxWidth )
482 width = mMaxWidth;
483
484 if ( height < mMinHeight )
485 height = mMinHeight;
486
487 if ( height > mMaxHeight )
488 height = mMaxHeight;
489
490
491 // scale movie to fit rect and invert vertically to match opengl image format
492 MatrixRecord transform;
493 SetIdentityMatrix( &transform ); // transforms are additive so start from identify matrix
494 double scaleX = (double) width / natural_width;
495 double scaleY = -1.0 * (double) height / natural_height;
496 double centerX = width / 2.0;
497 double centerY = height / 2.0;
498 ScaleMatrix( &transform, X2Fix ( scaleX ), X2Fix ( scaleY ), X2Fix ( centerX ), X2Fix ( centerY ) );
499 SetMovieMatrix( mMovieHandle, &transform );
500
501 // return the new rect
502 rect->right = width;
503 rect->bottom = height;
504 rect->left = 0;
505 rect->top = 0;
506
507 return true;
508}
509
510////////////////////////////////////////////////////////////////////////////////
511// virtual
512bool LLMediaImplQuickTime::updateMedia()
513{
514 if ( ! mMovieHandle )
515 return false;
516
517 if ( ! mMovieController )
518 return false;
519
520 if ( ! mGWorldHandle )
521 return false;
522
523 // service QuickTime
524 MoviesTask( mMovieHandle, 0 );
525 MCIdle( mMovieController );
526
527 // update state machine (deals with transport controls for example)
528 processState();
529
530 // special code for looping - need to rewind at the end of the movie
531
532 if ( isLooping() )
533 {
534 // QT call to see if we are at the end - can't do with controller
535 if ( IsMovieDone( mMovieHandle ) )
536 {
537 // go back to start
538 rewind();
539
540 // kick off new play
541 MCDoAction( mMovieController, mcActionPrerollAndPlay, (void*)GetMoviePreferredRate( mMovieHandle ) );
542
543 // set the volume
544 MCDoAction( mMovieController, mcActionSetVolume, (void*)mCurVolume );
545 }
546 }
547
548 return true;
549}
550
551////////////////////////////////////////////////////////////////////////////////
552// virtual
553unsigned char* LLMediaImplQuickTime::getMediaData()
554{
555 unsigned char* ptr = NULL;
556
557 if ( mGWorldHandle )
558 {
559 PixMapHandle pix_map_handle = GetGWorldPixMap( mGWorldHandle );
560
561 ptr = ( unsigned char* )GetPixBaseAddr( pix_map_handle );
562 };
563
564 return ptr;
565}
566
567////////////////////////////////////////////////////////////////////////////////
568// virtual
569int LLMediaImplQuickTime::getMediaDataWidth() const
570{
571 if ( mGWorldHandle )
572 {
573 int depth = getMediaDepth();
574
575 if (depth < 1)
576 depth = 1;
577
578 // ALWAYS use the row bytes from the PixMap if we have a GWorld because
579 // sometimes it's not the same as mMediaDepth * mMediaWidth !
580 PixMapHandle pix_map_handle = GetGWorldPixMap( mGWorldHandle );
581 return QTGetPixMapHandleRowBytes( pix_map_handle ) / depth;
582 }
583 else
584 {
585 return LLMediaImplCommon::getMediaDataWidth();
586 }
587}
588
589////////////////////////////////////////////////////////////////////////////////
590// virtual
591int LLMediaImplQuickTime::getTextureFormatPrimary() const
592{
593#if defined(__APPLE__) || defined(MACOSX)
594 return LL_MEDIA_BGRA;
595#else
596 return LL_MEDIA_RGB;
597#endif
598}
599
600////////////////////////////////////////////////////////////////////////////////
601// virtual
602int LLMediaImplQuickTime::getTextureFormatType() const
603{
604#if defined(__APPLE__) || defined(MACOSX)
605 #ifdef __BIG_ENDIAN__
606 return LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV;
607 #else
608 return LL_MEDIA_UNSIGNED_INT_8_8_8_8;
609 #endif
610#else
611 return LL_MEDIA_UNSIGNED_BYTE;
612#endif
613}
614
615////////////////////////////////////////////////////////////////////////////////
616// virtual
617bool LLMediaImplQuickTime::seek( double time )
618{
619 if ( mMovieController )
620 {
621 TimeRecord when;
622 when.scale = GetMovieTimeScale( mMovieHandle );
623 when.base = 0;
624
625 // 'time' is in (floating point) seconds. The timebase time will be in 'units', where
626 // there are 'scale' units per second.
627 SInt64 raw_time = ( SInt64 )( time * (double)( when.scale ) );
628
629 when.value.hi = ( SInt32 )( raw_time >> 32 );
630 when.value.lo = ( SInt32 )( ( raw_time & 0x00000000FFFFFFFF ) );
631
632 MCDoAction( mMovieController, mcActionGoToTime, &when );
633
634 return true;
635 }
636
637 return false;
638}
639
640////////////////////////////////////////////////////////////////////////////////
641// virtual
642bool LLMediaImplQuickTime::setVolume( float volume )
643{
644 mCurVolume = (short)(volume * ( double ) 0x100 );
645
646 if ( mMovieController )
647 {
648 MCDoAction( mMovieController, mcActionSetVolume, (void*)mCurVolume );
649
650 return true;
651 }
652
653 return false;
654}
655
656#endif // _3DNOW_InstructionExtensions/ LL_QUICKTIME_ENABLED
657
diff --git a/linden/indra/llmedia/llmediaimplquicktime.h b/linden/indra/llmedia/llmediaimplquicktime.h
deleted file mode 100644
index d4e1db8..0000000
--- a/linden/indra/llmedia/llmediaimplquicktime.h
+++ /dev/null
@@ -1,112 +0,0 @@
1/**
2 * @file llmediaimplquicktime.h
3 * @brief QuickTime media impl concrete class
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#ifndef LLMEDIAIMPLQUICKTIME_H
34#define LLMEDIAIMPLQUICKTIME_H
35
36#include "llmediaimplcommon.h"
37#include "llmediaimplfactory.h"
38
39#if LL_QUICKTIME_ENABLED
40
41#include <string>
42
43// QuickTime includes
44#if defined(__APPLE__)
45 #include <QuickTime/QuickTime.h>
46#elif defined(WIN32)
47 #include "MacTypes.h"
48 #include "QTML.h"
49 #include "Movies.h"
50 #include "QDoffscreen.h"
51 #include "FixMath.h"
52#endif
53
54class LLMediaManagerData;
55
56class LLMediaImplQuickTime :
57 public LLMediaImplCommon
58{
59 public:
60 LLMediaImplQuickTime();
61 virtual ~LLMediaImplQuickTime();
62
63 static bool startup( LLMediaManagerData* init_data );
64 static bool closedown();
65
66 /* virtual */ std::string getVersion();
67 /* virtual */ bool navigateTo( const std::string url );
68 /* virtual */ bool updateMedia();
69 /* virtual */ unsigned char* getMediaData();
70 /* virtual */ int getMediaDataWidth() const;
71 /* virtual */ int getTextureFormatPrimary() const;
72 /* virtual */ int getTextureFormatType() const;
73 /* virtual */ bool seek( double time );
74 /* virtual */ bool setVolume( float volume );
75
76 bool sizeChanged();
77
78 private:
79 static OSErr movieDrawingCompleteCallback( Movie call_back_movie, long ref );
80 static Boolean mcActionFilterCallBack( MovieController mc, short action, void *params, long ref );
81 static void moviePrePrerollCompleteCallback( Movie movie, OSErr preroll_err, void *refcon );
82
83 bool load( const std::string url );
84 bool unload();
85 void rewind();
86 bool processState();
87 bool setMovieBoxEnhanced( Rect* rect );
88
89 Movie mMovieHandle;
90 GWorldPtr mGWorldHandle;
91 ComponentInstance mMovieController;
92 const int mMinWidth;
93 const int mMaxWidth;
94 const int mMinHeight;
95 const int mMaxHeight;
96 int mCurVolume;
97};
98
99// The maker class
100class LLMediaImplQuickTimeMaker : public LLMediaImplMaker
101{
102 public:
103 LLMediaImplQuickTimeMaker();
104 LLMediaImplQuickTime* create()
105 {
106 return new LLMediaImplQuickTime();
107 }
108};
109
110#endif // LL_QUICKTIME_ENABLED
111
112#endif // LLMEDIAIMPLQUICKTIME_H
diff --git a/linden/indra/llmedia/llmediaimplregister.h b/linden/indra/llmedia/llmediaimplregister.h
deleted file mode 100644
index 5191274..0000000
--- a/linden/indra/llmedia/llmediaimplregister.h
+++ /dev/null
@@ -1,60 +0,0 @@
1/**
2 * @file llmediaimplregister.h
3 * @brief Allow impls to register themselves with the impl factory
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#ifndef LLIMEDIAIMPLREGISTER_H
34#define LLIMEDIAIMPLREGISTER_H
35
36#include <string>
37
38#include "llmediaimplfactory.h"
39
40///////////////////////////////////////////////////////////////////////////////
41//
42class LLMediaImplRegister
43{
44 public:
45 LLMediaImplRegister( std::string impl_name, LLMediaImplMaker* impl_maker ) :
46 mImplName( impl_name )
47 {
48 LLMediaImplFactory::getInstance()->registerImpl( impl_name, impl_maker );
49 };
50
51 std::string getImplName()
52 {
53 return mImplName;
54 };
55
56 private:
57 std::string mImplName;
58};
59
60#endif // LLIMEDIAIMPLREGISTER_H
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}
diff --git a/linden/indra/llmedia/llmediamanager.h b/linden/indra/llmedia/llmediamanager.h
deleted file mode 100644
index dc832d5..0000000
--- a/linden/indra/llmedia/llmediamanager.h
+++ /dev/null
@@ -1,127 +0,0 @@
1/**
2 * @file llmediamanager.h
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#ifndef LLMEDIAMANAGER_H
34#define LLMEDIAMANAGER_H
35
36#include <map>
37#include <set>
38
39#include "llmediaimplcommon.h"
40
41////////////////////////////////////////////////////////////////////////////////
42//
43class LLMediaManagerData
44{
45 public:
46 LLMediaManagerData() :
47 mBrowserParentWindow( 0 ),
48 mBrowserProfileDir( "" ),
49 mBrowserProfileName ( "" )
50 { };
51
52 void setBrowserApplicationDir( const std::string& browser_application_dir ) { mBrowserApplicationDir = browser_application_dir; };
53 std::string& getBrowserApplicationDir() { return mBrowserApplicationDir; };
54
55 void setBrowserComponentDir( const std::string& browser_component_dir ) { mBrowserComponentDir = browser_component_dir; };
56 std::string& getBrowserComponentDir() { return mBrowserComponentDir; };
57
58 void setBrowserParentWindow( void* browser_parent_window ) { mBrowserParentWindow = browser_parent_window; };
59 void* getBrowserParentWindow() { return mBrowserParentWindow; };
60
61 void setBrowserProfileDir( const std::string& browser_profile_dir ) { mBrowserProfileDir = browser_profile_dir; };
62 std::string& getBrowserProfileDir() { return mBrowserProfileDir; };
63
64 void setBrowserProfileName( const std::string& browser_profile_name ) { mBrowserProfileName = browser_profile_name; };
65 std::string& getBrowserProfileName() { return mBrowserProfileName; };
66
67 private:
68 void* mBrowserParentWindow;
69 std::string mBrowserProfileDir;
70 std::string mBrowserProfileName;
71 std::string mBrowserApplicationDir;
72 std::string mBrowserComponentDir;
73};
74
75////////////////////////////////////////////////////////////////////////////////
76//
77class LLMediaManager
78{
79 public:
80 virtual ~LLMediaManager();
81
82 // Special case early init for just web browser component
83 // so we can show login screen. See .cpp file for details. JC
84 static void initBrowser( LLMediaManagerData* init_data );
85
86 static void initClass( LLMediaManagerData* init_data );
87 static void cleanupClass();
88 static LLMediaManager* getInstance();
89
90 // We append the skin name to the browser user agent string, so
91 // we need to change it while the app is running, not just at
92 // init time.
93 // Must be called after initClass() above.
94 // *HACK: Breaks encapsulation model. JC
95 static void setBrowserUserAgent(std::string user_agent);
96
97 // Calls update on all media sources
98 static void updateClass();
99
100 // Given an URL and mime_type, construct/destroy a playback engine for
101 // it (a "media impl").
102 LLMediaBase* createSourceFromMimeType( std::string scheme, std::string mime_type );
103 bool destroySource( LLMediaBase* media_impl );
104
105 // mime type to impl mapping functions
106 bool addMimeTypeImplNameMap( std::string mime_type, std::string impl_name );
107 std::string getImplNameFromMimeType( std::string mime_type );
108
109 // Name accessor for querying type support
110 bool supportsMediaType( const std::string& impl_name, const std::string& scheme, const std::string& mime_type );
111
112 // convenience functions for getting suggested texture sizes to hold various size media
113 static int textureWidthFromMediaWidth( int media_width );
114 static int textureHeightFromMediaHeight( int media_height );
115
116 private:
117 LLMediaManager();
118 static LLMediaManager* sInstance;
119
120 typedef std::set< LLMediaBase* > media_impl_container_t;
121 media_impl_container_t mMediaImplContainer;
122
123 typedef std::map< std::string, std::string > mime_type_impl_name_container_t;
124 mime_type_impl_name_container_t mMimeTypeImplNameContainer;
125};
126
127#endif // LLMEDIAMANAGER_H
diff --git a/linden/indra/llmedia/llmediaobserver.h b/linden/indra/llmedia/llmediaobserver.h
deleted file mode 100644
index ab8d755..0000000
--- a/linden/indra/llmedia/llmediaobserver.h
+++ /dev/null
@@ -1,116 +0,0 @@
1/**
2 * @file llmediaobserver.h
3 * @brief Derrive from this class and override methods to observe events from emitter class
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#ifndef LLMEDIAEOBSERVER_H
34#define LLMEDIAEOBSERVER_H
35
36class LLMediaBase;
37
38class LLMediaEvent
39{
40 public:
41 LLMediaEvent( LLMediaBase* subject ) :
42 mSubject( subject ), mIntValue(-1)
43 {
44 };
45
46 LLMediaEvent( LLMediaBase* subject, std::string in ) :
47 mSubject( subject ), mIntValue(-1), mStringValue(in)
48 {
49 };
50
51 LLMediaEvent( LLMediaBase* subject, std::string string_in, std::string string_ex_in ) :
52 mSubject( subject ), mIntValue(-1), mStringValue(string_in), mStringValueEx(string_ex_in)
53 {
54 };
55
56 LLMediaEvent( LLMediaBase* subject, std::string string_in, int int_in ) :
57 mSubject( subject ), mIntValue(int_in), mStringValue(string_in)
58 {
59 };
60
61 LLMediaEvent( LLMediaBase* subject, int in ) :
62 mSubject( subject ), mIntValue(in)
63 {
64 };
65
66 virtual ~LLMediaEvent() { }
67
68 LLMediaBase* getSubject() const
69 {
70 return mSubject;
71 };
72
73 int getIntValue() const
74 {
75 return mIntValue;
76 }
77
78 std::string getStringValue() const
79 {
80 return mStringValue;
81 }
82
83 std::string getStringValueEx() const
84 {
85 return mStringValueEx;
86 }
87
88 private:
89 LLMediaBase* mSubject;
90 int mIntValue;
91 std::string mStringValue;
92 std::string mStringValueEx;
93};
94
95class LLMediaObserver
96{
97 public:
98 virtual ~LLMediaObserver() {}
99
100 typedef LLMediaEvent EventType;
101 virtual void onMediaPreroll( const EventType& event_in ) { }
102 virtual void onMediaLoaded( const EventType& event_in ) { }
103 virtual void onMediaSizeChange( const EventType& event_in ) { }
104 virtual void onMediaContentsChange( const EventType& event_in ) { }
105 virtual void onMediaStatusTextChange( const EventType& event_in ) { }
106 virtual void onMediaTitleChange( const EventType &event_in ) { }
107 virtual void onNavigateBegin( const EventType& event_in ) { }
108 virtual void onNavigateComplete( const EventType& event_in ) { }
109 virtual void onUpdateProgress( const EventType& event_in ) { }
110 virtual void onStatusTextChange( const EventType& event_in ) { }
111 virtual void onLocationChange( const EventType& event_in ) { }
112 virtual void onClickLinkHref( const EventType& event_in ) { }
113 virtual void onClickLinkNoFollow( const EventType& event_in ) { }
114};
115
116#endif // LLMEDIAEOBSERVER_H