2 * Copyright (C) 2012 Igalia, S.L.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
22 #include "GStreamerVersioning.h"
26 void webkitGstObjectRefSink(GstObject* gstObject)
28 #ifdef GST_API_VERSION_1
29 gst_object_ref_sink(gstObject);
31 gst_object_ref(gstObject);
32 gst_object_sink(gstObject);
36 GstCaps* webkitGstGetPadCaps(GstPad* pad)
42 #ifdef GST_API_VERSION_1
43 caps = gst_pad_get_current_caps(pad);
45 caps = gst_pad_query_caps(pad, 0);
47 caps = GST_PAD_CAPS(pad);
52 bool getVideoSizeAndFormatFromCaps(GstCaps* caps, WebCore::IntSize& size, GstVideoFormat& format, int& pixelAspectRatioNumerator, int& pixelAspectRatioDenominator, int& stride)
54 #ifdef GST_API_VERSION_1
56 if (!gst_video_info_from_caps(&info, caps))
59 format = GST_VIDEO_INFO_FORMAT(&info);
60 size.setWidth(GST_VIDEO_INFO_WIDTH(&info));
61 size.setHeight(GST_VIDEO_INFO_HEIGHT(&info));
62 pixelAspectRatioNumerator = GST_VIDEO_INFO_PAR_N(&info);
63 pixelAspectRatioDenominator = GST_VIDEO_INFO_PAR_D(&info);
64 stride = GST_VIDEO_INFO_PLANE_STRIDE(&info, 0);
67 if (!GST_IS_CAPS(caps) || !gst_caps_is_fixed(caps)
68 || !gst_video_format_parse_caps(caps, &format, &width, &height)
69 || !gst_video_parse_caps_pixel_aspect_ratio(caps, &pixelAspectRatioNumerator,
70 &pixelAspectRatioDenominator))
73 size.setHeight(height);
74 stride = size.width() * 4;
80 GstBuffer* createGstBuffer(GstBuffer* buffer)
82 #ifndef GST_API_VERSION_1
83 GstBuffer* newBuffer = gst_buffer_try_new_and_alloc(GST_BUFFER_SIZE(buffer));
85 gsize bufferSize = gst_buffer_get_size(buffer);
86 GstBuffer* newBuffer = gst_buffer_new_and_alloc(bufferSize);
92 #ifndef GST_API_VERSION_1
93 gst_buffer_copy_metadata(newBuffer, buffer, static_cast<GstBufferCopyFlags>(GST_BUFFER_COPY_ALL));
95 gst_buffer_copy_into(newBuffer, buffer, static_cast<GstBufferCopyFlags>(GST_BUFFER_COPY_METADATA), 0, bufferSize);
100 void setGstElementClassMetadata(GstElementClass* elementClass, const char* name, const char* longName, const char* description, const char* author)
102 #ifdef GST_API_VERSION_1
103 gst_element_class_set_metadata(elementClass, name, longName, description, author);
105 gst_element_class_set_details_simple(elementClass, name, longName, description, author);