xref: /aoo41x/main/avmedia/source/win/player.cxx (revision 144e4e62)
1f39251c4SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f39251c4SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f39251c4SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f39251c4SAndrew Rist  * distributed with this work for additional information
6f39251c4SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f39251c4SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f39251c4SAndrew Rist  * "License"); you may not use this file except in compliance
9f39251c4SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f39251c4SAndrew Rist  *
11f39251c4SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f39251c4SAndrew Rist  *
13f39251c4SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f39251c4SAndrew Rist  * software distributed under the License is distributed on an
15f39251c4SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f39251c4SAndrew Rist  * KIND, either express or implied.  See the License for the
17f39251c4SAndrew Rist  * specific language governing permissions and limitations
18f39251c4SAndrew Rist  * under the License.
19f39251c4SAndrew Rist  *
20f39251c4SAndrew Rist  *************************************************************/
21f39251c4SAndrew Rist 
22f39251c4SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #include <tools/prewin.h>
25cdf0e10cSrcweir #if defined _MSC_VER
26cdf0e10cSrcweir #pragma warning(push, 1)
27cdf0e10cSrcweir #pragma warning(disable: 4917)
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #include <windows.h>
30cdf0e10cSrcweir #include <objbase.h>
31cdf0e10cSrcweir #include <strmif.h>
32cdf0e10cSrcweir #include <control.h>
33cdf0e10cSrcweir #include <uuids.h>
34cdf0e10cSrcweir #include <evcode.h>
35cdf0e10cSrcweir #if defined _MSC_VER
36cdf0e10cSrcweir #pragma warning(pop)
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #include <tools/postwin.h>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #include "player.hxx"
41cdf0e10cSrcweir #include "framegrabber.hxx"
42cdf0e10cSrcweir #include "window.hxx"
43cdf0e10cSrcweir 
44cdf0e10cSrcweir #define AVMEDIA_WIN_PLAYER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Player_DirectX"
45cdf0e10cSrcweir #define AVMEDIA_WIN_PLAYER_SERVICENAME "com.sun.star.media.Player_DirectX"
46cdf0e10cSrcweir 
47cdf0e10cSrcweir using namespace ::com::sun::star;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir namespace avmedia { namespace win {
50cdf0e10cSrcweir 
MediaPlayerWndProc_2(HWND hWnd,UINT nMsg,WPARAM nPar1,LPARAM nPar2)51cdf0e10cSrcweir LRESULT CALLBACK MediaPlayerWndProc_2( HWND hWnd,UINT nMsg, WPARAM nPar1, LPARAM nPar2 )
52cdf0e10cSrcweir {
53cdf0e10cSrcweir     Player* pPlayer = (Player*) ::GetWindowLong( hWnd, 0 );
54cdf0e10cSrcweir     bool    bProcessed = true;
55cdf0e10cSrcweir 
56cdf0e10cSrcweir     if( pPlayer )
57cdf0e10cSrcweir     {
58cdf0e10cSrcweir         switch( nMsg )
59cdf0e10cSrcweir         {
60cdf0e10cSrcweir             case( WM_GRAPHNOTIFY ):
61cdf0e10cSrcweir                 pPlayer->processEvent();
62cdf0e10cSrcweir             break;
63cdf0e10cSrcweir             default:
64cdf0e10cSrcweir                 bProcessed = false;
65cdf0e10cSrcweir             break;
66cdf0e10cSrcweir         }
67cdf0e10cSrcweir     }
68cdf0e10cSrcweir     else
69cdf0e10cSrcweir         bProcessed = false;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir     return( bProcessed ? 0 : DefWindowProc( hWnd, nMsg, nPar1, nPar2 ) );
72cdf0e10cSrcweir }
73cdf0e10cSrcweir 
74cdf0e10cSrcweir 
isWindowsVistaOrHigher()75cdf0e10cSrcweir bool isWindowsVistaOrHigher()
76cdf0e10cSrcweir {
77cdf0e10cSrcweir     // POST: return true if we are at least on Windows Vista
78cdf0e10cSrcweir     OSVERSIONINFO osvi;
79cdf0e10cSrcweir     ZeroMemory(&osvi, sizeof(osvi));
80cdf0e10cSrcweir     osvi.dwOSVersionInfoSize = sizeof(osvi);
81cdf0e10cSrcweir     GetVersionEx(&osvi);
82cdf0e10cSrcweir     return osvi.dwMajorVersion >= 6;
83cdf0e10cSrcweir }
84cdf0e10cSrcweir 
85cdf0e10cSrcweir // ----------------
86cdf0e10cSrcweir // - Player -
87cdf0e10cSrcweir // ----------------
88cdf0e10cSrcweir 
Player(const uno::Reference<lang::XMultiServiceFactory> & rxMgr)89cdf0e10cSrcweir Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
90cdf0e10cSrcweir     Player_BASE(m_aMutex),
91cdf0e10cSrcweir     mxMgr( rxMgr ),
92cdf0e10cSrcweir     mpGB( NULL ),
93cdf0e10cSrcweir     mpOMF( NULL ),
94cdf0e10cSrcweir     mpMC( NULL ),
95cdf0e10cSrcweir     mpME( NULL ),
96cdf0e10cSrcweir     mpMS( NULL ),
97cdf0e10cSrcweir     mpMP( NULL ),
98cdf0e10cSrcweir     mpBA( NULL ),
99cdf0e10cSrcweir     mpBV( NULL ),
100cdf0e10cSrcweir     mpVW( NULL ),
101cdf0e10cSrcweir     mpEV( NULL ),
102cdf0e10cSrcweir     mnUnmutedVolume( 0 ),
103cdf0e10cSrcweir 	mnFrameWnd( 0 ),
104cdf0e10cSrcweir     mbMuted( false ),
105cdf0e10cSrcweir     mbLooping( false ),
106cdf0e10cSrcweir 	mbAddWindow(sal_True)
107cdf0e10cSrcweir {
108cdf0e10cSrcweir     ::CoInitialize( NULL );
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir // ------------------------------------------------------------------------------
112cdf0e10cSrcweir 
~Player()113cdf0e10cSrcweir Player::~Player()
114cdf0e10cSrcweir {
115cdf0e10cSrcweir 	if( mnFrameWnd )
116cdf0e10cSrcweir         ::DestroyWindow( (HWND) mnFrameWnd );
117cdf0e10cSrcweir 
118cdf0e10cSrcweir     ::CoUninitialize();
119cdf0e10cSrcweir }
120cdf0e10cSrcweir 
121cdf0e10cSrcweir // ------------------------------------------------------------------------------
122cdf0e10cSrcweir 
disposing()123cdf0e10cSrcweir void SAL_CALL Player::disposing()
124cdf0e10cSrcweir {
125cdf0e10cSrcweir     ::osl::MutexGuard aGuard(m_aMutex);
126cdf0e10cSrcweir     stop();
127cdf0e10cSrcweir     if( mpBA )
128cdf0e10cSrcweir         mpBA->Release();
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     if( mpBV )
131cdf0e10cSrcweir         mpBV->Release();
132cdf0e10cSrcweir 
133cdf0e10cSrcweir     if( mpVW )
134cdf0e10cSrcweir         mpVW->Release();
135cdf0e10cSrcweir 
136cdf0e10cSrcweir     if( mpMP )
137cdf0e10cSrcweir         mpMP->Release();
138cdf0e10cSrcweir 
139cdf0e10cSrcweir     if( mpMS )
140cdf0e10cSrcweir         mpMS->Release();
141cdf0e10cSrcweir 
142cdf0e10cSrcweir     if( mpME )
143cdf0e10cSrcweir 	{
144cdf0e10cSrcweir 		mpME->SetNotifyWindow( 0, WM_GRAPHNOTIFY, 0);
145cdf0e10cSrcweir         mpME->Release();
146cdf0e10cSrcweir 	}
147cdf0e10cSrcweir 
148cdf0e10cSrcweir 
149cdf0e10cSrcweir     if( mpMC )
150cdf0e10cSrcweir         mpMC->Release();
151cdf0e10cSrcweir 
152cdf0e10cSrcweir     if( mpEV )
153cdf0e10cSrcweir         mpEV->Release();
154cdf0e10cSrcweir 
155cdf0e10cSrcweir     if( mpOMF )
156cdf0e10cSrcweir         mpOMF->Release();
157cdf0e10cSrcweir 
158cdf0e10cSrcweir     if( mpGB )
159cdf0e10cSrcweir         mpGB->Release();
160cdf0e10cSrcweir }
161cdf0e10cSrcweir // ------------------------------------------------------------------------------
create(const::rtl::OUString & rURL)162cdf0e10cSrcweir bool Player::create( const ::rtl::OUString& rURL )
163cdf0e10cSrcweir {
164cdf0e10cSrcweir     HRESULT hR;
165cdf0e10cSrcweir     bool    bRet = false;
166cdf0e10cSrcweir 
167cdf0e10cSrcweir     if( SUCCEEDED( hR = CoCreateInstance( CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, IID_IGraphBuilder, (void**) &mpGB ) ) )
168cdf0e10cSrcweir     {
169cdf0e10cSrcweir         // Don't use the overlay mixer on Windows Vista
170cdf0e10cSrcweir 		// It disables the desktop composition as soon as RenderFile is called
171cdf0e10cSrcweir 		// also causes some other problems: video rendering is not reliable
172cdf0e10cSrcweir 		if( !isWindowsVistaOrHigher() && SUCCEEDED( CoCreateInstance( CLSID_OverlayMixer, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**) &mpOMF ) ) )
173cdf0e10cSrcweir 		{
174cdf0e10cSrcweir 			mpGB->AddFilter( mpOMF, L"com_sun_star_media_OverlayMixerFilter" );
175cdf0e10cSrcweir 
176cdf0e10cSrcweir 			if( !SUCCEEDED( mpOMF->QueryInterface( IID_IDDrawExclModeVideo, (void**) &mpEV ) ) )
177cdf0e10cSrcweir 				mpEV = NULL;
178cdf0e10cSrcweir 		}
179cdf0e10cSrcweir 
180cdf0e10cSrcweir         if( SUCCEEDED( hR = mpGB->RenderFile( reinterpret_cast<LPCWSTR>(rURL.getStr()), NULL ) ) &&
181cdf0e10cSrcweir             SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaControl, (void**) &mpMC ) ) &&
182cdf0e10cSrcweir             SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaEventEx, (void**) &mpME ) ) &&
183cdf0e10cSrcweir             SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaSeeking, (void**) &mpMS ) ) &&
184cdf0e10cSrcweir             SUCCEEDED( hR = mpGB->QueryInterface( IID_IMediaPosition, (void**) &mpMP ) ) )
185cdf0e10cSrcweir         {
186cdf0e10cSrcweir             // Video interfaces
187cdf0e10cSrcweir             mpGB->QueryInterface( IID_IVideoWindow, (void**) &mpVW );
188cdf0e10cSrcweir             mpGB->QueryInterface( IID_IBasicVideo, (void**) &mpBV );
189cdf0e10cSrcweir 
190cdf0e10cSrcweir             // Audio interface
191cdf0e10cSrcweir             mpGB->QueryInterface( IID_IBasicAudio, (void**) &mpBA );
192cdf0e10cSrcweir 
193cdf0e10cSrcweir             if( mpBA )
194cdf0e10cSrcweir                 mpBA->put_Volume( mnUnmutedVolume );
195cdf0e10cSrcweir 
196cdf0e10cSrcweir             bRet = true;
197cdf0e10cSrcweir         }
198cdf0e10cSrcweir     }
199cdf0e10cSrcweir 
200cdf0e10cSrcweir     if( bRet )
201cdf0e10cSrcweir         maURL = rURL;
202cdf0e10cSrcweir     else
203cdf0e10cSrcweir         maURL = ::rtl::OUString();
204cdf0e10cSrcweir 
205cdf0e10cSrcweir     return bRet;
206cdf0e10cSrcweir }
207cdf0e10cSrcweir 
208cdf0e10cSrcweir // ------------------------------------------------------------------------------
209cdf0e10cSrcweir 
getVideoWindow() const210cdf0e10cSrcweir const IVideoWindow* Player::getVideoWindow() const
211cdf0e10cSrcweir {
212cdf0e10cSrcweir     return mpVW;
213cdf0e10cSrcweir }
214cdf0e10cSrcweir 
215cdf0e10cSrcweir // ------------------------------------------------------------------------------
216cdf0e10cSrcweir 
setNotifyWnd(int nNotifyWnd)217cdf0e10cSrcweir void Player::setNotifyWnd( int nNotifyWnd )
218cdf0e10cSrcweir {
219cdf0e10cSrcweir 	mbAddWindow = sal_False;
220cdf0e10cSrcweir     if( mpME )
221cdf0e10cSrcweir         mpME->SetNotifyWindow( (OAHWND) nNotifyWnd, WM_GRAPHNOTIFY, reinterpret_cast< LONG_PTR>( this ) );
222cdf0e10cSrcweir }
223cdf0e10cSrcweir 
224cdf0e10cSrcweir // ------------------------------------------------------------------------------
225cdf0e10cSrcweir 
setDDrawParams(IDirectDraw * pDDraw,IDirectDrawSurface * pDDrawSurface)226cdf0e10cSrcweir void Player::setDDrawParams( IDirectDraw* pDDraw, IDirectDrawSurface* pDDrawSurface )
227cdf0e10cSrcweir {
228cdf0e10cSrcweir     if( mpEV && pDDraw && pDDrawSurface )
229cdf0e10cSrcweir     {
230cdf0e10cSrcweir         mpEV->SetDDrawObject( pDDraw );
231cdf0e10cSrcweir         mpEV->SetDDrawSurface( pDDrawSurface );
232cdf0e10cSrcweir     }
233cdf0e10cSrcweir }
234cdf0e10cSrcweir 
235cdf0e10cSrcweir // ------------------------------------------------------------------------------
236cdf0e10cSrcweir 
processEvent()237cdf0e10cSrcweir long Player::processEvent()
238cdf0e10cSrcweir {
239cdf0e10cSrcweir     long nCode, nParam1, nParam2;
240cdf0e10cSrcweir 
241cdf0e10cSrcweir     while( mpME && SUCCEEDED( mpME->GetEvent( &nCode, &nParam1, &nParam2, 0 ) ) )
242cdf0e10cSrcweir     {
243cdf0e10cSrcweir         if( EC_COMPLETE == nCode )
244cdf0e10cSrcweir         {
245cdf0e10cSrcweir             if( mbLooping )
246cdf0e10cSrcweir             {
247cdf0e10cSrcweir                 setMediaTime( 0.0 );
248cdf0e10cSrcweir                 start();
249cdf0e10cSrcweir             }
250cdf0e10cSrcweir             else
251cdf0e10cSrcweir             {
252cdf0e10cSrcweir                 setMediaTime( getDuration() );
253cdf0e10cSrcweir                 stop();
254cdf0e10cSrcweir             }
255cdf0e10cSrcweir         }
256cdf0e10cSrcweir 
257cdf0e10cSrcweir         mpME->FreeEventParams( nCode, nParam1, nParam2 );
258cdf0e10cSrcweir     }
259cdf0e10cSrcweir 
260cdf0e10cSrcweir     return 0;
261cdf0e10cSrcweir }
262cdf0e10cSrcweir 
263cdf0e10cSrcweir // ------------------------------------------------------------------------------
264cdf0e10cSrcweir 
start()265cdf0e10cSrcweir void SAL_CALL Player::start(  )
266cdf0e10cSrcweir     throw (uno::RuntimeException)
267cdf0e10cSrcweir {
268cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
269cdf0e10cSrcweir     if( mpMC )
270cdf0e10cSrcweir 	{
271cdf0e10cSrcweir 		if ( mbAddWindow )
272cdf0e10cSrcweir 		{
273cdf0e10cSrcweir 			static WNDCLASS* mpWndClass = NULL;
274cdf0e10cSrcweir 			if ( !mpWndClass )
275cdf0e10cSrcweir 			{
276cdf0e10cSrcweir 				mpWndClass = new WNDCLASS;
277cdf0e10cSrcweir 
278cdf0e10cSrcweir 				memset( mpWndClass, 0, sizeof( *mpWndClass ) );
279cdf0e10cSrcweir 				mpWndClass->hInstance = GetModuleHandle( NULL );
280cdf0e10cSrcweir 				mpWndClass->cbWndExtra = sizeof( DWORD );
281cdf0e10cSrcweir 				mpWndClass->lpfnWndProc = MediaPlayerWndProc_2;
282cdf0e10cSrcweir 				mpWndClass->lpszClassName = "com_sun_star_media_Sound_Player";
283cdf0e10cSrcweir 				mpWndClass->hbrBackground = (HBRUSH) ::GetStockObject( BLACK_BRUSH );
284cdf0e10cSrcweir 				mpWndClass->hCursor = ::LoadCursor( NULL, IDC_ARROW );
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 				::RegisterClass( mpWndClass );
287cdf0e10cSrcweir 			}
288cdf0e10cSrcweir 			if ( !mnFrameWnd )
289cdf0e10cSrcweir 			{
290cdf0e10cSrcweir 				mnFrameWnd = (int) ::CreateWindow( mpWndClass->lpszClassName, NULL,
291cdf0e10cSrcweir                                            0,
292cdf0e10cSrcweir                                            0, 0, 0, 0,
293cdf0e10cSrcweir                                            (HWND) NULL, NULL, mpWndClass->hInstance, 0 );
294cdf0e10cSrcweir 				if ( mnFrameWnd )
295cdf0e10cSrcweir 				{
296cdf0e10cSrcweir 					::ShowWindow((HWND) mnFrameWnd, SW_HIDE);
297cdf0e10cSrcweir 					::SetWindowLong( (HWND) mnFrameWnd, 0, (DWORD) this );
298cdf0e10cSrcweir 					// mpVW->put_Owner( (OAHWND) mnFrameWnd );
299cdf0e10cSrcweir 					setNotifyWnd( mnFrameWnd );
300cdf0e10cSrcweir 				}
301cdf0e10cSrcweir 			}
302cdf0e10cSrcweir 		}
303cdf0e10cSrcweir 
304cdf0e10cSrcweir         mpMC->Run();
305cdf0e10cSrcweir 	}
306cdf0e10cSrcweir }
307cdf0e10cSrcweir 
308cdf0e10cSrcweir // ------------------------------------------------------------------------------
309cdf0e10cSrcweir 
stop()310cdf0e10cSrcweir void SAL_CALL Player::stop(  )
311cdf0e10cSrcweir     throw (uno::RuntimeException)
312cdf0e10cSrcweir {
313cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
314cdf0e10cSrcweir 
315cdf0e10cSrcweir     if( mpMC )
316cdf0e10cSrcweir         mpMC->Stop();
317cdf0e10cSrcweir }
318cdf0e10cSrcweir 
319cdf0e10cSrcweir // ------------------------------------------------------------------------------
320cdf0e10cSrcweir 
isPlaying()321cdf0e10cSrcweir sal_Bool SAL_CALL Player::isPlaying()
322cdf0e10cSrcweir     throw (uno::RuntimeException)
323cdf0e10cSrcweir {
324cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
325cdf0e10cSrcweir 
326cdf0e10cSrcweir     OAFilterState   eFilterState;
327cdf0e10cSrcweir     bool            bRet = false;
328cdf0e10cSrcweir 
329cdf0e10cSrcweir     if( mpMC && SUCCEEDED( mpMC->GetState( 10, &eFilterState ) ) )
330cdf0e10cSrcweir         bRet = ( State_Running == eFilterState );
331cdf0e10cSrcweir 
332cdf0e10cSrcweir     return bRet;
333cdf0e10cSrcweir }
334cdf0e10cSrcweir 
335cdf0e10cSrcweir // ------------------------------------------------------------------------------
336cdf0e10cSrcweir 
getDuration()337cdf0e10cSrcweir double SAL_CALL Player::getDuration(  )
338cdf0e10cSrcweir     throw (uno::RuntimeException)
339cdf0e10cSrcweir {
340cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
341cdf0e10cSrcweir 
342cdf0e10cSrcweir     REFTIME aRefTime( 0.0 );
343cdf0e10cSrcweir 
344cdf0e10cSrcweir     if( mpMP  )
345cdf0e10cSrcweir         mpMP->get_Duration( &aRefTime );
346cdf0e10cSrcweir 
347cdf0e10cSrcweir     return aRefTime;
348cdf0e10cSrcweir }
349cdf0e10cSrcweir 
350cdf0e10cSrcweir // ------------------------------------------------------------------------------
351cdf0e10cSrcweir 
setMediaTime(double fTime)352cdf0e10cSrcweir void SAL_CALL Player::setMediaTime( double fTime )
353cdf0e10cSrcweir     throw (uno::RuntimeException)
354cdf0e10cSrcweir {
355cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
356cdf0e10cSrcweir 
357cdf0e10cSrcweir     if( mpMP  )
358cdf0e10cSrcweir     {
359cdf0e10cSrcweir         const bool bPlaying = isPlaying();
360cdf0e10cSrcweir 
361cdf0e10cSrcweir         mpMP->put_CurrentPosition( fTime );
362cdf0e10cSrcweir 
363cdf0e10cSrcweir         if( !bPlaying && mpMC )
364cdf0e10cSrcweir             mpMC->StopWhenReady();
365cdf0e10cSrcweir     }
366cdf0e10cSrcweir }
367cdf0e10cSrcweir 
368cdf0e10cSrcweir // ------------------------------------------------------------------------------
369cdf0e10cSrcweir 
getMediaTime()370cdf0e10cSrcweir double SAL_CALL Player::getMediaTime(  )
371cdf0e10cSrcweir     throw (uno::RuntimeException)
372cdf0e10cSrcweir {
373cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
374cdf0e10cSrcweir 
375cdf0e10cSrcweir     REFTIME aRefTime( 0.0 );
376cdf0e10cSrcweir 
377cdf0e10cSrcweir     if( mpMP  )
378cdf0e10cSrcweir         mpMP->get_CurrentPosition( &aRefTime );
379cdf0e10cSrcweir 
380cdf0e10cSrcweir     return aRefTime;
381cdf0e10cSrcweir }
382cdf0e10cSrcweir 
383cdf0e10cSrcweir // ------------------------------------------------------------------------------
384cdf0e10cSrcweir 
setStopTime(double fTime)385cdf0e10cSrcweir void SAL_CALL Player::setStopTime( double fTime )
386cdf0e10cSrcweir     throw (uno::RuntimeException)
387cdf0e10cSrcweir {
388cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
389cdf0e10cSrcweir 
390cdf0e10cSrcweir     if( mpMP  )
391cdf0e10cSrcweir         mpMP->put_StopTime( fTime );
392cdf0e10cSrcweir }
393cdf0e10cSrcweir 
394cdf0e10cSrcweir // ------------------------------------------------------------------------------
395cdf0e10cSrcweir 
getStopTime()396cdf0e10cSrcweir double SAL_CALL Player::getStopTime(  )
397cdf0e10cSrcweir     throw (uno::RuntimeException)
398cdf0e10cSrcweir {
399cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
400cdf0e10cSrcweir 
401cdf0e10cSrcweir     REFTIME aRefTime( 0.0 );
402cdf0e10cSrcweir 
403cdf0e10cSrcweir     if( mpMP  )
404cdf0e10cSrcweir         mpMP->get_StopTime( &aRefTime );
405cdf0e10cSrcweir 
406cdf0e10cSrcweir     return aRefTime;
407cdf0e10cSrcweir }
408cdf0e10cSrcweir 
409cdf0e10cSrcweir // ------------------------------------------------------------------------------
410cdf0e10cSrcweir 
setRate(double fRate)411cdf0e10cSrcweir void SAL_CALL Player::setRate( double fRate )
412cdf0e10cSrcweir     throw (uno::RuntimeException)
413cdf0e10cSrcweir {
414cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
415cdf0e10cSrcweir 
416cdf0e10cSrcweir     if( mpMP  )
417cdf0e10cSrcweir         mpMP->put_Rate( fRate );
418cdf0e10cSrcweir }
419cdf0e10cSrcweir 
420cdf0e10cSrcweir // ------------------------------------------------------------------------------
421cdf0e10cSrcweir 
getRate()422cdf0e10cSrcweir double SAL_CALL Player::getRate(  )
423cdf0e10cSrcweir     throw (uno::RuntimeException)
424cdf0e10cSrcweir {
425cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
426cdf0e10cSrcweir 
427cdf0e10cSrcweir     double fRet( 0.0 );
428cdf0e10cSrcweir 
429cdf0e10cSrcweir     if( mpMP  )
430cdf0e10cSrcweir         mpMP->get_Rate( &fRet );
431cdf0e10cSrcweir 
432cdf0e10cSrcweir     return fRet;
433cdf0e10cSrcweir }
434cdf0e10cSrcweir 
435cdf0e10cSrcweir // ------------------------------------------------------------------------------
436cdf0e10cSrcweir 
setPlaybackLoop(sal_Bool bSet)437cdf0e10cSrcweir void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet )
438cdf0e10cSrcweir     throw (uno::RuntimeException)
439cdf0e10cSrcweir {
440cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
441cdf0e10cSrcweir 
442cdf0e10cSrcweir     mbLooping = bSet;
443cdf0e10cSrcweir }
444cdf0e10cSrcweir 
445cdf0e10cSrcweir // ------------------------------------------------------------------------------
446cdf0e10cSrcweir 
isPlaybackLoop()447cdf0e10cSrcweir sal_Bool SAL_CALL Player::isPlaybackLoop(  )
448cdf0e10cSrcweir     throw (uno::RuntimeException)
449cdf0e10cSrcweir {
450cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
451cdf0e10cSrcweir 
452cdf0e10cSrcweir     return mbLooping;
453cdf0e10cSrcweir }
454cdf0e10cSrcweir 
455cdf0e10cSrcweir // ------------------------------------------------------------------------------
456cdf0e10cSrcweir 
setMute(sal_Bool bSet)457cdf0e10cSrcweir void SAL_CALL Player::setMute( sal_Bool bSet )
458cdf0e10cSrcweir     throw (uno::RuntimeException)
459cdf0e10cSrcweir {
460cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
461cdf0e10cSrcweir 
462cdf0e10cSrcweir     if( mpBA && ( mbMuted != bSet ) )
463cdf0e10cSrcweir     {
464cdf0e10cSrcweir         mbMuted = bSet;
465cdf0e10cSrcweir         mpBA->put_Volume( mbMuted ? -10000 : mnUnmutedVolume );
466cdf0e10cSrcweir     }
467cdf0e10cSrcweir }
468cdf0e10cSrcweir 
469cdf0e10cSrcweir // ------------------------------------------------------------------------------
470cdf0e10cSrcweir 
isMute()471cdf0e10cSrcweir sal_Bool SAL_CALL Player::isMute(  )
472cdf0e10cSrcweir     throw (uno::RuntimeException)
473cdf0e10cSrcweir {
474cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
475cdf0e10cSrcweir 
476cdf0e10cSrcweir     return mbMuted;
477cdf0e10cSrcweir }
478cdf0e10cSrcweir 
479cdf0e10cSrcweir // ------------------------------------------------------------------------------
480cdf0e10cSrcweir 
setVolumeDB(sal_Int16 nVolumeDB)481cdf0e10cSrcweir void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB )
482cdf0e10cSrcweir     throw (uno::RuntimeException)
483cdf0e10cSrcweir {
484cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
485cdf0e10cSrcweir 
486cdf0e10cSrcweir     mnUnmutedVolume = static_cast< long >( nVolumeDB ) * 100;
487cdf0e10cSrcweir 
488cdf0e10cSrcweir     if( !mbMuted && mpBA )
489cdf0e10cSrcweir         mpBA->put_Volume( mnUnmutedVolume );
490cdf0e10cSrcweir }
491cdf0e10cSrcweir 
492cdf0e10cSrcweir // ------------------------------------------------------------------------------
493cdf0e10cSrcweir 
getVolumeDB()494cdf0e10cSrcweir sal_Int16 SAL_CALL Player::getVolumeDB(  )
495cdf0e10cSrcweir     throw (uno::RuntimeException)
496cdf0e10cSrcweir {
497cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
498cdf0e10cSrcweir 
499cdf0e10cSrcweir     return( static_cast< sal_Int16 >( mnUnmutedVolume / 100 ) );
500cdf0e10cSrcweir }
501cdf0e10cSrcweir 
502cdf0e10cSrcweir // ------------------------------------------------------------------------------
503cdf0e10cSrcweir 
getPreferredPlayerWindowSize()504cdf0e10cSrcweir awt::Size SAL_CALL Player::getPreferredPlayerWindowSize(  )
505cdf0e10cSrcweir     throw (uno::RuntimeException)
506cdf0e10cSrcweir {
507cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
508cdf0e10cSrcweir 
509cdf0e10cSrcweir     awt::Size aSize( 0, 0 );
510cdf0e10cSrcweir 
511cdf0e10cSrcweir     if( mpBV )
512cdf0e10cSrcweir     {
513cdf0e10cSrcweir         long nWidth = 0, nHeight = 0;
514cdf0e10cSrcweir 
515cdf0e10cSrcweir         mpBV->GetVideoSize( &nWidth, &nHeight );
516cdf0e10cSrcweir         aSize.Width = nWidth;
517cdf0e10cSrcweir         aSize.Height = nHeight;
518cdf0e10cSrcweir     }
519cdf0e10cSrcweir 
520cdf0e10cSrcweir     return aSize;
521cdf0e10cSrcweir }
522cdf0e10cSrcweir 
523cdf0e10cSrcweir // ------------------------------------------------------------------------------
524cdf0e10cSrcweir 
createPlayerWindow(const uno::Sequence<uno::Any> & aArguments)525cdf0e10cSrcweir uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( const uno::Sequence< uno::Any >& aArguments )
526cdf0e10cSrcweir     throw (uno::RuntimeException)
527cdf0e10cSrcweir {
528cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
529cdf0e10cSrcweir 
530cdf0e10cSrcweir     uno::Reference< ::media::XPlayerWindow >    xRet;
531cdf0e10cSrcweir     awt::Size                                   aSize( getPreferredPlayerWindowSize() );
532cdf0e10cSrcweir 
533cdf0e10cSrcweir     if( mpVW && aSize.Width > 0 && aSize.Height > 0 )
534cdf0e10cSrcweir     {
535cdf0e10cSrcweir         ::avmedia::win::Window* pWindow = new ::avmedia::win::Window( mxMgr, *this );
536cdf0e10cSrcweir 
537cdf0e10cSrcweir         xRet = pWindow;
538cdf0e10cSrcweir 
539cdf0e10cSrcweir         if( !pWindow->create( aArguments ) )
540cdf0e10cSrcweir             xRet = uno::Reference< ::media::XPlayerWindow >();
541cdf0e10cSrcweir     }
542cdf0e10cSrcweir 
543cdf0e10cSrcweir     return xRet;
544cdf0e10cSrcweir }
545cdf0e10cSrcweir 
546cdf0e10cSrcweir // ------------------------------------------------------------------------------
547cdf0e10cSrcweir 
createFrameGrabber()548cdf0e10cSrcweir uno::Reference< media::XFrameGrabber > SAL_CALL Player::createFrameGrabber(  )
549cdf0e10cSrcweir     throw (uno::RuntimeException)
550cdf0e10cSrcweir {
551cdf0e10cSrcweir 	::osl::MutexGuard aGuard(m_aMutex);
552cdf0e10cSrcweir 
553cdf0e10cSrcweir     uno::Reference< media::XFrameGrabber > xRet;
554cdf0e10cSrcweir 
555*144e4e62SHerbert Dürr     if( !maURL.isEmpty() )
556cdf0e10cSrcweir     {
557cdf0e10cSrcweir         FrameGrabber* pGrabber = new FrameGrabber( mxMgr );
558cdf0e10cSrcweir 
559cdf0e10cSrcweir         xRet = pGrabber;
560cdf0e10cSrcweir 
561cdf0e10cSrcweir         if( !pGrabber->create( maURL ) )
562cdf0e10cSrcweir             xRet.clear();
563cdf0e10cSrcweir     }
564cdf0e10cSrcweir 
565cdf0e10cSrcweir     return xRet;
566cdf0e10cSrcweir }
567cdf0e10cSrcweir 
568cdf0e10cSrcweir // ------------------------------------------------------------------------------
569cdf0e10cSrcweir 
getImplementationName()570cdf0e10cSrcweir ::rtl::OUString SAL_CALL Player::getImplementationName(  )
571cdf0e10cSrcweir     throw (uno::RuntimeException)
572cdf0e10cSrcweir {
573cdf0e10cSrcweir     return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_WIN_PLAYER_IMPLEMENTATIONNAME ) );
574cdf0e10cSrcweir }
575cdf0e10cSrcweir 
576cdf0e10cSrcweir // ------------------------------------------------------------------------------
577cdf0e10cSrcweir 
supportsService(const::rtl::OUString & ServiceName)578cdf0e10cSrcweir sal_Bool SAL_CALL Player::supportsService( const ::rtl::OUString& ServiceName )
579cdf0e10cSrcweir     throw (uno::RuntimeException)
580cdf0e10cSrcweir {
581cdf0e10cSrcweir     return ServiceName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM ( AVMEDIA_WIN_PLAYER_SERVICENAME ) );
582cdf0e10cSrcweir }
583cdf0e10cSrcweir 
584cdf0e10cSrcweir // ------------------------------------------------------------------------------
585cdf0e10cSrcweir 
getSupportedServiceNames()586cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL Player::getSupportedServiceNames(  )
587cdf0e10cSrcweir     throw (uno::RuntimeException)
588cdf0e10cSrcweir {
589cdf0e10cSrcweir     uno::Sequence< ::rtl::OUString > aRet(1);
590cdf0e10cSrcweir     aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_WIN_PLAYER_SERVICENAME ) );
591cdf0e10cSrcweir 
592cdf0e10cSrcweir     return aRet;
593cdf0e10cSrcweir }
594cdf0e10cSrcweir 
595cdf0e10cSrcweir } // namespace win
596cdf0e10cSrcweir } // namespace avmedia
597