1 |
From d6297345b26d09d9f6caa25109a165c739e1f92b Mon Sep 17 00:00:00 2001 |
2 |
From: Michael Meeks <michael.meeks@suse.com> |
3 |
Date: Tue, 18 Sep 2012 17:48:10 +0100 |
4 |
Subject: [PATCH 6/7] gstreamer: various fixes for 1.0 and cleanups |
5 |
|
6 |
always re-create the playbin after the fakeVideo pre-roll to avoid 1.0 issues. |
7 |
handle the GstVideoOverlay object being created before we get our XID. |
8 |
set force-aspect-ratio to allow user scaling un-conditionally |
9 |
|
10 |
Conflicts: |
11 |
avmedia/source/gstreamer/gstplayer.cxx |
12 |
|
13 |
Change-Id: I8892b8f7a125c0daa7101e28f274bff3de57ee08 |
14 |
--- |
15 |
avmedia/source/gstreamer/gstplayer.cxx | 46 ++++++++++++++++++++-------------- |
16 |
1 file changed, 27 insertions(+), 19 deletions(-) |
17 |
|
18 |
diff --git a/avmedia/source/gstreamer/gstplayer.cxx b/avmedia/source/gstreamer/gstplayer.cxx |
19 |
index 3654410..4bcca8e 100644 |
20 |
--- a/avmedia/source/gstreamer/gstplayer.cxx |
21 |
+++ b/avmedia/source/gstreamer/gstplayer.cxx |
22 |
@@ -51,11 +51,11 @@ |
23 |
#endif |
24 |
|
25 |
#if !defined DBG |
26 |
-#if OSL_DEBUG_LEVEL > 2 |
27 |
+# if OSL_DEBUG_LEVEL > 2 |
28 |
#define DBG(...) do { fprintf (stderr, "%s", AVVERSION); fprintf (stderr, __VA_ARGS__); fprintf (stderr, "\n"); } while (0); |
29 |
-#else |
30 |
+# else |
31 |
#define DBG(...) |
32 |
-#endif |
33 |
+# endif |
34 |
#endif |
35 |
|
36 |
using namespace ::com::sun::star; |
37 |
@@ -207,17 +207,20 @@ GstBusSyncReply Player::processSyncMessage( GstMessage *message ) |
38 |
|
39 |
#ifdef AVMEDIA_GST_0_10 |
40 |
if (message->structure && |
41 |
- !strcmp( gst_structure_get_name( message->structure ), "prepare-xwindow-id" ) && mnWindowID != 0 ) |
42 |
+ !strcmp( gst_structure_get_name( message->structure ), "prepare-xwindow-id" ) ) |
43 |
#else |
44 |
- if (gst_message_has_name (message, "prepare-window-handle") && mnWindowID != 0 ) |
45 |
+ if (gst_is_video_overlay_prepare_window_handle_message (message) ) |
46 |
#endif |
47 |
{ |
48 |
- DBG( "%p processSyncMessage has handle: %s", this, GST_MESSAGE_TYPE_NAME( message ) ); |
49 |
+ DBG( "%p processSyncMessage prepare window id: %s %d", this, |
50 |
+ GST_MESSAGE_TYPE_NAME( message ), (int)mnWindowId ); |
51 |
if( mpXOverlay ) |
52 |
g_object_unref( G_OBJECT ( mpXOverlay ) ); |
53 |
+ g_object_set( GST_MESSAGE_SRC( message ), "force-aspect-ratio", FALSE, NULL ); |
54 |
mpXOverlay = GST_VIDEO_OVERLAY( GST_MESSAGE_SRC( message ) ); |
55 |
g_object_ref( G_OBJECT ( mpXOverlay ) ); |
56 |
- gst_video_overlay_set_window_handle( mpXOverlay, mnWindowID ); |
57 |
+ if ( mnWindowID != 0 ) |
58 |
+ gst_video_overlay_set_window_handle( mpXOverlay, mnWindowID ); |
59 |
return GST_BUS_DROP; |
60 |
} |
61 |
|
62 |
@@ -301,7 +304,7 @@ GstBusSyncReply Player::processSyncMessage( GstMessage *message ) |
63 |
mnWidth = w; |
64 |
mnHeight = h; |
65 |
|
66 |
- fprintf (stderr, "queried size: %d x %d", mnWidth, mnHeight ); |
67 |
+ DBG( "queried size: %d x %d", mnWidth, mnHeight ); |
68 |
|
69 |
maSizeCondition.set(); |
70 |
} |
71 |
@@ -310,7 +313,7 @@ GstBusSyncReply Player::processSyncMessage( GstMessage *message ) |
72 |
} |
73 |
#endif |
74 |
} else if( GST_MESSAGE_TYPE( message ) == GST_MESSAGE_ERROR ) { |
75 |
- fprintf (stderr, "Error !\n"); |
76 |
+ DBG( "Error !\n" ); |
77 |
if( mnWidth == 0 ) { |
78 |
// an error occurred, set condition so that OOo thread doesn't wait for us |
79 |
maSizeCondition.set(); |
80 |
@@ -331,9 +334,9 @@ void Player::preparePlaybin( const ::rtl::OUString& rURL, bool bFakeVideo ) |
81 |
} |
82 |
|
83 |
mpPlaybin = gst_element_factory_make( "playbin", NULL ); |
84 |
- |
85 |
- if( bFakeVideo ) |
86 |
- g_object_set( G_OBJECT( mpPlaybin ), "video-sink", gst_element_factory_make( "fakesink", NULL ), NULL ); |
87 |
+ if( bFakeVideo ) // used for getting prefered size etc. |
88 |
+ g_object_set( G_OBJECT( mpPlaybin ), "video-sink", |
89 |
+ gst_element_factory_make( "fakesink", NULL ), NULL ); |
90 |
|
91 |
mbFakeVideo = bFakeVideo; |
92 |
|
93 |
@@ -343,7 +346,11 @@ void Player::preparePlaybin( const ::rtl::OUString& rURL, bool bFakeVideo ) |
94 |
pBus = gst_element_get_bus( mpPlaybin ); |
95 |
gst_bus_add_watch( pBus, pipeline_bus_callback, this ); |
96 |
DBG( "%p set sync handler", this ); |
97 |
+#ifdef AVMEDIA_GST_0_10 |
98 |
gst_bus_set_sync_handler( pBus, pipeline_bus_sync_handler, this ); |
99 |
+#else |
100 |
+ gst_bus_set_sync_handler( pBus, pipeline_bus_sync_handler, this, NULL ); |
101 |
+#endif |
102 |
g_object_unref( pBus ); |
103 |
} |
104 |
|
105 |
@@ -582,13 +589,8 @@ awt::Size SAL_CALL Player::getPreferredPlayerWindowSize() |
106 |
#endif |
107 |
maSizeCondition.wait( &aTimeout ); |
108 |
|
109 |
- if( mbFakeVideo ) { |
110 |
- mbFakeVideo = sal_False; |
111 |
- |
112 |
- g_object_set( G_OBJECT( mpPlaybin ), "video-sink", NULL, NULL ); |
113 |
- gst_element_set_state( mpPlaybin, GST_STATE_READY ); |
114 |
- gst_element_set_state( mpPlaybin, GST_STATE_PAUSED ); |
115 |
- } |
116 |
+ if( mbFakeVideo ) // ready ourselves for the real thing |
117 |
+ preparePlaybin( maURL, false ); |
118 |
|
119 |
DBG( "%p Player::getPreferredPlayerWindowSize after waitCondition %d, member %d x %d", this, aResult, mnWidth, mnHeight ); |
120 |
|
121 |
@@ -624,7 +626,13 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( co |
122 |
const SystemEnvData* pEnvData = pParentWindow ? pParentWindow->GetSystemData() : NULL; |
123 |
OSL_ASSERT(pEnvData); |
124 |
if (pEnvData) |
125 |
+ { |
126 |
mnWindowID = pEnvData->aWindow; |
127 |
+ DBG( "set window id to %d XOverlay %p\n", (int)mnWindowID, mpXOverlay); |
128 |
+ gst_element_set_state( mpPlaybin, GST_STATE_PAUSED ); |
129 |
+ if ( mpXOverlay != NULL ) |
130 |
+ gst_video_overlay_set_window_handle( mpXOverlay, mnWindowID ); |
131 |
+ } |
132 |
} |
133 |
} |
134 |
|
135 |
-- |
136 |
1.7.11.4 |
137 |
|