Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2010 Novell, Inc.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <math.h>
30 : :
31 : : #include <rtl/string.hxx>
32 : :
33 : : #include <vcl/syschild.hxx>
34 : : #include <vcl/sysdata.hxx>
35 : :
36 : : #include "gstplayer.hxx"
37 : : #include "gstframegrabber.hxx"
38 : : #include "gstwindow.hxx"
39 : :
40 : : #ifndef AVMEDIA_GST_0_10
41 : : # include <gst/video/videooverlay.h>
42 : : #endif
43 : :
44 : : #define AVMEDIA_GST_PLAYER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Player_GStreamer"
45 : : #define AVMEDIA_GST_PLAYER_SERVICENAME "com.sun.star.media.Player_GStreamer"
46 : :
47 : : #ifdef AVMEDIA_GST_0_10
48 : : # define AVVERSION "gst 0.10: "
49 : : #else
50 : : # define AVVERSION "gst 1.0: "
51 : : #endif
52 : :
53 : : #if !defined DBG
54 : : #if OSL_DEBUG_LEVEL > 2
55 : : #define DBG(...) do { fprintf (stderr, "%s", AVVERSION); fprintf (stderr, __VA_ARGS__); fprintf (stderr, "\n"); } while (0);
56 : : #else
57 : : #define DBG(...)
58 : : #endif
59 : : #endif
60 : :
61 : : using namespace ::com::sun::star;
62 : :
63 : : namespace avmedia { namespace gstreamer {
64 : :
65 : : // ----------------
66 : : // - Player -
67 : : // ----------------
68 : :
69 : 0 : Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
70 : : mxMgr( rxMgr ),
71 : : mpPlaybin( NULL ),
72 : : mbFakeVideo (sal_False ),
73 : : mnUnmutedVolume( 0 ),
74 : : mbPlayPending ( false ),
75 : : mbMuted( false ),
76 : : mbLooping( false ),
77 : : mbInitialized( false ),
78 : : mnWindowID( 0 ),
79 : : mpXOverlay( NULL ),
80 : : mnDuration( 0 ),
81 : : mnWidth( 0 ),
82 : 0 : mnHeight( 0 )
83 : : {
84 : : // Initialize GStreamer library
85 : 0 : int argc = 1;
86 : 0 : char name[] = "libreoffice";
87 : 0 : char *arguments[] = { name };
88 : 0 : char** argv = arguments;
89 : 0 : GError* pError = NULL;
90 : :
91 : 0 : mbInitialized = gst_init_check( &argc, &argv, &pError );
92 : :
93 : : DBG( "%p Player::Player", this );
94 : :
95 : 0 : if (pError != NULL)
96 : : {
97 : : // TODO: thow an exception?
98 : : DBG( "%p Player::Player error '%s'", this, pError->message );
99 : 0 : g_error_free (pError);
100 : : }
101 : 0 : }
102 : :
103 : : // ------------------------------------------------------------------------------
104 : :
105 : 0 : Player::~Player()
106 : : {
107 : : DBG( "%p Player::~Player", this );
108 : :
109 : : // Release the elements and pipeline
110 : 0 : if( mbInitialized )
111 : : {
112 : 0 : if( mpPlaybin )
113 : : {
114 : 0 : gst_element_set_state( mpPlaybin, GST_STATE_NULL );
115 : 0 : g_object_unref( G_OBJECT( mpPlaybin ) );
116 : :
117 : 0 : mpPlaybin = NULL;
118 : : }
119 : :
120 : 0 : if( mpXOverlay ) {
121 : 0 : g_object_unref( G_OBJECT ( mpXOverlay ) );
122 : 0 : mpXOverlay = NULL;
123 : : }
124 : : }
125 : 0 : }
126 : :
127 : : // ------------------------------------------------------------------------------
128 : :
129 : 0 : static gboolean pipeline_bus_callback( GstBus *, GstMessage *message, gpointer data )
130 : : {
131 : 0 : Player* pPlayer = static_cast<Player*>(data);
132 : :
133 : 0 : pPlayer->processMessage( message );
134 : :
135 : 0 : return TRUE;
136 : : }
137 : :
138 : 0 : static GstBusSyncReply pipeline_bus_sync_handler( GstBus *, GstMessage * message, gpointer data )
139 : : {
140 : 0 : Player* pPlayer = static_cast<Player*>(data);
141 : :
142 : 0 : return pPlayer->processSyncMessage( message );
143 : : }
144 : :
145 : 0 : void Player::processMessage( GstMessage *message )
146 : : {
147 : 0 : switch( GST_MESSAGE_TYPE( message ) ) {
148 : : case GST_MESSAGE_EOS:
149 : 0 : gst_element_set_state( mpPlaybin, GST_STATE_READY );
150 : 0 : mbPlayPending = false;
151 : 0 : if (mbLooping)
152 : 0 : start();
153 : 0 : break;
154 : : case GST_MESSAGE_STATE_CHANGED:
155 : 0 : if( message->src == GST_OBJECT( mpPlaybin ) ) {
156 : : GstState newstate, pendingstate;
157 : :
158 : 0 : gst_message_parse_state_changed (message, NULL, &newstate, &pendingstate);
159 : :
160 : 0 : if( newstate == GST_STATE_PAUSED &&
161 : : pendingstate == GST_STATE_VOID_PENDING &&
162 : : mpXOverlay )
163 : 0 : gst_video_overlay_expose( mpXOverlay );
164 : :
165 : 0 : if (mbPlayPending)
166 : 0 : mbPlayPending = ((newstate == GST_STATE_READY) || (newstate == GST_STATE_PAUSED));
167 : : }
168 : : default:
169 : 0 : break;
170 : : }
171 : 0 : }
172 : :
173 : 0 : static gboolean wrap_element_query_position (GstElement *element, GstFormat format, gint64 *cur)
174 : : {
175 : : #ifdef AVMEDIA_GST_0_10
176 : 0 : GstFormat my_format = format;
177 : 0 : return gst_element_query_position( element, &my_format, cur) && my_format == format && *cur > 0L;
178 : : #else
179 : : return gst_element_query_position( element, format, cur );
180 : : #endif
181 : : }
182 : :
183 : 0 : static gboolean wrap_element_query_duration (GstElement *element, GstFormat format, gint64 *duration)
184 : : {
185 : : #ifdef AVMEDIA_GST_0_10
186 : 0 : GstFormat my_format = format;
187 : 0 : return gst_element_query_duration( element, &my_format, duration) && my_format == format && *duration > 0L;
188 : : #else
189 : : return gst_element_query_duration( element, format, duration );
190 : : #endif
191 : : }
192 : :
193 : 0 : GstBusSyncReply Player::processSyncMessage( GstMessage *message )
194 : : {
195 : : // DBG( "%p processSyncMessage has handle: %s", this, GST_MESSAGE_TYPE_NAME( message ) );
196 : :
197 : : #if OSL_DEBUG_LEVEL > 0
198 : : if ( GST_MESSAGE_TYPE( message ) == GST_MESSAGE_ERROR )
199 : : {
200 : : GError* error;
201 : : gchar* error_debug;
202 : :
203 : : gst_message_parse_error( message, &error, &error_debug );
204 : : fprintf(stderr, "gstreamer error: '%s' debug: '%s'", error->message, error_debug);
205 : : }
206 : : #endif
207 : :
208 : : #ifdef AVMEDIA_GST_0_10
209 : 0 : if (message->structure &&
210 : 0 : !strcmp( gst_structure_get_name( message->structure ), "prepare-xwindow-id" ) && mnWindowID != 0 )
211 : : #else
212 : : if (gst_message_has_name (message, "prepare-window-handle") && mnWindowID != 0 )
213 : : #endif
214 : : {
215 : : DBG( "%p processSyncMessage has handle: %s", this, GST_MESSAGE_TYPE_NAME( message ) );
216 : 0 : if( mpXOverlay )
217 : 0 : g_object_unref( G_OBJECT ( mpXOverlay ) );
218 : 0 : mpXOverlay = GST_VIDEO_OVERLAY( GST_MESSAGE_SRC( message ) );
219 : 0 : g_object_ref( G_OBJECT ( mpXOverlay ) );
220 : 0 : gst_video_overlay_set_window_handle( mpXOverlay, mnWindowID );
221 : 0 : return GST_BUS_DROP;
222 : : }
223 : :
224 : : #ifdef AVMEDIA_GST_0_10
225 : 0 : if( GST_MESSAGE_TYPE( message ) == GST_MESSAGE_STATE_CHANGED ) {
226 : 0 : if( message->src == GST_OBJECT( mpPlaybin ) ) {
227 : : GstState newstate, pendingstate;
228 : :
229 : 0 : gst_message_parse_state_changed (message, NULL, &newstate, &pendingstate);
230 : :
231 : : DBG( "%p state change received, new state %d pending %d", this,
232 : : (int)newstate, (int)pendingstate );
233 : 0 : if( newstate == GST_STATE_PAUSED &&
234 : : pendingstate == GST_STATE_VOID_PENDING ) {
235 : :
236 : : DBG( "%p change to paused received", this );
237 : :
238 : 0 : if( mnDuration == 0) {
239 : 0 : gint64 gst_duration = 0L;
240 : 0 : if( wrap_element_query_duration( mpPlaybin, GST_FORMAT_TIME, &gst_duration) )
241 : 0 : mnDuration = gst_duration;
242 : : }
243 : :
244 : 0 : if( mnWidth == 0 ) {
245 : 0 : GList *pStreamInfo = NULL;
246 : :
247 : 0 : g_object_get( G_OBJECT( mpPlaybin ), "stream-info", &pStreamInfo, NULL );
248 : :
249 : 0 : for ( ; pStreamInfo != NULL; pStreamInfo = pStreamInfo->next) {
250 : 0 : GObject *pInfo = G_OBJECT( pStreamInfo->data );
251 : :
252 : 0 : if( !pInfo )
253 : 0 : continue;
254 : :
255 : : int nType;
256 : 0 : g_object_get( pInfo, "type", &nType, NULL );
257 : 0 : GEnumValue *pValue = g_enum_get_value( G_PARAM_SPEC_ENUM( g_object_class_find_property( G_OBJECT_GET_CLASS( pInfo ), "type" ) )->enum_class,
258 : 0 : nType );
259 : :
260 : 0 : if( !g_ascii_strcasecmp( pValue->value_nick, "video" ) ) {
261 : : GstStructure *pStructure;
262 : : GstPad *pPad;
263 : :
264 : 0 : g_object_get( pInfo, "object", &pPad, NULL );
265 : 0 : pStructure = gst_caps_get_structure( GST_PAD_CAPS( pPad ), 0 );
266 : 0 : if( pStructure ) {
267 : 0 : gst_structure_get_int( pStructure, "width", &mnWidth );
268 : 0 : gst_structure_get_int( pStructure, "height", &mnHeight );
269 : : DBG( "queried size: %d x %d", mnWidth, mnHeight );
270 : : }
271 : : }
272 : : }
273 : :
274 : 0 : maSizeCondition.set();
275 : : }
276 : : }
277 : : }
278 : : #else
279 : : // We get to use the exciting new playbin2 ! (now known as playbin)
280 : : if( GST_MESSAGE_TYPE( message ) == GST_MESSAGE_ASYNC_DONE ) {
281 : : if( mnDuration == 0) {
282 : : gint64 gst_duration = 0L;
283 : : if( wrap_element_query_duration( mpPlaybin, GST_FORMAT_TIME, &gst_duration) )
284 : : mnDuration = gst_duration;
285 : : }
286 : : if( mnWidth == 0 ) {
287 : : GstPad *pad = NULL;
288 : : GstCaps *caps;
289 : :
290 : : g_signal_emit_by_name( mpPlaybin, "get-video-pad", 0, &pad );
291 : :
292 : : if( pad ) {
293 : : int w = 0, h = 0;
294 : :
295 : : caps = gst_pad_get_current_caps( pad );
296 : :
297 : : if( gst_structure_get( gst_caps_get_structure (caps, 0),
298 : : "width", G_TYPE_INT, &w,
299 : : "height", G_TYPE_INT, &h,
300 : : NULL ) ) {
301 : : mnWidth = w;
302 : : mnHeight = h;
303 : :
304 : : fprintf (stderr, "queried size: %d x %d", mnWidth, mnHeight );
305 : :
306 : : maSizeCondition.set();
307 : : }
308 : : gst_caps_unref( caps );
309 : : }
310 : : }
311 : : #endif
312 : 0 : } else if( GST_MESSAGE_TYPE( message ) == GST_MESSAGE_ERROR ) {
313 : 0 : fprintf (stderr, "Error !\n");
314 : 0 : if( mnWidth == 0 ) {
315 : : // an error occurred, set condition so that OOo thread doesn't wait for us
316 : 0 : maSizeCondition.set();
317 : : }
318 : : }
319 : :
320 : 0 : return GST_BUS_PASS;
321 : : }
322 : :
323 : 0 : void Player::preparePlaybin( const ::rtl::OUString& rURL, bool bFakeVideo )
324 : : {
325 : : GstBus *pBus;
326 : :
327 : 0 : if( mpPlaybin != NULL ) {
328 : 0 : gst_element_set_state( mpPlaybin, GST_STATE_NULL );
329 : 0 : mbPlayPending = false;
330 : 0 : g_object_unref( mpPlaybin );
331 : : }
332 : :
333 : 0 : mpPlaybin = gst_element_factory_make( "playbin", NULL );
334 : :
335 : 0 : if( bFakeVideo )
336 : 0 : g_object_set( G_OBJECT( mpPlaybin ), "video-sink", gst_element_factory_make( "fakesink", NULL ), NULL );
337 : :
338 : 0 : mbFakeVideo = bFakeVideo;
339 : :
340 : 0 : rtl::OString ascURL = OUStringToOString( rURL, RTL_TEXTENCODING_UTF8 );
341 : 0 : g_object_set( G_OBJECT( mpPlaybin ), "uri", ascURL.getStr() , NULL );
342 : :
343 : 0 : pBus = gst_element_get_bus( mpPlaybin );
344 : 0 : gst_bus_add_watch( pBus, pipeline_bus_callback, this );
345 : : DBG( "%p set sync handler", this );
346 : 0 : gst_bus_set_sync_handler( pBus, pipeline_bus_sync_handler, this );
347 : 0 : g_object_unref( pBus );
348 : 0 : }
349 : :
350 : 0 : bool Player::create( const ::rtl::OUString& rURL )
351 : : {
352 : 0 : bool bRet = false;
353 : :
354 : : // create all the elements and link them
355 : :
356 : : DBG("create player, URL: %s", OUStringToOString( rURL, RTL_TEXTENCODING_UTF8 ).getStr());
357 : :
358 : 0 : if( mbInitialized )
359 : : {
360 : 0 : preparePlaybin( rURL, true );
361 : :
362 : 0 : gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
363 : 0 : mbPlayPending = false;
364 : :
365 : 0 : bRet = true;
366 : : }
367 : :
368 : 0 : if( bRet )
369 : 0 : maURL = rURL;
370 : : else
371 : 0 : maURL = ::rtl::OUString();
372 : :
373 : 0 : return bRet;
374 : : }
375 : :
376 : : // ------------------------------------------------------------------------------
377 : :
378 : 0 : void SAL_CALL Player::start()
379 : : throw (uno::RuntimeException)
380 : : {
381 : : // set the pipeline state to READY and run the loop
382 : 0 : if( mbInitialized && NULL != mpPlaybin )
383 : : {
384 : 0 : gst_element_set_state( mpPlaybin, GST_STATE_PLAYING );
385 : 0 : mbPlayPending = true;
386 : : }
387 : 0 : }
388 : :
389 : : // ------------------------------------------------------------------------------
390 : :
391 : 0 : void SAL_CALL Player::stop()
392 : : throw (uno::RuntimeException)
393 : : {
394 : : // set the pipeline in PAUSED STATE
395 : 0 : if( mpPlaybin )
396 : 0 : gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
397 : :
398 : 0 : mbPlayPending = false;
399 : : DBG( "stop %p", mpPlaybin );
400 : 0 : }
401 : :
402 : : // ------------------------------------------------------------------------------
403 : :
404 : 0 : sal_Bool SAL_CALL Player::isPlaying()
405 : : throw (uno::RuntimeException)
406 : : {
407 : 0 : bool bRet = mbPlayPending;
408 : :
409 : : // return whether the pipeline is in PLAYING STATE or not
410 : 0 : if( !mbPlayPending && mbInitialized && mpPlaybin )
411 : : {
412 : 0 : bRet = GST_STATE_PLAYING == GST_STATE( mpPlaybin );
413 : : }
414 : :
415 : : DBG( "isPlaying %d", bRet );
416 : :
417 : 0 : return bRet;
418 : : }
419 : :
420 : : // ------------------------------------------------------------------------------
421 : :
422 : 0 : double SAL_CALL Player::getDuration()
423 : : throw (uno::RuntimeException)
424 : : {
425 : : // slideshow checks for non-zero duration, so cheat here
426 : 0 : double duration = 0.01;
427 : :
428 : 0 : if( mpPlaybin && mnDuration > 0 ) {
429 : 0 : duration = mnDuration / 1E9;
430 : : }
431 : :
432 : 0 : return duration;
433 : : }
434 : :
435 : : // ------------------------------------------------------------------------------
436 : :
437 : 0 : void SAL_CALL Player::setMediaTime( double fTime )
438 : : throw (uno::RuntimeException)
439 : : {
440 : 0 : if( mpPlaybin ) {
441 : 0 : gint64 gst_position = llround (fTime * 1E9);
442 : :
443 : : gst_element_seek( mpPlaybin, 1.0,
444 : : GST_FORMAT_TIME,
445 : : GST_SEEK_FLAG_FLUSH,
446 : : GST_SEEK_TYPE_SET, gst_position,
447 : 0 : GST_SEEK_TYPE_NONE, 0 );
448 : 0 : if( !isPlaying() )
449 : 0 : gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
450 : :
451 : : DBG( "seek to: %" SAL_PRIdINT64 " ns original: %lf s", gst_position, fTime );
452 : : }
453 : 0 : }
454 : :
455 : : // ------------------------------------------------------------------------------
456 : :
457 : 0 : double SAL_CALL Player::getMediaTime()
458 : : throw (uno::RuntimeException)
459 : : {
460 : 0 : double position = 0.0;
461 : :
462 : 0 : if( mpPlaybin ) {
463 : : // get current position in the stream
464 : : gint64 gst_position;
465 : 0 : if( wrap_element_query_position( mpPlaybin, GST_FORMAT_TIME, &gst_position ) )
466 : 0 : position = gst_position / 1E9;
467 : : }
468 : :
469 : 0 : return position;
470 : : }
471 : :
472 : : // ------------------------------------------------------------------------------
473 : :
474 : 0 : double SAL_CALL Player::getRate()
475 : : throw (uno::RuntimeException)
476 : : {
477 : 0 : double rate = 0.0;
478 : :
479 : : // TODO get the window rate
480 : 0 : if( mbInitialized )
481 : : {
482 : :
483 : : }
484 : :
485 : 0 : return rate;
486 : : }
487 : :
488 : : // ------------------------------------------------------------------------------
489 : :
490 : 0 : void SAL_CALL Player::setPlaybackLoop( sal_Bool bSet )
491 : : throw (uno::RuntimeException)
492 : : {
493 : : // TODO check how to do with GST
494 : 0 : mbLooping = bSet;
495 : 0 : }
496 : :
497 : : // ------------------------------------------------------------------------------
498 : :
499 : 0 : sal_Bool SAL_CALL Player::isPlaybackLoop()
500 : : throw (uno::RuntimeException)
501 : : {
502 : : // TODO check how to do with GST
503 : 0 : return mbLooping;
504 : : }
505 : :
506 : : // ------------------------------------------------------------------------------
507 : :
508 : 0 : void SAL_CALL Player::setMute( sal_Bool bSet )
509 : : throw (uno::RuntimeException)
510 : : {
511 : : DBG( "set mute: %d muted: %d unmuted volume: %lf", bSet, mbMuted, mnUnmutedVolume );
512 : :
513 : : // change the volume to 0 or the unmuted volume
514 : 0 : if( mpPlaybin && mbMuted != bSet )
515 : : {
516 : 0 : double nVolume = mnUnmutedVolume;
517 : 0 : if( bSet )
518 : : {
519 : 0 : nVolume = 0.0;
520 : : }
521 : :
522 : 0 : g_object_set( G_OBJECT( mpPlaybin ), "volume", nVolume, NULL );
523 : :
524 : 0 : mbMuted = bSet;
525 : : }
526 : 0 : }
527 : :
528 : : // ------------------------------------------------------------------------------
529 : :
530 : 0 : sal_Bool SAL_CALL Player::isMute()
531 : : throw (uno::RuntimeException)
532 : : {
533 : 0 : return mbMuted;
534 : : }
535 : :
536 : : // ------------------------------------------------------------------------------
537 : :
538 : 0 : void SAL_CALL Player::setVolumeDB( sal_Int16 nVolumeDB )
539 : : throw (uno::RuntimeException)
540 : : {
541 : 0 : mnUnmutedVolume = pow( 10.0, nVolumeDB / 20.0 );
542 : :
543 : : DBG( "set volume: %d gst volume: %lf", nVolumeDB, mnUnmutedVolume );
544 : :
545 : : // change volume
546 : 0 : if( !mbMuted && mpPlaybin )
547 : : {
548 : 0 : g_object_set( G_OBJECT( mpPlaybin ), "volume", (gdouble) mnUnmutedVolume, NULL );
549 : : }
550 : 0 : }
551 : :
552 : : // ------------------------------------------------------------------------------
553 : :
554 : 0 : sal_Int16 SAL_CALL Player::getVolumeDB()
555 : : throw (uno::RuntimeException)
556 : : {
557 : 0 : sal_Int16 nVolumeDB(0);
558 : :
559 : 0 : if( mpPlaybin ) {
560 : 0 : double nGstVolume = 0.0;
561 : :
562 : 0 : g_object_get( G_OBJECT( mpPlaybin ), "volume", &nGstVolume, NULL );
563 : :
564 : 0 : nVolumeDB = (sal_Int16) ( 20.0*log10 ( nGstVolume ) );
565 : : }
566 : :
567 : 0 : return nVolumeDB;
568 : : }
569 : :
570 : : // ------------------------------------------------------------------------------
571 : :
572 : 0 : awt::Size SAL_CALL Player::getPreferredPlayerWindowSize()
573 : : throw (uno::RuntimeException)
574 : : {
575 : 0 : awt::Size aSize( 0, 0 );
576 : :
577 : : DBG( "%p Player::getPreferredPlayerWindowSize, member %d x %d", this, mnWidth, mnHeight );
578 : :
579 : 0 : TimeValue aTimeout = { 10, 0 };
580 : : #if OSL_DEBUG_LEVEL > 2
581 : : osl::Condition::Result aResult =
582 : : #endif
583 : 0 : maSizeCondition.wait( &aTimeout );
584 : :
585 : 0 : if( mbFakeVideo ) {
586 : 0 : mbFakeVideo = sal_False;
587 : :
588 : 0 : g_object_set( G_OBJECT( mpPlaybin ), "video-sink", NULL, NULL );
589 : 0 : gst_element_set_state( mpPlaybin, GST_STATE_READY );
590 : 0 : gst_element_set_state( mpPlaybin, GST_STATE_PAUSED );
591 : : }
592 : :
593 : : DBG( "%p Player::getPreferredPlayerWindowSize after waitCondition %d, member %d x %d", this, aResult, mnWidth, mnHeight );
594 : :
595 : 0 : if( mnWidth != 0 && mnHeight != 0 ) {
596 : 0 : aSize.Width = mnWidth;
597 : 0 : aSize.Height = mnHeight;
598 : : }
599 : :
600 : 0 : return aSize;
601 : : }
602 : :
603 : : // ------------------------------------------------------------------------------
604 : :
605 : 0 : uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( const uno::Sequence< uno::Any >& rArguments )
606 : : throw (uno::RuntimeException)
607 : : {
608 : 0 : uno::Reference< ::media::XPlayerWindow > xRet;
609 : 0 : awt::Size aSize( getPreferredPlayerWindowSize() );
610 : :
611 : : DBG( "Player::createPlayerWindow %d %d length: %d", aSize.Width, aSize.Height, rArguments.getLength() );
612 : :
613 : 0 : if( aSize.Width > 0 && aSize.Height > 0 )
614 : : {
615 : 0 : ::avmedia::gstreamer::Window* pWindow = new ::avmedia::gstreamer::Window( mxMgr, *this );
616 : :
617 : 0 : xRet = pWindow;
618 : :
619 : 0 : if( rArguments.getLength() > 2 )
620 : : {
621 : 0 : sal_IntPtr pIntPtr = 0;
622 : 0 : rArguments[ 2 ] >>= pIntPtr;
623 : 0 : SystemChildWindow *pParentWindow = reinterpret_cast< SystemChildWindow* >( pIntPtr );
624 : 0 : const SystemEnvData* pEnvData = pParentWindow ? pParentWindow->GetSystemData() : NULL;
625 : : OSL_ASSERT(pEnvData);
626 : 0 : if (pEnvData)
627 : 0 : mnWindowID = pEnvData->aWindow;
628 : : }
629 : : }
630 : :
631 : 0 : return xRet;
632 : : }
633 : :
634 : : // ------------------------------------------------------------------------------
635 : :
636 : 0 : uno::Reference< media::XFrameGrabber > SAL_CALL Player::createFrameGrabber()
637 : : throw (uno::RuntimeException)
638 : : {
639 : 0 : uno::Reference< media::XFrameGrabber > xRet;
640 : :
641 : 0 : return xRet;
642 : : }
643 : :
644 : : // ------------------------------------------------------------------------------
645 : :
646 : 0 : ::rtl::OUString SAL_CALL Player::getImplementationName()
647 : : throw (uno::RuntimeException)
648 : : {
649 : 0 : return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( AVMEDIA_GST_PLAYER_IMPLEMENTATIONNAME ) );
650 : : }
651 : :
652 : : // ------------------------------------------------------------------------------
653 : :
654 : 0 : sal_Bool SAL_CALL Player::supportsService( const ::rtl::OUString& ServiceName )
655 : : throw (uno::RuntimeException)
656 : : {
657 : 0 : return ServiceName == AVMEDIA_GST_PLAYER_SERVICENAME;
658 : : }
659 : :
660 : : // ------------------------------------------------------------------------------
661 : :
662 : 0 : uno::Sequence< ::rtl::OUString > SAL_CALL Player::getSupportedServiceNames()
663 : : throw (uno::RuntimeException)
664 : : {
665 : 0 : uno::Sequence< ::rtl::OUString > aRet(1);
666 : 0 : aRet[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM ( AVMEDIA_GST_PLAYER_SERVICENAME ) );
667 : :
668 : 0 : return aRet;
669 : : }
670 : :
671 : : } // namespace gstreamer
672 : : } // namespace avmedia
673 : :
674 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|