65
67
GST_ERROR ("uri = %s", GST_STR_NULL (uri));
68
g_message ("Error: %s\n%s\n", GST_STR_NULL (err->message),
71
70
g_error_free (err);
77
destroy_pixbuf (guchar *pix, gpointer data)
79
gst_buffer_unref (GST_BUFFER (data));
83
totem_gst_playbin_get_frame (GstElement *play)
86
GstBuffer *buf = NULL;
92
g_return_val_if_fail (play != NULL, NULL);
93
g_return_val_if_fail (GST_IS_ELEMENT (play), NULL);
95
/* our desired output format (RGB24) */
96
to_caps = gst_caps_new_simple ("video/x-raw-rgb",
97
"bpp", G_TYPE_INT, 24,
98
"depth", G_TYPE_INT, 24,
99
/* Note: we don't ask for a specific width/height here, so that
100
* videoscale can adjust dimensions from a non-1/1 pixel aspect
101
* ratio to a 1/1 pixel-aspect-ratio. We also don't ask for a
102
* specific framerate, because the input framerate won't
103
* necessarily match the output framerate if there's a deinterlacer
104
* in the pipeline. */
105
"pixel-aspect-ratio", GST_TYPE_FRACTION, 1, 1,
106
"endianness", G_TYPE_INT, G_BIG_ENDIAN,
107
"red_mask", G_TYPE_INT, 0xff0000,
108
"green_mask", G_TYPE_INT, 0x00ff00,
109
"blue_mask", G_TYPE_INT, 0x0000ff,
113
g_signal_emit_by_name (play, "convert-frame", to_caps, &buf);
114
gst_caps_unref (to_caps);
117
GST_DEBUG ("Could not take screenshot: %s",
118
"failed to retrieve or convert video frame");
119
g_warning ("Could not take screenshot: %s",
120
"failed to retrieve or convert video frame");
124
if (!GST_BUFFER_CAPS (buf)) {
125
GST_DEBUG ("Could not take screenshot: %s", "no caps on output buffer");
126
g_warning ("Could not take screenshot: %s", "no caps on output buffer");
130
GST_DEBUG ("frame caps: %" GST_PTR_FORMAT, GST_BUFFER_CAPS (buf));
132
s = gst_caps_get_structure (GST_BUFFER_CAPS (buf), 0);
133
gst_structure_get_int (s, "width", &outwidth);
134
gst_structure_get_int (s, "height", &outheight);
135
g_return_val_if_fail (outwidth > 0 && outheight > 0, NULL);
137
/* create pixbuf from that - use our own destroy function */
138
pixbuf = gdk_pixbuf_new_from_data (GST_BUFFER_DATA (buf),
139
GDK_COLORSPACE_RGB, FALSE, 8, outwidth, outheight,
140
GST_ROUND_UP_4 (outwidth * 3), destroy_pixbuf, buf);
143
GST_DEBUG ("Could not take screenshot: %s", "could not create pixbuf");
144
g_warning ("Could not take screenshot: %s", "could not create pixbuf");
145
gst_buffer_unref (buf);
152
totem_gst_buffer_to_pixbuf (GstBuffer *buffer)
154
GdkPixbufLoader *loader;
155
GdkPixbuf *pixbuf = NULL;
158
loader = gdk_pixbuf_loader_new ();
160
if (gdk_pixbuf_loader_write (loader, buffer->data, buffer->size, &err) &&
161
gdk_pixbuf_loader_close (loader, &err)) {
162
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
164
g_object_ref (pixbuf);
166
GST_WARNING("could not convert tag image to pixbuf: %s", err->message);
170
g_object_unref (loader);
174
static const GValue *
175
totem_gst_tag_list_get_cover_real (GstTagList *tag_list)
177
const GValue *cover_value = NULL;
183
GstStructure *caps_struct;
186
value = gst_tag_list_get_value_index (tag_list,
192
buffer = gst_value_get_buffer (value);
194
caps_struct = gst_caps_get_structure (buffer->caps, 0);
195
gst_structure_get_enum (caps_struct,
197
GST_TYPE_TAG_IMAGE_TYPE,
199
if (type == GST_TAG_IMAGE_TYPE_UNDEFINED) {
200
if (cover_value == NULL)
202
} else if (type == GST_TAG_IMAGE_TYPE_FRONT_COVER) {
212
totem_gst_tag_list_get_cover (GstTagList *tag_list)
214
const GValue *cover_value;
216
g_return_val_if_fail (tag_list != NULL, FALSE);
218
cover_value = totem_gst_tag_list_get_cover_real (tag_list);
219
/* Fallback to preview */
221
cover_value = gst_tag_list_get_value_index (tag_list,
222
GST_TAG_PREVIEW_IMAGE,
230
buffer = gst_value_get_buffer (cover_value);
231
pixbuf = totem_gst_buffer_to_pixbuf (buffer);
239
76
* vim: sw=2 ts=8 cindent noai bs=2