aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmedia
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llmedia')
-rw-r--r--linden/indra/llmedia/files.lst10
-rw-r--r--linden/indra/llmedia/llmedia.vcproj73
-rw-r--r--linden/indra/llmedia/llmedia_vc8.vcproj60
-rw-r--r--linden/indra/llmedia/llmedia_vc9.vcproj626
-rw-r--r--linden/indra/llmedia/llmediabase.cpp210
-rw-r--r--linden/indra/llmedia/llmediabase.h313
-rw-r--r--linden/indra/llmedia/llmediaemitter.h80
-rw-r--r--linden/indra/llmedia/llmediaengine.cpp635
-rw-r--r--linden/indra/llmedia/llmediaengine.h150
-rw-r--r--linden/indra/llmedia/llmediaimplcommon.cpp540
-rw-r--r--linden/indra/llmedia/llmediaimplcommon.h161
-rw-r--r--linden/indra/llmedia/llmediaimplexample1.cpp228
-rw-r--r--linden/indra/llmedia/llmediaimplexample1.h (renamed from linden/indra/llmedia/llmediaobservers.h)60
-rw-r--r--linden/indra/llmedia/llmediaimplexample2.cpp195
-rw-r--r--linden/indra/llmedia/llmediaimplexample2.h75
-rw-r--r--linden/indra/llmedia/llmediaimplfactory.cpp104
-rw-r--r--linden/indra/llmedia/llmediaimplfactory.h99
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.cpp652
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer.h105
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamer_syms.cpp20
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamervidplug.cpp4
-rw-r--r--linden/indra/llmedia/llmediaimplgstreamervidplug.h4
-rw-r--r--linden/indra/llmedia/llmediaimplllmozlib.cpp590
-rw-r--r--linden/indra/llmedia/llmediaimplllmozlib.h120
-rw-r--r--linden/indra/llmedia/llmediaimplquicktime.cpp1191
-rw-r--r--linden/indra/llmedia/llmediaimplquicktime.h166
-rw-r--r--linden/indra/llmedia/llmediaimplregister.h (renamed from linden/indra/llmedia/llmediaemitterevents.h)48
-rw-r--r--linden/indra/llmedia/llmediamanager.cpp255
-rw-r--r--linden/indra/llmedia/llmediamanager.h120
-rw-r--r--linden/indra/llmedia/llmediamoviebase.cpp234
-rw-r--r--linden/indra/llmedia/llmediamoviebase.h84
-rw-r--r--linden/indra/llmedia/llmediaobserver.h103
32 files changed, 4201 insertions, 3114 deletions
diff --git a/linden/indra/llmedia/files.lst b/linden/indra/llmedia/files.lst
index bda6459..3ce18e5 100644
--- a/linden/indra/llmedia/files.lst
+++ b/linden/indra/llmedia/files.lst
@@ -1,7 +1,11 @@
1llmedia/llmediabase.cpp 1llmedia/llmediaimplcommon.cpp
2llmedia/llmediaengine.cpp 2llmedia/llmediaimplexample1.cpp
3llmedia/llmediaimplexample2.cpp
4llmedia/llmediaimplfactory.cpp
3llmedia/llmediaimplgstreamer.cpp 5llmedia/llmediaimplgstreamer.cpp
4llmedia/llmediaimplgstreamer_syms.cpp 6llmedia/llmediaimplgstreamer_syms.cpp
5llmedia/llmediaimplgstreamervidplug.cpp 7llmedia/llmediaimplgstreamervidplug.cpp
8llmedia/llmediaimplllmozlib.cpp
6llmedia/llmediaimplquicktime.cpp 9llmedia/llmediaimplquicktime.cpp
7llmedia/llmediamoviebase.cpp 10llmedia/llmediamanager.cpp
11
diff --git a/linden/indra/llmedia/llmedia.vcproj b/linden/indra/llmedia/llmedia.vcproj
index da87e26..38c53f0 100644
--- a/linden/indra/llmedia/llmedia.vcproj
+++ b/linden/indra/llmedia/llmedia.vcproj
@@ -20,7 +20,7 @@
20 <Tool 20 <Tool
21 Name="VCCLCompilerTool" 21 Name="VCCLCompilerTool"
22 Optimization="0" 22 Optimization="0"
23 AdditionalIncludeDirectories="..\llcommon;..\llrender;..\llwindow;..\llimage;..\llmath;..\llvfs;..\llmessage;..\llui;&quot;..\..\libraries\i686-win32\include&quot;;..\..\libraries\include\;&quot;..\..\libraries\i686-win32\include\quicktime&quot;" 23 AdditionalIncludeDirectories="&quot;..\..\libraries\i686-win32\include\quicktime&quot;;..\..\libraries\include"
24 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;LL_DEBUG;XP_WIN;XP_WIN32" 24 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;LL_DEBUG;XP_WIN;XP_WIN32"
25 MinimalRebuild="TRUE" 25 MinimalRebuild="TRUE"
26 BasicRuntimeChecks="3" 26 BasicRuntimeChecks="3"
@@ -37,8 +37,10 @@
37 Name="VCCustomBuildTool"/> 37 Name="VCCustomBuildTool"/>
38 <Tool 38 <Tool
39 Name="VCLibrarianTool" 39 Name="VCLibrarianTool"
40 AdditionalOptions="/IGNORE:4006"
41 AdditionalDependencies="qtmlclient.lib llmozlib2d.lib"
40 OutputFile="$(OutDir)/llmedia.lib" 42 OutputFile="$(OutDir)/llmedia.lib"
41 AdditionalLibraryDirectories=""/> 43 AdditionalLibraryDirectories="&quot;..\..\libraries\i686-win32\lib_debug&quot;"/>
42 <Tool 44 <Tool
43 Name="VCMIDLTool"/> 45 Name="VCMIDLTool"/>
44 <Tool 46 <Tool
@@ -66,13 +68,12 @@
66 CharacterSet="1"> 68 CharacterSet="1">
67 <Tool 69 <Tool
68 Name="VCCLCompilerTool" 70 Name="VCCLCompilerTool"
69 AdditionalOptions="/Oy-"
70 GlobalOptimizations="FALSE" 71 GlobalOptimizations="FALSE"
71 InlineFunctionExpansion="0" 72 InlineFunctionExpansion="0"
72 EnableIntrinsicFunctions="FALSE" 73 EnableIntrinsicFunctions="FALSE"
73 OptimizeForProcessor="0" 74 OptimizeForProcessor="0"
74 OptimizeForWindowsApplication="FALSE" 75 OptimizeForWindowsApplication="FALSE"
75 AdditionalIncludeDirectories="..\llcommon;..\llrender;..\llwindow;..\llimage;..\llmath;..\llvfs;..\llmessage;..\llui;&quot;..\..\libraries\i686-win32\include&quot;;..\..\libraries\include\;&quot;..\..\libraries\i686-win32\include\quicktime&quot;" 76 AdditionalIncludeDirectories="&quot;..\..\libraries\i686-win32\include\quicktime&quot;;..\..\libraries\include"
76 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE;XP_WIN;XP_WIN32" 77 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE;XP_WIN;XP_WIN32"
77 RuntimeLibrary="0" 78 RuntimeLibrary="0"
78 StructMemberAlignment="0" 79 StructMemberAlignment="0"
@@ -87,8 +88,10 @@
87 Name="VCCustomBuildTool"/> 88 Name="VCCustomBuildTool"/>
88 <Tool 89 <Tool
89 Name="VCLibrarianTool" 90 Name="VCLibrarianTool"
91 AdditionalOptions="/IGNORE:4006"
92 AdditionalDependencies="qtmlclient.lib llmozlib2.lib"
90 OutputFile="$(OutDir)/llmedia.lib" 93 OutputFile="$(OutDir)/llmedia.lib"
91 AdditionalLibraryDirectories="" 94 AdditionalLibraryDirectories="&quot;..\..\libraries\i686-win32\lib_release&quot;"
92 IgnoreAllDefaultLibraries="FALSE" 95 IgnoreAllDefaultLibraries="FALSE"
93 IgnoreDefaultLibraryNames=""/> 96 IgnoreDefaultLibraryNames=""/>
94 <Tool 97 <Tool
@@ -118,14 +121,13 @@
118 CharacterSet="1"> 121 CharacterSet="1">
119 <Tool 122 <Tool
120 Name="VCCLCompilerTool" 123 Name="VCCLCompilerTool"
121 AdditionalOptions="/Oy-"
122 Optimization="0" 124 Optimization="0"
123 GlobalOptimizations="FALSE" 125 GlobalOptimizations="FALSE"
124 InlineFunctionExpansion="0" 126 InlineFunctionExpansion="0"
125 EnableIntrinsicFunctions="FALSE" 127 EnableIntrinsicFunctions="FALSE"
126 OptimizeForProcessor="0" 128 OptimizeForProcessor="0"
127 OptimizeForWindowsApplication="FALSE" 129 OptimizeForWindowsApplication="FALSE"
128 AdditionalIncludeDirectories="..\llcommon;..\llrender;..\llwindow;..\llimage;..\llmath;..\llvfs;..\llmessage;..\llui;&quot;..\..\libraries\i686-win32\include&quot;;..\..\libraries\include\;&quot;..\..\libraries\i686-win32\include\quicktime&quot;" 130 AdditionalIncludeDirectories="&quot;..\..\libraries\i686-win32\include\quicktime&quot;;..\..\libraries\include"
129 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE;XP_WIN;XP_WIN32" 131 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE;XP_WIN;XP_WIN32"
130 RuntimeLibrary="0" 132 RuntimeLibrary="0"
131 StructMemberAlignment="0" 133 StructMemberAlignment="0"
@@ -140,8 +142,10 @@
140 Name="VCCustomBuildTool"/> 142 Name="VCCustomBuildTool"/>
141 <Tool 143 <Tool
142 Name="VCLibrarianTool" 144 Name="VCLibrarianTool"
145 AdditionalOptions="/IGNORE:4006"
146 AdditionalDependencies="qtmlclient.lib llmozlib2.lib"
143 OutputFile="$(OutDir)/llmedia.lib" 147 OutputFile="$(OutDir)/llmedia.lib"
144 AdditionalLibraryDirectories="" 148 AdditionalLibraryDirectories="&quot;..\..\libraries\i686-win32\lib_release&quot;"
145 IgnoreAllDefaultLibraries="FALSE" 149 IgnoreAllDefaultLibraries="FALSE"
146 IgnoreDefaultLibraryNames=""/> 150 IgnoreDefaultLibraryNames=""/>
147 <Tool 151 <Tool
@@ -172,42 +176,67 @@
172 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" 176 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
173 UniqueIdentifier="{44DBC47A-0AF0-4726-A094-2D6FBB65FFFA}"> 177 UniqueIdentifier="{44DBC47A-0AF0-4726-A094-2D6FBB65FFFA}">
174 <File 178 <File
175 RelativePath=".\llmediabase.cpp"> 179 RelativePath=".\llmediaimplfactory.cpp">
176 </File> 180 </File>
177 <File 181 <File
178 RelativePath=".\llmediaengine.cpp"> 182 RelativePath=".\llmediamanager.cpp">
179 </File> 183 </File>
184 </Filter>
185 <Filter
186 Name="Header Files"
187 Filter="h;hpp;hxx;hm;inl;inc;xsd"
188 UniqueIdentifier="{D188664C-B9B7-4982-8C4B-8D9A44B4D9EF}">
180 <File 189 <File
181 RelativePath=".\llmediaimplquicktime.cpp"> 190 RelativePath=".\llmediabase.h">
182 </File> 191 </File>
183 <File 192 <File
184 RelativePath=".\llmediamoviebase.cpp"> 193 RelativePath=".\llmediaemitter.h">
185 </File> 194 </File>
186 <File 195 <File
187 RelativePath=".\llmediamoviebase.h"> 196 RelativePath=".\llmediaimplfactory.h">
197 </File>
198 <File
199 RelativePath=".\llmediaimplregister.h">
200 </File>
201 <File
202 RelativePath=".\llmediamanager.h">
203 </File>
204 <File
205 RelativePath=".\llmediaobserver.h">
188 </File> 206 </File>
189 </Filter> 207 </Filter>
190 <Filter 208 <Filter
191 Name="Header Files" 209 Name="impls"
192 Filter="h;hpp;hxx;hm;inl;inc;xsd" 210 Filter="">
193 UniqueIdentifier="{D188664C-B9B7-4982-8C4B-8D9A44B4D9EF}">
194 <File 211 <File
195 RelativePath=".\llmediabase.h"> 212 RelativePath=".\llmediaimplcommon.cpp">
196 </File> 213 </File>
197 <File 214 <File
198 RelativePath=".\llmediaemitter.h"> 215 RelativePath=".\llmediaimplcommon.h">
199 </File> 216 </File>
200 <File 217 <File
201 RelativePath=".\llmediaemitterevents.h"> 218 RelativePath=".\llmediaimplexample1.cpp">
202 </File> 219 </File>
203 <File 220 <File
204 RelativePath=".\llmediaengine.h"> 221 RelativePath=".\llmediaimplexample1.h">
205 </File> 222 </File>
206 <File 223 <File
207 RelativePath=".\llmediaimplquicktime.h"> 224 RelativePath=".\llmediaimplexample2.cpp">
225 </File>
226 <File
227 RelativePath=".\llmediaimplexample2.h">
208 </File> 228 </File>
209 <File 229 <File
210 RelativePath=".\llmediaobservers.h"> 230 RelativePath=".\llmediaimplllmozlib.cpp">
231 </File>
232 <File
233 RelativePath=".\llmediaimplllmozlib.h">
234 </File>
235 <File
236 RelativePath=".\llmediaimplquicktime.cpp">
237 </File>
238 <File
239 RelativePath=".\llmediaimplquicktime.h">
211 </File> 240 </File>
212 </Filter> 241 </Filter>
213 </Files> 242 </Files>
diff --git a/linden/indra/llmedia/llmedia_vc8.vcproj b/linden/indra/llmedia/llmedia_vc8.vcproj
index e343f1e..4681a6c 100644
--- a/linden/indra/llmedia/llmedia_vc8.vcproj
+++ b/linden/indra/llmedia/llmedia_vc8.vcproj
@@ -41,8 +41,8 @@
41 <Tool 41 <Tool
42 Name="VCCLCompilerTool" 42 Name="VCCLCompilerTool"
43 Optimization="0" 43 Optimization="0"
44 AdditionalIncludeDirectories="..\llcommon;..\llrender;..\llwindow;..\llimage;..\llmath;..\llvfs;..\llmessage;..\llui;&quot;..\..\libraries\i686-win32\include&quot;;..\..\libraries\include\;&quot;..\..\libraries\i686-win32\include\quicktime&quot;" 44 AdditionalIncludeDirectories="&quot;..\..\libraries\i686-win32\include\quicktime&quot;;..\..\libraries\include"
45 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG;XP_WIN;XP_WIN32" 45 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;LL_DEBUG;XP_WIN;XP_WIN32"
46 MinimalRebuild="true" 46 MinimalRebuild="true"
47 BasicRuntimeChecks="3" 47 BasicRuntimeChecks="3"
48 RuntimeLibrary="1" 48 RuntimeLibrary="1"
@@ -69,6 +69,8 @@
69 Name="VCLibrarianTool" 69 Name="VCLibrarianTool"
70 OutputFile="$(OutDir)/llmedia.lib" 70 OutputFile="$(OutDir)/llmedia.lib"
71 AdditionalLibraryDirectories="" 71 AdditionalLibraryDirectories=""
72 IgnoreAllDefaultLibraries="false"
73 IgnoreDefaultLibraryNames=""
72 /> 74 />
73 <Tool 75 <Tool
74 Name="VCALinkTool" 76 Name="VCALinkTool"
@@ -111,11 +113,10 @@
111 /> 113 />
112 <Tool 114 <Tool
113 Name="VCCLCompilerTool" 115 Name="VCCLCompilerTool"
114 AdditionalOptions="/Oy-"
115 InlineFunctionExpansion="0" 116 InlineFunctionExpansion="0"
116 EnableIntrinsicFunctions="false" 117 EnableIntrinsicFunctions="false"
117 AdditionalIncludeDirectories="..\llcommon;..\llrender;..\llwindow;..\llimage;..\llmath;..\llvfs;..\llmessage;..\llui;&quot;..\..\libraries\i686-win32\include&quot;;..\..\libraries\include\;&quot;..\..\libraries\i686-win32\include\quicktime&quot;" 118 AdditionalIncludeDirectories="&quot;..\..\libraries\i686-win32\include\quicktime&quot;;..\..\libraries\include"
118 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE;XP_WIN;XP_WIN32" 119 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE;XP_WIN;XP_WIN32"
119 RuntimeLibrary="0" 120 RuntimeLibrary="0"
120 StructMemberAlignment="0" 121 StructMemberAlignment="0"
121 TreatWChar_tAsBuiltInType="false" 122 TreatWChar_tAsBuiltInType="false"
@@ -184,12 +185,11 @@
184 /> 185 />
185 <Tool 186 <Tool
186 Name="VCCLCompilerTool" 187 Name="VCCLCompilerTool"
187 AdditionalOptions="/Oy-"
188 Optimization="0" 188 Optimization="0"
189 InlineFunctionExpansion="0" 189 InlineFunctionExpansion="0"
190 EnableIntrinsicFunctions="false" 190 EnableIntrinsicFunctions="false"
191 AdditionalIncludeDirectories="..\llcommon;..\llrender;..\llwindow;..\llimage;..\llmath;..\llvfs;..\llmessage;..\llui;&quot;..\..\libraries\i686-win32\include&quot;;..\..\libraries\include\;&quot;..\..\libraries\i686-win32\include\quicktime&quot;" 191 AdditionalIncludeDirectories="&quot;..\..\libraries\i686-win32\include\quicktime&quot;;..\..\libraries\include"
192 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE;XP_WIN;XP_WIN32" 192 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE;XP_WIN;XP_WIN32"
193 RuntimeLibrary="0" 193 RuntimeLibrary="0"
194 StructMemberAlignment="0" 194 StructMemberAlignment="0"
195 TreatWChar_tAsBuiltInType="false" 195 TreatWChar_tAsBuiltInType="false"
@@ -243,23 +243,31 @@
243 UniqueIdentifier="{44DBC47A-0AF0-4726-A094-2D6FBB65FFFA}" 243 UniqueIdentifier="{44DBC47A-0AF0-4726-A094-2D6FBB65FFFA}"
244 > 244 >
245 <File 245 <File
246 RelativePath=".\llmediabase.cpp" 246 RelativePath=".\llmediaimplcommon.cpp"
247 > 247 >
248 </File> 248 </File>
249 <File 249 <File
250 RelativePath=".\llmediaengine.cpp" 250 RelativePath=".\llmediaimplexample1.cpp"
251 > 251 >
252 </File> 252 </File>
253 <File 253 <File
254 RelativePath=".\llmediaimplquicktime.cpp" 254 RelativePath=".\llmediaimplexample2.cpp"
255 >
256 </File>
257 <File
258 RelativePath=".\llmediaimplfactory.cpp"
255 > 259 >
256 </File> 260 </File>
257 <File 261 <File
258 RelativePath=".\llmediamoviebase.cpp" 262 RelativePath=".\llmediaimplllmozlib.cpp"
259 > 263 >
260 </File> 264 </File>
261 <File 265 <File
262 RelativePath=".\llmediamoviebase.h" 266 RelativePath=".\llmediaimplquicktime.cpp"
267 >
268 </File>
269 <File
270 RelativePath=".\llmediamanager.cpp"
263 > 271 >
264 </File> 272 </File>
265 </Filter> 273 </Filter>
@@ -269,19 +277,27 @@
269 UniqueIdentifier="{D188664C-B9B7-4982-8C4B-8D9A44B4D9EF}" 277 UniqueIdentifier="{D188664C-B9B7-4982-8C4B-8D9A44B4D9EF}"
270 > 278 >
271 <File 279 <File
272 RelativePath=".\llmediabase.h" 280 RelativePath=".\llmediaemitter.h"
273 > 281 >
274 </File> 282 </File>
275 <File 283 <File
276 RelativePath=".\llmediaemitter.h" 284 RelativePath=".\llmediaimplcommon.h"
277 > 285 >
278 </File> 286 </File>
279 <File 287 <File
280 RelativePath=".\llmediaemitterevents.h" 288 RelativePath=".\llmediaimplexample1.h"
281 > 289 >
282 </File> 290 </File>
283 <File 291 <File
284 RelativePath=".\llmediaengine.h" 292 RelativePath=".\llmediaimplexample2.h"
293 >
294 </File>
295 <File
296 RelativePath=".\llmediaimplfactory.h"
297 >
298 </File>
299 <File
300 RelativePath=".\llmediaimplllmozlib.h"
285 > 301 >
286 </File> 302 </File>
287 <File 303 <File
@@ -289,7 +305,15 @@
289 > 305 >
290 </File> 306 </File>
291 <File 307 <File
292 RelativePath=".\llmediaobservers.h" 308 RelativePath=".\llmediaimplregister.h"
309 >
310 </File>
311 <File
312 RelativePath=".\llmediamanager.h"
313 >
314 </File>
315 <File
316 RelativePath=".\llmediaobserver.h"
293 > 317 >
294 </File> 318 </File>
295 </Filter> 319 </Filter>
diff --git a/linden/indra/llmedia/llmedia_vc9.vcproj b/linden/indra/llmedia/llmedia_vc9.vcproj
index 440f714..d032711 100644
--- a/linden/indra/llmedia/llmedia_vc9.vcproj
+++ b/linden/indra/llmedia/llmedia_vc9.vcproj
@@ -1,300 +1,326 @@
1<?xml version="1.0" encoding="Windows-1252"?> 1<?xml version="1.0" encoding="Windows-1252"?>
2<VisualStudioProject 2<VisualStudioProject
3 ProjectType="Visual C++" 3 ProjectType="Visual C++"
4 Version="9.00" 4 Version="9.00"
5 Name="llmedia" 5 Name="llmedia"
6 ProjectGUID="{9D0C7E02-6506-4EE7-BC5C-75671D28D594}" 6 ProjectGUID="{9D0C7E02-6506-4EE7-BC5C-75671D28D594}"
7 RootNamespace="llmedia" 7 RootNamespace="llmedia"
8 Keyword="Win32Proj" 8 Keyword="Win32Proj"
9 TargetFrameworkVersion="131072" 9 TargetFrameworkVersion="131072"
10 > 10 >
11 <Platforms> 11 <Platforms>
12 <Platform 12 <Platform
13 Name="Win32" 13 Name="Win32"
14 /> 14 />
15 </Platforms> 15 </Platforms>
16 <ToolFiles> 16 <ToolFiles>
17 </ToolFiles> 17 </ToolFiles>
18 <Configurations> 18 <Configurations>
19 <Configuration 19 <Configuration
20 Name="Debug|Win32" 20 Name="Debug|Win32"
21 OutputDirectory="../lib_$(ConfigurationName)/i686-win32" 21 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
22 IntermediateDirectory="Debug" 22 IntermediateDirectory="Debug"
23 ConfigurationType="4" 23 ConfigurationType="4"
24 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" 24 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
25 CharacterSet="1" 25 CharacterSet="1"
26 > 26 >
27 <Tool 27 <Tool
28 Name="VCPreBuildEventTool" 28 Name="VCPreBuildEventTool"
29 /> 29 />
30 <Tool 30 <Tool
31 Name="VCCustomBuildTool" 31 Name="VCCustomBuildTool"
32 /> 32 />
33 <Tool 33 <Tool
34 Name="VCXMLDataGeneratorTool" 34 Name="VCXMLDataGeneratorTool"
35 /> 35 />
36 <Tool 36 <Tool
37 Name="VCWebServiceProxyGeneratorTool" 37 Name="VCWebServiceProxyGeneratorTool"
38 /> 38 />
39 <Tool 39 <Tool
40 Name="VCMIDLTool" 40 Name="VCMIDLTool"
41 /> 41 />
42 <Tool 42 <Tool
43 Name="VCCLCompilerTool" 43 Name="VCCLCompilerTool"
44 Optimization="0" 44 Optimization="0"
45 AdditionalIncludeDirectories="..\llcommon;..\llrender;..\llwindow;..\llimage;..\llmath;..\llvfs;..\llmessage;..\llui;&quot;..\..\libraries\i686-win32\include&quot;;..\..\libraries\include\;&quot;..\..\libraries\i686-win32\include\quicktime&quot;" 45 AdditionalIncludeDirectories="&quot;..\..\libraries\i686-win32\include\quicktime&quot;;..\..\libraries\include"
46 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG;XP_WIN;XP_WIN32" 46 PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;LL_DEBUG;XP_WIN;XP_WIN32"
47 MinimalRebuild="true" 47 MinimalRebuild="true"
48 BasicRuntimeChecks="3" 48 BasicRuntimeChecks="3"
49 RuntimeLibrary="1" 49 RuntimeLibrary="1"
50 StructMemberAlignment="4" 50 StructMemberAlignment="4"
51 TreatWChar_tAsBuiltInType="false" 51 TreatWChar_tAsBuiltInType="false"
52 ForceConformanceInForLoopScope="true" 52 ForceConformanceInForLoopScope="true"
53 UsePrecompiledHeader="0" 53 UsePrecompiledHeader="0"
54 WarningLevel="3" 54 WarningLevel="3"
55 WarnAsError="true" 55 WarnAsError="true"
56 Detect64BitPortabilityProblems="false" 56 Detect64BitPortabilityProblems="false"
57 DebugInformationFormat="4" 57 DebugInformationFormat="4"
58 DisableSpecificWarnings="4702" 58 DisableSpecificWarnings="4702"
59 /> 59 />
60 <Tool 60 <Tool
61 Name="VCManagedResourceCompilerTool" 61 Name="VCManagedResourceCompilerTool"
62 /> 62 />
63 <Tool 63 <Tool
64 Name="VCResourceCompilerTool" 64 Name="VCResourceCompilerTool"
65 /> 65 />
66 <Tool 66 <Tool
67 Name="VCPreLinkEventTool" 67 Name="VCPreLinkEventTool"
68 /> 68 />
69 <Tool 69 <Tool
70 Name="VCLibrarianTool" 70 Name="VCLibrarianTool"
71 OutputFile="$(OutDir)/llmedia.lib" 71 OutputFile="$(OutDir)/llmedia.lib"
72 AdditionalLibraryDirectories="" 72 AdditionalLibraryDirectories=""
73 /> 73 IgnoreAllDefaultLibraries="false"
74 <Tool 74 IgnoreDefaultLibraryNames=""
75 Name="VCALinkTool" 75 />
76 /> 76 <Tool
77 <Tool 77 Name="VCALinkTool"
78 Name="VCXDCMakeTool" 78 />
79 /> 79 <Tool
80 <Tool 80 Name="VCXDCMakeTool"
81 Name="VCBscMakeTool" 81 />
82 /> 82 <Tool
83 <Tool 83 Name="VCBscMakeTool"
84 Name="VCFxCopTool" 84 />
85 /> 85 <Tool
86 <Tool 86 Name="VCFxCopTool"
87 Name="VCPostBuildEventTool" 87 />
88 /> 88 <Tool
89 </Configuration> 89 Name="VCPostBuildEventTool"
90 <Configuration 90 />
91 Name="Release|Win32" 91 </Configuration>
92 OutputDirectory="../lib_$(ConfigurationName)/i686-win32" 92 <Configuration
93 IntermediateDirectory="Release" 93 Name="Release|Win32"
94 ConfigurationType="4" 94 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
95 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" 95 IntermediateDirectory="Release"
96 CharacterSet="1" 96 ConfigurationType="4"
97 > 97 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
98 <Tool 98 CharacterSet="1"
99 Name="VCPreBuildEventTool" 99 >
100 /> 100 <Tool
101 <Tool 101 Name="VCPreBuildEventTool"
102 Name="VCCustomBuildTool" 102 />
103 /> 103 <Tool
104 <Tool 104 Name="VCCustomBuildTool"
105 Name="VCXMLDataGeneratorTool" 105 />
106 /> 106 <Tool
107 <Tool 107 Name="VCXMLDataGeneratorTool"
108 Name="VCWebServiceProxyGeneratorTool" 108 />
109 /> 109 <Tool
110 <Tool 110 Name="VCWebServiceProxyGeneratorTool"
111 Name="VCMIDLTool" 111 />
112 /> 112 <Tool
113 <Tool 113 Name="VCMIDLTool"
114 Name="VCCLCompilerTool" 114 />
115 AdditionalOptions="/Oy-" 115 <Tool
116 InlineFunctionExpansion="0" 116 Name="VCCLCompilerTool"
117 EnableIntrinsicFunctions="false" 117 AdditionalOptions="/Oy-"
118 AdditionalIncludeDirectories="..\llcommon;..\llrender;..\llwindow;..\llimage;..\llmath;..\llvfs;..\llmessage;..\llui;&quot;..\..\libraries\i686-win32\include&quot;;..\..\libraries\include\;&quot;..\..\libraries\i686-win32\include\quicktime&quot;" 118 InlineFunctionExpansion="0"
119 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE;XP_WIN;XP_WIN32" 119 EnableIntrinsicFunctions="false"
120 RuntimeLibrary="0" 120 AdditionalIncludeDirectories="&quot;..\..\libraries\i686-win32\include\quicktime&quot;;..\..\libraries\include"
121 StructMemberAlignment="0" 121 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE;XP_WIN;XP_WIN32"
122 TreatWChar_tAsBuiltInType="false" 122 RuntimeLibrary="0"
123 ForceConformanceInForLoopScope="true" 123 StructMemberAlignment="0"
124 UsePrecompiledHeader="0" 124 TreatWChar_tAsBuiltInType="false"
125 WarningLevel="3" 125 ForceConformanceInForLoopScope="true"
126 WarnAsError="false" 126 UsePrecompiledHeader="0"
127 Detect64BitPortabilityProblems="false" 127 WarningLevel="3"
128 DebugInformationFormat="3" 128 WarnAsError="false"
129 DisableSpecificWarnings="4702" 129 Detect64BitPortabilityProblems="false"
130 /> 130 DebugInformationFormat="3"
131 <Tool 131 DisableSpecificWarnings="4702"
132 Name="VCManagedResourceCompilerTool" 132 />
133 /> 133 <Tool
134 <Tool 134 Name="VCManagedResourceCompilerTool"
135 Name="VCResourceCompilerTool" 135 />
136 /> 136 <Tool
137 <Tool 137 Name="VCResourceCompilerTool"
138 Name="VCPreLinkEventTool" 138 />
139 /> 139 <Tool
140 <Tool 140 Name="VCPreLinkEventTool"
141 Name="VCLibrarianTool" 141 />
142 OutputFile="$(OutDir)/llmedia.lib" 142 <Tool
143 AdditionalLibraryDirectories="" 143 Name="VCLibrarianTool"
144 IgnoreAllDefaultLibraries="false" 144 OutputFile="$(OutDir)/llmedia.lib"
145 IgnoreDefaultLibraryNames="" 145 AdditionalLibraryDirectories=""
146 /> 146 IgnoreAllDefaultLibraries="false"
147 <Tool 147 IgnoreDefaultLibraryNames=""
148 Name="VCALinkTool" 148 />
149 /> 149 <Tool
150 <Tool 150 Name="VCALinkTool"
151 Name="VCXDCMakeTool" 151 />
152 /> 152 <Tool
153 <Tool 153 Name="VCXDCMakeTool"
154 Name="VCBscMakeTool" 154 />
155 /> 155 <Tool
156 <Tool 156 Name="VCBscMakeTool"
157 Name="VCFxCopTool" 157 />
158 /> 158 <Tool
159 <Tool 159 Name="VCFxCopTool"
160 Name="VCPostBuildEventTool" 160 />
161 /> 161 <Tool
162 </Configuration> 162 Name="VCPostBuildEventTool"
163 <Configuration 163 />
164 Name="ReleaseNoOpt|Win32" 164 </Configuration>
165 OutputDirectory="../lib_$(ConfigurationName)/i686-win32" 165 <Configuration
166 IntermediateDirectory="$(ConfigurationName)" 166 Name="ReleaseNoOpt|Win32"
167 ConfigurationType="4" 167 OutputDirectory="../lib_$(ConfigurationName)/i686-win32"
168 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" 168 IntermediateDirectory="$(ConfigurationName)"
169 CharacterSet="1" 169 ConfigurationType="4"
170 > 170 InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
171 <Tool 171 CharacterSet="1"
172 Name="VCPreBuildEventTool" 172 >
173 /> 173 <Tool
174 <Tool 174 Name="VCPreBuildEventTool"
175 Name="VCCustomBuildTool" 175 />
176 /> 176 <Tool
177 <Tool 177 Name="VCCustomBuildTool"
178 Name="VCXMLDataGeneratorTool" 178 />
179 /> 179 <Tool
180 <Tool 180 Name="VCXMLDataGeneratorTool"
181 Name="VCWebServiceProxyGeneratorTool" 181 />
182 /> 182 <Tool
183 <Tool 183 Name="VCWebServiceProxyGeneratorTool"
184 Name="VCMIDLTool" 184 />
185 /> 185 <Tool
186 <Tool 186 Name="VCMIDLTool"
187 Name="VCCLCompilerTool" 187 />
188 AdditionalOptions="/Oy-" 188 <Tool
189 Optimization="0" 189 Name="VCCLCompilerTool"
190 InlineFunctionExpansion="0" 190 AdditionalOptions="/Oy-"
191 EnableIntrinsicFunctions="false" 191 Optimization="0"
192 AdditionalIncludeDirectories="..\llcommon;..\llrender;..\llwindow;..\llimage;..\llmath;..\llvfs;..\llmessage;..\llui;&quot;..\..\libraries\i686-win32\include&quot;;..\..\libraries\include\;&quot;..\..\libraries\i686-win32\include\quicktime&quot;" 192 InlineFunctionExpansion="0"
193 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE;XP_WIN;XP_WIN32" 193 EnableIntrinsicFunctions="false"
194 RuntimeLibrary="0" 194 AdditionalIncludeDirectories="&quot;..\..\libraries\i686-win32\include\quicktime&quot;;..\..\libraries\include"
195 StructMemberAlignment="0" 195 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;LL_RELEASE;XP_WIN;XP_WIN32"
196 TreatWChar_tAsBuiltInType="false" 196 RuntimeLibrary="0"
197 ForceConformanceInForLoopScope="true" 197 StructMemberAlignment="0"
198 UsePrecompiledHeader="0" 198 TreatWChar_tAsBuiltInType="false"
199 WarningLevel="3" 199 ForceConformanceInForLoopScope="true"
200 WarnAsError="true" 200 UsePrecompiledHeader="0"
201 Detect64BitPortabilityProblems="false" 201 WarningLevel="3"
202 DebugInformationFormat="3" 202 WarnAsError="true"
203 DisableSpecificWarnings="4702" 203 Detect64BitPortabilityProblems="false"
204 /> 204 DebugInformationFormat="3"
205 <Tool 205 DisableSpecificWarnings="4702"
206 Name="VCManagedResourceCompilerTool" 206 />
207 /> 207 <Tool
208 <Tool 208 Name="VCManagedResourceCompilerTool"
209 Name="VCResourceCompilerTool" 209 />
210 /> 210 <Tool
211 <Tool 211 Name="VCResourceCompilerTool"
212 Name="VCPreLinkEventTool" 212 />
213 /> 213 <Tool
214 <Tool 214 Name="VCPreLinkEventTool"
215 Name="VCLibrarianTool" 215 />
216 OutputFile="$(OutDir)/llmedia.lib" 216 <Tool
217 AdditionalLibraryDirectories="" 217 Name="VCLibrarianTool"
218 IgnoreAllDefaultLibraries="false" 218 OutputFile="$(OutDir)/llmedia.lib"
219 IgnoreDefaultLibraryNames="" 219 AdditionalLibraryDirectories=""
220 /> 220 IgnoreAllDefaultLibraries="false"
221 <Tool 221 IgnoreDefaultLibraryNames=""
222 Name="VCALinkTool" 222 />
223 /> 223 <Tool
224 <Tool 224 Name="VCALinkTool"
225 Name="VCXDCMakeTool" 225 />
226 /> 226 <Tool
227 <Tool 227 Name="VCXDCMakeTool"
228 Name="VCBscMakeTool" 228 />
229 /> 229 <Tool
230 <Tool 230 Name="VCBscMakeTool"
231 Name="VCFxCopTool" 231 />
232 /> 232 <Tool
233 <Tool 233 Name="VCFxCopTool"
234 Name="VCPostBuildEventTool" 234 />
235 /> 235 <Tool
236 </Configuration> 236 Name="VCPostBuildEventTool"
237 </Configurations> 237 />
238 <References> 238 </Configuration>
239 </References> 239 </Configurations>
240 <Files> 240 <References>
241 <Filter 241 </References>
242 Name="Source Files" 242 <Files>
243 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" 243 <Filter
244 UniqueIdentifier="{44DBC47A-0AF0-4726-A094-2D6FBB65FFFA}" 244 Name="Source Files"
245 > 245 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
246 <File 246 UniqueIdentifier="{44DBC47A-0AF0-4726-A094-2D6FBB65FFFA}"
247 RelativePath=".\llmediabase.cpp" 247 >
248 > 248 <File
249 </File> 249 RelativePath=".\llmediaimplcommon.cpp"
250 <File 250 >
251 RelativePath=".\llmediaengine.cpp" 251 </File>
252 > 252 <File
253 </File> 253 RelativePath=".\llmediaimplexample1.cpp"
254 <File 254 >
255 RelativePath=".\llmediaimplquicktime.cpp" 255 </File>
256 > 256 <File
257 </File> 257 RelativePath=".\llmediaimplexample2.cpp"
258 <File 258 >
259 RelativePath=".\llmediamoviebase.cpp" 259 </File>
260 > 260 <File
261 </File> 261 RelativePath=".\llmediaimplfactory.cpp"
262 <File 262 >
263 RelativePath=".\llmediamoviebase.h" 263 </File>
264 > 264 <File
265 </File> 265 RelativePath=".\llmediaimplllmozlib.cpp"
266 </Filter> 266 >
267 <Filter 267 </File>
268 Name="Header Files" 268 <File
269 Filter="h;hpp;hxx;hm;inl;inc;xsd" 269 RelativePath=".\llmediaimplquicktime.cpp"
270 UniqueIdentifier="{D188664C-B9B7-4982-8C4B-8D9A44B4D9EF}" 270 >
271 > 271 </File>
272 <File 272 <File
273 RelativePath=".\llmediabase.h" 273 RelativePath=".\llmediamanager.cpp"
274 > 274 >
275 </File> 275 </File>
276 <File 276 </Filter>
277 RelativePath=".\llmediaemitter.h" 277 <Filter
278 > 278 Name="Header Files"
279 </File> 279 Filter="h;hpp;hxx;hm;inl;inc;xsd"
280 <File 280 UniqueIdentifier="{D188664C-B9B7-4982-8C4B-8D9A44B4D9EF}"
281 RelativePath=".\llmediaemitterevents.h" 281 >
282 > 282 <File
283 </File> 283 RelativePath=".\llmediaemitter.h"
284 <File 284 >
285 RelativePath=".\llmediaengine.h" 285 </File>
286 > 286 <File
287 </File> 287 RelativePath=".\llmediaimplcommon.h"
288 <File 288 >
289 RelativePath=".\llmediaimplquicktime.h" 289 </File>
290 > 290 <File
291 </File> 291 RelativePath=".\llmediaimplexample1.h"
292 <File 292 >
293 RelativePath=".\llmediaobservers.h" 293 </File>
294 > 294 <File
295 </File> 295 RelativePath=".\llmediaimplexample2.h"
296 </Filter> 296 >
297 </Files> 297 </File>
298 <Globals> 298 <File
299 </Globals> 299 RelativePath=".\llmediaimplfactory.h"
300</VisualStudioProject> 300 >
301 </File>
302 <File
303 RelativePath=".\llmediaimplllmozlib.h"
304 >
305 </File>
306 <File
307 RelativePath=".\llmediaimplquicktime.h"
308 >
309 </File>
310 <File
311 RelativePath=".\llmediaimplregister.h"
312 >
313 </File>
314 <File
315 RelativePath=".\llmediamanager.h"
316 >
317 </File>
318 <File
319 RelativePath=".\llmediaobserver.h"
320 >
321 </File>
322 </Filter>
323 </Files>
324 <Globals>
325 </Globals>
326</VisualStudioProject>
diff --git a/linden/indra/llmedia/llmediabase.cpp b/linden/indra/llmedia/llmediabase.cpp
deleted file mode 100644
index 40acc5c..0000000
--- a/linden/indra/llmedia/llmediabase.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
1/**
2 * @file llmediabase.cpp
3 * @brief LLMedia support - base class
4 *
5 * $LicenseInfo:firstyear=2005&license=viewergpl$
6 *
7 * Copyright (c) 2005-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "linden_common.h"
33
34#include "llmediabase.h"
35#include "llmediaimplquicktime.h"
36#include "llmediaimplgstreamer.h"
37
38LLMediaBase::LLMediaBase() :
39 mBufferChangeCount ( 1 ),
40 mLastBufferChangeCount ( 0 ),
41 mMediaWidth ( 0 ),
42 mMediaHeight ( 0 ),
43 mMediaDepthBytes ( 0 ),
44 mMediaRowbytes( 0 ),
45 mTextureWidth ( 0 ),
46 mTextureHeight ( 0 ),
47 mTextureDepth ( 0 ),
48 mTextureFormatInternal ( 0 ),
49 mTextureFormatPrimary ( 0 ),
50 mTextureFormatType ( 0 ),
51 mTextureFormatSwapBytes ( 0 )
52{
53
54}
55
56///////////////////////////////////////////////////////////////////////////////
57// factory method based on explicit media type
58LLMediaBase* LLMediaBase::make( const MediaType mediaTypeIn, S32 width_pixels, S32 height_pixels )
59{
60#if LL_QUICKTIME_ENABLED
61 if ( mediaTypeIn == QuickTime )
62 {
63 return new LLMediaImplQuickTime ();
64 }
65 else
66#endif
67#if LL_GSTREAMER_ENABLED
68 if ( mediaTypeIn == QuickTime )
69 {
70 return new LLMediaImplGStreamer ();
71 }
72 else
73#endif
74
75 return 0;
76}
77
78///////////////////////////////////////////////////////////////////////////////
79//
80BOOL
81LLMediaBase::
82init ()
83{
84 // build event and emit it
85 LLMediaEvent event ( 0, "" );
86 mMediaEventEmitter.update ( &LLMediaObserver::onInit, event );
87
88 return TRUE;
89}
90
91///////////////////////////////////////////////////////////////////////////////
92//
93BOOL
94LLMediaBase::
95load ( const LLString& urlIn )
96{
97 // build event and emit it
98 LLMediaEvent event ( 0, urlIn );
99 mMediaEventEmitter.update ( &LLMediaObserver::onLoad, event );
100
101 return TRUE;
102}
103
104///////////////////////////////////////////////////////////////////////////////
105//
106BOOL
107LLMediaBase::
108unload ()
109{
110 LLMediaEvent event ( 0, "" );
111 mMediaEventEmitter.update ( &LLMediaObserver::onUnload, event );
112
113 return TRUE;
114}
115
116///////////////////////////////////////////////////////////////////////////////
117//
118S32 LLMediaBase::getTextureWidth() const
119{
120 return mTextureWidth;
121}
122
123///////////////////////////////////////////////////////////////////////////////
124//
125S32 LLMediaBase::getTextureHeight() const
126{
127 return mTextureHeight;
128}
129
130///////////////////////////////////////////////////////////////////////////////
131//
132S32 LLMediaBase::getTextureDepth() const
133{
134 return mTextureDepth;
135}
136
137///////////////////////////////////////////////////////////////////////////////
138//
139S32 LLMediaBase::getTextureFormatInternal() const
140{
141 return mTextureFormatInternal;
142}
143
144///////////////////////////////////////////////////////////////////////////////
145//
146S32 LLMediaBase::getTextureFormatPrimary() const
147{
148 return mTextureFormatPrimary;
149}
150
151///////////////////////////////////////////////////////////////////////////////
152//
153S32 LLMediaBase::getTextureFormatType() const
154{
155 return mTextureFormatType;
156}
157
158///////////////////////////////////////////////////////////////////////////////
159//
160S32 LLMediaBase::getTextureFormatSwapBytes() const
161{
162 return mTextureFormatSwapBytes;
163}
164
165///////////////////////////////////////////////////////////////////////////////
166//
167S32 LLMediaBase::getMediaWidth() const
168{
169 return mMediaWidth;
170}
171
172///////////////////////////////////////////////////////////////////////////////
173//
174S32 LLMediaBase::getMediaHeight() const
175{
176 return mMediaHeight;
177}
178
179///////////////////////////////////////////////////////////////////////////////
180//
181S32 LLMediaBase::getMediaDepthBytes() const
182{
183 return mMediaDepthBytes;
184}
185
186///////////////////////////////////////////////////////////////////////////////
187//
188S32 LLMediaBase::getMediaBufferSize() const
189{
190 if(mMediaRowbytes != 0)
191 {
192 return mMediaHeight * mMediaRowbytes;
193 }
194
195 return mMediaWidth * mMediaHeight * mMediaDepthBytes;
196};
197
198///////////////////////////////////////////////////////////////////////////////
199//
200BOOL LLMediaBase::addMediaObserver( LLMediaObserver* observerIn )
201{
202 return mMediaEventEmitter.addObserver( observerIn );
203}
204
205///////////////////////////////////////////////////////////////////////////////
206//
207BOOL LLMediaBase::remMediaObserver( LLMediaObserver* observerIn )
208{
209 return mMediaEventEmitter.remObserver( observerIn );
210}
diff --git a/linden/indra/llmedia/llmediabase.h b/linden/indra/llmedia/llmediabase.h
index ae9c8ee..49c6d69 100644
--- a/linden/indra/llmedia/llmediabase.h
+++ b/linden/indra/llmedia/llmediabase.h
@@ -1,6 +1,8 @@
1/** 1/**
2 * @file llmediabase.h 2 * @file llmediabase.h
3 * @brief LLMedia support - base class 3 * @author Callum Prentice
4 * @date 2007-10-22 00:00:00
5 * @brief Abstract class that defines LLMedia public interface
4 * 6 *
5 * $LicenseInfo:firstyear=2005&license=viewergpl$ 7 * $LicenseInfo:firstyear=2005&license=viewergpl$
6 * 8 *
@@ -29,112 +31,237 @@
29 * $/LicenseInfo$ 31 * $/LicenseInfo$
30 */ 32 */
31 33
32// header guard 34#ifndef LLMEDIABASE_H
33#ifndef llmediabase_h 35#define LLMEDIABASE_H
34#define llmediabase_h
35 36
36#include "llstring.h" 37// Per-OS feature switches.
37#include "llmediaemitter.h" 38#if LL_DARWIN
38#include "llmediaobservers.h" 39 #define LL_QUICKTIME_ENABLED 1
39#include "llmediaemitterevents.h" 40 #define LL_LLMOZLIB_ENABLED 1
41#elif LL_WINDOWS
42 #define LL_QUICKTIME_ENABLED 1
43 #define LL_LLMOZLIB_ENABLED 1
44#elif LL_LINUX
45 #define LL_QUICKTIME_ENABLED 0
46 #ifndef LL_LLMOZLIB_ENABLED
47 #define LL_LLMOZLIB_ENABLED 1
48 #endif // def LL_LLMOZLIB_ENABLED
49#elif LL_SOLARIS
50 #define LL_QUICKTIME_ENABLED 0
51 #ifndef LL_LLMOZLIB_ENABLED
52 #define LL_LLMOZLIB_ENABLED 0
53 #endif // def LL_LLMOZLIB_ENABLED
54#endif
55
56#if LL_LLMOZLIB_ENABLED && !defined ( MOZILLA_INTERNAL_API )
57 // Without this, nsTAString.h errors out with:
58 // "Cannot use internal string classes without MOZILLA_INTERNAL_API defined. Use the frozen header nsStringAPI.h instead."
59 // It might be worth our while to figure out if we can use the frozen apis at some point...
60 #define MOZILLA_INTERNAL_API 1
61#endif
62
63#include <string>
64
65class LLMediaObserver;
66class LLMediaImplMakerBase;
40 67
41class LLMediaBase 68class LLMediaBase
42{ 69{
43 public: 70 public:
44 LLMediaBase (); 71 LLMediaBase() {};
45 72 virtual ~LLMediaBase() {};
46 // do the right thing with dtor 73
47 virtual ~LLMediaBase () 74 ////////////////////////////////////////////////////////////////////////////////
48 { 75 // housekeeping
76
77 // local initialization, called by the media manager when creating a source
78 virtual bool init() = 0;
79
80 // undoes everything init() didm called by the media manager when destroying a source
81 virtual bool reset() = 0;
82
83 // accessor for MIME type
84 virtual bool setMimeType( const std::string mime_type ) = 0;
85 virtual std::string getMimeType() const = 0;
86
87 // accessor for intial URL. Note that this may have changed under the hood
88 // so pass back the original URL seeded to this impl
89 virtual std::string getMediaURL() const = 0;
90
91 // ask impl for version string
92 virtual std::string getVersion() = 0;
93
94 // set/clear URL to visit when a 404 page is reached
95 virtual bool set404RedirectUrl( std::string redirect_url ) = 0;
96 virtual bool clr404RedirectUrl() = 0;
97
98 // sets the background color of the browser window
99 virtual bool setBackgroundColor( unsigned int red, unsigned int green, unsigned int blue ) const = 0;
100
101 // sets the color of the caret in media impls that have one
102 virtual bool setCaretColor( unsigned int red, unsigned int green, unsigned int blue ) const = 0;
103
104 ////////////////////////////////////////////////////////////////////////////////
105 // media management
106
107 // needs to be called regularly to make media stream update itself
108 virtual bool updateMedia() = 0;
109
110 // allows you to request a change in media width, height - may fail if media doesn't support size change
111 virtual bool setRequestedMediaSize( int media_width, int media_height ) = 0;
112
113 // gets media width (may change throughout lifetime of media stream) - event emitted when media size changed too
114 virtual int getMediaWidth() const = 0;
115
116 // gets media height (may change throughout lifetime of media stream) - event emitted when media size changed too
117 virtual int getMediaHeight() const = 0;
118
119 // allows you to try to explicitly change media depth - may fail if media doesn't support depth change
120 virtual bool setMediaDepth( int media_depth ) = 0;
121
122 // gets media depth (may change throughout lifetime of media stream) - event emitted when media depth changed too
123 virtual int getMediaDepth() const = 0;
124
125 // gets size of media buffer for current frame (might NOT be the same as media width * height * depth)
126 virtual int getMediaBufferSize() const = 0;
127
128 // returns pointer to raw media pixels
129 virtual unsigned char* getMediaData() = 0;
130
131 // returns the size of the data, which may be different that the size of the media
132 virtual int getMediaDataWidth() const = 0;
133 virtual int getMediaDataHeight() const = 0;
134
135 ////////////////////////////////////////////////////////////////////////////////
136 // texture management
137
138 // gets internal format to use for OpenGL texture
139 virtual int getTextureFormatInternal() const = 0;
140
141 // gets primary format to use for OpenGL texture
142 virtual int getTextureFormatPrimary() const = 0;
143
144 // gets format type to use for OpenGL texture
145 virtual int getTextureFormatType() const = 0;
146
147
148
149
150 ////////////////////////////////////////////////////////////////////////////////
151 // audio
152
153 // set/get control volume from media stream if present
154 virtual bool setVolume( float volume ) = 0;
155 virtual float getVolume() const = 0;
156
157
158 ////////////////////////////////////////////////////////////////////////////////
159 // transport control etc.
160 enum ECommand {
161 COMMAND_NONE = 0,
162 COMMAND_STOP = 1,
163 COMMAND_START = 2,
164 COMMAND_PAUSE = 4,
165 COMMAND_BACK = 5,
166 COMMAND_FORWARD = 6
167 };
168 enum EStatus {
169 STATUS_UNKNOWN = 0,
170 STATUS_INITIALIZING = 1,
171 STATUS_NAVIGATING = 2,
172 STATUS_STARTED = 3,
173 STATUS_STOPPED = 4,
174 STATUS_PAUSED = 6,
175 STATUS_RESETTING = 7
49 }; 176 };
177 virtual bool addCommand( ECommand cmd ) = 0;
178 virtual bool clearCommand() = 0;
179 virtual bool updateCommand() = 0;
180 virtual EStatus getStatus() = 0;
181 virtual bool seek( double time ) = 0;
182 virtual bool setLooping( bool enable) = 0;
183 virtual bool isLooping() = 0;
50 184
51 /////////////////////////////////////////////////////////////////////////////// 185 ////////////////////////////////////////////////////////////////////////////////
52 // public interface: 186 // scaling
53 187
54 /////////////////////////////////////////////////////////////////////////////// 188 // autoscale means try to scale media to size of texture - may fail if media doesn't support size change
55 // different types of supported media 189 virtual bool setAutoScaled( bool auto_scaled ) = 0;
56 enum MediaType { Unknown, QuickTime }; 190 virtual bool isAutoScaled() const = 0;
57 191
58 ///////////////////////////////////////////////////////////////////////////////
59 // factory method based on explicit media type
60 static LLMediaBase* make ( const MediaType mediaTypeIn, S32 width_pixels, S32 height_pixels );
61
62 // Result codes for updateMedia
63 enum
64 {
65 updateMediaNoChanges,
66 updateMediaNeedsUpdate,
67 updateMediaNeedsSizeChange
68 192
69 } updateMediaResult; 193 ////////////////////////////////////////////////////////////////////////////////
194 // mouse and keyboard interaction
195 virtual bool mouseDown( int x_pos, int y_pos ) = 0;
196 virtual bool mouseUp( int x_pos, int y_pos ) = 0;
197 virtual bool mouseMove( int x_pos, int y_pos ) = 0;
198 virtual bool keyPress( int key_code ) = 0;
199 virtual bool scrollByLines( int lines ) = 0;
200 virtual bool focus( bool focus ) = 0;
201 virtual bool unicodeInput( unsigned long uni_char ) = 0;
202 virtual bool mouseLeftDoubleClick( int x_pos, int y_pos ) = 0;
70 203
71 // housekeeping
72 virtual BOOL setBuffer ( U8* bufferIn ) = 0;
73 virtual bool setBufferSize(S32 width_pixels, S32 height_pixels) { return false; }
74 virtual BOOL init ();
75 virtual BOOL load ( const LLString& urlIn );
76 virtual BOOL unload ();
77
78 // media data
79 virtual S32 updateMedia () = 0;
80 virtual U8* getMediaData () = 0;
81 virtual S32 getTextureWidth () const;
82 virtual S32 getTextureHeight () const;
83 virtual S32 getTextureDepth () const;
84 virtual S32 getTextureFormatInternal () const;
85 virtual S32 getTextureFormatPrimary () const;
86 virtual S32 getTextureFormatType () const;
87 virtual S32 getTextureFormatSwapBytes () const;
88 virtual S32 getMediaWidth () const;
89 virtual S32 getMediaHeight () const;
90 virtual S32 getMediaDepthBytes () const;
91 virtual S32 getMediaBufferSize () const;
92
93 // allow consumers to observe media events
94 virtual BOOL addMediaObserver( LLMediaObserver* observerIn );
95 virtual BOOL remMediaObserver( LLMediaObserver* observerIn );
96
97 // MBW -- XXX -- These don't belong here!
98 // LLMediaEngine should really only deal with LLMediaMovieBase subclasses
99 virtual BOOL stop () { return TRUE; }
100 virtual BOOL play () { return TRUE; }
101 virtual BOOL loop ( S32 howMany ) { return TRUE; }
102 virtual BOOL pause () { return TRUE; }
103 virtual BOOL seek ( F64 time ) { return TRUE; }
104 virtual BOOL setVolume ( F32 volumeIn ) { return TRUE; }
105 virtual BOOL isLoaded () const { return TRUE; }
106 virtual BOOL isPaused () const { return FALSE; }
107 virtual BOOL isPlaying () const { return TRUE; }
108 virtual BOOL isLooping () const { return FALSE; }
109 virtual void setAutoScaled ( BOOL autoScaledIn ) {}
110
111 protected:
112 // event emitter
113 LLMediaEmitter<LLMediaObserver> mMediaEventEmitter;
114 204
115 U32 mBufferChangeCount; // Incremented when the buffer changes 205 ////////////////////////////////////////////////////////////////////////////////
116 U32 mLastBufferChangeCount; // Set to mBufferChangeCount when the buffer is reported as changed 206 // navigation
207 virtual bool navigateTo( const std::string url ) = 0;
208 virtual bool navigateForward() = 0;
209 virtual bool navigateBack() = 0;
210 virtual bool canNavigateForward() = 0;
211 virtual bool canNavigateBack() = 0;
117 212
118 S32 mMediaWidth; 213 ////////////////////////////////////////////////////////////////////////////////
119 S32 mMediaHeight; 214 // caching/cookies
120 S32 mMediaDepthBytes; 215 virtual bool enableCookies( bool enable ) = 0;
121 S32 mMediaRowbytes; 216 virtual bool clearCache() = 0;
122 S32 mTextureWidth; 217 virtual bool clearCookies() = 0;
123 S32 mTextureHeight;
124 S32 mTextureDepth;
125 S32 mTextureFormatInternal;
126 S32 mTextureFormatPrimary;
127 S32 mTextureFormatType;
128 S32 mTextureFormatSwapBytes;
129 218
130 public: 219 ////////////////////////////////////////////////////////////////////////////////
131 220 // proxy
132 // Has memory buffer been updated? (page content change, scroll, movie frame drawn, etc) 221 virtual bool enableProxy(bool enable, std::string proxy_host_name, int proxy_port) = 0;
133 void bufferChanged() { mBufferChangeCount++; } 222
134 bool getBufferChanged() const { return mBufferChangeCount != mLastBufferChangeCount; } 223 ////////////////////////////////////////////////////////////////////////////////
135 void resetBufferChanged() { mLastBufferChangeCount = mBufferChangeCount; } 224 // observer interface
225 virtual bool addObserver( LLMediaObserver* subject ) = 0;
226 virtual bool remObserver( LLMediaObserver* subject ) = 0;
227
228 ////////////////////////////////////////////////////////////////////////////////
229 // factory interface
230 virtual void setImplMaker(LLMediaImplMakerBase* impl_maker) = 0;
136 231
232 ////////////////////////////////////////////////////////////////////////////////
233 // type registry interface
234 virtual bool supportsMediaType(std::string scheme, std::string type) = 0;
137}; 235};
138 236
237//////////////////////////////////////////////////////////////
238// media key codes - (mirroring mozilla's values)
239const unsigned long LL_MEDIA_KEY_BACKSPACE = 0x08;
240const unsigned long LL_MEDIA_KEY_TAB = 0x09;
241const unsigned long LL_MEDIA_KEY_RETURN = 0x0D;
242const unsigned long LL_MEDIA_KEY_PAD_RETURN = 0x0E;
243const unsigned long LL_MEDIA_KEY_ESCAPE = 0x1B;
244const unsigned long LL_MEDIA_KEY_PAGE_UP = 0x21;
245const unsigned long LL_MEDIA_KEY_PAGE_DOWN = 0x22;
246const unsigned long LL_MEDIA_KEY_END = 0x23;
247const unsigned long LL_MEDIA_KEY_HOME = 0x24;
248const unsigned long LL_MEDIA_KEY_LEFT = 0x25;
249const unsigned long LL_MEDIA_KEY_UP = 0x26;
250const unsigned long LL_MEDIA_KEY_RIGHT = 0x27;
251const unsigned long LL_MEDIA_KEY_DOWN = 0x28;
252const unsigned long LL_MEDIA_KEY_INSERT = 0x2D;
253const unsigned long LL_MEDIA_KEY_DELETE = 0x2E;
254
255//////////////////////////////////////////////////////////////
256// media frame buffer types - (mirroring GL values)
257const int LL_MEDIA_UNSIGNED_BYTE = 0x1401;
258const int LL_MEDIA_RGB = 0x1907;
259const int LL_MEDIA_RGBA = 0x1908;
260const int LL_MEDIA_RGB8 = 0x8051;
261const int LL_MEDIA_UNSIGNED_INT_8_8_8_8 = 0x8035;
262const int LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV = 0x8367;
263const int LL_MEDIA_BGR = 0x80E0;
264const int LL_MEDIA_BGRA = 0x80E1;
265
139 266
140#endif // llmediabase_h 267#endif // LLMEDIABASE_H
diff --git a/linden/indra/llmedia/llmediaemitter.h b/linden/indra/llmedia/llmediaemitter.h
index 658486d..e06a5ff 100644
--- a/linden/indra/llmedia/llmediaemitter.h
+++ b/linden/indra/llmedia/llmediaemitter.h
@@ -1,6 +1,8 @@
1/** 1/**
2 * @file llmediaemitter.h 2 * @file llmediaemitter.h
3 * @brief LLMedia support - templatized emitter class. 3 * @author Callum Prentice
4 * @date 2007-10-22 00:00:00
5 * @brief Manages and emits events to observers
4 * 6 *
5 * $LicenseInfo:firstyear=2005&license=viewergpl$ 7 * $LicenseInfo:firstyear=2005&license=viewergpl$
6 * 8 *
@@ -29,83 +31,73 @@
29 * $/LicenseInfo$ 31 * $/LicenseInfo$
30 */ 32 */
31 33
32// header guard 34#ifndef LLMEDIAEMITTER_H
33#ifndef llmediaemitter_h 35#define LLMEDIAEMITTER_H
34#define llmediaemitter_h
35 36
36// standard headers 37#include <list>
37#include <algorithm> 38#include <algorithm>
38#include <typeinfo> 39#include <typeinfo>
39#include <iostream>
40#include <list>
41
42#include "stdtypes.h"
43 40
44/////////////////////////////////////////////////////////////////////////////// 41///////////////////////////////////////////////////////////////////////////////
45// templatized emitter class 42//
46template < class T > 43template< class T >
47class LLMediaEmitter 44class LLMediaEmitter
48{ 45{
49 public: 46 public:
47 LLMediaEmitter() { };
48 ~LLMediaEmitter() { };
49
50 typedef typename T::EventType EventType; 50 typedef typename T::EventType EventType;
51 typedef std::list< T* > ObserverContainer; 51 typedef std::list< T* > ObserverContainer;
52 typedef void ( T::*observerMethod )( const EventType& ); 52 typedef void( T::*observerMethod )( const EventType& );
53
54 protected:
55 ObserverContainer observers;
56
57 public:
58 LLMediaEmitter()
59 {
60 };
61
62 ~LLMediaEmitter()
63 {
64 };
65 53
66 /////////////////////////////////////////////////////////////////////////////// 54 ///////////////////////////////////////////////////////////////////////////////
67 // 55 //
68 BOOL addObserver ( T* observerIn ) 56 bool addObserver( T* observer_in )
69 { 57 {
70 if ( ! observerIn ) 58 if ( ! observer_in )
71 return FALSE; 59 return false;
72 60
73 // check if observer already exists 61 if ( std::find( observers.begin(), observers.end(), observer_in) != observers.end() )
74 if ( std::find ( observers.begin (), observers.end (), observerIn ) != observers.end () ) 62 return false;
75 return FALSE;
76 63
77 // save it 64 observers.push_back( observer_in );
78 observers.push_back ( observerIn );
79 65
80 return true; 66 return true;
81 }; 67 };
82 68
83 /////////////////////////////////////////////////////////////////////////////// 69 ///////////////////////////////////////////////////////////////////////////////
84 // 70 //
85 BOOL remObserver ( T* observerIn ) 71 bool remObserver( T* observer_in )
86 { 72 {
87 if ( ! observerIn ) 73 if ( ! observer_in )
88 return FALSE; 74 return false;
75
76 observers.remove( observer_in );
77 observers.remove( observer_in );
78 observers.remove( observer_in );
89 79
90 observers.remove ( observerIn );
91 80
92 return TRUE; 81
82 return true;
93 }; 83 };
94 84
95 /////////////////////////////////////////////////////////////////////////////// 85 ///////////////////////////////////////////////////////////////////////////////
96 // 86 //
97 void update ( observerMethod method, const EventType& msgIn ) 87 void update( observerMethod method, const EventType& msgIn )
98 { 88 {
99 typename std::list< T* >::iterator iter = observers.begin (); 89 typename std::list< T* >::iterator iter = observers.begin();
100 90
101 while ( iter != observers.end () ) 91 while( iter != observers.end() )
102 { 92 {
103 ( ( *iter )->*method ) ( msgIn ); 93 ( ( *iter )->*method )( msgIn );
104 94
105 ++iter; 95 ++iter;
106 }; 96 };
107 }; 97 };
108 };
109 98
99 protected:
100 ObserverContainer observers;
101};
110 102
111#endif // llmediaemitter_h 103#endif // LLMEDIAEMITTER_H
diff --git a/linden/indra/llmedia/llmediaengine.cpp b/linden/indra/llmedia/llmediaengine.cpp
deleted file mode 100644
index bd8acd1..0000000
--- a/linden/indra/llmedia/llmediaengine.cpp
+++ /dev/null
@@ -1,635 +0,0 @@
1/**
2 * @file llmediaengine.cpp
3 * @brief Top level media engine - wraps more specific functionality
4 *
5 * $LicenseInfo:firstyear=2005&license=viewergpl$
6 *
7 * Copyright (c) 2005-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "linden_common.h"
33#include "llmediaengine.h"
34#include "llmediaimplquicktime.h"
35
36#include "indra_constants.h"
37#include "llstring.h"
38
39// singleton pattern - initialization
40LLMediaEngine* LLMediaEngine::sInstance = 0;
41
42//////////////////////////////////////////////////////////////////////////////
43
44//static
45void LLMediaEngine::initClass()
46{
47 llassert(!sInstance);
48 sInstance = new LLMediaEngine();
49}
50
51//static
52void LLMediaEngine::updateClass(F32 volume)
53{
54 llassert(sInstance);
55 sInstance->setVolume(volume);
56}
57
58//static
59void LLMediaEngine::cleanupClass()
60{
61 delete sInstance;
62 sInstance = NULL;
63}
64
65//////////////////////////////////////////////////////////////////////////////
66// default ctor
67LLMediaEngine::LLMediaEngine() :
68 mAvailable( TRUE ),
69 mEnabled( TRUE ),
70 mAutoScaled( FALSE ),
71 mUrl( "" ),
72 mMediaRenderer( 0 ),
73 mImageUUID( LLUUID::null ),
74 mVolume( 0.0f ),
75 mProxyEnabled ( FALSE ),
76 mProxyAddress ( "" ),
77 mProxyPort ( 3128 ),
78 mProxySocks ( 5 ),
79 mProxyExlude ( "" )
80{
81}
82
83//////////////////////////////////////////////////////////////////////////////
84// dtor
85LLMediaEngine::~LLMediaEngine()
86{
87 unload();
88 destroyImageRaw();
89}
90
91//////////////////////////////////////////////////////////////////////////////
92// create/destroy raw image
93void LLMediaEngine::createImageRaw()
94{
95 S32 width = getMediaRenderer()->getMediaWidth();
96 S32 height = getMediaRenderer()->getMediaHeight();
97 S32 depth = getMediaRenderer()->getMediaDepthBytes();
98 if ((width > 0) && (height > 0) && (depth > 0))
99 {
100 if (mImageRaw.isNull())
101 {
102 mImageRaw = new LLImageRaw;
103 }
104 mImageRaw->resize(width, height, depth);
105 mImageRaw->clear();
106 }
107 else
108 {
109 destroyImageRaw();
110 }
111}
112
113void LLMediaEngine::destroyImageRaw()
114{
115 mImageRaw = NULL; // deletes image
116}
117
118//////////////////////////////////////////////////////////////////////////////
119// retrieves the single instance of this class - based on singleton pattern
120LLMediaEngine* LLMediaEngine::getInstance()
121{
122 return sInstance;
123}
124
125//////////////////////////////////////////////////////////////////////////////
126//
127LLMediaBase* LLMediaEngine::getMediaRenderer()
128{
129 return mMediaRenderer;
130}
131
132
133//////////////////////////////////////////////////////////////////////////////
134//
135BOOL LLMediaEngine::init()
136{
137 if( ! isAvailable() )
138 return FALSE;
139
140 return TRUE;
141}
142
143//////////////////////////////////////////////////////////////////////////////
144//
145BOOL LLMediaEngine::update()
146{
147 BOOL res = FALSE;
148 if( mMediaRenderer )
149 {
150 S32 result = mMediaRenderer->updateMedia();
151 switch(result)
152 {
153 case LLMediaBase::updateMediaNeedsSizeChange:
154 // Media renderer is requesting a size change.
155 handleSizeChangedRequest();
156 res = TRUE; // Need to update size of texture
157 break;
158
159 case LLMediaBase::updateMediaNeedsUpdate:
160 res = TRUE;
161 break;
162
163 case LLMediaBase::updateMediaNoChanges:
164 default:
165 res = FALSE;
166 break;
167 }
168 }
169 return res;
170}
171
172
173//////////////////////////////////////////////////////////////////////////////
174//
175BOOL LLMediaEngine::load ( const LLString& urlIn, bool web_url, const LLString& path, S32 width_pixels, S32 height_pixels )
176{
177 if( ! isAvailable() )
178 return FALSE;
179
180 if( isLoaded() )
181 return TRUE;
182
183 this->unload();
184
185 mMediaRenderer = LLMediaBase::make( LLMediaBase::QuickTime, width_pixels, height_pixels);
186
187 if( ! mMediaRenderer )
188 return FALSE;
189
190 if( ! mMediaRenderer->init() )
191 {
192 delete mMediaRenderer;
193 mMediaRenderer = 0;
194 return FALSE;
195 }
196
197 // do this here since there is no media renderer when we get the update so we store and use here
198 if( mMediaRenderer )
199 mMediaRenderer->setAutoScaled( mAutoScaled );
200
201 if( ! mMediaRenderer->load( urlIn ) )
202 {
203 delete mMediaRenderer;
204 mMediaRenderer = 0;
205 return FALSE;
206 }
207
208 return TRUE;
209}
210
211//////////////////////////////////////////////////////////////////////////////
212//
213BOOL LLMediaEngine::isLoaded()
214{
215 if( ! isAvailable() )
216 return FALSE;
217
218 if( mMediaRenderer )
219 return mMediaRenderer->isLoaded();
220 else
221 return FALSE;
222}
223
224//////////////////////////////////////////////////////////////////////////////
225//
226BOOL LLMediaEngine::unload()
227{
228 if( ! isAvailable() )
229 return FALSE;
230
231 if( mMediaRenderer )
232 {
233 mMediaRenderer->stop();
234 mMediaRenderer->unload();
235 delete mMediaRenderer;
236 mMediaRenderer = 0;
237 // Don't do this here. load() calls unload(), and things get lost.
238// mUrl.clear();
239// mImageUUID = LLUUID::null;
240 return TRUE;
241 };
242
243 return FALSE;
244};
245
246//////////////////////////////////////////////////////////////////////////////
247//
248BOOL LLMediaEngine::play()
249{
250 if( ! isAvailable() )
251 return FALSE;
252
253 // base movie volume on slider in prefs (currently prefs also sets volume directly but other controls
254 // may eventually control volume and updat ethis variable
255 this->setVolume( mVolume );
256
257 if( mMediaRenderer )
258 if( ! mMediaRenderer->play() )
259 return FALSE;
260
261 return TRUE;
262}
263
264//////////////////////////////////////////////////////////////////////////////
265//
266BOOL LLMediaEngine::loop()
267{
268 if( ! isAvailable() )
269 return FALSE;
270
271 // base movie volume on slider in prefs (currently prefs also sets volume directly but other controls
272 // may eventually control volume and updat ethis variable
273 this->setVolume( mVolume );
274
275 if( mMediaRenderer )
276 if( ! mMediaRenderer->loop( 0 ) )
277 return FALSE;
278
279 return TRUE;
280}
281
282//////////////////////////////////////////////////////////////////////////////
283//
284BOOL LLMediaEngine::pause()
285{
286 if( ! isAvailable() )
287 return FALSE;
288
289 if( mMediaRenderer )
290 if( ! mMediaRenderer->pause() )
291 return FALSE;
292
293 return TRUE;
294}
295
296//////////////////////////////////////////////////////////////////////////////
297//
298BOOL LLMediaEngine::stop()
299{
300 if( ! isAvailable() )
301 return FALSE;
302
303 if( mMediaRenderer )
304 if( ! mMediaRenderer->stop() )
305 return FALSE;
306
307 return TRUE;
308}
309
310//////////////////////////////////////////////////////////////////////////////
311//
312BOOL LLMediaEngine::seek (F64 time)
313{
314 if( ! isAvailable() )
315 return FALSE;
316
317 if( mMediaRenderer )
318 if( ! mMediaRenderer->seek (time) )
319 return FALSE;
320
321 return TRUE;
322}
323
324//////////////////////////////////////////////////////////////////////////////
325//
326void LLMediaEngine::setAvailable( BOOL availableIn )
327{
328 mAvailable = availableIn;
329}
330
331//////////////////////////////////////////////////////////////////////////////
332//
333BOOL LLMediaEngine::isAvailable()
334{
335 return mAvailable;
336}
337
338//////////////////////////////////////////////////////////////////////////////
339//
340BOOL LLMediaEngine::setVolume( F32 volumeIn )
341{
342 if( ! isAvailable() )
343 return FALSE;
344
345 mVolume = volumeIn;
346
347 if( mMediaRenderer )
348 {
349 if( ! mMediaRenderer->setVolume( volumeIn ) )
350 {
351 return FALSE;
352 };
353 };
354
355 return TRUE;
356}
357
358//////////////////////////////////////////////////////////////////////////////
359//
360void LLMediaEngine::setEnabled( BOOL enabledIn )
361{
362 if( mAvailable )
363 mEnabled = enabledIn;
364}
365
366//////////////////////////////////////////////////////////////////////////////
367//
368BOOL LLMediaEngine::isEnabled()
369{
370 if( mAvailable )
371 return mEnabled;
372 else
373 return FALSE;
374}
375
376//////////////////////////////////////////////////////////////////////////////
377//
378void LLMediaEngine::setAutoScaled( BOOL autoScaledIn )
379{
380 mAutoScaled = autoScaledIn;
381}
382
383//////////////////////////////////////////////////////////////////////////////
384//
385BOOL LLMediaEngine::isAutoScaled()
386{
387 return mAutoScaled;
388}
389
390//////////////////////////////////////////////////////////////////////////////
391//
392void LLMediaEngine::setUrl( const LLString& urlIn )
393{
394 mUrl = urlIn;
395};
396
397//////////////////////////////////////////////////////////////////////////////
398//
399const LLString& LLMediaEngine::getUrl ()
400{
401 return mUrl;
402};
403
404//////////////////////////////////////////////////////////////////////////////
405//
406void LLMediaEngine::setImageUUID( LLUUID imageUUIDIn )
407{
408 mImageUUID = imageUUIDIn;
409};
410
411//////////////////////////////////////////////////////////////////////////////
412//
413LLUUID LLMediaEngine::getImageUUID()
414{
415 return mImageUUID;
416};
417
418//////////////////////////////////////////////////////////////////////////////
419//
420void LLMediaEngine::handleSizeChangedRequest()
421{
422 if( ! isAvailable() )
423 return;
424
425 // create / resize Raw image
426 LLMediaEngine::getInstance()->createImageRaw();
427
428 // tell media library to use this buffer instead of it's own
429 if (mImageRaw.notNull())
430 {
431 LLMediaEngine::getInstance()->getMediaRenderer()->setBuffer( mImageRaw->getData() );
432 }
433
434}
435
436//////////////////////////////////////////////////////////////////////////////////////////
437// static
438void LLMediaEngine::convertImageAndLoadUrl( bool enableLooping, bool web_url, const std::string& path)
439{
440 LLMediaEngine* engine = LLMediaEngine::getInstance();
441 LLString url = engine->getUrl();
442 S32 width_pixels = 512;
443 S32 height_pixels = 256;
444 if (web_url)
445 {
446 width_pixels = 512;
447 height_pixels = 512;
448 }
449
450 bool success = false;
451 if (engine->load( url, web_url, path, width_pixels, height_pixels ) )
452 {
453 // create / resize Raw image
454 engine->createImageRaw();
455
456 // tell media library to use this buffer instead of it's own
457 if (engine->getImageRaw())
458 {
459 engine->getMediaRenderer()->setBuffer( engine->mImageRaw->getData() );
460 engine->getMediaRenderer()->setBufferSize(width_pixels, height_pixels);
461
462 // start it playing or looping
463 if( enableLooping )
464 {
465 engine->loop();
466 }
467 else
468 {
469 engine->play();
470 }
471 success = true;
472 }
473 }
474
475 if (!success)
476 {
477 llinfos << "MEDIA> unable to load " << LLMediaEngine::getInstance()->getUrl() << llendl;
478 //LLMediaEngine::getInstance()->setAvailable( FALSE );
479 }
480}
481
482//////////////////////////////////////////////////////////////////////////////////////////
483// static
484void LLMediaEngine::process_parcel_media( LLMessageSystem *msg, void ** )
485{
486 // extract the agent id
487 // LLUUID agent_id;
488 // msg->getUUID( agent_id );
489
490 U32 flags;
491 U32 command;
492 F32 time;
493 msg->getU32( "CommandBlock", "Flags", flags );
494 msg->getU32( "CommandBlock", "Command", command);
495 msg->getF32( "CommandBlock", "Time", time );
496
497 if (flags &( (1<<PARCEL_MEDIA_COMMAND_STOP)
498 | (1<<PARCEL_MEDIA_COMMAND_PAUSE)
499 | (1<<PARCEL_MEDIA_COMMAND_PLAY)
500 | (1<<PARCEL_MEDIA_COMMAND_LOOP)
501 | (1<<PARCEL_MEDIA_COMMAND_UNLOAD) ))
502 {
503 // stop
504 if( command == PARCEL_MEDIA_COMMAND_STOP )
505 {
506 //llinfos << ">>> LLMediaEngine::process_parcel_media with command = " <<( '0' + command ) << llendl;
507
508 LLMediaEngine::getInstance()->stop();
509 }
510 else
511 // pause
512 if( command == PARCEL_MEDIA_COMMAND_PAUSE )
513 {
514 //llinfos << ">>> LLMediaEngine::process_parcel_media with command = " <<( '0' + command ) << llendl;
515
516 LLMediaEngine::getInstance()->pause();
517 }
518 else
519 // play
520 if( command == PARCEL_MEDIA_COMMAND_PLAY )
521 {
522 //llinfos << ">>> LLMediaEngine::process_parcel_media with command = " <<( '0' + command ) << llendl;
523
524 convertImageAndLoadUrl( false, false, std::string() );
525 }
526 else
527 // loop
528 if( command == PARCEL_MEDIA_COMMAND_LOOP )
529 {
530 //llinfos << ">>> LLMediaEngine::process_parcel_media with command = " <<( '0' + command ) << llendl;
531
532 // huh? what is play?
533 //convertImageAndLoadUrl( play );
534 convertImageAndLoadUrl( true, false, std::string() );
535 }
536 else
537 // unload
538 if( command == PARCEL_MEDIA_COMMAND_UNLOAD )
539 {
540 //llinfos << ">>> LLMediaEngine::process_parcel_media with command = " <<( '0' + command ) << llendl;
541
542 if (LLMediaEngine::getInstance()->isLoaded())
543 {
544 LLMediaEngine::getInstance()->unload();
545 LLMediaEngine::getInstance()->destroyImageRaw();
546 }
547 }
548 }
549
550 if (flags & (1<<PARCEL_MEDIA_COMMAND_TIME))
551 {
552 // do something about fast forward
553 LLMediaEngine::getInstance()->seek(time);
554 }
555}
556
557//////////////////////////////////////////////////////////////////////////////////////////
558// static
559/*
560// ParcelMediaUpdate
561// Sends a parcel media update to a single user
562// For global updates use the parcel manager.
563{
564 ParcelMediaUpdate Low NotTrusted Unencoded
565 {
566 DataBlock Single
567 { MediaURL Variable 1 } // string
568 { MediaID LLUUID }
569 { MediaAutoScale U8 }
570 }
571}
572*/
573void LLMediaEngine::process_parcel_media_update( LLMessageSystem *msg, void ** )
574{
575 LLUUID media_uuid;
576 char media_url[255]; /* Flawfinder: ignore */
577 U8 auto_align;
578 msg->getUUID( "DataBlock", "MediaID", media_uuid );
579 msg->getString( "DataBlock", "MediaURL", 255, media_url );
580 msg->getU8( "DataBlock", "MediaAutoScale", auto_align );
581
582 LLMediaEngine* media_engine = LLMediaEngine::getInstance();
583 LLString url_string ( media_url );
584
585 auto_align = (auto_align) ? TRUE : FALSE;
586
587 if( !( (media_engine->getUrl() == url_string)
588 && (media_engine->getImageUUID() == media_uuid)
589 && (media_engine->isAutoScaled() == auto_align ) ) )
590 {
591 if (media_engine->isLoaded())
592 {
593 media_engine->unload();
594 media_engine->destroyImageRaw();
595 }
596
597 media_engine->setUrl(url_string);
598 media_engine->setImageUUID(media_uuid);
599 media_engine->setAutoScaled(auto_align);
600 }
601}
602
603// sets proxy information for any of the media impls that may want to use it
604void LLMediaEngine::setNetworkProxy ( BOOL enabledIn, const LLString& addressIn,
605 S32 portIn, S32 socksIn, const LLString& excludeIn )
606{
607 mProxyEnabled = enabledIn;
608 mProxyAddress = addressIn;
609 mProxyPort = portIn;
610 mProxySocks = socksIn;
611 mProxyExlude = excludeIn;
612}
613
614// gets proxy information for any of the media impls that may want to use it
615void LLMediaEngine::getNetworkProxy ( BOOL& enabledOut, LLString& addressOut,
616 S32& portOut, S32& socksOut, LLString& excludeOut )
617{
618 enabledOut = mProxyEnabled;
619 addressOut = mProxyAddress;
620 portOut = mProxyPort;
621 socksOut = mProxySocks;
622 excludeOut = mProxyExlude;
623}
624
625// get QuickTime version (returned as a number which
626// only makes sense viewed as hex
627S32 LLMediaEngine::getQuickTimeVersion()
628{
629#if LL_QUICKTIME_ENABLED
630 return LLMediaImplQuickTime::getVersion();
631#else
632 return -1;
633#endif
634}
635
diff --git a/linden/indra/llmedia/llmediaengine.h b/linden/indra/llmedia/llmediaengine.h
deleted file mode 100644
index 4cae070..0000000
--- a/linden/indra/llmedia/llmediaengine.h
+++ /dev/null
@@ -1,150 +0,0 @@
1/**
2 * @file llmediaengine.h
3 * @brief Top level media engine - wraps more specific functionality.
4 *
5 * $LicenseInfo:firstyear=2005&license=viewergpl$
6 *
7 * Copyright (c) 2005-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#ifndef LLMEDIAENGINE_H
33#define LLMEDIAENGINE_H
34
35#include "linden_common.h"
36#include "lluuid.h"
37#include "llimage.h"
38
39#include "llmediabase.h"
40#include "llmediaobservers.h"
41
42
43#include "message.h"
44
45// older: after a 7.3.1 update version is 120684544 (dec) and 7318000 (hex)
46// older: current version on my Windows system after a 7.4 update version is 121667584 (dec) and 7408000 (hex)
47// current version on my Windows system after a 7.4.1 update version is 121733120 (dec) and 7418000 (hex)
48
49#define LL_MIN_QUICKTIME_VERSION ( 0x7418000 ) // QT 7.4.1
50
51//////////////////////////////////////////////////////////////////////////////
52// media engine singleton
53class LLMediaEngine
54{
55public:
56 static void initClass();
57 static void updateClass(F32 volume);
58 static void cleanupClass();
59
60protected:
61 // don't let anyone else make one of these
62 LLMediaEngine ();
63
64public:
65 virtual ~LLMediaEngine ();
66
67 // used to get access to single instance of the class (singleton pattern)
68 static LLMediaEngine* getInstance ();
69
70 // public methods
71 BOOL init ();
72 BOOL update ();
73
74 // Pass web_url true if it's a web page, false if it's a movie.
75 // path is to mozilla directory for mozilla
76 BOOL load( const LLString& urlIn, bool web_url, const LLString& path, S32 width_pixels, S32 height_pixels);
77
78 BOOL isLoaded ();
79 BOOL unload ();
80 BOOL play ();
81 BOOL loop ();
82 BOOL pause ();
83 BOOL stop ();
84 BOOL seek (F64 time);
85 void setAvailable ( BOOL availableIn );
86 BOOL isAvailable ();
87 void setEnabled ( BOOL enabledIn );
88 BOOL isEnabled ();
89 void setAutoScaled ( BOOL autoScaledIn );
90 BOOL isAutoScaled ();
91 BOOL setVolume ( F32 volumeIn );
92 S32 getQuickTimeVersion();
93
94 void setUrl ( const LLString& urlIn );
95 const LLString& getUrl ();
96 void setImageUUID ( LLUUID textureIdIn );
97 LLUUID getImageUUID ();
98
99 // MBW -- XXX -- This should return a LLMediaMovieBase, but the web and movie media classes still haven't been
100 // fully disentangled.
101 LLMediaBase* getMediaRenderer();
102 LLImageRaw* getImageRaw() { return mImageRaw; }
103 void handleSizeChangedRequest();
104
105 //////////////////////////////////////////////////////////////////////////////////////////
106 //
107 static void convertImageAndLoadUrl ( bool enableLooping, bool web_url, const std::string& path);
108
109 //////////////////////////////////////////////////////////////////////////////////////////
110 //
111 static void process_parcel_media ( LLMessageSystem *msg, void ** );
112 static void process_parcel_media_update ( LLMessageSystem *msg, void ** );
113
114 // proxy configuration
115 void setNetworkProxy ( BOOL enabledIn, const LLString& addressIn,
116 S32 portIn, S32 socksIn, const LLString& excludeIn );
117
118 void getNetworkProxy ( BOOL& enabledOut, LLString& addressOut,
119 S32& portOut, S32& socksOut, LLString& excludeOuy );
120
121private:
122 void createImageRaw();
123 void destroyImageRaw();
124
125private:
126 BOOL mAvailable;
127 BOOL mEnabled;
128 BOOL mAutoScaled;
129 LLString mUrl;
130 // MBW -- XXX -- This should be a LLMediaMovieBase, but the web and movie media classes still haven't been
131 // fully disentangled.
132 LLMediaBase* mMediaRenderer;
133 LLPointer<LLImageRaw> mImageRaw;
134
135 LLUUID mImageUUID;
136 F32 mVolume;
137
138 // proxy information
139 BOOL mProxyEnabled;
140 LLString mProxyAddress;
141 S32 mProxyPort;
142 S32 mProxySocks;
143 LLString mProxyExlude;
144
145private:
146 static LLMediaEngine* sInstance;
147};
148
149#endif // LLMEDIAENGINE_H
150
diff --git a/linden/indra/llmedia/llmediaimplcommon.cpp b/linden/indra/llmedia/llmediaimplcommon.cpp
new file mode 100644
index 0000000..a0705bb
--- /dev/null
+++ b/linden/indra/llmedia/llmediaimplcommon.cpp
@@ -0,0 +1,540 @@
1/**
2 * @file llmediaimplcommon.cpp
3 * @brief Common impl functionality
4 *
5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 *
7 * Copyright (c) 2007-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "llmediaimplcommon.h"
33#include "llmediaemitter.h"
34#include "llmediaimplfactory.h"
35#include "llmediaobserver.h"
36
37#ifdef WIN32
38 // platform specific includes needed before OpenGL header
39 #include <windows.h>
40 #include <GL/gl.h>
41#elif defined(__APPLE__)
42 // framework-style include path when building on the Mac.
43 #include <OpenGL/gl.h>
44#else // Assume this is linux
45 // Linux, MESA headers, but not necessarily assuming MESA runtime.
46 // quotes so we get libraries/.../GL/ version
47 #include "GL/gl.h"
48#endif
49
50////////////////////////////////////////////////////////////////////////////////
51// virtual (derives from LLMediaBase)
52LLMediaImplCommon::LLMediaImplCommon() :
53 mMimeType( std::string() ),
54 mInitialURL( std::string() ),
55 mAutoScaled( false ),
56 mMediaWidth( 0 ),
57 mMediaPrevWidth( 0 ),
58 mMediaHeight( 0 ),
59 mMediaPrevHeight( 0 ),
60 mMediaDepth( 0 ),
61 mMediaPrevDepth( 0 ),
62 mMediaRowSpan( 0 ),
63 mMediaRequestedWidth( 0 ),
64 mMediaRequestedHeight( 0 ),
65 mCommand( LLMediaBase::COMMAND_NONE ),
66 mStatus( LLMediaBase::STATUS_UNKNOWN ),
67 mVolume( 0 ),
68 mLooping( false )
69{
70}
71
72////////////////////////////////////////////////////////////////////////////////
73// virtual (derives from LLMediaBase)
74LLMediaImplCommon::~LLMediaImplCommon()
75{
76}
77
78////////////////////////////////////////////////////////////////////////////////
79// virtual (derives from LLMediaBase)
80bool LLMediaImplCommon::init()
81{
82 return false;
83}
84
85////////////////////////////////////////////////////////////////////////////////
86// virtual (derives from LLMediaBase)
87bool LLMediaImplCommon::reset()
88{
89 return false;
90}
91
92////////////////////////////////////////////////////////////////////////////////
93// virtual (derives from LLMediaBase)
94bool LLMediaImplCommon::setMimeType( const std::string mime_type )
95{
96 mMimeType = mime_type;
97
98 return true;
99}
100
101////////////////////////////////////////////////////////////////////////////////
102// virtual (derives from LLMediaBase)
103std::string LLMediaImplCommon::getMimeType() const
104{
105 return mMimeType;
106}
107
108////////////////////////////////////////////////////////////////////////////////
109// virtual (derives from LLMediaBase)
110std::string LLMediaImplCommon::getMediaURL() const
111{
112 return mInitialURL;
113}
114
115////////////////////////////////////////////////////////////////////////////////
116// virtual (derives from LLMediaBase)
117std::string LLMediaImplCommon::getVersion()
118{
119 return std::string( "" );
120}
121
122////////////////////////////////////////////////////////////////////////////////
123// virtual (derives from LLMediaBase)
124bool LLMediaImplCommon::set404RedirectUrl( std::string redirect_url )
125{
126 return true;
127}
128
129////////////////////////////////////////////////////////////////////////////////
130// virtual (derives from LLMediaBase)
131bool LLMediaImplCommon::clr404RedirectUrl()
132{
133 return true;
134}
135
136////////////////////////////////////////////////////////////////////////////////
137// virtual (derives from LLMediaBase)
138bool LLMediaImplCommon::setBackgroundColor( unsigned int red, unsigned int green, unsigned int blue ) const
139{
140 return true;
141}
142
143////////////////////////////////////////////////////////////////////////////////
144// virtual (derives from LLMediaBase)
145bool LLMediaImplCommon::setCaretColor( unsigned int red, unsigned int green, unsigned int blue ) const
146{
147 return true;
148}
149
150////////////////////////////////////////////////////////////////////////////////
151// virtual (derives from LLMediaBase)
152bool LLMediaImplCommon::updateMedia()
153{
154 return false;
155}
156
157////////////////////////////////////////////////////////////////////////////////
158// virtual (derives from LLMediaBase)
159unsigned char* LLMediaImplCommon::getMediaData()
160{
161 return 0;
162}
163
164////////////////////////////////////////////////////////////////////////////////
165// virtual (derives from LLMediaBase)
166int LLMediaImplCommon::getMediaDataWidth() const
167{
168 return getMediaWidth();
169}
170
171////////////////////////////////////////////////////////////////////////////////
172// virtual (derives from LLMediaBase)
173int LLMediaImplCommon::getMediaDataHeight() const
174{
175 return getMediaHeight();
176}
177
178
179////////////////////////////////////////////////////////////////////////////////
180// virtual (derives from LLMediaBase)
181bool LLMediaImplCommon::setMediaSize( int media_width, int media_height )
182{
183 // if nothing changed, don't do anything
184 if ( ( mMediaWidth == media_width ) &&
185 ( mMediaHeight == media_height ) )
186 return false;
187
188 // save old values so we can tell elsewhere if media size has changed
189 mMediaPrevWidth = mMediaWidth;
190 mMediaPrevHeight = mMediaHeight;
191
192 mMediaWidth = media_width;
193 mMediaHeight = media_height;
194
195 // only fire an event if the width changed
196 LLMediaEvent event( this );
197 mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event );
198
199 return true;
200}
201
202////////////////////////////////////////////////////////////////////////////////
203// virtual (derives from LLMediaBase)
204int LLMediaImplCommon::getMediaWidth() const
205{
206 return mMediaWidth;
207}
208
209
210////////////////////////////////////////////////////////////////////////////////
211// virtual (derives from LLMediaBase)
212int LLMediaImplCommon::getMediaHeight() const
213{
214 return mMediaHeight;
215}
216
217////////////////////////////////////////////////////////////////////////////////
218// virtual (derives from LLMediaBase)
219bool LLMediaImplCommon::setRequestedMediaSize(int width, int height)
220{
221 mMediaRequestedWidth = width;
222 mMediaRequestedHeight = height;
223
224 return true;
225}
226
227////////////////////////////////////////////////////////////////////////////////
228// virtual (derives from LLMediaBase)
229bool LLMediaImplCommon::setMediaDepth( int media_depth )
230{
231 // if nothing changed, don't do anything
232 if ( mMediaDepth == media_depth )
233 return false;
234
235 // save old values so we can tell elsewhere if media size has changed
236 mMediaPrevDepth = mMediaDepth;
237 mMediaDepth = media_depth;
238
239 // update value of rowspan too since it's based on media width & depth
240 mMediaRowSpan = mMediaWidth * mMediaDepth;
241
242 // only fire an event if the depth changed
243 //LLMediaEvent event( this );
244 //mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event );
245
246 return true;
247}
248
249////////////////////////////////////////////////////////////////////////////////
250// virtual (derives from LLMediaBase)
251int LLMediaImplCommon::getMediaDepth() const
252{
253 return mMediaDepth;
254}
255
256////////////////////////////////////////////////////////////////////////////////
257// virtual (derives from LLMediaBase)
258int LLMediaImplCommon::getMediaBufferSize() const
259{
260 return mMediaRowSpan * mMediaHeight;
261}
262
263////////////////////////////////////////////////////////////////////////////////
264// virtual (derives from LLMediaBase)
265int LLMediaImplCommon::getTextureFormatInternal() const
266{
267 return LL_MEDIA_RGB;
268}
269
270////////////////////////////////////////////////////////////////////////////////
271// virtual (derives from LLMediaBase)
272int LLMediaImplCommon::getTextureFormatPrimary() const
273{
274 return LL_MEDIA_RGB;
275}
276
277////////////////////////////////////////////////////////////////////////////////
278// virtual (derives from LLMediaBase)
279int LLMediaImplCommon::getTextureFormatType() const
280{
281 return LL_MEDIA_UNSIGNED_BYTE;
282}
283
284////////////////////////////////////////////////////////////////////////////////
285// virtual (derives from LLMediaBase)
286bool LLMediaImplCommon::setVolume( float volume )
287{
288 mVolume = volume;
289
290 return true;
291}
292
293////////////////////////////////////////////////////////////////////////////////
294// virtual (derives from LLMediaBase)
295float LLMediaImplCommon::getVolume() const
296{
297 return mVolume;
298}
299
300////////////////////////////////////////////////////////////////////////////////
301// virtual (derives from LLMediaBase)
302bool LLMediaImplCommon::addCommand( LLMediaBase::ECommand cmd )
303{
304 // eventually will be a std::queue so you can add multiple commands
305 mCommand = cmd;
306
307 return true;
308}
309
310////////////////////////////////////////////////////////////////////////////////
311// virtual (derives from LLMediaBase)
312bool LLMediaImplCommon::clearCommand()
313{
314 // eventually will be a std::queue so you can add multiple commands
315 mCommand = LLMediaBase::COMMAND_NONE;
316
317 return true;
318}
319
320////////////////////////////////////////////////////////////////////////////////
321// virtual (derives from LLMediaBase)
322bool LLMediaImplCommon::updateCommand()
323{
324 if ( nextCommand() == LLMediaBase::COMMAND_START )
325 {
326 setStatus( LLMediaBase::STATUS_STARTED );
327 clearCommand();
328 };
329
330 if ( nextCommand() == LLMediaBase::COMMAND_STOP )
331 {
332 setStatus( LLMediaBase::STATUS_STOPPED );
333 clearCommand();
334 };
335
336 if ( nextCommand() == LLMediaBase::COMMAND_PAUSE )
337 {
338 setStatus( LLMediaBase::STATUS_PAUSED );
339 clearCommand();
340 };
341
342 return true;
343}
344
345////////////////////////////////////////////////////////////////////////////////
346// non-virtual (only impls use this)
347LLMediaBase::ECommand LLMediaImplCommon::nextCommand()
348{
349 return mCommand;
350}
351
352////////////////////////////////////////////////////////////////////////////////
353// virtual (derives from LLMediaBase)
354LLMediaBase::EStatus LLMediaImplCommon::getStatus()
355{
356 return mStatus;
357}
358
359////////////////////////////////////////////////////////////////////////////////
360// non-virtual (only impls set this)
361bool LLMediaImplCommon::setStatus( LLMediaBase::EStatus status )
362{
363 mStatus = status;
364
365 return true;
366}
367
368////////////////////////////////////////////////////////////////////////////////
369// virtual (derives from LLMediaBase)
370bool LLMediaImplCommon::seek( double time )
371{
372 return false;
373}
374
375////////////////////////////////////////////////////////////////////////////////
376// virtual (derives from LLMediaBase)
377bool LLMediaImplCommon::navigateTo( const std::string url )
378{
379 return false;
380}
381
382////////////////////////////////////////////////////////////////////////////////
383// virtual (derives from LLMediaBase)
384bool LLMediaImplCommon::setAutoScaled( bool auto_scaled )
385{
386 mAutoScaled = auto_scaled;
387
388 return true;
389}
390
391////////////////////////////////////////////////////////////////////////////////
392// virtual (derives from LLMediaBase)
393bool LLMediaImplCommon::isAutoScaled() const
394{
395 return mAutoScaled;
396}
397
398////////////////////////////////////////////////////////////////////////////////
399// virtual (derives from LLMediaBase)
400bool LLMediaImplCommon::mouseDown( int x_pos, int y_pos )
401{
402 return false;
403}
404
405////////////////////////////////////////////////////////////////////////////////
406// virtual (derives from LLMediaBase)
407bool LLMediaImplCommon::mouseUp( int x_pos, int y_pos )
408{
409 return false;
410}
411
412////////////////////////////////////////////////////////////////////////////////
413// virtual (derives from LLMediaBase)
414bool LLMediaImplCommon::mouseMove( int x_pos, int y_pos )
415{
416 return false;
417}
418
419////////////////////////////////////////////////////////////////////////////////
420// virtual (derives from LLMediaBase)
421bool LLMediaImplCommon::keyPress( int key_code )
422{
423 return false;
424}
425
426////////////////////////////////////////////////////////////////////////////////
427// virtual (derives from LLMediaBase)
428bool LLMediaImplCommon::scrollByLines( int lines )
429{
430 return false;
431}
432
433////////////////////////////////////////////////////////////////////////////////
434// virtual (derives from LLMediaBase)
435bool LLMediaImplCommon::focus( bool focus )
436{
437 return false;
438}
439
440////////////////////////////////////////////////////////////////////////////////
441// virtual (derives from LLMediaBase)
442bool LLMediaImplCommon::unicodeInput( unsigned long uni_char )
443{
444 return false;
445}
446
447////////////////////////////////////////////////////////////////////////////////
448// virtual (derives from LLMediaBase)
449bool LLMediaImplCommon::mouseLeftDoubleClick( int x_pos, int y_pos )
450{
451 return false;
452}
453
454////////////////////////////////////////////////////////////////////////////////
455// virtual (derives from LLMediaBase)
456bool LLMediaImplCommon::navigateForward()
457{
458 return false;
459}
460
461////////////////////////////////////////////////////////////////////////////////
462// virtual (derives from LLMediaBase)
463bool LLMediaImplCommon::navigateBack()
464{
465 return false;
466}
467
468////////////////////////////////////////////////////////////////////////////////
469// virtual (derives from LLMediaBase)
470bool LLMediaImplCommon::canNavigateForward()
471{
472 return false;
473}
474
475////////////////////////////////////////////////////////////////////////////////
476// virtual (derives from LLMediaBase)
477bool LLMediaImplCommon::canNavigateBack()
478{
479 return false;
480}
481
482////////////////////////////////////////////////////////////////////////////////
483// virtual (derives from LLMediaBase)
484bool LLMediaImplCommon::enableCookies( bool enable )
485{
486 return false;
487}
488
489////////////////////////////////////////////////////////////////////////////////
490// virtual (derives from LLMediaBase)
491bool LLMediaImplCommon::clearCache()
492{
493 return false;
494}
495
496////////////////////////////////////////////////////////////////////////////////
497// virtual (derives from LLMediaBase)
498bool LLMediaImplCommon::clearCookies()
499{
500 return false;
501}
502
503////////////////////////////////////////////////////////////////////////////////
504// virtual (derives from LLMediaBase)
505bool LLMediaImplCommon::enableProxy(bool enable, std::string proxy_host_name, int proxy_port)
506{
507 return false;
508}
509////////////////////////////////////////////////////////////////////////////////
510//
511bool LLMediaImplCommon::addObserver( LLMediaObserver* subject )
512{
513 return mEventEmitter.addObserver( subject );
514}
515
516////////////////////////////////////////////////////////////////////////////////
517//
518bool LLMediaImplCommon::remObserver( LLMediaObserver* subject )
519{
520 return mEventEmitter.remObserver( subject );
521}
522
523////////////////////////////////////////////////////////////////////////////////
524//
525void LLMediaImplCommon::setImplMaker(LLMediaImplMakerBase* impl_maker)
526{
527 mImplMaker = impl_maker;
528}
529////////////////////////////////////////////////////////////////////////////////
530//
531bool LLMediaImplCommon::supportsMediaType(std::string scheme, std::string type)
532{
533 int idx1 = type.find("/");
534 int len = (idx1 == std::string::npos) ? 0 : idx1;
535 std::string category = type.substr(0,len);
536
537 return mImplMaker->supportsScheme(scheme) ||
538 mImplMaker->supportsMimeType(type) ||
539 mImplMaker->supportsMimeTypeCategory(category);
540}
diff --git a/linden/indra/llmedia/llmediaimplcommon.h b/linden/indra/llmedia/llmediaimplcommon.h
new file mode 100644
index 0000000..aa6c4d5
--- /dev/null
+++ b/linden/indra/llmedia/llmediaimplcommon.h
@@ -0,0 +1,161 @@
1/**
2 * @file llmediaimplcommon.h
3 * @brief Common impl functionality
4 *
5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 *
7 * Copyright (c) 2007-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#ifndef LLMEDIAIMPLCOMMON_H
33#define LLMEDIAIMPLCOMMON_H
34
35#include "llmediabase.h"
36#include "llmediaemitter.h"
37#include "llmediaobserver.h"
38
39#include <string>
40
41class LLMediaImplMakerBase;
42
43class LLMediaImplCommon :
44 public LLMediaBase
45{
46 public:
47 LLMediaImplCommon();
48 virtual ~LLMediaImplCommon();
49
50 ////////////////////////////////////////////////////////////////////////////////
51 // begin: default implementation of the abstract interface
52 // see llmediabase.h for documentation
53
54 // housekeeping
55 virtual bool init();
56 virtual bool reset();
57 virtual bool setMimeType( const std::string url );
58 virtual std::string getMimeType() const;
59 virtual std::string getMediaURL() const;
60 virtual std::string getVersion();
61 virtual bool set404RedirectUrl( std::string redirect_url );
62 virtual bool clr404RedirectUrl();
63 virtual bool setBackgroundColor( unsigned int red, unsigned int green, unsigned int blue ) const;
64 virtual bool setCaretColor( unsigned int red, unsigned int green, unsigned int blue ) const;
65
66 // media management
67 virtual bool updateMedia();
68 virtual bool setRequestedMediaSize( int width, int height );
69 virtual int getMediaWidth() const;
70 virtual int getMediaHeight() const;
71 virtual int getMediaDepth() const;
72 virtual int getMediaBufferSize() const;
73 virtual unsigned char* getMediaData();
74 virtual int getMediaDataWidth() const;
75 virtual int getMediaDataHeight() const;
76
77 // texture management
78 virtual int getTextureFormatInternal() const;
79 virtual int getTextureFormatPrimary() const;
80 virtual int getTextureFormatType() const;
81
82 // audio
83 virtual bool setVolume( float volume );
84 virtual float getVolume() const;
85
86 // transport control
87 virtual bool addCommand( ECommand cmd );
88 virtual bool clearCommand();
89 virtual bool updateCommand();
90 LLMediaBase::ECommand nextCommand();
91 virtual LLMediaBase::EStatus getStatus();
92 bool setStatus( LLMediaBase::EStatus status );
93
94 virtual bool seek( double time );
95 virtual bool setLooping(bool enable) { mLooping = enable; return true; }
96 virtual bool isLooping() { return mLooping; }
97 virtual bool navigateTo( const std::string url );
98
99 // scaling
100 virtual bool setAutoScaled( bool auto_scaled );
101 virtual bool isAutoScaled() const;
102
103 // mouse and keyboard interaction
104 virtual bool mouseDown( int x_pos, int y_pos );
105 virtual bool mouseUp( int x_pos, int y_pos );
106 virtual bool mouseMove( int x_pos, int y_pos );
107 virtual bool keyPress( int key_code );
108 virtual bool scrollByLines( int lines );
109 virtual bool focus( bool focus );
110 virtual bool unicodeInput( unsigned long uni_char );
111 virtual bool mouseLeftDoubleClick( int x_pos, int y_pos );
112
113 // navigation
114 virtual bool navigateForward();
115 virtual bool navigateBack();
116 virtual bool canNavigateForward();
117 virtual bool canNavigateBack();
118
119 // caching/cookies
120 virtual bool enableCookies( bool enable );
121 virtual bool clearCache();
122 virtual bool clearCookies();
123
124 virtual bool enableProxy(bool enable, std::string proxy_host_name, int proxy_port);
125
126 // observer interface
127 bool addObserver( LLMediaObserver* subject );
128 bool remObserver( LLMediaObserver* subject );
129
130 // type registry interface
131 void setImplMaker(LLMediaImplMakerBase* impl_maker);
132 bool supportsMediaType(std::string scheme, std::string type);
133
134 protected:
135 virtual bool setMediaSize( int width, int height );
136 virtual bool setMediaDepth( int media_depth );
137
138 LLMediaEmitter< LLMediaObserver > mEventEmitter;
139
140 // Back pointer to the construction object, which is used to discover types handled
141 // by the Impl, and meta data associated with the Impl.
142 LLMediaImplMakerBase* mImplMaker;
143 std::string mMimeType;
144 std::string mInitialURL;
145 bool mAutoScaled;
146 int mMediaWidth;
147 int mMediaPrevWidth;
148 int mMediaHeight;
149 int mMediaPrevHeight;
150 int mMediaDepth;
151 int mMediaPrevDepth;
152 int mMediaRowSpan;
153 int mMediaRequestedWidth;
154 int mMediaRequestedHeight;
155 float mVolume;
156 LLMediaBase::ECommand mCommand;
157 LLMediaBase::EStatus mStatus;
158 bool mLooping;
159};
160
161#endif // LLMEDIAIMPLCOMMON_H
diff --git a/linden/indra/llmedia/llmediaimplexample1.cpp b/linden/indra/llmedia/llmediaimplexample1.cpp
new file mode 100644
index 0000000..03e8291
--- /dev/null
+++ b/linden/indra/llmedia/llmediaimplexample1.cpp
@@ -0,0 +1,228 @@
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-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "llmediaimplexample1.h"
33#include "llmediaimplregister.h"
34
35// register this impl with media manager factory
36static LLMediaImplRegister sLLMediaImplExample1Reg( "LLMediaImplExample1", new LLMediaImplExample1Maker() );
37
38#include <iostream>
39
40#include <time.h>
41
42///////////////////////////////////////////////////////////////////////////////
43//
44LLMediaImplExample1Maker::LLMediaImplExample1Maker()
45{
46 // Register to handle the scheme
47 mSchema.push_back( "example1" );
48}
49
50///////////////////////////////////////////////////////////////////////////////
51//
52LLMediaImplExample1::LLMediaImplExample1() :
53 mMediaPixels( 0 )
54{
55 setRequestedMediaSize( 400, 200 );
56 setMediaDepth( 3 );
57
58 srand( (unsigned int)(time( NULL )) );
59}
60
61////////////////////////////////////////////////////////////////////////////////
62// (static) super-initialization - called once at application startup
63bool LLMediaImplExample1::startup( LLMediaManagerData* init_data )
64{
65 return true;
66}
67
68////////////////////////////////////////////////////////////////////////////////
69// (static) super-uninitialization - called once at application closedown
70bool LLMediaImplExample1::closedown()
71{
72 return true;
73}
74
75////////////////////////////////////////////////////////////////////////////////
76// virtual
77bool LLMediaImplExample1::init()
78{
79 int buffer_size = getMediaBufferSize();
80
81 mMediaPixels = new unsigned char[ buffer_size ];
82
83 memset( mMediaPixels, 0xAA, buffer_size );
84
85 return true;
86}
87
88////////////////////////////////////////////////////////////////////////////////
89// virtual
90bool LLMediaImplExample1::navigateTo( const std::string url )
91{
92 std::cout << "LLMediaImplExample1::navigateTo" << std::endl;
93
94 setStatus( LLMediaBase::STATUS_NAVIGATING );
95
96 // force a size change event for new URL
97 LLMediaEvent event( this );
98 mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event );
99
100 return true;
101}
102
103////////////////////////////////////////////////////////////////////////////////
104// virtual
105std::string LLMediaImplExample1::getVersion()
106{
107 std::string version_string = "[" + sLLMediaImplExample1Reg.getImplName() + "] - " + "1.0.0.0";
108
109 return version_string;
110}
111
112////////////////////////////////////////////////////////////////////////////////
113// virtual
114bool LLMediaImplExample1::updateMedia()
115{
116 if ( mMediaPixels && getStatus() == LLMediaBase::STATUS_STARTED )
117 {
118 // first time - make sure it's a few seconds back so first update happens immediately
119 static time_t t = time( 0 ) - 4;
120
121 // selected time period elapsed (1 second)
122 if ( time( 0 ) - t > 1 )
123 {
124 // display checkerboard
125 const int num_squares = rand() % 20 + 4;
126 int sqr1_r = rand() % 0x80;
127 int sqr1_g = rand() % 0x80;
128 int sqr1_b = rand() % 0x80;
129 int sqr2_r = rand() % 0x80;
130 int sqr2_g = rand() % 0x80;
131 int sqr2_b = rand() % 0x80;
132
133 for ( int y1 = 0; y1 < num_squares; ++y1 )
134 {
135 for ( int x1 = 0; x1 < num_squares; ++x1 )
136 {
137 int px_start = getMediaWidth() * x1 / num_squares;
138 int px_end = ( getMediaWidth() * ( x1 + 1 ) ) / num_squares;
139 int py_start = getMediaHeight() * y1 / num_squares;
140 int py_end = ( getMediaHeight() * ( y1 + 1 ) ) / num_squares;
141
142 for( int y2 = py_start; y2 < py_end; ++y2 )
143 {
144 for( int x2 = px_start; x2 < px_end; ++x2 )
145 {
146 int rowspan = getMediaWidth() * getMediaDepth();
147
148 if ( ( y1 % 2 ) ^ ( x1 % 2 ) )
149 {
150 mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 0 ] = sqr1_r;
151 mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 1 ] = sqr1_g;
152 mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 2 ] = sqr1_b;
153 }
154 else
155 {
156 mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 0 ] = sqr2_r;
157 mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 1 ] = sqr2_g;
158 mMediaPixels[ y2 * rowspan + x2 * getMediaDepth() + 2 ] = sqr2_b;
159 };
160 };
161 };
162 };
163 };
164
165 // emit an event to say that something in the media stream changed
166 LLMediaEvent event( this );
167 mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event );
168
169 // reset time
170 t = time( 0 );
171
172 return true;
173 };
174 };
175
176 // update the command (e.g. transport controls) state
177 updateCommand();
178
179 return false;
180}
181
182////////////////////////////////////////////////////////////////////////////////
183// virtual
184unsigned char* LLMediaImplExample1::getMediaData()
185{
186 return mMediaPixels;
187}
188
189////////////////////////////////////////////////////////////////////////////////
190// virtual
191bool LLMediaImplExample1::reset()
192{
193 if ( mMediaPixels )
194 {
195 delete [] mMediaPixels;
196 };
197
198 return true;
199}
200
201////////////////////////////////////////////////////////////////////////////////
202// virtual
203bool LLMediaImplExample1::mouseMove( int x_pos, int y_pos )
204{
205 if ( mMediaPixels && getStatus() == LLMediaBase::STATUS_STARTED )
206 {
207 int base_pos = x_pos * getMediaDepth() + y_pos * getMediaDepth() * getMediaWidth();
208 // example: write a bright pixel to the display when we move the mouse
209 mMediaPixels[ base_pos + 0 ] = rand() % 0x80 + 0x80;
210 mMediaPixels[ base_pos + 1 ] = rand() % 0x80 + 0x80;
211 mMediaPixels[ base_pos + 2 ] = rand() % 0x80 + 0x80;
212
213 // emit an event to say that something in the media stream changed
214 LLMediaEvent event( this );
215 mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event );
216 };
217
218 return true;
219}
220
221
222////////////////////////////////////////////////////////////////////////////////
223// virtual
224bool LLMediaImplExample1::setRequestedMediaSize( int width, int height )
225{
226 // we accept any size:
227 return setMediaSize(width, height);
228}
diff --git a/linden/indra/llmedia/llmediaobservers.h b/linden/indra/llmedia/llmediaimplexample1.h
index 09dd3b8..b78a887 100644
--- a/linden/indra/llmedia/llmediaobservers.h
+++ b/linden/indra/llmedia/llmediaimplexample1.h
@@ -1,10 +1,10 @@
1/** 1/**
2 * @file llmediaobservers.h 2 * @file llmediaimplexample1.h
3 * @brief LLMedia support - observer classes to be overridden. 3 * @brief Example 1 of a media impl concrete class
4 * 4 *
5 * $LicenseInfo:firstyear=2005&license=viewergpl$ 5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2005-2008, Linden Research, Inc. 7 * Copyright (c) 2007-2008, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -29,26 +29,44 @@
29 * $/LicenseInfo$ 29 * $/LicenseInfo$
30 */ 30 */
31 31
32// header guard 32#ifndef LLMEDIAIMPLEXAMPLE1_H
33#ifndef llmediaobservers_h 33#define LLMEDIAIMPLEXAMPLE1_H
34#define llmediaobservers_h
35 34
36#include "llmediaemitterevents.h" 35#include "llmediaimplcommon.h"
36#include "llmediaimplfactory.h"
37 37
38class LLMediaObserver 38class LLMediaManagerData;
39
40class LLMediaImplExample1 :
41 public LLMediaImplCommon
39{ 42{
40 public: 43 public:
41 typedef LLMediaEvent EventType; 44 LLMediaImplExample1();
42 virtual ~LLMediaObserver() {} 45
43 virtual void onInit ( const EventType& eventIn ) { } 46 static bool startup( LLMediaManagerData* init_data );
44 virtual void onSetUrl ( const EventType& eventIn ) { } 47 static bool closedown();
45 virtual void onLoad ( const EventType& eventIn ) { } 48
46 virtual void onPlay ( const EventType& eventIn ) { } 49 /* virtual */ bool init();
47 virtual void onPause ( const EventType& eventIn ) { } 50 /* virtual */ bool navigateTo( const std::string url );
48 virtual void onStop ( const EventType& eventIn ) { } 51 /* virtual */ bool updateMedia();
49 virtual void onUnload ( const EventType& eventIn ) { } 52 /* virtual */ std::string getVersion();
50 virtual void onPopupMessage ( const EventType& eventIn ) { } 53 /* virtual */ unsigned char* getMediaData();
54 /* virtual */ bool reset();
55 /* virtual */ bool mouseMove( int x_pos, int y_pos );
56 /* virtual */ bool setRequestedMediaSize( int width, int height );
57
58 private:
59 unsigned char* mMediaPixels;
51}; 60};
52 61
62class LLMediaImplExample1Maker : public LLMediaImplMaker
63{
64 public:
65 LLMediaImplExample1Maker();
66 LLMediaImplExample1* create()
67 {
68 return new LLMediaImplExample1();
69 }
70};
53 71
54#endif // llmediaobservers_h 72#endif // LLMEDIAIMPLEXAMPLE1_H
diff --git a/linden/indra/llmedia/llmediaimplexample2.cpp b/linden/indra/llmedia/llmediaimplexample2.cpp
new file mode 100644
index 0000000..dc20e03
--- /dev/null
+++ b/linden/indra/llmedia/llmediaimplexample2.cpp
@@ -0,0 +1,195 @@
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-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "llmediaimplexample2.h"
33#include "llmediaimplregister.h"
34
35// register this impl with media manager factory
36static LLMediaImplRegister sLLMediaImplExample2Reg( "LLMediaImplExample2", new LLMediaImplExample2Maker() );
37
38#include <iostream>
39#include <time.h>
40
41///////////////////////////////////////////////////////////////////////////////
42//
43LLMediaImplExample2Maker::LLMediaImplExample2Maker()
44{
45 // Register to handle the scheme
46 mSchema.push_back( "example2" );
47}
48
49///////////////////////////////////////////////////////////////////////////////
50//
51LLMediaImplExample2::LLMediaImplExample2() :
52 mMediaPixels( 0 )
53{
54 setRequestedMediaSize( 500, 500 );
55 setMediaDepth( 3 );
56
57 mXpos = ( getMediaWidth() / 2 ) + rand() % ( getMediaWidth() / 16 ) - ( getMediaWidth() / 32 );
58 mYpos = ( getMediaHeight() / 2 ) + rand() % ( getMediaHeight() / 16 ) - ( getMediaHeight() / 32 );
59
60 srand( (unsigned int)(time( NULL )) );
61}
62
63////////////////////////////////////////////////////////////////////////////////
64// (static) super-initialization - called once at application startup
65bool LLMediaImplExample2::startup( LLMediaManagerData* init_data )
66{
67 return true;
68}
69
70////////////////////////////////////////////////////////////////////////////////
71// (static) super-uninitialization - called once at application closedown
72bool LLMediaImplExample2::closedown()
73{
74 return true;
75}
76
77////////////////////////////////////////////////////////////////////////////////
78// virtual
79bool LLMediaImplExample2::init()
80{
81 int buffer_size = getMediaBufferSize();
82
83 mMediaPixels = new unsigned char[ buffer_size ];
84
85 memset( mMediaPixels, 0x00, buffer_size );
86
87 return true;
88}
89
90////////////////////////////////////////////////////////////////////////////////
91// virtual
92bool LLMediaImplExample2::navigateTo( const std::string url )
93{
94 std::cout << "LLMediaImplExample2::navigateTo" << std::endl;
95
96 setStatus( LLMediaBase::STATUS_NAVIGATING );
97
98 // force a size change event for new URL
99 LLMediaEvent event( this );
100 mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event );
101
102 return true;
103}
104
105////////////////////////////////////////////////////////////////////////////////
106// virtual
107std::string LLMediaImplExample2::getVersion()
108{
109 std::string version_string = "[" + sLLMediaImplExample2Reg.getImplName() + "] - " + "1.0.0.0";
110
111 return version_string;
112}
113
114////////////////////////////////////////////////////////////////////////////////
115// virtual
116bool LLMediaImplExample2::updateMedia()
117{
118 if ( mMediaPixels && getStatus() == LLMediaBase::STATUS_STARTED )
119 {
120 static int x_inc = rand() % 5 + 2;
121 static int y_inc = rand() % 5 + 2;
122 int block_size = 32;
123
124 for( int y = 0; y < block_size; ++y )
125 {
126 for( int x = 0; x < block_size; ++x )
127 {
128 int rowspan = getMediaWidth() * getMediaDepth();
129 mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 0 ] = 0;
130 mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 1 ] = 0;
131 mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 2 ] = 0;
132 };
133 };
134
135 if ( mXpos + x_inc < 0 || mXpos + x_inc >= getMediaWidth() - block_size )
136 x_inc =- x_inc;
137
138 if ( mYpos + y_inc < 0 || mYpos + y_inc >= getMediaHeight() - block_size )
139 y_inc =- y_inc;
140
141 mXpos += x_inc;
142 mYpos += y_inc;
143
144 unsigned char col_r = rand() % 0xff;
145 unsigned char col_g = rand() % 0xff;
146 unsigned char col_b = rand() % 0xff;
147
148 for( int y = 0; y < block_size; ++y )
149 {
150 for( int x = 0; x < block_size; ++x )
151 {
152 int rowspan = getMediaWidth() * getMediaDepth();
153 mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 0 ] = col_r;
154 mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 1 ] = col_g;
155 mMediaPixels[ ( mXpos + x ) * getMediaDepth() + ( mYpos + y ) * rowspan + 2 ] = col_b;
156 };
157 };
158
159 // emit an event to say that something in the media stream changed
160 LLMediaEvent event( this );
161 mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event );
162 };
163
164 // update the command (e.g. transport controls) state
165 updateCommand();
166
167 return false;
168}
169
170////////////////////////////////////////////////////////////////////////////////
171// virtual
172unsigned char* LLMediaImplExample2::getMediaData()
173{
174 return mMediaPixels;
175}
176
177////////////////////////////////////////////////////////////////////////////////
178// virtual
179bool LLMediaImplExample2::reset()
180{
181 if ( mMediaPixels )
182 {
183 delete [] mMediaPixels;
184 };
185
186 return true;
187}
188
189////////////////////////////////////////////////////////////////////////////////
190// virtual
191bool LLMediaImplExample2::setRequestedMediaSize( int width, int height )
192{
193 // we accept any size:
194 return setMediaSize(width, height);
195}
diff --git a/linden/indra/llmedia/llmediaimplexample2.h b/linden/indra/llmedia/llmediaimplexample2.h
new file mode 100644
index 0000000..475915d
--- /dev/null
+++ b/linden/indra/llmedia/llmediaimplexample2.h
@@ -0,0 +1,75 @@
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-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#ifndef LLMEDIAIMPLEXAMPLE2_H
33#define LLMEDIAIMPLEXAMPLE2_H
34
35#include "llmediaimplcommon.h"
36#include "llmediaimplfactory.h"
37
38class LLMediaManagerData;
39class LLMediaImplMaker;
40
41class LLMediaImplExample2 :
42 public LLMediaImplCommon
43{
44 public:
45 LLMediaImplExample2();
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 load( const std::string url );
53 /* virtual */ std::string getVersion();
54 /* virtual */ bool updateMedia();
55 /* virtual */ unsigned char* getMediaData();
56 /* virtual */ bool reset();
57 /* virtual */ bool setRequestedMediaSize( int width, int height );
58
59 private:
60 unsigned char* mMediaPixels;
61 int mXpos;
62 int mYpos;
63};
64
65class LLMediaImplExample2Maker : public LLMediaImplMaker
66{
67 public:
68 LLMediaImplExample2Maker();
69 LLMediaImplExample2* create()
70 {
71 return new LLMediaImplExample2();
72 }
73};
74
75#endif // LLMEDIAIMPLEXAMPLE2_H
diff --git a/linden/indra/llmedia/llmediaimplfactory.cpp b/linden/indra/llmedia/llmediaimplfactory.cpp
new file mode 100644
index 0000000..0ca7757
--- /dev/null
+++ b/linden/indra/llmedia/llmediaimplfactory.cpp
@@ -0,0 +1,104 @@
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-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "llmediaimplfactory.h"
33
34#include <iostream>
35
36LLMediaImplFactory* LLMediaImplFactory::sInstance = NULL;
37
38///////////////////////////////////////////////////////////////////////////////
39// static
40LLMediaImplFactory* LLMediaImplFactory::getInstance()
41{
42 if ( ! sInstance )
43 sInstance = new LLMediaImplFactory();
44
45 return sInstance;
46}
47
48///////////////////////////////////////////////////////////////////////////////
49//
50void LLMediaImplFactory::registerImpl( const std::string& impl_name, LLMediaImplMakerBase* impl_maker )
51{
52 mNameImplMakerContainer.insert( name_impl_maker_container_t::value_type( impl_name, impl_maker ) );
53}
54
55///////////////////////////////////////////////////////////////////////////////
56//
57LLMediaImplMakerBase* LLMediaImplFactory::getImplMaker( const std::string& scheme, const std::string& type )
58{
59 name_impl_maker_container_t::const_iterator iter;
60 name_impl_maker_container_t::const_iterator begin = mNameImplMakerContainer.begin();
61 name_impl_maker_container_t::const_iterator end = mNameImplMakerContainer.end();
62
63 for(iter = begin; iter != end; ++iter)
64 {
65 if(( *iter->second ).supportsScheme(scheme))
66 {
67 return ( iter->second );
68 }
69 }
70
71 for(iter = begin; iter != end; ++iter)
72 {
73 if(( *iter->second ).supportsMimeType(type))
74 {
75 return ( iter->second );
76 }
77 }
78 int idx1 = type.find("/");
79 int len = (idx1 == std::string::npos) ? 0 : idx1;
80 std::string category = type.substr(0,len);
81 for(iter = begin; iter != end; ++iter)
82 {
83 if(( *iter->second ).supportsMimeTypeCategory(category))
84 {
85 return ( iter->second );
86 }
87 }
88
89 return NULL;
90};
91
92///////////////////////////////////////////////////////////////////////////////
93//
94LLMediaImplMakerBase* LLMediaImplFactory::getImplMaker( const std::string& impl_name )
95{
96 name_impl_maker_container_t::const_iterator found = mNameImplMakerContainer.find( impl_name );
97
98 if ( found == mNameImplMakerContainer.end() )
99 {
100 return NULL;
101 };
102
103 return found->second;
104}
diff --git a/linden/indra/llmedia/llmediaimplfactory.h b/linden/indra/llmedia/llmediaimplfactory.h
new file mode 100644
index 0000000..fb99c2f
--- /dev/null
+++ b/linden/indra/llmedia/llmediaimplfactory.h
@@ -0,0 +1,99 @@
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-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#ifndef LLMEDIAIMPLFACTORY_H
33#define LLMEDIAIMPLFACTORY_H
34
35#include <algorithm>
36#include <map>
37#include <string>
38#include <vector>
39
40#include "llmediabase.h"
41
42///////////////////////////////////////////////////////////////////////////////
43//
44class LLMediaImplMakerBase
45{
46 public:
47 virtual bool supportsScheme(std::string scheme) = 0;
48 virtual bool supportsMimeType(std::string type) = 0;
49 virtual bool supportsMimeTypeCategory(std::string category) = 0;
50 virtual LLMediaBase* create() = 0;
51 virtual ~LLMediaImplMakerBase() {};
52
53 protected:
54 typedef std::vector <std::string> vector_impl_registry_t;
55 vector_impl_registry_t mSchema;
56 vector_impl_registry_t mMimeTypes;
57 vector_impl_registry_t mMimeTypeCategories;
58};
59
60///////////////////////////////////////////////////////////////////////////////
61//
62class LLMediaImplMaker : public LLMediaImplMakerBase
63{
64 public:
65 bool supportsScheme(std::string scheme)
66 {
67 vector_impl_registry_t::iterator found = std::find(mSchema.begin(), mSchema.end(), scheme);
68 return found != mSchema.end();
69 }
70 bool supportsMimeType(std::string type)
71 {
72 vector_impl_registry_t::iterator found = std::find(mMimeTypes.begin(), mMimeTypes.end(), type);
73 return found != mMimeTypes.end();
74 }
75 bool supportsMimeTypeCategory(std::string category)
76 {
77 vector_impl_registry_t::iterator found = std::find(mMimeTypeCategories.begin(), mMimeTypeCategories.end(), category);
78 return found != mMimeTypeCategories.end();
79 }
80};
81
82///////////////////////////////////////////////////////////////////////////////
83//
84class LLMediaImplFactory
85{
86 public:
87 static LLMediaImplFactory* getInstance();
88 void registerImpl( const std::string& impl_name, LLMediaImplMakerBase* impl_maker );
89 LLMediaImplMakerBase* getImplMaker( const std::string& scheme, const std::string& type );
90 LLMediaImplMakerBase* getImplMaker( const std::string& impl_name);
91
92 private:
93 typedef std::map< std::string, LLMediaImplMakerBase* > name_impl_maker_container_t;
94 name_impl_maker_container_t mNameImplMakerContainer;
95
96 static LLMediaImplFactory* sInstance;
97};
98
99#endif // LLMEDIAIMPLFACTORY_H
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp
index 50dc052..b54d088 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer.cpp
+++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp
@@ -1,5 +1,6 @@
1/** 1/**
2 * @file llmediaimplgstreamer.cpp 2 * @file llmediaimplgstreamer.cpp
3 * @author Tofu Linden
3 * @brief implementation that supports various media through GStreamer. 4 * @brief implementation that supports various media through GStreamer.
4 * 5 *
5 * $LicenseInfo:firstyear=2007&license=viewergpl$ 6 * $LicenseInfo:firstyear=2007&license=viewergpl$
@@ -29,7 +30,7 @@
29 * $/LicenseInfo$ 30 * $/LicenseInfo$
30 */ 31 */
31 32
32#include "linden_common.h" 33#include "llmediaimplgstreamer.h"
33 34
34#if LL_GSTREAMER_ENABLED 35#if LL_GSTREAMER_ENABLED
35 36
@@ -37,7 +38,8 @@ extern "C" {
37#include <gst/gst.h> 38#include <gst/gst.h>
38} 39}
39 40
40#include "llmediaimplgstreamer.h" 41#include "llmediamanager.h"
42#include "llmediaimplregister.h"
41 43
42#include "llmediaimplgstreamervidplug.h" 44#include "llmediaimplgstreamervidplug.h"
43 45
@@ -47,17 +49,28 @@ extern "C" {
47 49
48#include "llmediaimplgstreamer_syms.h" 50#include "llmediaimplgstreamer_syms.h"
49 51
50#include "llgl.h" 52// register this impl with media manager factory
51#include "llglheaders.h" // For gl texture modes 53static LLMediaImplRegister sLLMediaImplGStreamerReg( "LLMediaImplGStreamer", new LLMediaImplGStreamerMaker() );
54
55LLMediaImplGStreamerMaker::LLMediaImplGStreamerMaker()
56{
57 // Register to handle the scheme
58 mSchema.push_back( "rtsp" );
59 mSchema.push_back( "rtmp" );
60
61 // Register to handle the category
62 mMimeTypeCategories.push_back( "video" );
63 mMimeTypeCategories.push_back( "audio" );
64}
52 65
53/////////////////////////////////////////////////////////////////////////////// 66///////////////////////////////////////////////////////////////////////////////
54// 67//
55LLMediaImplGStreamer:: 68LLMediaImplGStreamer::
56LLMediaImplGStreamer () : 69LLMediaImplGStreamer () :
57 mediaData ( NULL ), 70 mediaData ( NULL ),
58 ownBuffer ( TRUE ), 71 mMediaRowbytes ( 1 ),
59 mVolume ( 1.0f ), 72 mTextureFormatPrimary ( LL_MEDIA_BGRA ),
60 currentMode ( ModeIdle ), 73 mTextureFormatType ( LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV ),
61 mPump ( NULL ), 74 mPump ( NULL ),
62 mPlaybin ( NULL ), 75 mPlaybin ( NULL ),
63 mVideoSink ( NULL ) 76 mVideoSink ( NULL )
@@ -65,80 +78,95 @@ LLMediaImplGStreamer () :
65 ,mAudioSink ( NULL ) 78 ,mAudioSink ( NULL )
66#endif // LL_GST_SOUNDSINK 79#endif // LL_GST_SOUNDSINK
67{ 80{
68 mMediaDepthBytes = 4; 81 DEBUGMSG("constructing media...");
69 mTextureDepth = 4; 82
70 mTextureFormatInternal = GL_RGB8; 83 setMediaDepth(4);
71 mTextureFormatPrimary = GL_BGRA; 84
72 mTextureFormatType = GL_UNSIGNED_INT_8_8_8_8_REV; 85 // Create a pumpable main-loop for this media
86 mPump = g_main_loop_new (NULL, FALSE);
87 if (!mPump)
88 {
89 return; // error
90 }
91
92 // instantiate a playbin element to do the hard work
93 mPlaybin = llgst_element_factory_make ("playbin", "play");
94 if (!mPlaybin)
95 {
96 // todo: cleanup pump
97 return; // error
98 }
99
100 if (NULL == getenv("LL_GSTREAMER_EXTERNAL")) {
101 // instantiate and connect a custom video sink
102 mVideoSink =
103 GST_SLVIDEO(llgst_element_factory_make ("private-slvideo", "slvideo"));
104 if (!mVideoSink)
105 {
106 WARNMSG("Could not instantiate private-slvideo element.");
107 // todo: cleanup.
108 return; // error
109 }
110
111 g_object_set(mPlaybin, "video-sink", mVideoSink, NULL);
112
113#ifdef LL_GST_SOUNDSINK
114 // instantiate and connect a custom audio sink
115 mAudioSink =
116 GST_SLSOUND(llgst_element_factory_make ("private-slsound", "slsound"));
117 if (!mAudioSink)
118 {
119 WARNMSG("Could not instantiate private-slsound element.");
120 // todo: cleanup.
121 return; // error
122 }
123
124 g_object_set(mPlaybin, "audio-sink", mAudioSink, NULL);
125#endif
126 }
73} 127}
74 128
75/////////////////////////////////////////////////////////////////////////////// 129// virtual
76// 130int LLMediaImplGStreamer::getTextureFormatPrimary() const
77LLMediaImplGStreamer::
78~LLMediaImplGStreamer ()
79{ 131{
80 unload(); 132 return mTextureFormatPrimary;
81} 133}
82 134
83void UnloadGStreamer() 135// virtual
136int LLMediaImplGStreamer::getTextureFormatType() const
84{ 137{
85 ungrab_gst_syms(); 138 return mTextureFormatType;
86} 139}
87 140
141// virtual
142int LLMediaImplGStreamer::getTextureFormatInternal() const
143{
144 return LL_MEDIA_RGB8;
145}
88 146
89/////////////////////////////////////////////////////////////////////////////// 147///////////////////////////////////////////////////////////////////////////////
90// 148//
91BOOL
92LLMediaImplGStreamer:: 149LLMediaImplGStreamer::
93setBuffer ( U8* bufferIn ) 150~LLMediaImplGStreamer ()
94{ 151{
95 // Since we've pointed GStreamer at the old media data buffer 152 DEBUGMSG("dtor of media...");
96 // directly, we need to be somewhat careful deleting it... 153 unload();
97 U8* oldMediaData = mediaData; 154}
98 BOOL ownedMediaData = ownBuffer;
99
100 if(bufferIn == NULL)
101 {
102 // Passing NULL to this function requests that the object
103 // allocate its own buffer.
104 mediaData = new unsigned char[ mMediaHeight * mMediaRowbytes ];
105 ownBuffer = TRUE;
106 }
107 else
108 {
109 // Use the supplied buffer.
110 mediaData = bufferIn;
111 ownBuffer = FALSE;
112 }
113
114 if(mediaData == NULL)
115 {
116 // This is bad - probably out of memory.
117 llerrs << "LLMediaImplGStreamer::setBuffer: mediaData is NULL" << llendl;
118 // NOTE: This case doesn't clean up properly. This assert is fatal, so this isn't a huge problem,
119 // but if this assert is ever removed the code should be fixed to clean up correctly.
120 return FALSE;
121 }
122
123 // [..]
124 155
125 // Delete the old media data buffer iff we owned it. 156////////////////////////////////////////////////////////////////////////////////
126 if ( ownedMediaData ) 157// virtual
127 { 158std::string LLMediaImplGStreamer::getVersion()
128 if ( oldMediaData ) 159{
129 { 160 std::string rtn;
130 delete [] oldMediaData; 161 rtn = "[" + sLLMediaImplGStreamerReg.getImplName() + "] - GStreamer 0.10.x";
131 } 162 return rtn;
132 }
133
134 return TRUE;
135} 163}
136 164
137/////////////////////////////////////////////////////////////////////////////// 165///////////////////////////////////////////////////////////////////////////////
138// 166// (static) super-initialization - called once at application startup
139BOOL 167bool
140LLMediaImplGStreamer:: 168LLMediaImplGStreamer::
141init () 169startup ( LLMediaManagerData* init_data )
142{ 170{
143 static bool done_init = false; 171 static bool done_init = false;
144 if (!done_init) 172 if (!done_init)
@@ -148,19 +176,19 @@ init ()
148 "libgstvideo-0.10.so.0", 176 "libgstvideo-0.10.so.0",
149 "libgstaudio-0.10.so.0") ) 177 "libgstaudio-0.10.so.0") )
150 { 178 {
151 llwarns << "Couldn't find suitable GStreamer 0.10 support on this system - video playback disabled." << llendl; 179 WARNMSG("Couldn't find suitable GStreamer 0.10 support on this system - video playback disabled.");
152 return FALSE; 180 return false;
153 } 181 }
154 182
155 if (llgst_segtrap_set_enabled) 183 if (llgst_segtrap_set_enabled)
156 llgst_segtrap_set_enabled(FALSE); 184 llgst_segtrap_set_enabled(FALSE);
157 else 185 else
158 llwarns << "gst_segtrap_set_enabled() is not available; Second Life automated crash-reporter may cease to function until next restart." << llendl; 186 WARNMSG("gst_segtrap_set_enabled() is not available; Automated crash-reporter may cease to function until next restart.");
159 187
160 if (0 == llgst_init_check(NULL, NULL, NULL)) 188 if (0 == llgst_init_check(NULL, NULL, NULL))
161 { 189 {
162 llwarns << "GST init failed for unspecified reason." << llendl; 190 WARNMSG("GST init failed for unspecified reason.");
163 return FALSE; 191 return false;
164 } 192 }
165 193
166 // Init our custom plugins - only really need do this once. 194 // Init our custom plugins - only really need do this once.
@@ -172,52 +200,16 @@ init ()
172 done_init = true; 200 done_init = true;
173 } 201 }
174 202
175 // Create a pumpable main-loop for this media 203 return true;
176 mPump = g_main_loop_new (NULL, FALSE); 204}
177 if (!mPump)
178 {
179 return FALSE;
180 }
181
182 // instantiate a playbin element to do the hard work
183 mPlaybin = llgst_element_factory_make ("playbin", "play");
184 if (!mPlaybin)
185 {
186 // todo: cleanup pump
187 return FALSE;
188 }
189
190 if (NULL == getenv("LL_GSTREAMER_EXTERNAL")) {
191 // instantiate and connect a custom video sink
192 mVideoSink =
193 GST_SLVIDEO(llgst_element_factory_make ("private-slvideo", "slvideo"));
194 if (!mVideoSink)
195 {
196 llwarns << "Could not instantiate private-slvideo element."
197 << llendl;
198 // todo: cleanup.
199 return FALSE;
200 }
201
202 g_object_set(mPlaybin, "video-sink", mVideoSink, NULL);
203 205
204#ifdef LL_GST_SOUNDSINK
205 // instantiate and connect a custom audio sink
206 mAudioSink =
207 GST_SLSOUND(llgst_element_factory_make ("private-slsound", "slsound"));
208 if (!mAudioSink)
209 {
210 llwarns << "Could not instantiate private-slsound element."
211 << llendl;
212 // todo: cleanup.
213 return FALSE;
214 }
215 206
216 g_object_set(mPlaybin, "audio-sink", mAudioSink, NULL); 207bool LLMediaImplGStreamer::
217#endif 208closedown()
218 } 209{
210 ungrab_gst_syms();
219 211
220 return LLMediaMovieBase::init(); 212 return true;
221} 213}
222 214
223 215
@@ -239,22 +231,20 @@ static char* get_gst_state_name(GstState state)
239#endif // LL_GST_REPORT_STATE_CHANGES 231#endif // LL_GST_REPORT_STATE_CHANGES
240 232
241static gboolean 233static gboolean
242my_bus_callback (GstBus *bus, 234bus_callback (GstBus *bus,
243 GstMessage *message, 235 GstMessage *message,
244 gpointer data) 236 gpointer data)
245{ 237{
246 if (GST_MESSAGE_TYPE(message) != GST_MESSAGE_STATE_CHANGED && 238 if (GST_MESSAGE_TYPE(message) != GST_MESSAGE_STATE_CHANGED &&
247 GST_MESSAGE_TYPE(message) != GST_MESSAGE_BUFFERING) 239 GST_MESSAGE_TYPE(message) != GST_MESSAGE_BUFFERING)
248 { 240 {
249 llinfos << "Got GST message type: " 241 DEBUGMSG("Got GST message type: %s",
250 << LLGST_MESSAGE_TYPE_NAME (message) 242 LLGST_MESSAGE_TYPE_NAME (message));
251 << llendl;
252 } 243 }
253 else 244 else
254 { 245 {
255 lldebugs << "Got GST message type: " 246 DEBUGMSG("Got GST message type: %s",
256 << LLGST_MESSAGE_TYPE_NAME (message) 247 LLGST_MESSAGE_TYPE_NAME (message));
257 << llendl;
258 } 248 }
259 249
260 LLMediaImplGStreamer *impl = (LLMediaImplGStreamer*)data; 250 LLMediaImplGStreamer *impl = (LLMediaImplGStreamer*)data;
@@ -266,11 +256,10 @@ my_bus_callback (GstBus *bus,
266 { 256 {
267 gint percent = 0; 257 gint percent = 0;
268 llgst_message_parse_buffering(message, &percent); 258 llgst_message_parse_buffering(message, &percent);
269 llinfos << "GST buffering: " << percent 259 DEBUGMSG("GST buffering: %d%%", percent);
270 << "%" << llendl; 260 LLMediaEvent event( impl, percent );
271 // ModeBuffering seems to do nothing except make 261 impl->getEventEmitter().update( &LLMediaObserver::onUpdateProgress, event );
272 // the UI worse 262
273 /*if (percent < 100) impl->setCurrentMode(LLMediaImplGStreamer::ModeBuffering);*/
274 } 263 }
275 break; 264 break;
276 } 265 }
@@ -284,66 +273,63 @@ my_bus_callback (GstBus *bus,
284 &pending_state); 273 &pending_state);
285#ifdef LL_GST_REPORT_STATE_CHANGES 274#ifdef LL_GST_REPORT_STATE_CHANGES
286 // not generally very useful, and rather spammy. 275 // not generally very useful, and rather spammy.
287 llinfos << "state change (old,<new>,pending): " 276 DEBUGMSG("state change (old,<new>,pending): %s,<%s>,%s",
288 << get_gst_state_name(old_state) << ", <" 277 get_gst_state_name(old_state),
289 << get_gst_state_name(new_state) << ">, " 278 get_gst_state_name(new_state),
290 << get_gst_state_name(pending_state) << 279 get_gst_state_name(pending_state));
291 llendl;
292#endif // LL_GST_REPORT_STATE_CHANGES 280#endif // LL_GST_REPORT_STATE_CHANGES
293 281
294 switch (new_state) { 282 switch (new_state) {
295 case GST_STATE_VOID_PENDING: 283 case GST_STATE_VOID_PENDING:
296 impl->setCurrentMode(LLMediaImplGStreamer::ModeNone);
297 break; 284 break;
298 case GST_STATE_NULL: 285 case GST_STATE_NULL:
299 impl->setCurrentMode(LLMediaImplGStreamer::ModeNone);
300 break; 286 break;
301 case GST_STATE_READY: 287 case GST_STATE_READY:
302 impl->setCurrentMode(LLMediaImplGStreamer::ModeStopped);
303 break; 288 break;
304 case GST_STATE_PAUSED: 289 case GST_STATE_PAUSED:
305 impl->setCurrentMode(LLMediaImplGStreamer::ModePaused);
306 break; 290 break;
307 case GST_STATE_PLAYING: 291 case GST_STATE_PLAYING:
308 impl->setCurrentMode(LLMediaImplGStreamer::ModePlaying); 292 LLMediaEvent event( impl, 100 );
293 impl->getEventEmitter().update( &LLMediaObserver::onUpdateProgress, event );
294 // emit an event to say that a media source was loaded
295 LLMediaEvent event2( impl );
296 impl->getEventEmitter().update( &LLMediaObserver::onMediaLoaded, event2 );
309 break; 297 break;
310 } 298 }
311 break; 299 break;
312 } 300 }
313 case GST_MESSAGE_ERROR: { 301 case GST_MESSAGE_ERROR: {
314 GError *err; 302 GError *err = NULL;
315 gchar *debug; 303 gchar *debug = NULL;
316 304
317 llgst_message_parse_error (message, &err, &debug); 305 llgst_message_parse_error (message, &err, &debug);
318 llinfos << "GST error: " << err->message << llendl; 306 WARNMSG("GST error: %s", err->message);
319 g_error_free (err); 307 g_error_free (err);
320 g_free (debug); 308 g_free (debug);
321 309
322 impl->setCurrentMode(LLMediaImplGStreamer::ModeError); 310 impl->addCommand(LLMediaBase::COMMAND_STOP);
323
324 impl->stop();
325 311
326 break; 312 break;
327 } 313 }
328 case GST_MESSAGE_INFO: { 314 case GST_MESSAGE_INFO: {
329 if (llgst_message_parse_info) 315 if (llgst_message_parse_info)
330 { 316 {
331 GError *err; 317 GError *err = NULL;
332 gchar *debug; 318 gchar *debug = NULL;
333 319
334 llgst_message_parse_info (message, &err, &debug); 320 llgst_message_parse_info (message, &err, &debug);
335 llinfos << "GST info: " << err->message << llendl; 321 INFOMSG("GST info: %s", err->message);
336 g_error_free (err); 322 g_error_free (err);
337 g_free (debug); 323 g_free (debug);
338 } 324 }
339 break; 325 break;
340 } 326 }
341 case GST_MESSAGE_WARNING: { 327 case GST_MESSAGE_WARNING: {
342 GError *err; 328 GError *err = NULL;
343 gchar *debug; 329 gchar *debug = NULL;
344 330
345 llgst_message_parse_warning (message, &err, &debug); 331 llgst_message_parse_warning (message, &err, &debug);
346 llinfos << "GST warning: " << err->message << llendl; 332 WARNMSG("GST warning: %s", err->message);
347 g_error_free (err); 333 g_error_free (err);
348 g_free (debug); 334 g_free (debug);
349 335
@@ -351,9 +337,18 @@ my_bus_callback (GstBus *bus,
351 } 337 }
352 case GST_MESSAGE_EOS: 338 case GST_MESSAGE_EOS:
353 /* end-of-stream */ 339 /* end-of-stream */
354 llinfos << "GST EOS." << llendl; 340 DEBUGMSG("GST end-of-stream.");
355 impl->setCurrentMode(LLMediaImplGStreamer::ModeStopped);//? 341 if (impl->isLooping())
356 impl->stop(); 342 {
343 DEBUGMSG("looping media...");
344 impl->stop();
345 impl->play();
346 }
347 else
348 {
349 // inject a COMMAND_STOP
350 impl->addCommand(LLMediaBase::COMMAND_STOP);
351 }
357 break; 352 break;
358 default: 353 default:
359 /* unhandled message */ 354 /* unhandled message */
@@ -361,52 +356,57 @@ my_bus_callback (GstBus *bus,
361 } 356 }
362 357
363 /* we want to be notified again the next time there is a message 358 /* we want to be notified again the next time there is a message
364 * on the bus, so returning TRUE (FALSE means we want to stop watching 359 * on the bus, so return true (false means we want to stop watching
365 * for messages on the bus and our callback should not be called again) 360 * for messages on the bus and our callback should not be called again)
366 */ 361 */
367 return TRUE; 362 return TRUE;
368} 363}
369 364
370BOOL 365///////////////////////////////////////////////////////////
366// virtual
367bool
371LLMediaImplGStreamer:: 368LLMediaImplGStreamer::
372load ( const LLString& urlIn ) 369navigateTo ( const std::string urlIn )
373{ 370{
374 llinfos << "Setting media URI: " << urlIn << llendl; 371 DEBUGMSG("Setting media URI: %s", urlIn.c_str());
372
373 if (NULL == mPump
374#ifdef LL_GST_SOUNDSINK
375 || NULL == mAudioSink
376#endif
377 || NULL == mPlaybin)
378 {
379 return false;
380 }
381
382 setStatus( LLMediaBase::STATUS_NAVIGATING );
375 383
376 // set URI 384 // set URI
377 g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL); 385 g_object_set (G_OBJECT (mPlaybin), "uri", urlIn.c_str(), NULL);
378 //g_object_set (G_OBJECT (mPlaybin), "uri", "file:///tmp/movie", NULL); 386 //g_object_set (G_OBJECT (mPlaybin), "uri", "file:///tmp/movie", NULL);
379 387
380 // get playbin's bus - perhaps this can/should be done at init() 388 // get playbin's bus - perhaps this can/should be done in ctor
381 GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin)); 389 GstBus *bus = llgst_pipeline_get_bus (GST_PIPELINE (mPlaybin));
382 if (!bus) 390 if (!bus)
383 { 391 {
384 return FALSE; 392 return false;
385 } 393 }
386 llgst_bus_add_watch (bus, my_bus_callback, this); 394 llgst_bus_add_watch (bus, bus_callback, this);
387 llgst_object_unref (bus); 395 llgst_object_unref (bus);
388 396
389 if (true) // dummy values 397 // navigateTo implicitly plays, too.
390 { 398 play();
391 const int fixedsize = 2;
392 mMediaRowbytes = mMediaDepthBytes * fixedsize;
393 mMediaWidth = fixedsize;
394 mMediaHeight = fixedsize;
395 mTextureWidth = fixedsize;
396 mTextureHeight = fixedsize;
397 }
398 399
399 BOOL rtn = LLMediaMovieBase::load(urlIn); 400 return true;
400 llinfos << "load returns " << int(rtn) << llendl;
401 return rtn;
402} 401}
403 402
404/////////////////////////////////////////////////////////////////////////////// 403///////////////////////////////////////////////////////////////////////////////
405// 404//
406BOOL 405bool
407LLMediaImplGStreamer:: 406LLMediaImplGStreamer::
408unload () 407unload ()
409{ 408{
409 DEBUGMSG("unloading media...");
410 if (mPlaybin) 410 if (mPlaybin)
411 { 411 {
412 llgst_element_set_state (mPlaybin, GST_STATE_NULL); 412 llgst_element_set_state (mPlaybin, GST_STATE_NULL);
@@ -422,25 +422,75 @@ unload ()
422 422
423 if (mediaData) 423 if (mediaData)
424 { 424 {
425 if (ownBuffer) 425 delete mediaData;
426 { 426 mediaData = NULL;
427 delete mediaData;
428 mediaData = NULL;
429 }
430 } 427 }
431 428
432 mVideoSink = NULL; 429 mVideoSink = NULL;
433 430
434 return TRUE; 431 return true;
435} 432}
436 433
437/////////////////////////////////////////////////////////////////////////////// 434///////////////////////////////////////////////////////////////////////////////
438// 435// virtual
439S32 436bool
440LLMediaImplGStreamer:: 437LLMediaImplGStreamer::
441updateMedia () 438updateMedia ()
442{ 439{
443 //llinfos << "updating media..." << llendl; 440 DEBUGMSG("updating media...");
441
442 // sanity check
443 if (NULL == mPump
444#ifdef LL_GST_SOUNDSINK
445 || NULL == mAudioSink
446#endif
447 || NULL == mPlaybin)
448 {
449 DEBUGMSG("dead media...");
450 return false;
451 }
452
453 // process next outstanding command
454 switch (nextCommand())
455 {
456 case LLMediaBase::COMMAND_START:
457 DEBUGMSG("COMMAND_START");
458 if (getStatus() == LLMediaBase::STATUS_PAUSED ||
459 getStatus() == LLMediaBase::STATUS_NAVIGATING ||
460 getStatus() == LLMediaBase::STATUS_STOPPED)
461 {
462 DEBUGMSG("doing COMMAND_START");
463 play();
464 setStatus(LLMediaBase::STATUS_STARTED);
465 clearCommand();
466 }
467 break;
468 case LLMediaBase::COMMAND_STOP:
469 DEBUGMSG("COMMAND_STOP");
470 DEBUGMSG("doing COMMAND_STOP");
471 stop();
472 setStatus(LLMediaBase::STATUS_STOPPED);
473 clearCommand();
474 break;
475 case LLMediaBase::COMMAND_PAUSE:
476 DEBUGMSG("COMMAND_PAUSE");
477 if (getStatus() == LLMediaBase::STATUS_STARTED)
478 {
479 DEBUGMSG("doing COMMAND_PAUSE");
480 pause();
481 setStatus(LLMediaBase::STATUS_PAUSED);
482 clearCommand();
483 }
484 break;
485 default:
486 DEBUGMSG("COMMAND_?");
487 clearCommand();
488 break;
489 case LLMediaBase::COMMAND_NONE:
490 break;
491 }
492
493 // deal with results
444 if (g_main_context_pending(g_main_loop_get_context(mPump))) 494 if (g_main_context_pending(g_main_loop_get_context(mPump)))
445 { 495 {
446 g_main_context_iteration(g_main_loop_get_context(mPump), FALSE); 496 g_main_context_iteration(g_main_loop_get_context(mPump), FALSE);
@@ -451,269 +501,121 @@ updateMedia ()
451 GST_OBJECT_LOCK(mVideoSink); 501 GST_OBJECT_LOCK(mVideoSink);
452 if (mVideoSink->retained_frame_ready) 502 if (mVideoSink->retained_frame_ready)
453 { 503 {
454 //llinfos << "NEW FRAME " << llendl; 504 DEBUGMSG("NEW FRAME ");
455 if (mVideoSink->retained_frame_width != mMediaWidth || 505 if (mVideoSink->retained_frame_width != getMediaWidth() ||
456 mVideoSink->retained_frame_height != mMediaHeight) 506 mVideoSink->retained_frame_height != getMediaHeight())
457 // *TODO: also check for change in format 507 // *TODO: also check for change in format
458 { 508 {
459 // just resize container 509 // just resize containe
460 mMediaWidth = mVideoSink->retained_frame_width; 510 int neww = mVideoSink->retained_frame_width;
461 mMediaHeight = mVideoSink->retained_frame_height; 511 int newh = mVideoSink->retained_frame_height;
462 mTextureWidth = mMediaWidth; 512 int newd = SLVPixelFormatBytes[mVideoSink->retained_frame_format];
463 mTextureHeight = mMediaHeight;
464 mMediaDepthBytes = mTextureDepth =
465 SLVPixelFormatBytes[mVideoSink->retained_frame_format];
466 if (SLV_PF_RGBX == mVideoSink->retained_frame_format) 513 if (SLV_PF_RGBX == mVideoSink->retained_frame_format)
467 { 514 {
468 mTextureFormatPrimary = GL_RGBA; 515 mTextureFormatPrimary = LL_MEDIA_RGBA;
469 mTextureFormatType=GL_UNSIGNED_INT_8_8_8_8_REV; 516 mTextureFormatType = LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV;
470 } 517 }
471 else 518 else
472 { 519 {
473 mTextureFormatPrimary = GL_BGRA; 520 mTextureFormatPrimary = LL_MEDIA_BGRA;
474 mTextureFormatType=GL_UNSIGNED_INT_8_8_8_8_REV; 521 mTextureFormatType = LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV;
475 } 522 }
476 mMediaRowbytes = mMediaWidth * mMediaDepthBytes; 523 mMediaRowbytes = neww * newd;
477 llinfos << "video container resized to " << 524 DEBUGMSG("video container resized to %dx%d",
478 mMediaWidth << "x" << mMediaHeight << llendl; 525 neww, newh);
479 526
480 if (ownBuffer) 527 delete[] mediaData;
481 { 528 mediaData = new unsigned char[mMediaRowbytes *
482 // we manage the buffer, so we need to realloc 529 newh];
483 delete[] mediaData;
484 mediaData = new U8[mMediaRowbytes *
485 mMediaHeight];
486 }
487 530
488 GST_OBJECT_UNLOCK(mVideoSink); 531 GST_OBJECT_UNLOCK(mVideoSink);
489 return updateMediaNeedsSizeChange; 532
533 setMediaDepth(newd);
534 setMediaSize(neww, newh);
535 return true;
490 } 536 }
491 537
492 // we're gonna totally consume this frame - reset 'ready' flag 538 // we're gonna totally consume this frame - reset 'ready' flag
493 mVideoSink->retained_frame_ready = FALSE; 539 mVideoSink->retained_frame_ready = FALSE;
494 memcpy(mediaData, mVideoSink->retained_frame_data, 540 memcpy(mediaData, mVideoSink->retained_frame_data,
495 mMediaRowbytes * mMediaHeight); 541 mMediaRowbytes * getMediaHeight());
496 542
497 GST_OBJECT_UNLOCK(mVideoSink); 543 GST_OBJECT_UNLOCK(mVideoSink);
498 return updateMediaNeedsUpdate; 544 LLMediaEvent event( this );
545 mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event );
546 return true;
499 } 547 }
500 else 548 else
501 { 549 {
502 // nothing to do yet. 550 // nothing to do yet.
503 GST_OBJECT_UNLOCK(mVideoSink); 551 GST_OBJECT_UNLOCK(mVideoSink);
504 return updateMediaNoChanges; 552 return true;
505 } 553 }
506 } 554 }
507 555
508 return updateMediaNoChanges; 556 return true;
509}
510
511///////////////////////////////////////////////////////////////////////////////
512//
513void
514LLMediaImplGStreamer::
515setAutoScaled ( BOOL autoScaledIn )
516{
517 autoScaled = autoScaledIn;
518} 557}
519 558
520/////////////////////////////////////////////////////////////////////////////// 559///////////////////////////////////////////////////////////////////////////////
521// 560//
522BOOL 561bool
523LLMediaImplGStreamer:: 562LLMediaImplGStreamer::
524stop () 563stop ()
525{ 564{
526 llinfos << "stopping media..." << llendl; 565 DEBUGMSG("stopping media...");
527 // todo: error-check this? 566 // todo: error-check this?
528 llgst_element_set_state(mPlaybin, GST_STATE_READY); 567 llgst_element_set_state(mPlaybin, GST_STATE_READY);
529 568 return true;
530 BOOL rtn = LLMediaMovieBase::stop();
531 setCurrentMode(LLMediaImplGStreamer::ModeStopped);//?
532 return rtn;
533} 569}
534 570
535/////////////////////////////////////////////////////////////////////////////// 571///////////////////////////////////////////////////////////////////////////////
536// 572//
537BOOL 573bool
538LLMediaImplGStreamer:: 574LLMediaImplGStreamer::
539play () 575play ()
540{ 576{
541 llinfos << "playing media..." << llendl; 577 DEBUGMSG("playing media...");
542 // todo: error-check this? 578 // todo: error-check this?
543 llgst_element_set_state(mPlaybin, GST_STATE_PLAYING); 579 llgst_element_set_state(mPlaybin, GST_STATE_PLAYING);
544 580 return true;
545 return LLMediaMovieBase::play();
546} 581}
547 582
548/////////////////////////////////////////////////////////////////////////////// 583///////////////////////////////////////////////////////////////////////////////
549// 584//
550BOOL 585bool
551LLMediaImplGStreamer::
552loop ( S32 howMany )
553{
554 llinfos << "looping media... " << howMany << llendl;
555 // todo: implement this
556 if (!play())
557 return FALSE;
558
559 return LLMediaMovieBase::loop(howMany);
560};
561
562///////////////////////////////////////////////////////////////////////////////
563//
564BOOL
565LLMediaImplGStreamer:: 586LLMediaImplGStreamer::
566pause () 587pause ()
567{ 588{
568 llinfos << "pausing media..." << llendl; 589 DEBUGMSG("pausing media...");
569 // todo: error-check this? 590 // todo: error-check this?
570 llgst_element_set_state(mPlaybin, GST_STATE_PAUSED); 591 llgst_element_set_state(mPlaybin, GST_STATE_PAUSED);
571 592 return true;
572 return LLMediaMovieBase::pause();
573}; 593};
574 594
575///////////////////////////////////////////////////////////////////////////////
576//
577BOOL
578LLMediaImplGStreamer::
579setVolume ( F32 volumeIn )
580{
581 mVolume = volumeIn;
582 g_object_set(mPlaybin, "volume", mVolume, NULL);
583 return TRUE;
584}
585 595
586/////////////////////////////////////////////////////////////////////////////// 596///////////////////////////////////////////////////////////////////////////////
587// 597// virtual
588F32 598unsigned char*
589LLMediaImplGStreamer::
590getVolume ()
591{
592 return mVolume;
593}
594
595///////////////////////////////////////////////////////////////////////////////
596//
597BOOL
598LLMediaImplGStreamer::
599isIdle () const
600{
601 // todo: probably semantically decouple from currentMode
602 return currentMode == ModeIdle;
603}
604
605///////////////////////////////////////////////////////////////////////////////
606//
607BOOL
608LLMediaImplGStreamer::
609isError () const
610{
611 // todo: probably semantically decouple from currentMode
612 return currentMode == ModeError;
613}
614
615///////////////////////////////////////////////////////////////////////////////
616//
617BOOL
618LLMediaImplGStreamer::
619isBuffering () const
620{
621 // todo: probably semantically decouple from currentMode
622 return currentMode == ModeBuffering;
623}
624
625///////////////////////////////////////////////////////////////////////////////
626//
627BOOL
628LLMediaImplGStreamer::
629isLoaded () const
630{
631 // todo: probably semantically decouple from currentMode
632 //return currentMode == ModeLoaded;
633 return (mPump != NULL);
634}
635
636///////////////////////////////////////////////////////////////////////////////
637//
638BOOL
639LLMediaImplGStreamer::
640isPlaying () const
641{
642 // todo: probably semantically decouple from currentMode
643 return currentMode == ModePlaying;
644}
645
646///////////////////////////////////////////////////////////////////////////////
647//
648BOOL
649LLMediaImplGStreamer::
650isLooping () const
651{
652 // todo: probably semantically decouple from currentMode
653 return currentMode == ModeLooping;
654}
655
656///////////////////////////////////////////////////////////////////////////////
657//
658BOOL
659LLMediaImplGStreamer::
660isPaused () const
661{
662 // todo: probably semantically decouple from currentMode
663 return currentMode == ModePaused;
664}
665
666///////////////////////////////////////////////////////////////////////////////
667//
668BOOL
669LLMediaImplGStreamer::
670isStopped () const
671{
672 // todo: probably semantically decouple from currentMode
673 return currentMode == ModeStopped;
674}
675
676///////////////////////////////////////////////////////////////////////////////
677//
678U8*
679LLMediaImplGStreamer:: 599LLMediaImplGStreamer::
680getMediaData () 600getMediaData ()
681{ 601{
682 return mediaData; 602 return mediaData;
683} 603}
684 604
685///////////////////////////////////////////////////////////////////////////////
686//
687BOOL
688LLMediaImplGStreamer::
689seek ( F64 time )
690{
691 // todo: implement this
692 llinfos << "Tried to seek to time " << time
693 << " - faking it" << llendl;
694 return TRUE;
695}
696
697///////////////////////////////////////////////////////////////////////////////
698//
699F64
700LLMediaImplGStreamer::
701getTime () const
702{
703 // todo: implement this
704 F64 result = 0;
705 return result;
706}
707 605
708/////////////////////////////////////////////////////////////////////////////// 606///////////////////////////////////////////////////////////////////////////////
709// 607// virtual
710F64 608bool
711LLMediaImplGStreamer:: 609LLMediaImplGStreamer::
712getMediaDuration () const 610setVolume(float volume)
713{ 611{
714 // todo: implement this 612 mVolume = volume;
715 F64 result = 0; 613 if (mPlaybin)
716 return result; 614 {
615 g_object_set(mPlaybin, "volume", mVolume, NULL);
616 return true;
617 }
618 return false;
717} 619}
718 620
719#endif // LL_GSTREAMER_ENABLED 621#endif // LL_GSTREAMER_ENABLED
diff --git a/linden/indra/llmedia/llmediaimplgstreamer.h b/linden/indra/llmedia/llmediaimplgstreamer.h
index f1a7956..944db59 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer.h
+++ b/linden/indra/llmedia/llmediaimplgstreamer.h
@@ -1,5 +1,6 @@
1/** 1/**
2 * @file llmediaimplgstreamer.h 2 * @file llmediaimplgstreamer.h
3 * @author Tofu Linden
3 * @brief implementation that supports media playback via GStreamer. 4 * @brief implementation that supports media playback via GStreamer.
4 * 5 *
5 * $LicenseInfo:firstyear=2007&license=viewergpl$ 6 * $LicenseInfo:firstyear=2007&license=viewergpl$
@@ -33,27 +34,30 @@
33#ifndef llmediaimplgstreamer_h 34#ifndef llmediaimplgstreamer_h
34#define llmediaimplgstreamer_h 35#define llmediaimplgstreamer_h
35 36
37#include "llmediaimplcommon.h"
38#include "llmediaimplfactory.h"
39
36#if LL_GSTREAMER_ENABLED 40#if LL_GSTREAMER_ENABLED
37 41
38extern "C" { 42extern "C" {
43#include <stdio.h>
39#include <gst/gst.h> 44#include <gst/gst.h>
40 45
41#include <apr-1/apr_pools.h> 46#include <apr-1/apr_pools.h>
42#include <apr-1/apr_dso.h> 47#include <apr-1/apr_dso.h>
43} 48}
44 49
45#include "stdtypes.h"
46
47#include "llmediamoviebase.h"
48
49#include "llmediaimplgstreamervidplug.h" 50#include "llmediaimplgstreamervidplug.h"
50#ifdef LL_GST_SOUNDSINK 51#ifdef LL_GST_SOUNDSINK
51#include "llmediaimplgstreamersndplug.h" 52#include "llmediaimplgstreamersndplug.h"
52#endif // LL_GST_SOUNDSINK 53#endif // LL_GST_SOUNDSINK
53 54
55class LLMediaManagerData;
56class LLMediaImplMaker;
57
54/////////////////////////////////////////////////////////////////////////// 58///////////////////////////////////////////////////////////////////////////
55class LLMediaImplGStreamer: 59class LLMediaImplGStreamer:
56 public LLMediaMovieBase 60 public LLMediaImplCommon
57{ 61{
58 public: 62 public:
59 LLMediaImplGStreamer (); 63 LLMediaImplGStreamer ();
@@ -62,54 +66,31 @@ class LLMediaImplGStreamer:
62 //////////////////////////////////////////////////////// 66 ////////////////////////////////////////////////////////
63 // implementation of the media public interface 67 // implementation of the media public interface
64 68
65 // housekeeping 69 static bool startup( LLMediaManagerData* init_data );
66 virtual BOOL setBuffer ( U8* bufferIn ); 70 static bool closedown();
67 virtual BOOL init (); 71
68 virtual BOOL load ( const LLString& urlIn ); 72 /* virtual */ std::string getVersion();
69 virtual BOOL unload (); 73 /* virtual */ bool navigateTo( const std::string url );
70 74 /* virtual */ bool updateMedia();
71 // transport controls 75 /* virtual */ unsigned char* getMediaData();
72 virtual BOOL stop (); 76 /* virtual */ int getTextureFormatPrimary() const;
73 virtual BOOL play (); 77 /* virtual */ int getTextureFormatType() const;
74 virtual BOOL loop ( S32 howMany ); 78 /* virtual */ int getTextureFormatInternal() const;
75 virtual BOOL pause (); 79 /* virtual */ bool setVolume( float volume );
76 virtual BOOL seek ( F64 time ); 80
77 81 bool stop();
78 // audio levels 82 bool play();
79 virtual BOOL setVolume ( F32 volumeIn ); 83 LLMediaEmitter< LLMediaObserver > getEventEmitter() const {return mEventEmitter;};
80 virtual F32 getVolume ();
81
82 // status
83 virtual BOOL isIdle () const;
84 virtual BOOL isBuffering () const;
85 virtual BOOL isError () const;
86 virtual BOOL isLoaded () const;
87 virtual BOOL isStopped () const;
88 virtual BOOL isPaused () const;
89 virtual BOOL isPlaying () const;
90 virtual BOOL isLooping () const;
91 virtual F64 getTime () const;
92
93 // media data
94 virtual S32 updateMedia ();
95 virtual void setAutoScaled ( BOOL autoScaledIn );
96 virtual U8* getMediaData ();
97 virtual F64 getMediaDuration () const;
98
99 // class-specific
100 GMainLoop *getPump() {return mPump;};
101 typedef enum { ModeNone, ModeIdle, ModeError, ModeBuffering, ModeStopped, ModePaused, ModePlaying, ModeLooping } llGstMode;
102 llGstMode getCurrentMode() {return currentMode;};
103 void setCurrentMode(llGstMode mode) {currentMode = mode;};
104 84
105 private: 85 private:
106 // misc 86 // misc
107 U8* mediaData; 87 bool unload();
108 BOOL ownBuffer; 88 bool pause();
109 BOOL autoScaled; 89 unsigned char* mediaData;
110 F32 mVolume; 90 int mMediaRowbytes;
111 91
112 llGstMode currentMode; 92 int mTextureFormatPrimary;
93 int mTextureFormatType;
113 94
114 // GStreamer-specific 95 // GStreamer-specific
115 GMainLoop *mPump; // event pump for this media 96 GMainLoop *mPump; // event pump for this media
@@ -120,9 +101,29 @@ class LLMediaImplGStreamer:
120#endif // LL_GST_SOUNDSINK 101#endif // LL_GST_SOUNDSINK
121}; 102};
122 103
123// called during shutdown when no instances may exist 104class LLMediaImplGStreamerMaker : public LLMediaImplMaker
124void UnloadGStreamer(); 105{
106public:
107 LLMediaImplGStreamerMaker();
108 LLMediaImplGStreamer* create()
109 {
110 return new LLMediaImplGStreamer();
111 }
112};
125 113
114/////////////////////////////////////////////////////////////////////////
115// Debug/Info/Warning macros.
116#define STDERRMSG(...) do{\
117 fprintf(stderr, "%s:%d: ", __FUNCTION__, __LINE__);\
118 fprintf(stderr, __VA_ARGS__);\
119 fputc('\n',stderr);\
120 }while(0)
121#define NULLMSG(...) do{}while(0)
122
123#define DEBUGMSG NULLMSG
124#define INFOMSG STDERRMSG
125#define WARNMSG STDERRMSG
126/////////////////////////////////////////////////////////////////////////
126 127
127#endif // LL_GSTREAMER_ENABLED 128#endif // LL_GSTREAMER_ENABLED
128 129
diff --git a/linden/indra/llmedia/llmediaimplgstreamer_syms.cpp b/linden/indra/llmedia/llmediaimplgstreamer_syms.cpp
index 5d54689..bba3ef5 100644
--- a/linden/indra/llmedia/llmediaimplgstreamer_syms.cpp
+++ b/linden/indra/llmedia/llmediaimplgstreamer_syms.cpp
@@ -29,8 +29,6 @@
29 * $/LicenseInfo$ 29 * $/LicenseInfo$
30 */ 30 */
31 31
32#include "linden_common.h"
33
34#if LL_GSTREAMER_ENABLED 32#if LL_GSTREAMER_ENABLED
35 33
36extern "C" { 34extern "C" {
@@ -71,7 +69,7 @@ bool grab_gst_syms(std::string gst_dso_name,
71 apr_status_t rv; 69 apr_status_t rv;
72 apr_dso_handle_t *sSymGSTDSOHandle = NULL; 70 apr_dso_handle_t *sSymGSTDSOHandle = NULL;
73 71
74#define LL_GST_SYM(REQ, GSTSYM, RTN, ...) do{rv = apr_dso_sym((apr_dso_handle_sym_t*)&ll##GSTSYM, sSymGSTDSOHandle, #GSTSYM); if (rv != APR_SUCCESS) {llwarns << "Failed to grab symbol: " << #GSTSYM << llendl; if (REQ) sym_error = true;} else llinfos << "grabbed symbol: " << #GSTSYM << " from " << (void*)ll##GSTSYM << llendl;}while(0) 72#define LL_GST_SYM(REQ, GSTSYM, RTN, ...) do{rv = apr_dso_sym((apr_dso_handle_sym_t*)&ll##GSTSYM, sSymGSTDSOHandle, #GSTSYM); if (rv != APR_SUCCESS) {INFOMSG("Failed to grab symbol: %s", #GSTSYM); if (REQ) sym_error = true;} else DEBUGMSG("grabbed symbol: %s from %p", #GSTSYM, (void*)ll##GSTSYM);}while(0)
75 73
76 //attempt to load the shared libraries 74 //attempt to load the shared libraries
77 apr_pool_create(&sSymGSTDSOMemoryPool, NULL); 75 apr_pool_create(&sSymGSTDSOMemoryPool, NULL);
@@ -80,7 +78,7 @@ bool grab_gst_syms(std::string gst_dso_name,
80 gst_dso_name.c_str(), 78 gst_dso_name.c_str(),
81 sSymGSTDSOMemoryPool) )) 79 sSymGSTDSOMemoryPool) ))
82 { 80 {
83 llinfos << "Found DSO: " << gst_dso_name << llendl; 81 INFOMSG("Found DSO: %s", gst_dso_name.c_str());
84#include "llmediaimplgstreamer_syms_raw.inc" 82#include "llmediaimplgstreamer_syms_raw.inc"
85 83
86 if ( sSymGSTDSOHandle ) 84 if ( sSymGSTDSOHandle )
@@ -93,7 +91,7 @@ bool grab_gst_syms(std::string gst_dso_name,
93 gst_dso_name_aud.c_str(), 91 gst_dso_name_aud.c_str(),
94 sSymGSTDSOMemoryPool) )) 92 sSymGSTDSOMemoryPool) ))
95 { 93 {
96 llinfos << "Found DSO: " << gst_dso_name_aud << llendl; 94 INFOMSG("Found DSO: %s", gst_dso_name_aud.c_str());
97#include "llmediaimplgstreamer_syms_rawa.inc" 95#include "llmediaimplgstreamer_syms_rawa.inc"
98 96
99 if ( sSymGSTDSOHandle ) 97 if ( sSymGSTDSOHandle )
@@ -107,20 +105,18 @@ bool grab_gst_syms(std::string gst_dso_name,
107 gst_dso_name_vid.c_str(), 105 gst_dso_name_vid.c_str(),
108 sSymGSTDSOMemoryPool) )) 106 sSymGSTDSOMemoryPool) ))
109 { 107 {
110 llinfos << "Found DSO: " << gst_dso_name_vid << llendl; 108 INFOMSG("Found DSO: %s", gst_dso_name_vid.c_str());
111#include "llmediaimplgstreamer_syms_rawv.inc" 109#include "llmediaimplgstreamer_syms_rawv.inc"
112 } 110 }
113 else 111 else
114 { 112 {
115 llwarns << "Couldn't load DSO: " 113 INFOMSG("Couldn't load DSO: %s", gst_dso_name_vid.c_str());
116 << gst_dso_name_vid << llendl;
117 rtn = false; // failure 114 rtn = false; // failure
118 } 115 }
119 } 116 }
120 else 117 else
121 { 118 {
122 llwarns << "Couldn't load DSO: " 119 INFOMSG("Couldn't load DSO: %s", gst_dso_name_aud.c_str());
123 << gst_dso_name_aud << llendl;
124 rtn = false; // failure 120 rtn = false; // failure
125 } 121 }
126 122
@@ -128,13 +124,13 @@ bool grab_gst_syms(std::string gst_dso_name,
128 } 124 }
129 else 125 else
130 { 126 {
131 llwarns << "Couldn't load DSO: " << gst_dso_name << llendl; 127 INFOMSG("Couldn't load DSO: ", gst_dso_name.c_str());
132 rtn = false; // failure 128 rtn = false; // failure
133 } 129 }
134 130
135 if (sym_error) 131 if (sym_error)
136 { 132 {
137 llwarns << "Failed to find necessary symbols in GStreamer libraries." << llendl; 133 WARNMSG("Failed to find necessary symbols in GStreamer libraries.");
138 } 134 }
139 135
140 if ( sSymGSTDSOHandle ) 136 if ( sSymGSTDSOHandle )
diff --git a/linden/indra/llmedia/llmediaimplgstreamervidplug.cpp b/linden/indra/llmedia/llmediaimplgstreamervidplug.cpp
index 7c59caf..f9c2f89 100644
--- a/linden/indra/llmedia/llmediaimplgstreamervidplug.cpp
+++ b/linden/indra/llmedia/llmediaimplgstreamervidplug.cpp
@@ -137,7 +137,7 @@ gst_slvideo_show_frame (GstBaseSink * bsink, GstBuffer * buf)
137 if (needbytes != slvideo->retained_frame_allocbytes) 137 if (needbytes != slvideo->retained_frame_allocbytes)
138 { 138 {
139 delete[] slvideo->retained_frame_data; 139 delete[] slvideo->retained_frame_data;
140 slvideo->retained_frame_data = new U8[needbytes]; 140 slvideo->retained_frame_data = new unsigned char[needbytes];
141 slvideo->retained_frame_allocbytes = needbytes; 141 slvideo->retained_frame_allocbytes = needbytes;
142 142
143 } 143 }
@@ -146,7 +146,7 @@ gst_slvideo_show_frame (GstBaseSink * bsink, GstBuffer * buf)
146 for (int ypos=0; ypos<slvideo->height; ++ypos) 146 for (int ypos=0; ypos<slvideo->height; ++ypos)
147 { 147 {
148 memcpy(&slvideo->retained_frame_data[(slvideo->height-1-ypos)*rowbytes], 148 memcpy(&slvideo->retained_frame_data[(slvideo->height-1-ypos)*rowbytes],
149 &(((U8*)GST_BUFFER_DATA(buf))[ypos*rowbytes]), 149 &(((unsigned char*)GST_BUFFER_DATA(buf))[ypos*rowbytes]),
150 rowbytes); 150 rowbytes);
151 } 151 }
152 // done with the shared data 152 // done with the shared data
diff --git a/linden/indra/llmedia/llmediaimplgstreamervidplug.h b/linden/indra/llmedia/llmediaimplgstreamervidplug.h
index a15798e..27957db 100644
--- a/linden/indra/llmedia/llmediaimplgstreamervidplug.h
+++ b/linden/indra/llmedia/llmediaimplgstreamervidplug.h
@@ -82,7 +82,7 @@ struct _GstSLVideo
82 // (i.e. all written at once to reflect the current retained frame info 82 // (i.e. all written at once to reflect the current retained frame info
83 // when the retained frame is updated.) 83 // when the retained frame is updated.)
84 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.) 84 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.)
85 U8* retained_frame_data; 85 unsigned char* retained_frame_data;
86 int retained_frame_allocbytes; 86 int retained_frame_allocbytes;
87 int retained_frame_width, retained_frame_height; 87 int retained_frame_width, retained_frame_height;
88 SLVPixelFormat retained_frame_format; 88 SLVPixelFormat retained_frame_format;
@@ -90,7 +90,7 @@ struct _GstSLVideo
90 90
91struct _GstSLVideoClass 91struct _GstSLVideoClass
92{ 92{
93 GstVideoSink parent_class; 93 GstVideoSinkClass parent_class;
94}; 94};
95 95
96GType gst_slvideo_get_type (void); 96GType gst_slvideo_get_type (void);
diff --git a/linden/indra/llmedia/llmediaimplllmozlib.cpp b/linden/indra/llmedia/llmediaimplllmozlib.cpp
new file mode 100644
index 0000000..06250f7
--- /dev/null
+++ b/linden/indra/llmedia/llmediaimplllmozlib.cpp
@@ -0,0 +1,590 @@
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-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "llmediaimplllmozlib.h"
33
34#if LL_LLMOZLIB_ENABLED
35
36#include "llmediaimplregister.h"
37#include "llmediamanager.h"
38
39#ifdef WIN32
40 // platform specific includes needed before OpenGL header
41 #include <windows.h>
42 #include <GL/gl.h>
43#elif defined(__APPLE__)
44 // framework-style include path when building on the Mac.
45 #include <OpenGL/gl.h>
46#else // Assume this is linux
47 // Linux, MESA headers, but not necessarily assuming MESA runtime.
48 // quotes so we get libraries/.../GL/ version
49 #include "GL/gl.h"
50#endif
51
52#include <iostream>
53
54// register this impl with media manager factory
55static LLMediaImplRegister sLLMediaImplLLMozLibReg( "LLMediaImplLLMozLib", new LLMediaImplLLMozLibMaker() );
56
57///////////////////////////////////////////////////////////////////////////////
58//
59LLMediaImplLLMozLibMaker::LLMediaImplLLMozLibMaker()
60{
61 // Register to handle the scheme
62 mMimeTypeCategories.push_back( "text" );
63#if !LL_QUICKTIME_ENABLED
64 mMimeTypeCategories.push_back( "image" );
65#endif
66}
67
68///////////////////////////////////////////////////////////////////////////////
69//
70LLMediaImplLLMozLib::LLMediaImplLLMozLib() :
71 mBrowserWindowWidth( 800 ),
72 mBrowserWindowHeight( 600 ),
73 mMediaDataWidth( 0 ),
74 mMediaDataHeight( 0 ),
75 mWindowId( 0 ),
76 mNeedsUpdate( false )
77{
78 setRequestedMediaSize( mBrowserWindowWidth, mBrowserWindowHeight );
79
80 setMediaDepth( 4 );
81}
82
83////////////////////////////////////////////////////////////////////////////////
84// (static) super-initialization - called once at application startup
85bool LLMediaImplLLMozLib::startup( LLMediaManagerData* init_data )
86{
87 bool result = LLMozLib::getInstance()->init( init_data->getBrowserApplicationDir(),
88 init_data->getBrowserComponentDir(),
89 init_data->getBrowserProfileDir(),
90 init_data->getBrowserParentWindow() );
91
92 // append special string to the embedded browser user agent string
93 LLMozLib::getInstance()->setBrowserAgentId( init_data->getBrowserUserAgentId() );
94
95 return result;
96}
97
98////////////////////////////////////////////////////////////////////////////////
99// (static) super-uninitialization - called once at application closedown
100bool LLMediaImplLLMozLib::closedown()
101{
102 // name discrepancy - this reset actually shuts down LLMozLib
103 LLMozLib::getInstance()->reset();
104
105 return true;
106}
107
108////////////////////////////////////////////////////////////////////////////////
109// virtual
110bool LLMediaImplLLMozLib::init()
111{
112 // if mWindowId is non-0, it's we already called init() and shouldn't call it again
113 // (::reset() will zero this value)
114 if ( mWindowId )
115 return false;
116
117 mWindowId = LLMozLib::getInstance()->createBrowserWindow( mBrowserWindowWidth, mBrowserWindowHeight );
118
119 LLMozLib::getInstance()->setSize( mWindowId, mBrowserWindowWidth, mBrowserWindowHeight );
120
121 LLMozLib::getInstance()->setBackgroundColor( mWindowId, 0x00, 0x00, 0x00 );
122
123 LLMozLib::getInstance()->addObserver( mWindowId, this );
124
125 // plugins only work with some client-side hackery and they cause
126 // exception handling issues (DEV-10020) so we turn them off
127 LLMozLib::getInstance()->enablePlugins( false );
128
129 // second life client needs the bitmap flipped
130 LLMozLib::getInstance()->flipWindow( mWindowId, true );
131
132 // set media depth now we have created a browser window and know what it is
133 setMediaDepth( LLMozLib::getInstance()->getBrowserDepth( mWindowId ) );
134
135 return true;
136}
137
138////////////////////////////////////////////////////////////////////////////////
139// virtual
140std::string LLMediaImplLLMozLib::getVersion()
141{
142 std::string version_string = "[" + sLLMediaImplLLMozLibReg.getImplName() + "] - " + LLMozLib::getInstance()->getVersion();
143
144 return version_string;
145}
146
147////////////////////////////////////////////////////////////////////////////////
148// virtual
149bool LLMediaImplLLMozLib::set404RedirectUrl( std::string redirect_url )
150{
151 return LLMozLib::getInstance()->set404RedirectUrl( mWindowId, redirect_url );
152}
153
154////////////////////////////////////////////////////////////////////////////////
155// virtual
156
157bool LLMediaImplLLMozLib::clr404RedirectUrl()
158{
159 return LLMozLib::getInstance()->clr404RedirectUrl( mWindowId );
160}
161
162////////////////////////////////////////////////////////////////////////////////
163// virtual
164bool LLMediaImplLLMozLib::setBackgroundColor( unsigned int red, unsigned int green, unsigned int blue ) const
165{
166 return LLMozLib::getInstance()->setBackgroundColor( mWindowId, red, green, blue );
167}
168
169////////////////////////////////////////////////////////////////////////////////
170// virtual
171bool LLMediaImplLLMozLib::setCaretColor( unsigned int red, unsigned int green, unsigned int blue ) const
172{
173 return LLMozLib::getInstance()->setCaretColor( mWindowId, red, green, blue );
174}
175
176////////////////////////////////////////////////////////////////////////////////
177// virtual
178bool LLMediaImplLLMozLib::navigateTo( const std::string url )
179{
180 // pass url to llmozlib
181 LLMozLib::getInstance()->navigateTo( mWindowId, url );
182
183 // emit event with size change to kick things off
184 LLMediaEvent event( this );
185 mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event );
186
187 // not that useful right now but maybe later
188 return true;
189}
190
191////////////////////////////////////////////////////////////////////////////////
192// virtual
193bool LLMediaImplLLMozLib::updateMedia()
194{
195 if ( getStatus() == LLMediaBase::STATUS_STARTED )
196 {
197 // if flag set, the page changed and we need to update
198 if ( mNeedsUpdate )
199 {
200 // snap browser pixels
201 LLMozLib::getInstance()->grabBrowserWindow( mWindowId );
202
203 // update media width - rendering the page can change it
204 mMediaDataWidth = LLMozLib::getInstance()->getBrowserRowSpan( mWindowId ) / getMediaDepth();
205 mMediaDataHeight = LLMozLib::getInstance()->getBrowserHeight( mWindowId );
206
207 // emit an event to say that something in the media stream changed
208 LLMediaEvent event( this );
209 mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event );
210
211 // flag that we've done the update and one isn't needed next frame
212 mNeedsUpdate = false;
213 };
214 };
215
216 // update the state (e.g. transport controls) state
217 updateState();
218
219 return false;
220}
221
222////////////////////////////////////////////////////////////////////////////////
223//
224bool LLMediaImplLLMozLib::updateState()
225{
226 if ( nextCommand() == LLMediaBase::COMMAND_START )
227 {
228 setStatus( LLMediaBase::STATUS_STARTED );
229 clearCommand();
230 };
231
232 if ( nextCommand() == LLMediaBase::COMMAND_STOP )
233 {
234 setStatus( LLMediaBase::STATUS_STOPPED );
235 clearCommand();
236 };
237
238 if ( nextCommand() == LLMediaBase::COMMAND_BACK )
239 {
240 setStatus( LLMediaBase::STATUS_STARTED );
241 LLMozLib::getInstance()->navigateBack( mWindowId );
242 clearCommand();
243 };
244
245 if ( nextCommand() == LLMediaBase::COMMAND_FORWARD )
246 {
247 setStatus( LLMediaBase::STATUS_STARTED );
248 LLMozLib::getInstance()->navigateForward( mWindowId );
249 clearCommand();
250 };
251
252 return true;
253}
254
255////////////////////////////////////////////////////////////////////////////////
256// virtual
257void LLMediaImplLLMozLib::onPageChanged( const EventType& eventIn )
258{
259 // force an update when the contents of the page changes
260 mNeedsUpdate = true;
261}
262
263////////////////////////////////////////////////////////////////////////////////
264// virtual
265void LLMediaImplLLMozLib::onClickLinkHref( const EventType& eventIn )
266{
267 LLMediaEvent event( this, eventIn.getStringValue() );
268 mEventEmitter.update( &LLMediaObserver::onClickLinkHref, event );
269}
270
271////////////////////////////////////////////////////////////////////////////////
272// virtual
273void LLMediaImplLLMozLib::onClickLinkNoFollow( const EventType& eventIn )
274{
275 LLMediaEvent event( this, eventIn.getStringValue() );
276 mEventEmitter.update( &LLMediaObserver::onClickLinkNoFollow, event );
277}
278
279////////////////////////////////////////////////////////////////////////////////
280// virtual
281void LLMediaImplLLMozLib::onUpdateProgress( const EventType& eventIn )
282{
283 LLMediaEvent event( this, eventIn.getIntValue() );
284 mEventEmitter.update( &LLMediaObserver::onUpdateProgress, event );
285}
286
287////////////////////////////////////////////////////////////////////////////////
288// virtual
289void LLMediaImplLLMozLib::onStatusTextChange( const EventType& eventIn )
290{
291 LLMediaEvent event( this, eventIn.getStringValue() );
292 mEventEmitter.update( &LLMediaObserver::onStatusTextChange, event );
293}
294
295////////////////////////////////////////////////////////////////////////////////
296// virtual
297void LLMediaImplLLMozLib::onLocationChange( const EventType& eventIn )
298{
299 LLMediaEvent event( this, eventIn.getEventUri() );
300 mEventEmitter.update( &LLMediaObserver::onLocationChange, event );
301}
302
303////////////////////////////////////////////////////////////////////////////////
304// virtual
305void LLMediaImplLLMozLib::onNavigateBegin( const EventType& eventIn )
306{
307 LLMediaEvent event( this, eventIn.getEventUri() );
308 mEventEmitter.update( &LLMediaObserver::onNavigateBegin, event );
309}
310
311////////////////////////////////////////////////////////////////////////////////
312// virtual
313void LLMediaImplLLMozLib::onNavigateComplete( const EventType& eventIn )
314{
315 // force an update when the page is finished
316 mNeedsUpdate = true;
317
318 // pass in url and HTML response code (200/404 etc.)
319 LLMediaEvent event( this, eventIn.getEventUri(), eventIn.getIntValue() );
320 mEventEmitter.update( &LLMediaObserver::onNavigateComplete, event );
321}
322
323////////////////////////////////////////////////////////////////////////////////
324// virtual
325unsigned char* LLMediaImplLLMozLib::getMediaData()
326{
327 return (unsigned char*)LLMozLib::getInstance()->getBrowserWindowPixels( mWindowId );
328}
329
330// helper func to compute size of media data
331bool LLMediaImplLLMozLib::recomputeSizes()
332{
333 int new_width = mMediaRequestedWidth;
334 int new_height = mMediaRequestedHeight;
335
336 if (new_width < 0)
337 new_width = 512;
338
339 if (new_height < 0)
340 new_height = 512;
341
342 if (mAutoScaled)
343 {
344 new_width = LLMediaManager::textureWidthFromMediaWidth( new_width );
345 new_height = LLMediaManager::textureHeightFromMediaHeight( new_height );
346 }
347
348 bool status = LLMozLib::getInstance()->setSize( mWindowId, new_width, new_height );
349
350 if (status)
351 setMediaSize(new_width, new_height);
352
353 return status;
354}
355
356
357////////////////////////////////////////////////////////////////////////////////
358// virtual
359int LLMediaImplLLMozLib::getMediaDataWidth() const
360{
361 return mMediaDataWidth;
362}
363
364////////////////////////////////////////////////////////////////////////////////
365// virtual
366int LLMediaImplLLMozLib::getMediaDataHeight() const
367{
368 return mMediaDataHeight;
369}
370
371////////////////////////////////////////////////////////////////////////////////
372// virtual
373bool LLMediaImplLLMozLib::setRequestedMediaSize(int width, int height)
374{
375 LLMediaImplCommon::setRequestedMediaSize(width, height);
376
377 return recomputeSizes();
378}
379
380////////////////////////////////////////////////////////////////////////////////
381// virtual
382bool LLMediaImplLLMozLib::setAutoScaled( bool auto_scaled )
383{
384 LLMediaImplCommon::setAutoScaled(auto_scaled);
385
386 return recomputeSizes();
387}
388
389
390////////////////////////////////////////////////////////////////////////////////
391// virtual
392int LLMediaImplLLMozLib::getTextureFormatPrimary() const
393{
394#if defined(__APPLE__) || defined(MACOSX)
395 return GL_BGRA_EXT;
396#else
397 return LLMozLib::getInstance()->getBrowserDepth( mWindowId ) == 3 ? GL_BGR_EXT : GL_BGRA_EXT;
398#endif
399}
400
401////////////////////////////////////////////////////////////////////////////////
402// virtual
403int LLMediaImplLLMozLib::getTextureFormatType() const
404{
405#if defined(__APPLE__) || defined(MACOSX)
406 #ifdef __BIG_ENDIAN__
407 return GL_UNSIGNED_INT_8_8_8_8_REV;
408 #else
409 return GL_UNSIGNED_INT_8_8_8_8;
410 #endif
411#else
412 return GL_UNSIGNED_BYTE;
413#endif
414}
415
416////////////////////////////////////////////////////////////////////////////////
417// virtual
418bool LLMediaImplLLMozLib::mouseDown( int x_pos, int y_pos )
419{
420 return LLMozLib::getInstance()->mouseDown( mWindowId, x_pos, y_pos );
421}
422
423////////////////////////////////////////////////////////////////////////////////
424// virtual
425bool LLMediaImplLLMozLib::mouseUp( int x_pos, int y_pos )
426{
427 LLMozLib::getInstance()->mouseUp( mWindowId, x_pos, y_pos );
428
429 // this seems better than sending focus on mouse down (still need to improve this)
430 LLMozLib::getInstance()->focusBrowser( mWindowId, true );
431
432 return true;
433}
434
435////////////////////////////////////////////////////////////////////////////////
436// virtual
437bool LLMediaImplLLMozLib::mouseMove( int x_pos, int y_pos )
438{
439 return LLMozLib::getInstance()->mouseMove( mWindowId, x_pos, y_pos );
440}
441
442////////////////////////////////////////////////////////////////////////////////
443// virtual
444bool LLMediaImplLLMozLib::keyPress( int key_code )
445{
446 // We don't have to deal with printable characters here - they should
447 // go through handleUnicodeChar(). This table could be more complete
448 // than it is, but I think this covers all of the important
449 // non-printables.
450
451 unsigned long moz_key;
452
453 switch(key_code)
454 {
455 case LL_MEDIA_KEY_BACKSPACE:
456 moz_key = LL_DOM_VK_BACK_SPACE; break;
457 case LL_MEDIA_KEY_TAB:
458 moz_key = LL_DOM_VK_TAB; break;
459 case LL_MEDIA_KEY_RETURN:
460 moz_key = LL_DOM_VK_RETURN; break;
461 case LL_MEDIA_KEY_PAD_RETURN:
462 moz_key = LL_DOM_VK_ENTER; break;
463 case LL_MEDIA_KEY_ESCAPE:
464 moz_key = LL_DOM_VK_ESCAPE; break;
465 case LL_MEDIA_KEY_PAGE_UP:
466 moz_key = LL_DOM_VK_PAGE_UP; break;
467 case LL_MEDIA_KEY_PAGE_DOWN:
468 moz_key = LL_DOM_VK_PAGE_DOWN; break;
469 case LL_MEDIA_KEY_END:
470 moz_key = LL_DOM_VK_END; break;
471 case LL_MEDIA_KEY_HOME:
472 moz_key = LL_DOM_VK_HOME; break;
473 case LL_MEDIA_KEY_LEFT:
474 moz_key = LL_DOM_VK_LEFT; break;
475 case LL_MEDIA_KEY_UP:
476 moz_key = LL_DOM_VK_UP; break;
477 case LL_MEDIA_KEY_RIGHT:
478 moz_key = LL_DOM_VK_RIGHT; break;
479 case LL_MEDIA_KEY_DOWN:
480 moz_key = LL_DOM_VK_DOWN; break;
481 case LL_MEDIA_KEY_INSERT:
482 moz_key = LL_DOM_VK_INSERT; break;
483 case LL_MEDIA_KEY_DELETE:
484 moz_key = LL_DOM_VK_DELETE; break;
485
486 default:
487 return false; // don't know how to map this key.
488 }
489
490 return LLMozLib::getInstance()->keyPress( mWindowId, moz_key );
491}
492
493////////////////////////////////////////////////////////////////////////////////
494// virtual
495bool LLMediaImplLLMozLib::scrollByLines( int lines )
496{
497 return LLMozLib::getInstance()->scrollByLines(mWindowId, lines);
498}
499
500////////////////////////////////////////////////////////////////////////////////
501// virtual
502bool LLMediaImplLLMozLib::focus( bool focus )
503{
504 return LLMozLib::getInstance()->focusBrowser(mWindowId, focus);
505}
506
507////////////////////////////////////////////////////////////////////////////////
508// virtual
509bool LLMediaImplLLMozLib::unicodeInput( unsigned long uni_char )
510{
511 return LLMozLib::getInstance()->unicodeInput(mWindowId, uni_char);
512}
513
514////////////////////////////////////////////////////////////////////////////////
515// virtual
516bool LLMediaImplLLMozLib::mouseLeftDoubleClick( int x_pos, int y_pos )
517{
518 return LLMozLib::getInstance()->mouseLeftDoubleClick( mWindowId, x_pos, y_pos );
519}
520
521////////////////////////////////////////////////////////////////////////////////
522// virtual
523bool LLMediaImplLLMozLib::navigateForward()
524{
525 return LLMozLib::getInstance()->navigateForward(mWindowId);
526}
527
528////////////////////////////////////////////////////////////////////////////////
529// virtual
530bool LLMediaImplLLMozLib::navigateBack()
531{
532 return LLMozLib::getInstance()->navigateBack(mWindowId);
533}
534
535////////////////////////////////////////////////////////////////////////////////
536// virtual
537bool LLMediaImplLLMozLib::canNavigateForward()
538{
539 return LLMozLib::getInstance()->canNavigateForward(mWindowId);
540}
541
542////////////////////////////////////////////////////////////////////////////////
543// virtual
544bool LLMediaImplLLMozLib::canNavigateBack()
545{
546 return LLMozLib::getInstance()->canNavigateBack(mWindowId);
547}
548
549////////////////////////////////////////////////////////////////////////////////
550// virtual
551bool LLMediaImplLLMozLib::enableCookies(bool enable)
552{
553 return LLMozLib::getInstance()->enableCookies(enable);
554}
555
556////////////////////////////////////////////////////////////////////////////////
557// virtual
558bool LLMediaImplLLMozLib::enableProxy(bool enable, std::string proxy_host_name, int proxy_port)
559{
560 return LLMozLib::getInstance()->enableProxy(enable, proxy_host_name, proxy_port);
561}
562
563////////////////////////////////////////////////////////////////////////////////
564// virtual
565bool LLMediaImplLLMozLib::clearCache()
566{
567 return LLMozLib::getInstance()->clearCache();
568}
569
570////////////////////////////////////////////////////////////////////////////////
571// virtual
572bool LLMediaImplLLMozLib::clearCookies()
573{
574 return LLMozLib::getInstance()->clearAllCookies();
575}
576
577////////////////////////////////////////////////////////////////////////////////
578// virtual
579bool LLMediaImplLLMozLib::reset()
580{
581 LLMozLib::getInstance()->remObserver( mWindowId, this );
582
583 LLMozLib::getInstance()->destroyBrowserWindow( mWindowId );
584
585 mWindowId = 0;
586
587 return true;
588}
589
590#endif // LL_LLMOZLIB_ENABLED
diff --git a/linden/indra/llmedia/llmediaimplllmozlib.h b/linden/indra/llmedia/llmediaimplllmozlib.h
new file mode 100644
index 0000000..fc5d4e5
--- /dev/null
+++ b/linden/indra/llmedia/llmediaimplllmozlib.h
@@ -0,0 +1,120 @@
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-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#ifndef LLMEDIAIMPLLLMOZLIB_H
33#define LLMEDIAIMPLLLMOZLIB_H
34
35#include "llmediaimplcommon.h"
36#include "llmediaimplfactory.h"
37
38#if LL_LLMOZLIB_ENABLED
39
40#include "llmozlib2.h"
41
42class LLMediaManagerData;
43
44class LLMediaImplLLMozLib :
45 public LLMediaImplCommon,
46 public LLEmbeddedBrowserWindowObserver
47{
48 public:
49 LLMediaImplLLMozLib();
50
51 static bool startup( LLMediaManagerData* init_data );
52 static bool closedown();
53
54 /* virtual */ bool init();
55 /* virtual */ std::string getVersion();
56 /* virtual */ bool set404RedirectUrl( std::string redirect_url );
57 /* virtual */ bool clr404RedirectUrl();
58 /* virtual */ bool setBackgroundColor( unsigned int red, unsigned int green, unsigned int blue ) const;
59 /* virtual */ bool setCaretColor( unsigned int red, unsigned int green, unsigned int blue ) const;
60 /* virtual */ bool navigateTo( const std::string url );
61 /* virtual */ bool updateMedia();
62 /* virtual */ unsigned char* getMediaData();
63 /* virtual */ int getMediaDataWidth() const;
64 /* virtual */ int getMediaDataHeight() const;
65 /* virtual */ bool setRequestedMediaSize(int width, int height);
66 /* virtual */ bool setAutoScaled( bool auto_scaled );
67 /* virtual */ int getTextureFormatPrimary() const;
68 /* virtual */ int getTextureFormatType() const;
69 /* virtual */ bool mouseDown( int x_pos, int y_pos );
70 /* virtual */ bool mouseUp( int x_pos, int y_pos );
71 /* virtual */ bool mouseMove( int x_pos, int y_pos );
72 /* virtual */ bool keyPress( int key_code );
73 /* virtual */ bool scrollByLines( int lines );
74 /* virtual */ bool focus( bool focus );
75 /* virtual */ bool unicodeInput( unsigned long uni_char );
76 /* virtual */ bool mouseLeftDoubleClick( int x_pos, int y_pos );
77 /* virtual */ bool navigateForward();
78 /* virtual */ bool navigateBack();
79 /* virtual */ bool canNavigateForward();
80 /* virtual */ bool canNavigateBack();
81 /* virtual */ bool enableCookies(bool enable);
82 /* virtual */ bool enableProxy(bool enable, std::string proxy_host_name, int proxy_port);
83 /* virtual */ bool clearCache();
84 /* virtual */ bool clearCookies();
85 /* virtual */ bool reset();
86
87 // LLMozLib observerables
88 virtual void onNavigateBegin( const EventType& eventIn );
89 virtual void onNavigateComplete( const EventType& eventIn );
90 virtual void onUpdateProgress( const EventType& eventIn );
91 virtual void onPageChanged( const EventType& eventIn );
92 virtual void onStatusTextChange( const EventType& eventIn );
93 virtual void onLocationChange( const EventType& eventIn );
94 virtual void onClickLinkHref( const EventType& eventIn );
95 virtual void onClickLinkNoFollow( const EventType& eventIn );
96
97 private:
98 bool recomputeSizes();
99 int mWindowId;
100 int mBrowserWindowWidth;
101 int mBrowserWindowHeight;
102 int mMediaDataWidth;
103 int mMediaDataHeight;
104 bool mNeedsUpdate;
105 bool updateState();
106};
107
108// The maker class
109class LLMediaImplLLMozLibMaker : public LLMediaImplMaker
110{
111 public:
112 LLMediaImplLLMozLibMaker();
113 LLMediaImplLLMozLib* create()
114 {
115 return new LLMediaImplLLMozLib();
116 }
117};
118#endif // LL_LLMOZLIB_ENABLED
119
120#endif // LLMEDIAIMPLLLMOZLIB_H
diff --git a/linden/indra/llmedia/llmediaimplquicktime.cpp b/linden/indra/llmedia/llmediaimplquicktime.cpp
index 8fcd7bf..f9a3b05 100644
--- a/linden/indra/llmedia/llmediaimplquicktime.cpp
+++ b/linden/indra/llmedia/llmediaimplquicktime.cpp
@@ -1,10 +1,10 @@
1/** 1/**
2 * @file llmediaimplquicktime.cpp 2 * @file llmediaimplquicktime.cpp
3 * @brief implementation that supports Apple QuickTime media. 3 * @brief QuickTime media impl concrete class
4 * 4 *
5 * $LicenseInfo:firstyear=2005&license=viewergpl$ 5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2005-2008, Linden Research, Inc. 7 * Copyright (c) 2007-2008, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -29,382 +29,269 @@
29 * $/LicenseInfo$ 29 * $/LicenseInfo$
30 */ 30 */
31 31
32#include "linden_common.h" 32#include "llmediaimplquicktime.h"
33 33
34#if LL_QUICKTIME_ENABLED 34#if LL_QUICKTIME_ENABLED
35 35
36#include <iostream> 36#include "llmediamanager.h"
37#include "llmediaimplregister.h"
37 38
38#include "llmediaimplquicktime.h" 39#if LL_WINDOWS
40#include <windows.h>
41#endif
42
43#include <iostream>
44#include <sstream>
39 45
40#include "llgl.h" 46// register this impl with media manager factory
41#include "llglheaders.h" // For gl texture modes 47static LLMediaImplRegister sLLMediaImplQuickTimeReg( "LLMediaImplQuickTime", new LLMediaImplQuickTimeMaker() );
42 48
43/////////////////////////////////////////////////////////////////////////////// 49///////////////////////////////////////////////////////////////////////////////
44// 50//
45LLMediaImplQuickTime:: 51LLMediaImplQuickTimeMaker::LLMediaImplQuickTimeMaker()
46LLMediaImplQuickTime () :
47 theController ( NULL ),
48 currentMode ( ModeIdle ),
49 theGWorld ( 0 ),
50 theMovie ( 0 ),
51 mediaData ( 0 ),
52 loopsLeft ( 0 ),
53 ownBuffer ( TRUE ),
54 curVolume ( 0 ),
55 sizeChangeInProgress ( FALSE ),
56 initialStartDone ( FALSE ),
57 autoScaled ( FALSE )
58{ 52{
59// These should probably be in the initializer list above, but that seemed uglier... 53 // Register to handle the scheme
60#if LL_DARWIN 54 mSchema.push_back( "rtsp" );
61 // Mac OS -- gworld will be xRGB (4 byte pixels, like ARGB, but QuickDraw doesn't actually do alpha...)
62 mMediaDepthBytes = 4;
63 mTextureDepth = 4;
64 mTextureFormatInternal = GL_RGB8;
65 mTextureFormatPrimary = GL_BGRA;
66#ifdef LL_BIG_ENDIAN
67 mTextureFormatType = GL_UNSIGNED_INT_8_8_8_8_REV;
68#else
69 mTextureFormatType = GL_UNSIGNED_INT_8_8_8_8;
70#endif
71 55
72#else 56 // Register to handle the category
73 // Windows -- GWorld will be RGB (3 byte pixels) 57 mMimeTypeCategories.push_back( "video" );
74 mMediaDepthBytes = 3; 58 mMimeTypeCategories.push_back( "audio" );
75 mTextureDepth = 3; 59 mMimeTypeCategories.push_back( "image" );
76 mTextureFormatInternal = GL_RGB8; 60}
77 mTextureFormatPrimary = GL_RGB;
78 mTextureFormatType = GL_UNSIGNED_BYTE;
79#endif
80};
81 61
82/////////////////////////////////////////////////////////////////////////////// 62///////////////////////////////////////////////////////////////////////////////
83// 63//
84LLMediaImplQuickTime:: 64LLMediaImplQuickTime::LLMediaImplQuickTime() :
85~LLMediaImplQuickTime () 65 mMovieHandle( 0 ),
66 mGWorldHandle( 0 ),
67 mMovieController( 0 ),
68 mMinWidth( 32 ),
69 mMaxWidth( 2048 ),
70 mMinHeight( 32 ),
71 mMaxHeight( 2048 ),
72 mCurVolume( 0 )
86{ 73{
87 unload();
88} 74}
89 75
90/////////////////////////////////////////////////////////////////////////////// 76///////////////////////////////////////////////////////////////////////////////
91// 77//
92BOOL 78LLMediaImplQuickTime::~LLMediaImplQuickTime()
93LLMediaImplQuickTime::
94setBuffer ( U8* bufferIn )
95{ 79{
96 OSErr err = noErr; 80 unload();
97 81}
98 // If we're waiting for a size change, we just got one.
99 sizeChangeInProgress = FALSE;
100
101 // Since we've pointed QuickTime at the old media data buffer directly, we need to be somewhat careful deleting it...
102 U8* oldMediaData = mediaData;
103 BOOL ownedMediaData = ownBuffer;
104#if LL_DARWIN
105 GWorldPtr oldGWorld = theGWorld;
106#endif
107
108 if(bufferIn == NULL)
109 {
110 // Passing NULL to this function requests that the object allocate its own buffer.
111 mediaData = new unsigned char [ mMediaHeight * mMediaRowbytes ];
112 ownBuffer = TRUE;
113 }
114 else
115 {
116 // Use the supplied buffer.
117 mediaData = bufferIn;
118 ownBuffer = FALSE;
119 }
120
121 if(mediaData == NULL)
122 {
123 // This is bad.
124 llerrs << "LLMediaImplQuickTime::setBuffer: mediaData is NULL" << llendl;
125 // NOTE: This case doesn't clean up properly. This assert is fatal, so this isn't a huge problem,
126 // but if this assert is ever removed the code should be fixed to clean up correctly.
127 return FALSE;
128 }
129
130 err = NewGWorldFromPtr ( &theGWorld, mMediaDepthBytes * 8, &movieRect, NULL, NULL, 0, (Ptr)mediaData, mMediaRowbytes);
131 if(err == noErr)
132 {
133 if(theMovie)
134 {
135 // tell the movie about it
136 SetMovieGWorld ( theMovie, theGWorld, GetGWorldDevice ( theGWorld ) );
137 }
138
139 if(theController)
140 {
141 // and tell the movie controller about it.
142 MCSetControllerPort(theController, theGWorld);
143 }
144 82
145#if LL_DARWIN 83////////////////////////////////////////////////////////////////////////////////
146// NOTE: (CP) This call ultimately leads to a crash in NewGWorldFromPtr on Windows (only) 84// (static) super-initialization - called once at application startup
147// Not calling DisposeGWorld doesn't appear to leak anything significant and stops the crash occuring. 85bool LLMediaImplQuickTime::startup( LLMediaManagerData* init_data )
148// This will eventually be fixed but for now, leaking slightly is better than crashing. 86{
149 if ( oldGWorld != NULL ) 87#ifdef WIN32
150 { 88 if ( InitializeQTML( 0L ) != noErr )
151 // Delete the old GWorld
152 DisposeGWorld ( oldGWorld );
153 oldGWorld = NULL;
154 }
155#endif
156 }
157 else
158 {
159 // Hmm... this may be bad. Assert here?
160 llerrs << "LLMediaImplQuickTime::setBuffer: NewGWorldFromPtr failed" << llendl;
161 theGWorld = NULL;
162 return FALSE;
163 }
164
165 // Delete the old media data buffer iff we owned it.
166 if ( ownedMediaData )
167 { 89 {
168 if ( oldMediaData ) 90 return false;
169 { 91 };
170 delete [] oldMediaData; 92#endif
171 } 93
172 } 94 EnterMovies();
173 95
174 // build event and emit it 96 return true;
175
176 return TRUE;
177} 97}
178 98
179/////////////////////////////////////////////////////////////////////////////// 99////////////////////////////////////////////////////////////////////////////////
180// 100// (static) super-uninitialization - called once at application closedown
181BOOL 101bool LLMediaImplQuickTime::closedown()
182LLMediaImplQuickTime::
183init ()
184{ 102{
185 // movied to main application initialization for now because it's non-trivial and only needs to be done once 103 ExitMovies();
186 // (even though it goes against the media framework design) 104
187 //if ( InitializeQTML ( 0L ) != 0 ) 105#ifdef WIN32
188 //{ 106 TerminateQTML();
189 // return FALSE; 107#endif
190 //}; 108
191 109 return true;
192 //if ( EnterMovies () != 0 )
193 //{
194 // return FALSE;
195 //};
196
197 return LLMediaMovieBase::init();
198} 110}
199 111
200/////////////////////////////////////////////////////////////////////////////// 112////////////////////////////////////////////////////////////////////////////////
201// 113// private
202void 114bool LLMediaImplQuickTime::load( const std::string url )
203LLMediaImplQuickTime::
204updateMediaSize()
205{ 115{
206 if((theController == NULL) && (!isQTLoaded())) 116 if ( url.empty() )
207 { 117 return false;
208 // The movie's not loaded enough to get info about it yet.
209 // Set up a dummy buffer.
210 movieRect.left = movieRect.top = 0;
211 movieRect.right = movieRect.bottom = 64;
212 mMediaRowbytes = mMediaDepthBytes * 64;
213 mMediaWidth = 64;
214 mMediaHeight = 64;
215 mTextureWidth = 64;
216 mTextureHeight = 64;
217
218 return;
219 }
220
221 // pick up the size of the movie
222 GetMovieBox ( theMovie, &movieRect );
223
224 // save the size of the media so consumer of media class can use it
225 mMediaWidth = movieRect.right - movieRect.left;
226 mMediaHeight = movieRect.bottom - movieRect.top;
227
228 // Giant media could make us try to use textures bigger than the opengl implementation can handle.
229 // Pin the maximum X or Y dimension to 1024.
230 // NOTE: 1024x1024 may still hurt a lot, but it shouldn't cause opengl to flame out.
231 if(mMediaWidth > 1024)
232 {
233 mMediaWidth = 1024;
234 }
235 if(mMediaHeight > 1024)
236 {
237 mMediaHeight = 1024;
238 }
239
240 // calculate the texture size required to hold media of this size (next power of 2 bigger)
241 for ( mTextureWidth = 1; mTextureWidth < mMediaWidth; mTextureWidth <<= 1 )
242 {
243 };
244 118
245 for ( mTextureHeight = 1; mTextureHeight < mMediaHeight; mTextureHeight <<= 1 ) 119 Handle handle = NewHandleClear( ( Size )( url.length() + 1 ) );
246 { 120 if ( NULL == handle )
247 }; 121 return false;
248 122
249// llinfos << "Media texture size will be " << mTextureWidth << " x " << mTextureHeight << llendl; 123 BlockMove( url.c_str(), *handle, ( Size )( url.length() + 1 ) );
250
251 // if autoscale is on we simply make the media & texture sizes the same and quicktime does all the hard work
252 if ( autoScaled )
253 {
254 // Stretch the movie to fill the texture.
255 mMediaWidth = mTextureWidth;
256 mMediaHeight = mTextureHeight;
257
258 // scale movie using high quality but slow algorithm.
259 // NOTE: this results in close to same quality as texture scaling option but with (perhaps) significant
260 // loss of performance (e.g. my machine, release build, frame rate goes from 92 -> 82 fps
261 // To revert to original behaviour, just remove the line below.
262
263 // MBW -- There seems to be serious drop in performance above a particular size, on both low and high end machines.
264 // 512x256 is fine, while 512x512 is unusable. I theorize that this is due to CPU cache getting broken around that size.
265 if((mTextureWidth * mTextureHeight) <= (512 * 256))
266 {
267// llinfos << "Setting high-quality hint." << llendl;
268 SetMoviePlayHints ( theMovie, hintsHighQuality, hintsHighQuality );
269 }
270 };
271
272 // always flip movie using quicktime (little performance impact and no loss in quality)
273 if ( TRUE )
274 {
275 // Invert the movie in the Y directon to match the expected orientation of GL textures.
276 MatrixRecord transform;
277 GetMovieMatrix ( theMovie, &transform );
278
279 double centerX = mMediaWidth / 2.0;
280 double centerY = mMediaHeight / 2.0;
281 ScaleMatrix ( &transform, X2Fix ( 1.0 ), X2Fix ( -1.0 ), X2Fix ( centerX ), X2Fix ( centerY ) );
282
283 SetMovieMatrix ( theMovie, &transform );
284 };
285 124
286 movieRect.left = 0; 125 //std::cout << "LLMediaImplQuickTime::load( " << url << " )" << std::endl;
287 movieRect.top = 0;
288 movieRect.right = mMediaWidth;
289 movieRect.bottom = mMediaHeight;
290 126
291 // Calculate the rowbytes of the texture 127 // TODO: supposed to use NewMovieFromDataParams now
292 mMediaRowbytes = mMediaWidth * mMediaDepthBytes; 128 OSErr err = NewMovieFromDataRef( &mMovieHandle, newMovieActive | newMovieDontInteractWithUser | newMovieAsyncOK | newMovieIdleImportOK, nil, handle, URLDataHandlerSubType );
293 129 DisposeHandle( handle );
294 SetMovieBox(theMovie, &movieRect); 130 if ( noErr != err )
131 return false;
295 132
296 if(theController == NULL) 133 // do pre-roll actions (typically fired for streaming movies but not always)
297 { 134 PrePrerollMovie( mMovieHandle, 0, GetMoviePreferredRate( mMovieHandle ), moviePrePrerollCompleteCallback, ( void * )this );
298 SetGWorld(theGWorld, NULL); 135
299 136 // get movie rect (and check for min/max)
300 // Create a movie controller for the movie 137 Rect movie_rect;
301 theController = NewMovieController(theMovie, &movieRect, mcNotVisible|mcTopLeftMovie); 138 setMovieBoxEnhanced( &movie_rect );
302 139
303 MCSetActionFilterWithRefCon(theController, myMCActionFilterProc, (long)this); 140 // make a new movie controller
304 141 mMovieController = NewMovieController( mMovieHandle, &movie_rect, mcNotVisible | mcTopLeftMovie );
305 // Allow the movie to dynamically resize (may be necessary for streaming movies to work right...) 142
306 SetMoviePlayHints(theMovie, hintsAllowDynamicResize, hintsAllowDynamicResize); 143#if defined(__APPLE__) || defined(MACOSX)
307 } 144 setMediaDepth( 4 );
308 else 145#else
309 { 146 setMediaDepth( 3 );
310 MCPositionController(theController, &movieRect, &movieRect, mcTopLeftMovie|mcPositionDontInvalidate); 147#endif
311 } 148
149 // tell manager about the media size
150 setMediaSize( movie_rect.right - movie_rect.left, movie_rect.bottom - movie_rect.top);
151
152 // movie controller
153 MCSetActionFilterWithRefCon( mMovieController, mcActionFilterCallBack, ( long )this );
154
155 SetMoviePlayHints( mMovieHandle, hintsAllowDynamicResize, hintsAllowDynamicResize );
156
157 // function that gets called when a frame is drawn
158 SetMovieDrawingCompleteProc( mMovieHandle, movieDrawingCallWhenChanged, movieDrawingCompleteCallback, ( long )this );
159
160 // emit an event to say that a media source was loaded
161 LLMediaEvent event( this );
162 mEventEmitter.update( &LLMediaObserver::onMediaLoaded, event );
163
164 // set up inital state
165 sizeChanged();
166
167 return true;
312} 168}
313 169
314/////////////////////////////////////////////////////////////////////////////// 170////////////////////////////////////////////////////////////////////////////////
315// 171// virtual
316void 172std::string LLMediaImplQuickTime::getVersion()
317LLMediaImplQuickTime::
318setupDummyBuffer()
319{ 173{
320 // Used when the movie can't be drawn for some reason. This sets up a buffer that keeps callers from getting annoyed. 174 long version;
321 movieRect.left = movieRect.top = 0; 175 Gestalt( gestaltQuickTimeVersion, &version );
322 movieRect.right = movieRect.bottom = 64; 176
323 mMediaRowbytes = mMediaDepthBytes * 64; 177 std::ostringstream codec( "" );
324 mMediaWidth = 64; 178 codec << "[";
325 mMediaHeight = 64; 179 codec << sLLMediaImplQuickTimeReg.getImplName();
326 mTextureWidth = 64; 180 codec << "] - ";
327 mTextureHeight = 64; 181 codec << "QuickTime: " << std::hex << version;
328 182
329 setBuffer ( NULL ); 183 return codec.str();
330
331 memset(mediaData, 0, mMediaRowbytes * mMediaHeight );
332} 184}
333 185
334/////////////////////////////////////////////////////////////////////////////// 186////////////////////////////////////////////////////////////////////////////////
335// 187// virtual
336BOOL 188bool LLMediaImplQuickTime::navigateTo( const std::string url )
337LLMediaImplQuickTime::
338load ( const LLString& urlIn )
339{ 189{
340 // The movie may do things to the current port when it's created. Make sure we have a valid port set. 190 // tell engine what we're doing
341 setupDummyBuffer(); 191 setStatus( LLMediaBase::STATUS_NAVIGATING );
342 SetGWorld(theGWorld, NULL);
343
344 Size mySize = ( Size ) urlIn.length () + 1;
345 if ( mySize == 0 )
346 return FALSE;
347
348 Handle myHandle = NewHandleClear ( mySize );
349 if ( myHandle == NULL )
350 return FALSE;
351
352 BlockMove ( urlIn.c_str (), *myHandle, mySize );
353
354 // Might be able to make this asynchronous with (newMovieActive|newMovieAsyncOK|newMovieIdleImportOK)?
355 OSErr err = NewMovieFromDataRef ( &theMovie, newMovieActive|newMovieDontInteractWithUser|newMovieAsyncOK|newMovieIdleImportOK, NULL, myHandle, URLDataHandlerSubType );
356
357 if ( err != noErr )
358 return false;
359 192
360 // function that gets called when a frame is drawn 193 // remove the movie we were looking at
361 SetMovieDrawingCompleteProc ( theMovie, movieDrawingCallWhenChanged, myFrameDrawnCallback, ( long ) this ); 194 unload();
362 195
363 if(isQTLoaded()) 196 // load the new one (no real 'go to this url' function in QT)
364 { 197 load( url );
365 updateMediaSize(); 198
366 setBuffer(NULL); 199 return true;
367 }
368
369 // Tell the controller to play the movie. This also deals with the movie still loading.
370 //play();
371
372 return LLMediaMovieBase::load(urlIn);
373} 200}
374 201
375/////////////////////////////////////////////////////////////////////////////// 202////////////////////////////////////////////////////////////////////////////////
376// 203// virtual
377OSErr 204bool LLMediaImplQuickTime::sizeChanged()
378LLMediaImplQuickTime::
379myFrameDrawnCallback ( Movie callbackMovie, long refCon )
380{ 205{
381 LLMediaImplQuickTime* myQtRenderer = ( LLMediaImplQuickTime* ) refCon; 206 if ( ! mMovieHandle )
382 207 return false;
383 // The gworld quicktime is playing back into is now wrapped around myQtRenderer->mediaData,
384 // so there's no need to copy any data here.
385#if 0
386 Ptr pixels = GetPixBaseAddr ( myQtRenderer->pixmapHandle );
387 208
388 LockPixels ( myQtRenderer->pixmapHandle ); 209 // sanitize size of movie
210 Rect movie_rect;
211 setMovieBoxEnhanced( &movie_rect );
389 212
390 memcpy ( ( U8* ) myQtRenderer->mediaData, pixels, myQtRenderer->getMediaBufferSize () ); /* Flawfinder: ignore */ 213 // we need this later
214 int width = ( movie_rect.right - movie_rect.left );
215 int height = ( movie_rect.bottom - movie_rect.top );
391 216
392 UnlockPixels ( myQtRenderer->pixmapHandle ); 217 std::cout << "LLMEDIA> size changed to " << width << " x " << height << std::endl;
393#endif 218
219 setMediaSize( width, height );
220
221 // media depth won't change
222 int depth_bits = getMediaDepth() * 8;
394 223
395 myQtRenderer->bufferChanged(); 224 GWorldPtr old_gworld_handle = mGWorldHandle;
396 225
397 return 0; 226 if (old_gworld_handle)
227 {
228 GWorldFlags result = UpdateGWorld( &mGWorldHandle, depth_bits, &movie_rect, NULL, NULL, 0 );
229 if ( gwFlagErr == result )
230 {
231 // TODO: unrecoverable?? throw exception? return something?
232 return false;
233 }
234 }
235 else
236 {
237 OSErr result = NewGWorld( &mGWorldHandle, depth_bits, &movie_rect, NULL, NULL, keepLocal | pixelsLocked );
238 if ( noErr != result )
239 {
240 // ATODO: unrecoverable?? throw exception? return something?
241 return false;
242 }
243
244 // clear memory in GWorld to avoid random screen visual fuzz from uninitialized texture data
245 if ( mGWorldHandle )
246 {
247 PixMapHandle pix_map_handle = GetGWorldPixMap( mGWorldHandle );
248 unsigned char* ptr = ( unsigned char* )GetPixBaseAddr( pix_map_handle );
249 memset( ptr, 0x00, height * QTGetPixMapHandleRowBytes( pix_map_handle ) );
250 }
251 }
252
253 // point movie at GWorld if it's new
254 if ( mMovieHandle && ! old_gworld_handle )
255 {
256 SetMovieGWorld( mMovieHandle, mGWorldHandle, GetGWorldDevice ( mGWorldHandle ) );
257 }
258
259 // flip movie to match the way the client expects textures (sigh!)
260 MatrixRecord transform;
261 SetIdentityMatrix( &transform ); // transforms are additive so start from identify matrix
262 double scaleX = 1.0 / (double)LLMediaManager::textureWidthFromMediaWidth( width );
263 double scaleY = -1.0 / (double)LLMediaManager::textureHeightFromMediaHeight( height );
264 double centerX = width / 2.0;
265 double centerY = height / 2.0;
266 ScaleMatrix( &transform, X2Fix ( scaleX ), X2Fix ( scaleY ), X2Fix ( centerX ), X2Fix ( centerY ) );
267 SetMovieMatrix( mMovieHandle, &transform );
268 std::cout << "LLMEDIA> Flipping stream to match expected OpenGL orientation size=" << width << " x " << height << std::endl;
269
270 // update movie controller
271 if ( mMovieController )
272 {
273 MCSetControllerPort( mMovieController, mGWorldHandle );
274 MCPositionController( mMovieController, &movie_rect, &movie_rect,
275 mcTopLeftMovie | mcPositionDontInvalidate );
276 MCMovieChanged( mMovieController, mMovieHandle );
277 }
278
279 // Emit event with size change so the calling app knows about it too
280 LLMediaEvent event( this );
281 mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event );
282
283 return true;
398} 284}
399 285
400/////////////////////////////////////////////////////////////////////////////// 286////////////////////////////////////////////////////////////////////////////////
401Boolean 287// static
402LLMediaImplQuickTime::myMCActionFilterProc (MovieController theMC, short theAction, void *theParams, long theRefCon) 288Boolean LLMediaImplQuickTime::mcActionFilterCallBack( MovieController mc, short action, void *params, long ref )
403{ 289{
404 Boolean result = false; 290 Boolean result = false;
405 LLMediaImplQuickTime *self = (LLMediaImplQuickTime*)theRefCon;
406 291
407 switch ( theAction ) 292 LLMediaImplQuickTime* self = ( LLMediaImplQuickTime* )ref;
293
294 switch( action )
408 { 295 {
409 // handle window resizing 296 // handle window resizing
410 case mcActionControllerSizeChanged: 297 case mcActionControllerSizeChanged:
@@ -423,502 +310,336 @@ LLMediaImplQuickTime::myMCActionFilterProc (MovieController theMC, short theActi
423 break; 310 break;
424 }; 311 };
425 312
426 return ( result ); 313 return result;
427} 314}
428 315
429/////////////////////////////////////////////////////////////////////////////// 316////////////////////////////////////////////////////////////////////////////////
430// 317// private
431void 318bool LLMediaImplQuickTime::unload()
432LLMediaImplQuickTime::rewind()
433{ 319{
434 // MBW -- XXX -- I don't see an easy way to do this via the movie controller. 320 if ( mMovieHandle )
435 GoToBeginningOfMovie ( theMovie ); 321 {
436 322 StopMovie( mMovieHandle );
437 // Call this afterwards so the movie controller can sync itself with the movie. 323 if ( mMovieController )
438 MCMovieChanged(theController, theMovie); 324 {
439 325 MCMovieChanged( mMovieController, mMovieHandle );
440#if 0 326 };
441 // Maybe something like this? 327 };
442 TimeRecord when; 328
443 when.value.hi = 0; 329 if ( mMovieController )
444 when.value.lo = 0; 330 {
445 when.scale = GetMovieTimeScale(theMovie); 331 MCSetActionFilterWithRefCon( mMovieController, NULL, (long)this );
446 332 DisposeMovieController( mMovieController );
447 // This seems like the obvious thing, but a tech note (http://developer.apple.com/technotes/qt/qt_510.html) says otherwise... 333 mMovieController = NULL;
448// when.base = GetMovieTimeBase(theMovie); 334 };
449 when.base = 0; 335
450 336 if ( mMovieHandle )
451 MCDoAction(theController, mcActionGoToTime, &when); 337 {
452#endif 338 SetMovieDrawingCompleteProc( mMovieHandle, movieDrawingCallWhenChanged, nil, ( long )this );
339 DisposeMovie ( mMovieHandle );
340 mMovieHandle = NULL;
341 };
342
343 if ( mGWorldHandle )
344 {
345 DisposeGWorld( mGWorldHandle );
346 mGWorldHandle = NULL;
347 };
348
349 return true;
453} 350}
454 351
455/////////////////////////////////////////////////////////////////////////////// 352////////////////////////////////////////////////////////////////////////////////
456// 353// static
457void 354OSErr LLMediaImplQuickTime::movieDrawingCompleteCallback( Movie call_back_movie, long ref )
458LLMediaImplQuickTime::sizeChanged()
459{ 355{
460 // Set the movie to render (well, actually NOT render) to an internal buffer until the size change can be handled. 356 LLMediaImplQuickTime* self = ( LLMediaImplQuickTime* )ref;
461 setupDummyBuffer(); 357
462 358 // IMPORTANT: typically, a consumer who is observing this event will set a flag
463 // Make the next call to updateMedia request a size change. 359 // when this event is fired then render later. Be aware that the media stream
464 sizeChangeInProgress = true; 360 // can change during this period - dimensions, depth, format etc.
465 361 LLMediaEvent event( self );
466 // Recalculate the values that depend on the movie rect. 362 self->mEventEmitter.update( &LLMediaObserver::onMediaContentsChange, event );
467 updateMediaSize(); 363
364 return noErr;
468} 365}
469 366
470/////////////////////////////////////////////////////////////////////////////// 367////////////////////////////////////////////////////////////////////////////////
471// 368// static
472BOOL 369void LLMediaImplQuickTime::moviePrePrerollCompleteCallback( Movie movie, OSErr preroll_err, void *ref )
473LLMediaImplQuickTime::
474isQTLoaded()
475{ 370{
476 BOOL result = false; 371 LLMediaImplQuickTime* self = ( LLMediaImplQuickTime* )ref;
477 372
478 if(theMovie) 373 LLMediaEvent event( self );
479 { 374 self->mEventEmitter.update( &LLMediaObserver::onMediaPreroll, event );
480 if(GetMovieLoadState(theMovie) >= kMovieLoadStateLoaded)
481 {
482 result = true;
483 }
484 }
485
486 return result;
487} 375}
488 376
489/////////////////////////////////////////////////////////////////////////////// 377///////////////////////////////////////////////////////////////////////////////
490// 378// used for stop / loop
491BOOL 379void LLMediaImplQuickTime::rewind()
492LLMediaImplQuickTime::
493isQTPlaythroughOK()
494{ 380{
495 BOOL result = false; 381 GoToBeginningOfMovie ( mMovieHandle );
496 382
497 if(theMovie) 383 MCMovieChanged( mMovieController, mMovieHandle );
498 {
499 if(GetMovieLoadState(theMovie) >= kMovieLoadStatePlaythroughOK)
500 {
501 result = true;
502 }
503 }
504
505 return result;
506} 384}
507 385
508/////////////////////////////////////////////////////////////////////////////// 386////////////////////////////////////////////////////////////////////////////////
509// 387//
510BOOL 388bool LLMediaImplQuickTime::processState()
511LLMediaImplQuickTime::
512unload ()
513{ 389{
514 390 // start stream
515 if( theController ) 391 if ( nextCommand() == LLMediaBase::COMMAND_START )
516 { 392 {
517 // Slight paranoia... 393 // valid when we are in these states
518 MCSetActionFilterWithRefCon(theController, NULL, (long)this); 394 if ( getStatus() == LLMediaBase::STATUS_NAVIGATING|| getStatus() == LLMediaBase::STATUS_STOPPED || getStatus() == LLMediaBase::STATUS_PAUSED )
395 {
396 // it appears that the movie must be in a loaded state before we do this command
397 if ( GetMovieLoadState( mMovieHandle ) >= kMovieLoadStatePlaythroughOK )
398 {
399 MCDoAction( mMovieController, mcActionPrerollAndPlay, (void*)GetMoviePreferredRate( mMovieHandle ) );
519 400
520 DisposeMovieController( theController ); 401 MCDoAction( mMovieController, mcActionSetVolume, (void*)mCurVolume );
521 theController = NULL;
522 };
523
524 if ( theMovie )
525 {
526 // Slight paranoia...
527 SetMovieDrawingCompleteProc ( theMovie, movieDrawingCallWhenChanged, nil, ( long ) this );
528 402
529 DisposeMovie ( theMovie ); 403 setStatus( LLMediaBase::STATUS_STARTED );
530 theMovie = NULL;
531 };
532 404
533 if ( theGWorld ) 405 clearCommand();
534 { 406 }
535 DisposeGWorld ( theGWorld ); 407 }
536 theGWorld = NULL; 408 }
537 }; 409 else
538 410 if ( nextCommand() == LLMediaBase::COMMAND_STOP )
539 if ( mediaData )
540 { 411 {
541 if ( ownBuffer ) 412 // valid when we are in these states
413 if ( getStatus() == LLMediaBase::STATUS_NAVIGATING || getStatus() == LLMediaBase::STATUS_STARTED || getStatus() == LLMediaBase::STATUS_PAUSED )
542 { 414 {
543 delete mediaData; 415 // it appears that the movie must be in a loaded state before we do this command
544 mediaData = NULL; 416 if ( GetMovieLoadState( mMovieHandle ) >= kMovieLoadStatePlaythroughOK )
545 }; 417 {
546 }; 418 // stop playing
419 Fixed rate = X2Fix( 0.0 );
420 MCDoAction( mMovieController, mcActionPlay, (void*)rate );
547 421
548 return TRUE; 422 // go back to start
549} 423 rewind();
550 424
551/////////////////////////////////////////////////////////////////////////////// 425 setStatus( LLMediaBase::STATUS_STOPPED );
552// 426 clearCommand();
553S32 427 };
554LLMediaImplQuickTime:: 428 };
555updateMedia ()
556{
557 if(!theController)
558 {
559 if(isQTLoaded())
560 {
561 // Movie has finished loading. Request a size change to update buffers, etc.
562 // We MUST update the media size here, so it will be correct before the size change request.
563 updateMediaSize();
564 return updateMediaNeedsSizeChange;
565 }
566 else
567 {
568 // Movie is still loading.
569 MoviesTask ( theMovie, 0 );
570 }
571 } 429 }
572 430 else
573 if(theController) 431 if ( nextCommand() == LLMediaBase::COMMAND_PAUSE )
574 { 432 {
575 switch(currentMode) 433 // valid when we are in these states
434 if ( getStatus() == LLMediaBase::STATUS_NAVIGATING || getStatus() == LLMediaBase::STATUS_STARTED || getStatus() == LLMediaBase::STATUS_STOPPED )
576 { 435 {
577 case ModePlaying: 436 // it appears that the movie must be in a loaded state before we do this command
578 case ModeLooping: 437 if ( GetMovieLoadState( mMovieHandle ) >= kMovieLoadStatePlaythroughOK )
579 if(!initialStartDone)
580 { 438 {
581 if(isQTPlaythroughOK()) 439 // stop playing
582 { 440 Fixed rate = X2Fix( 0.0 );
583 // The movie is loaded enough to start playing. Start it now. 441 MCDoAction( mMovieController, mcActionPlay, (void*)rate );
584 MCDoAction(theController, mcActionPrerollAndPlay, (void*)GetMoviePreferredRate(theMovie));
585 442
586 MCDoAction(theController, mcActionSetVolume, (void*)curVolume ); 443 setStatus( LLMediaBase::STATUS_PAUSED );
444 clearCommand();
445 };
446 };
447 };
587 448
588 initialStartDone = TRUE; 449 return true;
589 } 450}
590 } 451
591 break; 452////////////////////////////////////////////////////////////////////////////////
592 } 453// virtual
454bool LLMediaImplQuickTime::setMovieBoxEnhanced( Rect* rect )
455{
456 // get movie rect
457 GetMovieBox( mMovieHandle, rect );
458 int width = ( rect->right - rect->left );
459 int height = ( rect->bottom - rect->top );
593 460
594// // This function may copy decompressed movie frames into our media data pointer. JC 461 // if the user has requested a specific size, use it:
595// if (!mediaData) 462 if ((mMediaRequestedWidth != 0) && (mMediaRequestedHeight != 0))
596// { 463 {
597// llwarns << "LLMediaImplQuickTime::updateMedia() about to update with null media pointer" << llendl; 464 width = mMediaRequestedWidth;
598// } 465 height = mMediaRequestedHeight;
599// else
600// {
601// // try writing to the pointer to see if it's valid
602// *mediaData = 0;
603// }
604
605 MCIdle(theController);
606 } 466 }
607 467
608 // If we need a size change, that takes precedence. 468 // if the user has requested, resize media to exactly fit texture
609 if(sizeChangeInProgress) 469 if (mAutoScaled)
610 { 470 {
611 return updateMediaNeedsSizeChange; 471 width = LLMediaManager::textureWidthFromMediaWidth( width );
472 height = LLMediaManager::textureHeightFromMediaHeight( height );
612 } 473 }
613 474
614 BOOL updated = getBufferChanged(); 475 // make sure it falls in valid range
476 if ( width < mMinWidth )
477 width = mMinWidth;
615 478
616 resetBufferChanged(); 479 if ( width > mMaxWidth )
617 480 width = mMaxWidth;
618 if(updated)
619 return updateMediaNeedsUpdate;
620 481
621 // don't use movie controller for looping - appears to be broken on PCs (volume issue) 482 if ( height < mMinHeight )
622 if ( currentMode == ModeLooping ) 483 height = mMinHeight;
623 if ( IsMovieDone ( theMovie ) )
624 loop ( 0 );
625 484
626 return updateMediaNoChanges; 485 if ( height > mMaxHeight )
627} 486 height = mMaxHeight;
628 487
629/////////////////////////////////////////////////////////////////////////////// 488 // tell quicktime about new size
630// 489 rect->right = width;
631void 490 rect->bottom = height;
632LLMediaImplQuickTime:: 491 rect->left = 0;
633setAutoScaled ( BOOL autoScaledIn ) 492 rect->top = 0;
634{ 493 SetMovieBox( mMovieHandle, rect );
635 autoScaled = autoScaledIn; 494
495 return true;
636} 496}
637 497
638/////////////////////////////////////////////////////////////////////////////// 498////////////////////////////////////////////////////////////////////////////////
639// 499// virtual
640BOOL 500bool LLMediaImplQuickTime::updateMedia()
641LLMediaImplQuickTime::
642stop ()
643{ 501{
644 currentMode = ModeStopped; 502 if ( ! mMovieHandle )
503 return false;
645 504
646 if(theController) 505 if ( ! mMovieController )
647 { 506 return false;
648 Fixed rate = X2Fix(0.0);
649 MCDoAction(theController, mcActionPlay, (void*)rate);
650
651 rewind();
652 }
653
654 return LLMediaMovieBase::stop();
655};
656 507
657/////////////////////////////////////////////////////////////////////////////// 508 if ( ! mGWorldHandle )
658// 509 return false;
659BOOL
660LLMediaImplQuickTime::
661play ()
662{
663 currentMode = ModePlaying;
664
665 if(theController)
666 {
667 if ( IsMovieDone ( theMovie ) )
668 {
669 rewind();
670 };
671 510
672 MCDoAction(theController, mcActionPrerollAndPlay, (void*)GetMoviePreferredRate(theMovie)); 511 // service QuickTime
512 MoviesTask( mMovieHandle, 0 );
513 MCIdle( mMovieController );
673 514
674 MCDoAction(theController, mcActionSetVolume, (void*)curVolume ); 515 // update state machine (deals with transport controls for example)
675 } 516 processState();
676
677 return LLMediaMovieBase::play();
678};
679 517
680/////////////////////////////////////////////////////////////////////////////// 518 // special code for looping - need to rewind at the end of the movie
681//
682BOOL
683LLMediaImplQuickTime::
684loop ( S32 howMany )
685{
686 currentMode = ModeLooping;
687
688 // MBW -- XXX -- This may be harder to do with a movie controller...
689// loopsLeft = howMany;
690 519
691 if ( theController ) 520 if ( isLooping() )
692 { 521 {
693 // Movie is loaded and set up. 522 // QT call to see if we are at the end - can't do with controller
694 if ( IsMovieDone ( theMovie ) ) 523 if ( IsMovieDone( mMovieHandle ) )
695 { 524 {
525 // go back to start
696 rewind(); 526 rewind();
697 };
698
699 MCDoAction(theController, mcActionPrerollAndPlay, (void*)GetMoviePreferredRate(theMovie));
700
701 MCDoAction(theController, mcActionSetVolume, (void*)curVolume );
702 }
703
704 return LLMediaMovieBase::loop(howMany);
705};
706
707///////////////////////////////////////////////////////////////////////////////
708//
709BOOL
710LLMediaImplQuickTime::
711pause ()
712{
713 currentMode = ModePaused;
714
715 if(theController)
716 {
717 // Movie is loaded and set up.
718 Fixed rate = X2Fix(0.0);
719 MCDoAction(theController, mcActionPlay, (void*)rate);
720 }
721 527
722 return LLMediaMovieBase::pause(); 528 // kick off new play
723}; 529 MCDoAction( mMovieController, mcActionPrerollAndPlay, (void*)GetMoviePreferredRate( mMovieHandle ) );
724 530
725/////////////////////////////////////////////////////////////////////////////// 531 // set the volume
726// 532 MCDoAction( mMovieController, mcActionSetVolume, (void*)mCurVolume );
727BOOL 533 }
728LLMediaImplQuickTime::
729setVolume ( F32 volumeIn )
730{
731 // Fixed point signed short, 8.8
732 curVolume = (short)(volumeIn * ( F32 ) 0x100);
733
734 if(theController != NULL)
735 {
736 MCDoAction(theController, mcActionSetVolume, (void*)curVolume);
737 } 534 }
738
739 return TRUE;
740}
741 535
742/////////////////////////////////////////////////////////////////////////////// 536 return true;
743//
744F32
745LLMediaImplQuickTime::
746getVolume ()
747{
748 return ( ( F32 ) curVolume ) / ( F32 ) 0x100;
749} 537}
750 538
751/////////////////////////////////////////////////////////////////////////////// 539////////////////////////////////////////////////////////////////////////////////
752// 540// virtual
753BOOL 541unsigned char* LLMediaImplQuickTime::getMediaData()
754LLMediaImplQuickTime::
755isIdle () const
756{ 542{
757 return ( currentMode == ModeIdle ); 543 unsigned char* ptr = NULL;
758};
759 544
760/////////////////////////////////////////////////////////////////////////////// 545 if ( mGWorldHandle )
761// 546 {
762BOOL 547 PixMapHandle pix_map_handle = GetGWorldPixMap( mGWorldHandle );
763LLMediaImplQuickTime::
764isError () const
765{
766 return ( currentMode == ModeError );
767};
768 548
769/////////////////////////////////////////////////////////////////////////////// 549 ptr = ( unsigned char* )GetPixBaseAddr( pix_map_handle );
770// 550 };
771BOOL
772LLMediaImplQuickTime::
773isBuffering () const
774{
775 return ( currentMode == ModeBuffering );
776};
777 551
778/////////////////////////////////////////////////////////////////////////////// 552 return ptr;
779// 553}
780BOOL
781LLMediaImplQuickTime::
782isLoaded () const
783{
784 // Only tell the caller the movie is loaded if we've had a chance to set up the movie controller.
785
786 return (theController != NULL);
787};
788 554
789/////////////////////////////////////////////////////////////////////////////// 555////////////////////////////////////////////////////////////////////////////////
790// 556// virtual
791BOOL 557int LLMediaImplQuickTime::getMediaDataWidth() const
792LLMediaImplQuickTime::
793isPlaying () const
794{ 558{
795 return ( currentMode == ModePlaying ); 559 if ( mGWorldHandle )
796}; 560 {
561 int depth = getMediaDepth();
797 562
798/////////////////////////////////////////////////////////////////////////////// 563 if (depth < 1)
799// 564 depth = 1;
800BOOL
801LLMediaImplQuickTime::
802isLooping () const
803{
804 return ( currentMode == ModeLooping );
805};
806 565
807/////////////////////////////////////////////////////////////////////////////// 566 // ALWAYS use the row bytes from the PixMap if we have a GWorld because
808// 567 // sometimes it's not the same as mMediaDepth * mMediaWidth !
809BOOL 568 PixMapHandle pix_map_handle = GetGWorldPixMap( mGWorldHandle );
810LLMediaImplQuickTime:: 569 return QTGetPixMapHandleRowBytes( pix_map_handle ) / depth;
811isPaused () const 570 }
812{ 571 else
813 return ( currentMode == ModePaused ); 572 {
814}; 573 return LLMediaImplCommon::getMediaDataWidth();
574 }
575}
815 576
816/////////////////////////////////////////////////////////////////////////////// 577////////////////////////////////////////////////////////////////////////////////
817// 578// virtual
818BOOL 579int LLMediaImplQuickTime::getTextureFormatPrimary() const
819LLMediaImplQuickTime::
820isStopped () const
821{ 580{
822 return ( currentMode == ModeStopped ); 581#if defined(__APPLE__) || defined(MACOSX)
823}; 582 return LL_MEDIA_BGRA;
583#else
584 return LL_MEDIA_RGB;
585#endif
586}
824 587
825/////////////////////////////////////////////////////////////////////////////// 588////////////////////////////////////////////////////////////////////////////////
826// 589// virtual
827U8* 590int LLMediaImplQuickTime::getTextureFormatType() const
828LLMediaImplQuickTime::
829getMediaData ()
830{ 591{
831 return mediaData; 592#if defined(__APPLE__) || defined(MACOSX)
593 #ifdef __BIG_ENDIAN__
594 return LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV;
595 #else
596 return LL_MEDIA_UNSIGNED_INT_8_8_8_8;
597 #endif
598#else
599 return LL_MEDIA_UNSIGNED_BYTE;
600#endif
832} 601}
833 602
834/////////////////////////////////////////////////////////////////////////////// 603////////////////////////////////////////////////////////////////////////////////
835// 604// virtual
836BOOL 605bool LLMediaImplQuickTime::seek( double time )
837LLMediaImplQuickTime::
838seek ( F64 time )
839{ 606{
840 // MBW -- XXX -- This should stash the time if theController is NULL, and seek to there when the movie's loaded. 607 if ( mMovieController )
841 // Do this later.
842 if(theController != NULL)
843 { 608 {
844 TimeRecord when; 609 TimeRecord when;
845 when.scale = GetMovieTimeScale(theMovie); 610 when.scale = GetMovieTimeScale( mMovieHandle );
846 when.base = 0; 611 when.base = 0;
847 612
848 // 'time' is in (floating point) seconds. The timebase time will be in 'units', where 613 // 'time' is in (floating point) seconds. The timebase time will be in 'units', where
849 // there are 'scale' units per second. 614 // there are 'scale' units per second.
850 S64 rawTime = (S64)(time * (F64)(when.scale)); 615 SInt64 raw_time = ( SInt64 )( time * (double)( when.scale ) );
851
852 when.value.hi = ( SInt32 ) ( rawTime >> 32 );
853 when.value.lo = ( SInt32 ) ( ( rawTime & 0x00000000FFFFFFFF ) );
854
855 MCDoAction(theController, mcActionGoToTime, &when);
856 }
857
858 return TRUE;
859}
860 616
861/////////////////////////////////////////////////////////////////////////////// 617 when.value.hi = ( SInt32 )( raw_time >> 32 );
862// 618 when.value.lo = ( SInt32 )( ( raw_time & 0x00000000FFFFFFFF ) );
863F64
864LLMediaImplQuickTime::
865getTime () const
866{
867 F64 result = 0;
868
869 if(theController != NULL)
870 {
871 TimeValue time;
872 TimeScale scale = 0;
873 619
874 time = MCGetCurrentTime(theController, &scale); 620 MCDoAction( mMovieController, mcActionGoToTime, &when );
875 if(scale != 0) 621
876 { 622 return true;
877 result = ((F64)time) / ((F64)scale);
878 }
879 } 623 }
880 624
881 return result; 625 return false;
882} 626}
883 627
884/////////////////////////////////////////////////////////////////////////////// 628////////////////////////////////////////////////////////////////////////////////
885// 629// virtual
886F64 630bool LLMediaImplQuickTime::setVolume( float volume )
887LLMediaImplQuickTime::
888getMediaDuration () const
889{ 631{
890 F64 result = 0; 632 mCurVolume = (short)(volume * ( double ) 0x100 );
891 TimeScale scale = GetMovieTimeScale(theMovie); 633
892 TimeValue duration = GetMovieDuration(theMovie); 634 if ( mMovieController )
893
894 if(duration == kQTSUnknownDuration)
895 {
896 // Hmph.
897 // Return 0 in this case.
898 }
899 else if(duration == kQTSInfiniteDuration)
900 {
901 // This is the magic number for "indefinite duration", i.e. a live stream.
902 // Note that the docs claim this value is 0x7FFFFFF, while the symbolic constant is 0x7FFFFFFF. Go figure.
903 // Return 0 in this case.
904 }
905 else if(scale != 0)
906 { 635 {
907 // Timescale is a useful number. Convert to seconds. 636 MCDoAction( mMovieController, mcActionSetVolume, (void*)mCurVolume );
908 result = (F64)duration;
909 result /= (F64)scale;
910 }
911
912 return result;
913}
914 637
915// static since we need this before an impl is created by media manager 638 return true;
916S32 LLMediaImplQuickTime::getVersion() 639 }
917{
918 S32 version;
919 Gestalt( gestaltQuickTimeVersion, (long*)&version );
920 640
921 return version; 641 return false;
922} 642}
923 643
924#endif 644#endif // _3DNOW_InstructionExtensions/ LL_QUICKTIME_ENABLED
645
diff --git a/linden/indra/llmedia/llmediaimplquicktime.h b/linden/indra/llmedia/llmediaimplquicktime.h
index b170a06..de8e9e2 100644
--- a/linden/indra/llmedia/llmediaimplquicktime.h
+++ b/linden/indra/llmedia/llmediaimplquicktime.h
@@ -1,10 +1,10 @@
1/** 1/**
2 * @file llmediaimplquicktime.h 2 * @file llmediaimplquicktime.h
3 * @brief implementation that supports Apple QuickTime media. 3 * @brief QuickTime media impl concrete class
4 * 4 *
5 * $LicenseInfo:firstyear=2005&license=viewergpl$ 5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2005-2008, Linden Research, Inc. 7 * Copyright (c) 2007-2008, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -29,111 +29,83 @@
29 * $/LicenseInfo$ 29 * $/LicenseInfo$
30 */ 30 */
31 31
32#if LL_QUICKTIME_ENABLED 32#ifndef LLMEDIAIMPLQUICKTIME_H
33 33#define LLMEDIAIMPLQUICKTIME_H
34// header guard
35#ifndef llmediaimplquicktime_h
36#define llmediaimplquicktime_h
37 34
38#include "stdtypes.h" 35#include "llmediaimplcommon.h"
39 36#include "llmediaimplfactory.h"
40#include "llmediamoviebase.h"
41 37
42#if LL_QUICKTIME_ENABLED 38#if LL_QUICKTIME_ENABLED
43#if LL_DARWIN 39
44#include <QuickTime/QuickTime.h> 40#include <string>
45#else 41
46#include "MacTypes.h" 42// QuickTime includes
47#include "QTML.h" 43#if defined(__APPLE__)
48#include "Movies.h" 44 #include <QuickTime/QuickTime.h>
49#include "FixMath.h" 45#elif defined(WIN32)
50#include "Gestalt.h" 46 #include "MacTypes.h"
51#include "QuickTimeStreaming.h" 47 #include "QTML.h"
52#endif 48 #include "Movies.h"
49 #include "QDoffscreen.h"
50 #include "FixMath.h"
53#endif 51#endif
54 52
53class LLMediaManagerData;
55 54
56//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 55class LLMediaImplQuickTime :
57// 56 public LLMediaImplCommon
58////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
59class LLMediaImplQuickTime:
60 public LLMediaMovieBase
61{ 57{
62 public: 58 public:
63 LLMediaImplQuickTime (); 59 LLMediaImplQuickTime();
64 virtual ~LLMediaImplQuickTime (); 60 virtual ~LLMediaImplQuickTime();
65 61
66 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 62 static bool startup( LLMediaManagerData* init_data );
67 // implementation of the media public interface 63 static bool closedown();
68 64
69 // housekeeping 65 /* virtual */ std::string getVersion();
70 virtual BOOL setBuffer ( U8* bufferIn ); 66 /* virtual */ bool navigateTo( const std::string url );
71 virtual BOOL init (); 67 /* virtual */ bool updateMedia();
72 virtual BOOL load ( const LLString& urlIn ); 68 /* virtual */ unsigned char* getMediaData();
73 virtual BOOL unload (); 69 /* virtual */ int getMediaDataWidth() const;
74 70 /* virtual */ int getTextureFormatPrimary() const;
75 // transport controls 71 /* virtual */ int getTextureFormatType() const;
76 virtual BOOL stop (); 72 /* virtual */ bool seek( double time );
77 virtual BOOL play (); 73 /* virtual */ bool setVolume( float volume );
78 virtual BOOL loop ( S32 howMany ); 74
79 virtual BOOL pause (); 75 bool sizeChanged();
80 virtual BOOL seek ( F64 time );
81
82 // audio levels
83 virtual BOOL setVolume ( F32 volumeIn );
84 virtual F32 getVolume ();
85
86 // status
87 virtual BOOL isIdle () const;
88 virtual BOOL isBuffering () const;
89 virtual BOOL isError () const;
90 virtual BOOL isLoaded () const;
91 virtual BOOL isStopped () const;
92 virtual BOOL isPaused () const;
93 virtual BOOL isPlaying () const;
94 virtual BOOL isLooping () const;
95 virtual F64 getTime () const;
96
97 // media data
98 virtual S32 updateMedia ();
99 virtual void setAutoScaled ( BOOL autoScaledIn );
100 virtual U8* getMediaData ();
101 virtual F64 getMediaDuration () const;
102
103 // static since we need this before an impl is created by media manager
104 static S32 getVersion();
105 76
106 private: 77 private:
107 // quicktime specific 78 static OSErr movieDrawingCompleteCallback( Movie call_back_movie, long ref );
108 Movie theMovie; 79 static Boolean mcActionFilterCallBack( MovieController mc, short action, void *params, long ref );
109 ComponentInstance theController; 80 static void moviePrePrerollCompleteCallback( Movie movie, OSErr preroll_err, void *refcon );
110 PixMapHandle pixmapHandle; 81
111 GWorldPtr theGWorld; 82 bool load( const std::string url );
112 Rect movieRect; 83 bool unload();
113 U8* mediaData;
114 BOOL movieLoaded;
115 BOOL ownBuffer;
116 short curVolume;
117 S32 loopsLeft;
118
119 BOOL autoScaled;
120 BOOL sizeChangeInProgress;
121 BOOL initialStartDone;
122 BOOL isQTLoaded ();
123 BOOL isQTPlaythroughOK ();
124 void setupDummyBuffer ();
125
126 static OSErr myFrameDrawnCallback ( Movie callbackMovie, long refCon );
127 static Boolean myMCActionFilterProc (MovieController theMC, short theAction, void *theParams, long theRefCon);
128
129 void rewind(); 84 void rewind();
130 void sizeChanged(); 85 bool processState();
131 void updateMediaSize(); 86 bool setMovieBoxEnhanced( Rect* rect );
132 87
133 enum { ModeNone, ModeIdle, ModeError, ModeBuffering, ModeLoaded, ModeStopped, ModePaused, ModePlaying, ModeLooping } currentMode; 88 Movie mMovieHandle;
89 GWorldPtr mGWorldHandle;
90 ComponentInstance mMovieController;
91 const int mMinWidth;
92 const int mMaxWidth;
93 const int mMinHeight;
94 const int mMaxHeight;
95 int mCurVolume;
134}; 96};
135 97
98// The maker class
99class LLMediaImplQuickTimeMaker : public LLMediaImplMaker
100{
101 public:
102 LLMediaImplQuickTimeMaker();
103 LLMediaImplQuickTime* create()
104 {
105 return new LLMediaImplQuickTime();
106 }
107};
136 108
137#endif // llmediaimplquicktime_h 109#endif // LL_QUICKTIME_ENABLED
138 110
139#endif 111#endif // LLMEDIAIMPLQUICKTIME_H
diff --git a/linden/indra/llmedia/llmediaemitterevents.h b/linden/indra/llmedia/llmediaimplregister.h
index 8a4111b..a4b802f 100644
--- a/linden/indra/llmedia/llmediaemitterevents.h
+++ b/linden/indra/llmedia/llmediaimplregister.h
@@ -1,10 +1,10 @@
1/** 1/**
2 * @file llmediaemitterevents.h 2 * @file llmediaimplregister.h
3 * @brief LLMedia support - events emitted by emitter to observer. 3 * @brief Allow impls to register themselves with the impl factory
4 * 4 *
5 * $LicenseInfo:firstyear=2005&license=viewergpl$ 5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 * 6 *
7 * Copyright (c) 2005-2008, Linden Research, Inc. 7 * Copyright (c) 2007-2008, Linden Research, Inc.
8 * 8 *
9 * Second Life Viewer Source Code 9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab 10 * The source code in this file ("Source Code") is provided by Linden Lab
@@ -29,33 +29,31 @@
29 * $/LicenseInfo$ 29 * $/LicenseInfo$
30 */ 30 */
31 31
32// header guard 32#ifndef LLIMEDIAIMPLREGISTER_H
33#ifndef llmediaemitterevents_h 33#define LLIMEDIAIMPLREGISTER_H
34#define llmediaemitterevents_h
35 34
36#include "stdtypes.h" 35#include <string>
37 36
37#include "llmediaimplfactory.h"
38 38
39class LLMediaEvent 39///////////////////////////////////////////////////////////////////////////////
40//
41class LLMediaImplRegister
40{ 42{
41 public: 43 public:
42 LLMediaEvent ( S32 actionIn, const LLString& urlIn, void* data = NULL ): 44 LLMediaImplRegister( std::string impl_name, LLMediaImplMaker* impl_maker ) :
43 action ( actionIn ), 45 mImplName( impl_name )
44 url ( urlIn ), 46 {
45 mData(data) 47 LLMediaImplFactory::getInstance()->registerImpl( impl_name, impl_maker );
46 { } 48 };
47 49
48 virtual ~LLMediaEvent () { } 50 std::string getImplName()
49 51 {
50 S32 getAction () const { return action; } 52 return mImplName;
51 LLString getUrl () const { return url; } 53 };
52 void* getData() const { return mData; }
53 54
54 private: 55 private:
55 S32 action; 56 std::string mImplName;
56 std::string url;
57 void* mData;
58}; 57};
59 58
60 59#endif // LLIMEDIAIMPLREGISTER_H
61#endif // llmediaemitterevents_h
diff --git a/linden/indra/llmedia/llmediamanager.cpp b/linden/indra/llmedia/llmediamanager.cpp
new file mode 100644
index 0000000..c9b673d
--- /dev/null
+++ b/linden/indra/llmedia/llmediamanager.cpp
@@ -0,0 +1,255 @@
1/**
2 * @file llmediamanager.cpp
3 * @brief Manages instances of media impls
4 *
5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 *
7 * Copyright (c) 2007-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "llmediamanager.h"
33#include "llmediaimplfactory.h"
34
35#include "llmediaimplexample1.h"
36#include "llmediaimplexample2.h"
37#include "llmediaimplquicktime.h"
38#include "llmediaimplgstreamer.h"
39#include "llmediaimplllmozlib.h"
40
41LLMediaManager* LLMediaManager::sInstance = 0;
42
43////////////////////////////////////////////////////////////////////////////////
44// (private)
45LLMediaManager::LLMediaManager()
46{
47}
48
49////////////////////////////////////////////////////////////////////////////////
50LLMediaManager::~LLMediaManager()
51{
52}
53
54////////////////////////////////////////////////////////////////////////////////
55// (static)
56void LLMediaManager::initClass( LLMediaManagerData* init_data )
57{
58 if ( ! sInstance )
59 sInstance = new LLMediaManager();
60
61 // Initialize impl classes here - this breaks the encapsulation model
62 // but some of the initialization takes a long time and we only want to
63 // do it once at app startup before any of the impls have been created
64 // Each impl provides a static startup method that does any initialization
65 // which takes a significant amount of time.
66 LLMediaImplExample1::startup( init_data );
67 LLMediaImplExample2::startup( init_data );
68
69#if LL_QUICKTIME_ENABLED
70 LLMediaImplQuickTime::startup( init_data );
71#endif // LL_QUICKTIME_ENABLED
72
73#if LL_GSTREAMER_ENABLED
74 LLMediaImplGStreamer::startup( init_data );
75#endif // LL_GSTREAMER_ENABLED
76
77#if LL_LLMOZLIB_ENABLED
78 LLMediaImplLLMozLib::startup( init_data );
79#endif // LL_LLMOZLIB_ENABLED
80}
81
82////////////////////////////////////////////////////////////////////////////////
83// (static)
84void LLMediaManager::updateClass()
85{
86 if (!sInstance) return;
87
88 media_impl_container_t::iterator it
89 = sInstance->mMediaImplContainer.begin();
90 media_impl_container_t::iterator end
91 = sInstance->mMediaImplContainer.end();
92 for ( ; it != end; ++it )
93 {
94 LLMediaBase* impl = *it;
95 impl->updateMedia();
96 }
97}
98
99////////////////////////////////////////////////////////////////////////////////
100// (static)
101void LLMediaManager::cleanupClass()
102{
103 // Uninitialize impl classes here - this breaks the encapsulation model
104 // but some of the uninitialization takes a long time and we only want to
105 // do it once at app startup before any of the impls have been created.
106 // Each impl provides a static closedown method that does any uninitialization
107 // which takes a significant amount of time.
108 LLMediaImplExample1::closedown();
109 LLMediaImplExample2::closedown();
110
111#if LL_LLMOZLIB_ENABLED
112 LLMediaImplLLMozLib::closedown();
113#endif // LL_LLMOZLIB_ENABLED
114
115#if LL_QUICKTIME_ENABLED
116 LLMediaImplQuickTime::closedown();
117#endif // LL_QUICKTIME_ENABLED
118
119#if LL_GSTREAMER_ENABLED
120 LLMediaImplGStreamer::closedown();
121#endif // LL_QUICKTIME_ENABLED
122
123 if ( sInstance )
124 delete sInstance;
125
126 sInstance = 0;
127}
128
129////////////////////////////////////////////////////////////////////////////////
130// (static)
131LLMediaManager* LLMediaManager::getInstance()
132{
133 return sInstance;
134}
135
136////////////////////////////////////////////////////////////////////////////////
137//
138LLMediaBase* LLMediaManager::createSourceFromMimeType( std::string scheme, std::string mime_type )
139{
140
141 LLMediaImplMakerBase* impl_maker = LLMediaImplFactory::getInstance()->getImplMaker( scheme, mime_type );
142
143 // If an impl maker is return it means this media type is supported
144 if ( impl_maker )
145 {
146 LLMediaBase* media_impl = impl_maker->create();
147 if( media_impl )
148 {
149 media_impl->setImplMaker( impl_maker );
150 std::pair< media_impl_container_t::iterator, bool > result =
151 mMediaImplContainer.insert( media_impl );
152
153 if ( result.second )
154 {
155 media_impl->setMimeType( mime_type );
156
157 media_impl->init();
158
159 return media_impl;
160 };
161 };
162 };
163
164 return 0;
165}
166
167////////////////////////////////////////////////////////////////////////////////
168//
169bool LLMediaManager::destroySource( LLMediaBase* media_impl )
170{
171 media_impl_container_t::iterator iter =
172 mMediaImplContainer.find( media_impl );
173
174 if ( iter != mMediaImplContainer.end() )
175 {
176 if ( *iter )
177 {
178 ( *iter)->reset();
179
180 delete ( *iter );
181
182 mMediaImplContainer.erase( iter );
183
184 return true;
185 };
186 };
187
188 return false;
189}
190
191////////////////////////////////////////////////////////////////////////////////
192//
193bool LLMediaManager::addMimeTypeImplNameMap( std::string mime_type, std::string impl_name )
194{
195 std::pair< mime_type_impl_name_container_t::iterator, bool > result =
196 mMimeTypeImplNameContainer.insert( std::make_pair( mime_type, impl_name ) );
197
198 return result.second;
199}
200
201////////////////////////////////////////////////////////////////////////////////
202//
203std::string LLMediaManager::getImplNameFromMimeType( std::string mime_type )
204{
205 mime_type_impl_name_container_t::iterator iter =
206 mMimeTypeImplNameContainer.find( mime_type );
207
208 if ( iter != mMimeTypeImplNameContainer.end() )
209 {
210 return ( *iter ).second;
211 }
212 else
213 {
214 return std::string( "" );
215 };
216}
217////////////////////////////////////////////////////////////////////////////////
218//
219bool LLMediaManager::supportsMediaType( const std::string& impl_name, const std::string& scheme, const std::string& mime_type )
220{
221 LLMediaImplMakerBase* impl_maker = LLMediaImplFactory::getInstance()->getImplMaker( impl_name );
222 if( impl_maker )
223 {
224 int idx1 = mime_type.find("/");
225 int len = (idx1 == std::string::npos) ? 0 : idx1;
226 std::string category = mime_type.substr(0,len);
227
228 return impl_maker->supportsScheme(scheme) ||
229 impl_maker->supportsMimeType(mime_type) ||
230 impl_maker->supportsMimeTypeCategory(category);
231 }
232 return false;
233}
234
235// static
236int LLMediaManager::textureWidthFromMediaWidth( int media_width )
237{
238 int texture_width = 1;
239 while ( texture_width < media_width )
240 {
241 texture_width <<= 1;
242 };
243 return texture_width;
244}
245
246// static
247int LLMediaManager::textureHeightFromMediaHeight( int media_height )
248{
249 int texture_height = 1;
250 while ( texture_height < media_height )
251 {
252 texture_height <<= 1;
253 };
254 return texture_height;
255}
diff --git a/linden/indra/llmedia/llmediamanager.h b/linden/indra/llmedia/llmediamanager.h
new file mode 100644
index 0000000..7a2c868
--- /dev/null
+++ b/linden/indra/llmedia/llmediamanager.h
@@ -0,0 +1,120 @@
1/**
2 * @file llmediamanager.h
3 * @brief Manages instances of media impls
4 *
5 * $LicenseInfo:firstyear=2007&license=viewergpl$
6 *
7 * Copyright (c) 2007-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#ifndef LLMEDIAMANAGER_H
33#define LLMEDIAMANAGER_H
34
35#include <map>
36#include <set>
37
38#include "llmediaimplcommon.h"
39
40////////////////////////////////////////////////////////////////////////////////
41//
42class LLMediaManagerData
43{
44 public:
45 LLMediaManagerData() :
46 mBrowserParentWindow( 0 ),
47 mBrowserProfileDir( "" ),
48 mBrowserProfileName ( "" ),
49 mBrowserUserAgentId( "" )
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 void setBrowserUserAgentId( const std::string& browser_user_agent_id ) { mBrowserUserAgentId = browser_user_agent_id; };
68 std::string& getBrowserUserAgentId() { return mBrowserUserAgentId; };
69
70 private:
71 void* mBrowserParentWindow;
72 std::string mBrowserProfileDir;
73 std::string mBrowserProfileName;
74 std::string mBrowserApplicationDir;
75 std::string mBrowserComponentDir;
76 std::string mBrowserUserAgentId;
77};
78
79////////////////////////////////////////////////////////////////////////////////
80//
81class LLMediaManager
82{
83 public:
84 virtual ~LLMediaManager();
85
86 static void initClass( LLMediaManagerData* init_data );
87 static void cleanupClass();
88 static LLMediaManager* getInstance();
89
90 // Calls update on all media sources
91 static void updateClass();
92
93 // Given an URL and mime_type, construct/destroy a playback engine for
94 // it (a "media impl").
95 LLMediaBase* createSourceFromMimeType( std::string scheme, std::string mime_type );
96 bool destroySource( LLMediaBase* media_impl );
97
98 // mime type to impl mapping functions
99 bool addMimeTypeImplNameMap( std::string mime_type, std::string impl_name );
100 std::string getImplNameFromMimeType( std::string mime_type );
101
102 // Name accessor for querying type support
103 bool supportsMediaType( const std::string& impl_name, const std::string& scheme, const std::string& mime_type );
104
105 // convenience functions for getting suggested texture sizes to hold various size media
106 static int textureWidthFromMediaWidth( int media_width );
107 static int textureHeightFromMediaHeight( int media_height );
108
109 private:
110 LLMediaManager();
111 static LLMediaManager* sInstance;
112
113 typedef std::set< LLMediaBase* > media_impl_container_t;
114 media_impl_container_t mMediaImplContainer;
115
116 typedef std::map< std::string, std::string > mime_type_impl_name_container_t;
117 mime_type_impl_name_container_t mMimeTypeImplNameContainer;
118};
119
120#endif // LLMEDIAMANAGER_H
diff --git a/linden/indra/llmedia/llmediamoviebase.cpp b/linden/indra/llmedia/llmediamoviebase.cpp
deleted file mode 100644
index 87b84b9..0000000
--- a/linden/indra/llmedia/llmediamoviebase.cpp
+++ /dev/null
@@ -1,234 +0,0 @@
1/**
2 * @file llmediamoviebase.cpp
3 * @brief LLMedia support - base class.
4 *
5 * $LicenseInfo:firstyear=2005&license=viewergpl$
6 *
7 * Copyright (c) 2005-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#include "linden_common.h"
33
34#include "llmediamoviebase.h"
35#include "llmediaimplquicktime.h"
36#include "llmediaimplgstreamer.h"
37
38LLMediaMovieBase::LLMediaMovieBase()
39{
40
41}
42
43///////////////////////////////////////////////////////////////////////////////
44// factory method based on explicit media type
45LLMediaMovieBase* LLMediaMovieBase::make( const MediaType mediaTypeIn, S32 width_pixels, S32 height_pixels )
46{
47#if LL_QUICKTIME_ENABLED
48 if ( mediaTypeIn == QuickTime )
49 {
50 return new LLMediaImplQuickTime ();
51 }
52 else
53#endif
54#if LL_GSTREAMER_ENABLED
55 if ( mediaTypeIn == QuickTime )
56 {
57 return new LLMediaImplGStreamer ();
58 }
59 else
60#endif
61
62 return 0;
63}
64
65///////////////////////////////////////////////////////////////////////////////
66//
67BOOL
68LLMediaMovieBase::
69play ()
70{
71 // build event and emit it
72 LLMediaEvent event ( 0, "" );
73 mMediaEventEmitter.update ( &LLMediaObserver::onPlay, event );
74
75 return TRUE;
76}
77
78///////////////////////////////////////////////////////////////////////////////
79//
80BOOL
81LLMediaMovieBase::
82pause ()
83{
84 LLMediaEvent event ( 0, "" );
85 mMediaEventEmitter.update ( &LLMediaObserver::onPause, event );
86
87 return TRUE;
88}
89
90///////////////////////////////////////////////////////////////////////////////
91//
92BOOL
93LLMediaMovieBase::
94stop ()
95{
96 LLMediaEvent event ( 0, "" );
97 mMediaEventEmitter.update ( &LLMediaObserver::onStop, event );
98
99 return TRUE;
100}
101
102///////////////////////////////////////////////////////////////////////////////
103//
104BOOL
105LLMediaMovieBase::
106loop ( S32 howMany )
107{
108 return TRUE;
109};
110
111///////////////////////////////////////////////////////////////////////////////
112//
113void LLMediaMovieBase::setAutoScaled ( BOOL autoScaledIn )
114{
115}
116
117///////////////////////////////////////////////////////////////////////////////
118//
119BOOL
120LLMediaMovieBase::
121setVolume ( F32 volumeIn )
122{
123 return TRUE;
124}
125
126///////////////////////////////////////////////////////////////////////////////
127//
128F32
129LLMediaMovieBase::
130getVolume ()
131{
132 return ( F32 ) 0.0f;
133}
134
135///////////////////////////////////////////////////////////////////////////////
136//
137BOOL
138LLMediaMovieBase::
139isIdle () const
140{
141 return FALSE;
142}
143
144///////////////////////////////////////////////////////////////////////////////
145//
146BOOL
147LLMediaMovieBase::
148isBuffering () const
149{
150 return FALSE;
151}
152
153///////////////////////////////////////////////////////////////////////////////
154//
155BOOL
156LLMediaMovieBase::
157isError () const
158{
159 return FALSE;
160}
161
162///////////////////////////////////////////////////////////////////////////////
163//
164BOOL
165LLMediaMovieBase::
166isLoaded () const
167{
168 return TRUE;
169}
170
171///////////////////////////////////////////////////////////////////////////////
172//
173BOOL
174LLMediaMovieBase::
175isStopped () const
176{
177 return FALSE;
178}
179
180///////////////////////////////////////////////////////////////////////////////
181//
182BOOL
183LLMediaMovieBase::
184isPaused () const
185{
186 return FALSE;
187}
188
189///////////////////////////////////////////////////////////////////////////////
190//
191BOOL
192LLMediaMovieBase::
193isPlaying () const
194{
195 return TRUE;
196}
197
198///////////////////////////////////////////////////////////////////////////////
199//
200BOOL
201LLMediaMovieBase::
202isLooping () const
203{
204 return FALSE;
205}
206
207///////////////////////////////////////////////////////////////////////////////
208//
209BOOL
210LLMediaMovieBase::
211seek ( F64 time )
212{
213 return TRUE;
214}
215
216///////////////////////////////////////////////////////////////////////////////
217//
218F64
219LLMediaMovieBase::
220getTime () const
221{
222 F64 result = 0;
223 return result;
224}
225
226///////////////////////////////////////////////////////////////////////////////
227//
228F64
229LLMediaMovieBase::
230getMediaDuration () const
231{
232 F64 result = 0;
233 return result;
234}
diff --git a/linden/indra/llmedia/llmediamoviebase.h b/linden/indra/llmedia/llmediamoviebase.h
deleted file mode 100644
index d763b28..0000000
--- a/linden/indra/llmedia/llmediamoviebase.h
+++ /dev/null
@@ -1,84 +0,0 @@
1/**
2 * @file llmediamoviebase.h
3 * @brief LLMedia support - intermediate base class, for media types
4 * that want movie-style controls (i.e play/pause and volume)
5 *
6 * $LicenseInfo:firstyear=2005&license=viewergpl$
7 *
8 * Copyright (c) 2005-2008, 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 llmediamoviebase_h
35#define llmediamoviebase_h
36
37#include "llmediabase.h"
38
39class LLMediaMovieBase : public LLMediaBase
40{
41 public:
42 LLMediaMovieBase ();
43
44 // do the right thing with dtor
45 virtual ~LLMediaMovieBase ()
46 {
47 };
48
49 ///////////////////////////////////////////////////////////////////////////////
50 // factory method based on explicit media type
51 static LLMediaMovieBase* make ( const MediaType mediaTypeIn, S32 width_pixels, S32 height_pixels );
52
53 ///////////////////////////////////////////////////////////////////////////////
54 // public interface:
55
56 // transport controls
57 virtual BOOL stop ();
58 virtual BOOL play ();
59 virtual BOOL loop ( S32 howMany );
60 virtual BOOL pause ();
61 virtual BOOL seek ( F64 time );
62
63 // audio levels
64 virtual BOOL setVolume ( F32 volumeIn );
65 virtual F32 getVolume ();
66
67 // status
68 virtual BOOL isIdle () const;
69 virtual BOOL isBuffering () const;
70 virtual BOOL isError () const;
71 virtual BOOL isLoaded () const;
72 virtual BOOL isStopped () const;
73 virtual BOOL isPaused () const;
74 virtual BOOL isPlaying () const;
75 virtual BOOL isLooping () const;
76 virtual F64 getTime () const;
77
78 // media data
79 virtual void setAutoScaled ( BOOL autoScaledIn );
80 virtual F64 getMediaDuration () const;
81};
82
83
84#endif // llmediamoviebase_h
diff --git a/linden/indra/llmedia/llmediaobserver.h b/linden/indra/llmedia/llmediaobserver.h
new file mode 100644
index 0000000..aeb2c39
--- /dev/null
+++ b/linden/indra/llmedia/llmediaobserver.h
@@ -0,0 +1,103 @@
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-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
21 *
22 * By copying, modifying or distributing this software, you acknowledge
23 * that you have read and understood your obligations described above,
24 * and agree to abide by those obligations.
25 *
26 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
27 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
28 * COMPLETENESS OR PERFORMANCE.
29 * $/LicenseInfo$
30 */
31
32#ifndef LLMEDIAEOBSERVER_H
33#define LLMEDIAEOBSERVER_H
34
35class LLMediaBase;
36
37class LLMediaEvent
38{
39 public:
40 LLMediaEvent( LLMediaBase* subject ) :
41 mSubject( subject )
42 {
43 };
44
45 LLMediaEvent( LLMediaBase* subject, std::string in ) :
46 mSubject( subject ), mStringValue(in)
47 {
48 };
49
50 LLMediaEvent( LLMediaBase* subject, std::string string_in, int int_in ) :
51 mSubject( subject ), mStringValue(string_in), mIntValue(int_in)
52 {
53 };
54
55 LLMediaEvent( LLMediaBase* subject, int in ) :
56 mSubject( subject ), mIntValue(in)
57 {
58 };
59
60 virtual ~LLMediaEvent() { }
61
62 LLMediaBase* getSubject() const
63 {
64 return mSubject;
65 };
66
67 int getIntValue() const
68 {
69 return mIntValue;
70 }
71
72 std::string getStringValue() const
73 {
74 return mStringValue;
75 }
76
77 private:
78 LLMediaBase* mSubject;
79 int mIntValue;
80 std::string mStringValue;
81};
82
83class LLMediaObserver
84{
85 public:
86 virtual ~LLMediaObserver() {}
87
88 typedef LLMediaEvent EventType;
89 virtual void onMediaPreroll( const EventType& event_in ) { }
90 virtual void onMediaLoaded( const EventType& event_in ) { }
91 virtual void onMediaSizeChange( const EventType& event_in ) { }
92 virtual void onMediaContentsChange( const EventType& event_in ) { }
93 virtual void onMediaStatusTextChange( const EventType& event_in ) { }
94 virtual void onNavigateBegin( const EventType& event_in ) { }
95 virtual void onNavigateComplete( const EventType& event_in ) { }
96 virtual void onUpdateProgress( const EventType& event_in ) { }
97 virtual void onStatusTextChange( const EventType& event_in ) { }
98 virtual void onLocationChange( const EventType& event_in ) { }
99 virtual void onClickLinkHref( const EventType& event_in ) { }
100 virtual void onClickLinkNoFollow( const EventType& event_in ) { }
101};
102
103#endif // LLMEDIAEOBSERVER_H