Merge lp:~ballogy/gloobus-preview/gstreamer-1.0 into lp:gloobus-preview
- gstreamer-1.0
- Merge into last_working_branch
Proposed by
Balló György
Status: | Merged |
---|---|
Merged at revision: | 296 |
Proposed branch: | lp:~ballogy/gloobus-preview/gstreamer-1.0 |
Merge into: | lp:gloobus-preview |
Diff against target: |
395 lines (+82/-84) 4 files modified
configure.ac (+3/-4) src/plugin-gstreamer-audio/plugin-gstreamer-audio.cpp (+27/-13) src/plugin-gstreamer-video/plugin-gstreamer-video.cpp (+49/-64) src/plugin-gstreamer-video/plugin-gstreamer-video.h (+3/-3) |
To merge this branch: | bzr merge lp:~ballogy/gloobus-preview/gstreamer-1.0 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gloobus Developers | Pending | ||
Review via email:
|
Commit message
Description of the change
This is the port of gloobus-preview to GStreamer 1.0.
To post a comment you must log in.
- 292. By Balló György
-
Fix album cover rendering for audio files
- 293. By Balló György
-
Fix info handling
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'configure.ac' |
2 | --- configure.ac 2012-05-13 19:48:02 +0000 |
3 | +++ configure.ac 2014-12-23 10:10:06 +0000 |
4 | @@ -44,10 +44,9 @@ |
5 | PKG_CHECK_MODULES(GTKSOURCEVIEW, gtksourceview-3.0) |
6 | PKG_CHECK_MODULES(GCONF2, gconf-2.0) |
7 | PKG_CHECK_MODULES(CAIRO, cairo) |
8 | -PKG_CHECK_MODULES(GSTREAMER, gstreamer-0.10) |
9 | -PKG_CHECK_MODULES(GSTREAMER_PLUGINS, gstreamer-plugins-base-0.10) |
10 | -PKG_CHECK_MODULES(GSTREAMER_INTERFACES, gstreamer-interfaces-0.10) |
11 | -PKG_CHECK_MODULES(GSTREAMER_VIDEO, gstreamer-video-0.10) |
12 | +PKG_CHECK_MODULES(GSTREAMER, gstreamer-1.0) |
13 | +PKG_CHECK_MODULES(GSTREAMER_PLUGINS, gstreamer-plugins-base-1.0) |
14 | +PKG_CHECK_MODULES(GSTREAMER_VIDEO, gstreamer-video-1.0) |
15 | PKG_CHECK_MODULES(POPPLER, poppler-glib) |
16 | PKG_CHECK_MODULES(SPECTRE, libspectre >= 0.2.2) |
17 | PKG_CHECK_MODULES(DJVU, ddjvuapi) |
18 | |
19 | === modified file 'src/plugin-gstreamer-audio/plugin-gstreamer-audio.cpp' |
20 | --- src/plugin-gstreamer-audio/plugin-gstreamer-audio.cpp 2012-04-06 10:42:24 +0000 |
21 | +++ src/plugin-gstreamer-audio/plugin-gstreamer-audio.cpp 2014-12-23 10:10:06 +0000 |
22 | @@ -145,7 +145,7 @@ |
23 | GstFormat format = GST_FORMAT_TIME; |
24 | gint64 pos; |
25 | gboolean result; |
26 | - result = gst_element_query_position (pipeline, &format, &pos); |
27 | + result = gst_element_query_position (pipeline, format, &pos); |
28 | if (!result || format != GST_FORMAT_TIME) |
29 | return 0; |
30 | return pos/GST_SECOND; |
31 | @@ -156,7 +156,7 @@ |
32 | GstFormat format = GST_FORMAT_TIME; |
33 | gint64 len; |
34 | gboolean result; |
35 | - result = gst_element_query_duration (pipeline, &format, &len); |
36 | + result = gst_element_query_duration (pipeline, format, &len); |
37 | if( !result || format != GST_FORMAT_TIME ) |
38 | return 0; |
39 | return len/GST_SECOND; |
40 | @@ -222,7 +222,8 @@ |
41 | GdkPixbufLoader * loader = gdk_pixbuf_loader_new(); |
42 | gdk_pixbuf_loader_write(loader,(guchar*)data,size,NULL); |
43 | gdk_pixbuf_loader_close(loader,NULL); |
44 | - GdkPixbuf * pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); |
45 | + GdkPixbuf *pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); |
46 | + g_object_ref(pixbuf); |
47 | g_object_unref(loader); |
48 | return pixbuf; |
49 | } |
50 | @@ -276,11 +277,15 @@ |
51 | gchar *title, *artist, *album, *info; |
52 | |
53 | if( !gst_tag_list_get_string_index (tags, GST_TAG_TITLE, 0, &title) ) |
54 | - title = g_strdup(" "); |
55 | + title = g_strdup(""); |
56 | if( !gst_tag_list_get_string_index (tags, GST_TAG_ARTIST, 0, &artist) ) |
57 | - artist = g_strdup(" "); |
58 | + artist = g_strdup(""); |
59 | if( !gst_tag_list_get_string_index (tags, GST_TAG_ALBUM, 0, &album) ) |
60 | - album = g_strdup(" "); |
61 | + album = g_strdup(""); |
62 | + |
63 | + this->title = title; |
64 | + this->artist = artist; |
65 | + this->album = album; |
66 | |
67 | info = g_strdup_printf("%s\n\n%s\n\n%s", title, artist, album); |
68 | gtk_label_set_text(GTK_LABEL(info_label), info); |
69 | @@ -290,20 +295,28 @@ |
70 | g_free(album); |
71 | g_free(info); |
72 | |
73 | - if( !cover_found ) { |
74 | - GstBuffer *buff; |
75 | - if( gst_tag_list_get_buffer_index (tags, GST_TAG_IMAGE, 0, &buff) ) { |
76 | + GstSample *sample; |
77 | + GstBuffer *buff; |
78 | + GstMapInfo cover_info; |
79 | + |
80 | + if(gst_tag_list_get_sample_index (tags, GST_TAG_IMAGE, 0, &sample)) { |
81 | + buff = gst_sample_get_buffer (sample); |
82 | + if(gst_buffer_map (buff, &cover_info, GST_MAP_READ)) { |
83 | g_debug("Cover?"); |
84 | GdkPixbuf *pixbuf = NULL; |
85 | - |
86 | - guchar * data = GST_BUFFER_DATA(buff); |
87 | - gsize size = GST_BUFFER_SIZE(buff); |
88 | + guchar * data = NULL; |
89 | + gsize size; |
90 | GError *error = NULL; |
91 | |
92 | + data = cover_info.data; |
93 | + size = cover_info.size; |
94 | + gst_buffer_unmap (buff, &cover_info); |
95 | + |
96 | GdkPixbufLoader *loader = gdk_pixbuf_loader_new(); |
97 | if(gdk_pixbuf_loader_write(loader, data, size, &error)) { |
98 | if(gdk_pixbuf_loader_close(loader, NULL)) { |
99 | pixbuf = gdk_pixbuf_loader_get_pixbuf(loader); |
100 | + g_object_ref(pixbuf); |
101 | } else { |
102 | g_warning("Error: %s", error->message); |
103 | g_error_free(error); |
104 | @@ -323,9 +336,10 @@ |
105 | |
106 | gtk_image_set_from_pixbuf(GTK_IMAGE(cover), pix_cover); |
107 | gtk_image_set_from_pixbuf(GTK_IMAGE(reflection), pix_reflection); |
108 | + g_object_unref(pixbuf); |
109 | } |
110 | - gst_buffer_unref(buff); |
111 | } |
112 | + gst_sample_unref(sample); |
113 | } |
114 | } |
115 | |
116 | |
117 | === modified file 'src/plugin-gstreamer-video/plugin-gstreamer-video.cpp' |
118 | --- src/plugin-gstreamer-video/plugin-gstreamer-video.cpp 2011-10-29 10:09:05 +0000 |
119 | +++ src/plugin-gstreamer-video/plugin-gstreamer-video.cpp 2014-12-23 10:10:06 +0000 |
120 | @@ -16,7 +16,7 @@ |
121 | :bus(0) |
122 | ,playbin(0) |
123 | ,audio_capsfilter(0) |
124 | - ,xoverlay(0) |
125 | + ,video_overlay(0) |
126 | ,bus_msg_id(0) |
127 | ,bus_msg_id_sync(0) |
128 | ,interface_update_id(0) |
129 | @@ -54,7 +54,7 @@ |
130 | gst_init (NULL, NULL); |
131 | //gst_pb_utils_init (); |
132 | |
133 | - playbin = gst_element_factory_make ("playbin2", "playbin"); |
134 | + playbin = gst_element_factory_make ("playbin", "playbin"); |
135 | if( !playbin ) { |
136 | m_error = g_error_new(g_quark_from_string ("iVideo"), 1601, |
137 | _("Error initializing video interface")); |
138 | @@ -65,32 +65,18 @@ |
139 | gst_bus_add_signal_watch (bus); |
140 | bus_msg_id = g_signal_connect( bus, "message", G_CALLBACK (bus_message_cb), this); |
141 | |
142 | - audio_sink = gst_element_factory_make ("gconfaudiosink", "audio-sink"); |
143 | + audio_sink = gst_element_factory_make ("autoaudiosink", "audio-sink"); |
144 | if( !audio_sink ) { |
145 | - g_warning ("Could not create element 'gconfaudiosink'"); |
146 | - audio_sink = gst_element_factory_make ("autoaudiosink", "audio-sink"); |
147 | - if( !audio_sink ) { |
148 | - m_error = g_error_new(g_quark_from_string ("iVideo"), 1602, |
149 | - _("Failed to open audio output")); |
150 | - return false; |
151 | - } |
152 | - } else { |
153 | - /* set the profile property on the gconfaudiosink to "music and movies" */ |
154 | - if (g_object_class_find_property (G_OBJECT_GET_CLASS (audio_sink), "profile")) |
155 | - g_object_set (G_OBJECT (audio_sink), "profile", 1, NULL); |
156 | - } |
157 | - |
158 | - |
159 | - video_sink = gst_element_factory_make ("gconfvideosink", "video-sink"); |
160 | + m_error = g_error_new(g_quark_from_string ("iVideo"), 1602, |
161 | + _("Failed to open audio output")); |
162 | + return false; |
163 | + } |
164 | + |
165 | + video_sink = gst_element_factory_make ("autovideosink", "video-sink"); |
166 | if( !video_sink ) { |
167 | - g_warning ("Could not create element 'gconfvideosink'"); |
168 | - /* Try to fallback on ximagesink */ |
169 | - video_sink = gst_element_factory_make ("ximagesink", "video-sink"); |
170 | - if( !video_sink ) { |
171 | - m_error = g_error_new(g_quark_from_string ("iVideo"), 1602, |
172 | - _("Failed to open video output")); |
173 | - return false; |
174 | - } |
175 | + m_error = g_error_new(g_quark_from_string ("iVideo"), 1602, |
176 | + _("Failed to open video output")); |
177 | + return false; |
178 | } |
179 | |
180 | GstStateChangeReturn ret; |
181 | @@ -141,21 +127,21 @@ |
182 | G_CALLBACK (video_tags_changed_cb), this); |
183 | |
184 | GstElement *element = gst_bin_get_by_interface (GST_BIN (video_sink), |
185 | - GST_TYPE_X_OVERLAY); |
186 | - if (GST_IS_X_OVERLAY (element)) { |
187 | - g_debug("Found xoverlay: %s", GST_OBJECT_NAME (element)); |
188 | - xoverlay = GST_X_OVERLAY (element); |
189 | + GST_TYPE_VIDEO_OVERLAY); |
190 | + if (GST_IS_VIDEO_OVERLAY (element)) { |
191 | + g_debug("Found video overlay: %s", GST_OBJECT_NAME (element)); |
192 | + video_overlay = GST_VIDEO_OVERLAY (element); |
193 | } else { |
194 | - g_debug("No xoverlay found"); |
195 | + g_debug("No video overlay found"); |
196 | if (element) |
197 | gst_object_unref (element); |
198 | - xoverlay = NULL; |
199 | + video_overlay = NULL; |
200 | } |
201 | |
202 | //g_signal_connect (video_sink, "element-added", |
203 | // G_CALLBACK (got_new_video_sink_bin_element), this); |
204 | |
205 | - gst_bus_set_sync_handler (bus, gst_bus_sync_signal_handler, this); |
206 | + gst_bus_set_sync_handler (bus, gst_bus_sync_signal_handler, this, NULL); |
207 | bus_msg_id_sync = g_signal_connect( bus, "sync-message::element", |
208 | G_CALLBACK (bus_message_sync_cb), this); |
209 | |
210 | @@ -289,7 +275,7 @@ |
211 | GstFormat format = GST_FORMAT_TIME; |
212 | gint64 pos; |
213 | gboolean result; |
214 | - result = gst_element_query_position (playbin, &format, &pos); |
215 | + result = gst_element_query_position (playbin, format, &pos); |
216 | if (!result || format != GST_FORMAT_TIME) |
217 | return 0; |
218 | return pos/GST_SECOND; |
219 | @@ -300,7 +286,7 @@ |
220 | GstFormat format = GST_FORMAT_TIME; |
221 | gint64 len; |
222 | gboolean result; |
223 | - result = gst_element_query_duration (playbin, &format, &len); |
224 | + result = gst_element_query_duration (playbin, format, &len); |
225 | if( !result || format != GST_FORMAT_TIME ) |
226 | return 0; |
227 | return len/GST_SECOND; |
228 | @@ -381,27 +367,24 @@ |
229 | |
230 | g_assert (msg->type == GST_MESSAGE_ELEMENT); |
231 | |
232 | - if (msg->structure == NULL) |
233 | - return; |
234 | - |
235 | - if (gst_structure_has_name (msg->structure, "prepare-xwindow-id")) { |
236 | + if (gst_is_video_overlay_prepare_window_handle_message (msg)) { |
237 | gulong xid; |
238 | |
239 | g_debug("Handling sync prepare-xwindow-id message"); |
240 | |
241 | g_mutex_lock (video->lock); |
242 | video->update_interface(); |
243 | - if (video->xoverlay == NULL) { |
244 | + if (video->video_overlay == NULL) { |
245 | GstObject *sender = GST_MESSAGE_SRC (msg); |
246 | - if (sender && GST_IS_X_OVERLAY (sender)) |
247 | - video->xoverlay = GST_X_OVERLAY (gst_object_ref (sender)); |
248 | + if (sender && GST_IS_VIDEO_OVERLAY (sender)) |
249 | + video->video_overlay = GST_VIDEO_OVERLAY (gst_object_ref (sender)); |
250 | } |
251 | g_mutex_unlock (video->lock); |
252 | |
253 | - g_return_if_fail (video->xoverlay != NULL); |
254 | + g_return_if_fail (video->video_overlay != NULL); |
255 | |
256 | xid = GDK_WINDOW_XID (gtk_widget_get_window(video->video_box)); |
257 | - gst_x_overlay_set_xwindow_id (video->xoverlay, xid); |
258 | + gst_video_overlay_set_window_handle (video->video_overlay, xid); |
259 | } |
260 | //g_debug("BUS_MESSAGE_SYNC_CB END"); |
261 | } |
262 | @@ -409,13 +392,13 @@ |
263 | /* Must be called with lock held */ |
264 | void iVideo::update_interface( void ) |
265 | { |
266 | - GstXOverlay *old_xoverlay = xoverlay; |
267 | + GstVideoOverlay *old_video_overlay = video_overlay; |
268 | GstElement *video_sink, *element, *play; |
269 | |
270 | if (g_thread_self() != gui_thread) { |
271 | - if (xoverlay) |
272 | - gst_object_unref (xoverlay); |
273 | - xoverlay = NULL; |
274 | + if (video_overlay) |
275 | + gst_object_unref (video_overlay); |
276 | + video_overlay = NULL; |
277 | if (interface_update_id) |
278 | g_source_remove (interface_update_id); |
279 | interface_update_id = g_idle_add( &update_interfaces_delayed, this); |
280 | @@ -433,24 +416,24 @@ |
281 | |
282 | /* We try to get an element supporting XOverlay interface */ |
283 | if (GST_IS_BIN (video_sink)) { |
284 | - g_debug ("Retrieving xoverlay from bin ..."); |
285 | - element = gst_bin_get_by_interface (GST_BIN (video_sink), GST_TYPE_X_OVERLAY); |
286 | + g_debug ("Retrieving video overlay from bin ..."); |
287 | + element = gst_bin_get_by_interface (GST_BIN (video_sink), GST_TYPE_VIDEO_OVERLAY); |
288 | } else { |
289 | element = (GstElement*)gst_object_ref(video_sink); |
290 | } |
291 | |
292 | - if (GST_IS_X_OVERLAY (element)) { |
293 | - g_debug ("Found xoverlay: %s", GST_OBJECT_NAME (element)); |
294 | - xoverlay = GST_X_OVERLAY (element); |
295 | + if (GST_IS_VIDEO_OVERLAY (element)) { |
296 | + g_debug ("Found video overlay: %s", GST_OBJECT_NAME (element)); |
297 | + video_overlay = GST_VIDEO_OVERLAY (element); |
298 | } else { |
299 | - GST_DEBUG ("No xoverlay found"); |
300 | + GST_DEBUG ("No video overlay found"); |
301 | if (element) |
302 | gst_object_unref (element); |
303 | - xoverlay = NULL; |
304 | + video_overlay = NULL; |
305 | } |
306 | |
307 | - if (old_xoverlay) |
308 | - gst_object_unref (GST_OBJECT (old_xoverlay)); |
309 | + if (old_video_overlay) |
310 | + gst_object_unref (GST_OBJECT (old_video_overlay)); |
311 | |
312 | gst_object_unref (video_sink); |
313 | } |
314 | @@ -477,8 +460,8 @@ |
315 | { |
316 | //g_debug("CONFIGURE_CB START"); |
317 | iVideo *video = (iVideo*)data; |
318 | - if (video->xoverlay != NULL && GST_IS_X_OVERLAY (video->xoverlay)) { |
319 | - gst_x_overlay_expose (video->xoverlay); |
320 | + if (video->video_overlay != NULL && GST_IS_VIDEO_OVERLAY (video->video_overlay)) { |
321 | + gst_video_overlay_expose (video->video_overlay); |
322 | } |
323 | //g_debug("CONFIGURE_CB end"); |
324 | return false; |
325 | @@ -529,13 +512,15 @@ |
326 | void iVideo::handle_application_message( GstMessage *msg ) |
327 | { |
328 | const gchar *msg_name; |
329 | + const GstStructure *structure; |
330 | //GdkWindow *window; |
331 | //GtkAllocation allocation; |
332 | |
333 | - msg_name = gst_structure_get_name (msg->structure); |
334 | + structure = gst_message_get_structure (msg); |
335 | + msg_name = gst_structure_get_name (structure); |
336 | g_return_if_fail (msg_name != NULL); |
337 | |
338 | - g_debug("Handling application message: %" GST_PTR_FORMAT, msg->structure); |
339 | + g_debug("Handling application message: %" GST_PTR_FORMAT, structure); |
340 | |
341 | if( !g_strcmp0( msg_name, "stream-changed" ) ) { |
342 | update_stream_info(); |
343 | @@ -568,7 +553,7 @@ |
344 | if (videopad) { |
345 | GstCaps *caps; |
346 | |
347 | - if( (caps = gst_pad_get_negotiated_caps( videopad ) ) ) { |
348 | + if( (caps = gst_pad_get_current_caps( videopad ) ) ) { |
349 | caps_set_cb( G_OBJECT( videopad ), NULL, this ); |
350 | gst_caps_unref (caps); |
351 | } |
352 | @@ -586,7 +571,7 @@ |
353 | GstStructure *s; |
354 | GstCaps *caps; |
355 | |
356 | - if( !(caps = gst_pad_get_negotiated_caps(pad) ) ) |
357 | + if( !(caps = gst_pad_get_current_caps(pad) ) ) |
358 | return; |
359 | |
360 | /* Get video decoder caps */ |
361 | @@ -769,7 +754,7 @@ |
362 | |
363 | GstTagList *tags; |
364 | |
365 | - g_debug("Tags: %" GST_PTR_FORMAT, pack->tags); |
366 | + //g_debug("Tags: %" GST_PTR_FORMAT, pack->tags); |
367 | tags = gst_tag_list_merge (pack->video->tags, pack->tags, GST_TAG_MERGE_REPLACE); |
368 | if( pack->video->tags ) |
369 | gst_tag_list_free ( pack->video->tags ); |
370 | |
371 | === modified file 'src/plugin-gstreamer-video/plugin-gstreamer-video.h' |
372 | --- src/plugin-gstreamer-video/plugin-gstreamer-video.h 2011-10-31 16:27:21 +0000 |
373 | +++ src/plugin-gstreamer-video/plugin-gstreamer-video.h 2014-12-23 10:10:06 +0000 |
374 | @@ -4,10 +4,10 @@ |
375 | #ifndef PLUGIN_LOADER |
376 | |
377 | #include <gst/gst.h> |
378 | -#include <gst/interfaces/xoverlay.h> |
379 | +#include <gst/video/videooverlay.h> |
380 | #include <gst/video/gstvideosink.h> |
381 | #include <gst/video/video.h> |
382 | -#include <gst/audio/gstbaseaudiosink.h> |
383 | +#include <gst/audio/gstaudiobasesink.h> |
384 | #include <gst/tag/tag.h> |
385 | #include <string.h> |
386 | |
387 | @@ -21,7 +21,7 @@ |
388 | GstBus * bus; |
389 | GstElement * playbin; |
390 | GstElement * audio_capsfilter; |
391 | - GstXOverlay * xoverlay; |
392 | + GstVideoOverlay * video_overlay; |
393 | |
394 | gulong bus_msg_id; |
395 | gulong bus_msg_id_sync; |