Changeset 120790 in webkit
- Timestamp:
- Jun 19, 2012 7:25:14 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r120713 r120790 1 2012-06-18 Philippe Normand <pnormand@igalia.com> 2 3 [GStreamer] 0.11 video-sink 4 https://bugs.webkit.org/show_bug.cgi?id=77087 5 6 Reviewed by Martin Robinson. 7 8 * configure.ac: Fix required gstreamer 0.11 version 9 1 10 2012-06-19 Jocelyn Turcotte <jocelyn.turcotte@nokia.com> 2 11 -
trunk/Source/WebCore/ChangeLog
r120789 r120790 1 2012-06-18 Philippe Normand <pnormand@igalia.com> 2 3 [GStreamer] 0.11 video-sink 4 https://bugs.webkit.org/show_bug.cgi?id=77087 5 6 Reviewed by Martin Robinson. 7 8 Port the video sink to GStreamer 0.11 APIs. There is no change in 9 functionality compared to 0.10, for now. 10 11 * platform/graphics/gstreamer/GStreamerVersioning.cpp: 12 (webkitGetVideoSizeAndFormatFromCaps): 13 (webkitGstCreateBuffer): 14 * platform/graphics/gstreamer/GStreamerVersioning.h: 15 (WebCore): 16 * platform/graphics/gstreamer/ImageGStreamer.h: 17 (WebCore::ImageGStreamer::createImage): 18 (WebCore::ImageGStreamer::setCropRect): 19 (WebCore::ImageGStreamer::rect): 20 (ImageGStreamer): 21 * platform/graphics/gstreamer/ImageGStreamerCairo.cpp: 22 (ImageGStreamer::ImageGStreamer): 23 * platform/graphics/gstreamer/ImageGStreamerQt.cpp: 24 (ImageGStreamer::ImageGStreamer): 25 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: 26 (WebCore::MediaPlayerPrivateGStreamer::~MediaPlayerPrivateGStreamer): 27 (WebCore::MediaPlayerPrivateGStreamer::naturalSize): 28 * platform/graphics/gstreamer/VideoSinkGStreamer.cpp: 29 (_WebKitVideoSinkPrivate): 30 (webkitVideoSinkRender): 31 (webkitVideoSinkProposeAllocation): 32 (webkit_video_sink_class_init): 33 * platform/graphics/gstreamer/VideoSinkGStreamer.h: 34 * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp: 35 1 36 2012-06-19 Tony Payne <tpayne@chromium.org> 2 37 -
trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.cpp
r120563 r120790 22 22 #include "GStreamerVersioning.h" 23 23 24 #include <gst/gst.h>24 #include "IntSize.h" 25 25 26 26 void webkitGstObjectRefSink(GstObject* gstObject) … … 49 49 return caps; 50 50 } 51 52 bool getVideoSizeAndFormatFromCaps(GstCaps* caps, WebCore::IntSize& size, GstVideoFormat& format, int& pixelAspectRatioNumerator, int& pixelAspectRatioDenominator, int& stride) 53 { 54 #ifdef GST_API_VERSION_1 55 GstVideoInfo info; 56 if (!gst_video_info_from_caps(&info, caps)) 57 return false; 58 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); 65 #else 66 gint width, height; 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)) 71 return false; 72 size.setWidth(width); 73 size.setHeight(height); 74 stride = size.width() * 4; 75 #endif 76 77 return true; 78 } 79 80 GstBuffer* createGstBuffer(GstBuffer* buffer) 81 { 82 #ifndef GST_API_VERSION_1 83 GstBuffer* newBuffer = gst_buffer_try_new_and_alloc(GST_BUFFER_SIZE(buffer)); 84 #else 85 gsize bufferSize = gst_buffer_get_size(buffer); 86 GstBuffer* newBuffer = gst_buffer_new_and_alloc(bufferSize); 87 #endif 88 89 if (!newBuffer) 90 return 0; 91 92 #ifndef GST_API_VERSION_1 93 gst_buffer_copy_metadata(newBuffer, buffer, static_cast<GstBufferCopyFlags>(GST_BUFFER_COPY_ALL)); 94 #else 95 gst_buffer_copy_into(newBuffer, buffer, static_cast<GstBufferCopyFlags>(GST_BUFFER_COPY_METADATA), 0, bufferSize); 96 #endif 97 return newBuffer; 98 } 99 100 void setGstElementClassMetadata(GstElementClass* elementClass, const char* name, const char* longName, const char* description, const char* author) 101 { 102 #ifdef GST_API_VERSION_1 103 gst_element_class_set_metadata(elementClass, name, longName, description, author); 104 #else 105 gst_element_class_set_details_simple(elementClass, name, longName, description, author); 106 #endif 107 } -
trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerVersioning.h
r120563 r120790 21 21 #define GStreamerVersioning_h 22 22 23 typedef struct _GstCaps GstCaps; 24 typedef struct _GstObject GstObject; 25 typedef struct _GstPad GstPad; 23 #include <gst/gst.h> 24 #include <gst/video/video.h> 25 26 namespace WebCore { 27 class IntSize; 28 }; 26 29 27 30 void webkitGstObjectRefSink(GstObject*); 28 31 GstCaps* webkitGstGetPadCaps(GstPad*); 29 32 bool getVideoSizeAndFormatFromCaps(GstCaps*, WebCore::IntSize&, GstVideoFormat&, int& pixelAspectRatioNumerator, int& pixelAspectRatioDenominator, int& stride); 33 GstBuffer* createGstBuffer(GstBuffer*); 34 void setGstElementClassMetadata(GstElementClass*, const char* name, const char* longName, const char* description, const char* author); 30 35 #endif // GStreamerVersioning_h -
trunk/Source/WebCore/platform/graphics/gstreamer/ImageGStreamer.h
r118610 r120790 1 1 /* 2 * Copyright (C) 2010 Igalia S.L2 * Copyright (C) 2010, 2011, 2012 Igalia S.L 3 3 * 4 4 * This library is free software; you can redistribute it and/or … … 24 24 25 25 #include "BitmapImage.h" 26 #include <gst/gst.h>27 #include <gst/video/video.h>26 #include "FloatRect.h" 27 #include "GStreamerVersioning.h" 28 28 #include <wtf/PassRefPtr.h> 29 30 #if USE(CAIRO) 31 #include <cairo.h> 32 #endif 29 #include <wtf/RefCounted.h> 30 #include <wtf/RefPtr.h> 33 31 34 32 namespace WebCore { … … 37 35 class ImageGStreamer : public RefCounted<ImageGStreamer> { 38 36 public: 39 static PassRefPtr<ImageGStreamer> createImage(GstBuffer*); 37 static PassRefPtr<ImageGStreamer> createImage(GstBuffer* buffer, GstCaps* caps) 38 { 39 return adoptRef(new ImageGStreamer(buffer, caps)); 40 } 40 41 ~ImageGStreamer(); 41 42 … … 46 47 } 47 48 49 void setCropRect(FloatRect rect) { m_cropRect = rect; } 50 FloatRect rect() 51 { 52 if (!m_cropRect.isEmpty()) 53 return FloatRect(m_cropRect); 54 55 // Default rectangle used by GraphicsContext::drawImage(). 56 return FloatRect(0, 0, -1, -1); 57 } 58 48 59 private: 60 ImageGStreamer(GstBuffer*, GstCaps*); 49 61 RefPtr<BitmapImage> m_image; 50 51 #if USE(CAIRO) 52 ImageGStreamer(GstBuffer*&, IntSize, cairo_format_t&); 53 #endif 54 55 #if PLATFORM(QT) 56 ImageGStreamer(GstBuffer*&, IntSize, QImage::Format); 57 #endif 58 62 FloatRect m_cropRect; 59 63 }; 60 64 } -
trunk/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerCairo.cpp
r111354 r120790 23 23 #if ENABLE(VIDEO) && USE(GSTREAMER) 24 24 25 #include <cairo.h> 26 #include <gst/gst.h> 27 #include <gst/video/video.h> 25 28 #include <wtf/gobject/GOwnPtr.h> 29 30 #ifdef GST_API_VERSION_1 31 #include <gst/video/gstvideometa.h> 32 #endif 33 26 34 27 35 using namespace std; 28 36 using namespace WebCore; 29 37 30 PassRefPtr<ImageGStreamer> ImageGStreamer::createImage(GstBuffer* buffer)38 ImageGStreamer::ImageGStreamer(GstBuffer* buffer, GstCaps* caps) 31 39 { 32 int width = 0, height = 0;33 GstCaps* caps = gst_buffer_get_caps(buffer);34 40 GstVideoFormat format; 35 if (!gst_video_format_parse_caps(caps, &format, &width, &height)) { 36 gst_caps_unref(caps); 37 return 0; 38 } 41 IntSize size; 42 int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride; 43 getVideoSizeAndFormatFromCaps(caps, size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride); 39 44 40 gst_caps_unref(caps); 45 #ifdef GST_API_VERSION_1 46 GstMapInfo mapInfo; 47 gst_buffer_map(buffer, &mapInfo, GST_MAP_READ); 48 unsigned char* bufferData = reinterpret_cast<unsigned char*>(mapInfo.data); 49 #else 50 unsigned char* bufferData = reinterpret_cast<unsigned char*>(GST_BUFFER_DATA(buffer)); 51 #endif 41 52 42 53 cairo_format_t cairoFormat; 43 if (format == GST_VIDEO_FORMAT_ARGB || format == GST_VIDEO_FORMAT_BGRA) 44 cairoFormat = CAIRO_FORMAT_ARGB32; 45 else 46 cairoFormat = CAIRO_FORMAT_RGB24; 54 #if G_BYTE_ORDER == G_LITTLE_ENDIAN 55 cairoFormat = (format == GST_VIDEO_FORMAT_BGRA) ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24; 56 #else 57 cairoFormat = (format == GST_VIDEO_FORMAT_ARGB) ? CAIRO_FORMAT_ARGB32 : CAIRO_FORMAT_RGB24; 58 #endif 47 59 48 return adoptRef(new ImageGStreamer(buffer, IntSize(width, height), cairoFormat)); 49 } 50 51 ImageGStreamer::ImageGStreamer(GstBuffer*& buffer, IntSize size, cairo_format_t& cairoFormat) 52 : m_image(0) 53 { 54 cairo_surface_t* surface = cairo_image_surface_create_for_data(GST_BUFFER_DATA(buffer), cairoFormat, 55 size.width(), size.height(), 56 cairo_format_stride_for_width(cairoFormat, size.width())); 60 cairo_surface_t* surface = cairo_image_surface_create_for_data(bufferData, cairoFormat, size.width(), size.height(), stride); 57 61 ASSERT(cairo_surface_status(surface) == CAIRO_STATUS_SUCCESS); 58 62 m_image = BitmapImage::create(surface); 63 64 #ifdef GST_API_VERSION_1 65 if (GstVideoCropMeta* cropMeta = gst_buffer_get_video_crop_meta(buffer)) 66 setCropRect(FloatRect(cropMeta->x, cropMeta->y, cropMeta->width, cropMeta->height)); 67 68 gst_buffer_unmap(buffer, &mapInfo); 69 #endif 59 70 } 60 71 -
trunk/Source/WebCore/platform/graphics/gstreamer/ImageGStreamerQt.cpp
r111354 r120790 22 22 23 23 #if ENABLE(VIDEO) && USE(GSTREAMER) 24 #include <gst/gst.h> 25 #include <gst/video/video.h> 26 27 #ifdef GST_API_VERSION_1 28 #include <gst/video/gstvideometa.h> 29 #endif 30 24 31 #include <wtf/gobject/GOwnPtr.h> 25 32 … … 27 34 using namespace WebCore; 28 35 29 PassRefPtr<ImageGStreamer> ImageGStreamer::createImage(GstBuffer* buffer) 30 { 31 int width = 0, height = 0; 32 GstCaps* caps = gst_buffer_get_caps(buffer); 33 GstVideoFormat format; 34 if (!gst_video_format_parse_caps(caps, &format, &width, &height)) { 35 gst_caps_unref(caps); 36 return 0; 37 } 38 39 gst_caps_unref(caps); 40 41 QImage::Format imageFormat; 42 if (format == GST_VIDEO_FORMAT_RGB) 43 imageFormat = QImage::Format_RGB888; 44 else 45 imageFormat = QImage::Format_RGB32; 46 47 return adoptRef(new ImageGStreamer(buffer, IntSize(width, height), imageFormat)); 48 } 49 50 ImageGStreamer::ImageGStreamer(GstBuffer*& buffer, IntSize size, QImage::Format imageFormat) 36 ImageGStreamer::ImageGStreamer(GstBuffer* buffer, GstCaps* caps) 51 37 : m_image(0) 52 38 { 53 39 QPixmap* surface = new QPixmap; 54 QImage image(GST_BUFFER_DATA(buffer), size.width(), size.height(), imageFormat); 40 GstVideoFormat format; 41 IntSize size; 42 int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride; 43 webkitGetVideoSizeAndFormatFromCaps(caps, size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride); 44 45 #ifdef GST_API_VERSION_1 46 GstMapInfo info; 47 gst_buffer_map(buffer, &info, GST_MAP_READ); 48 uchar* bufferData = reinterpret_cast<uchar*>(info.data); 49 #else 50 uchar* bufferData = reinterpret_cast<uchar*>(GST_BUFFER_DATA(buffer)); 51 #endif 52 QImage::Format imageFormat; 53 #if G_BYTE_ORDER == G_LITTLE_ENDIAN 54 imageFormat = (format == GST_VIDEO_FORMAT_BGRA) ? QImage::Format_RGB32 : QImage::Format_RGB888; 55 #else 56 imageFormat = (format == GST_VIDEO_FORMAT_ARGB) ? QImage::Format_ARGB32 : QImage::Format_RGB888; 57 #endif 58 59 QImage image(bufferData, size.width(), size.height(), imageFormat); 60 55 61 surface->convertFromImage(image); 56 62 m_image = BitmapImage::create(surface); 63 64 #ifdef GST_API_VERSION_1 65 gst_buffer_unmap(buffer, &info); 66 #endif 57 67 } 58 68 -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
r120654 r120790 255 255 } 256 256 257 #ifndef GST_API_VERSION_1 257 258 if (m_videoSinkBin) { 258 259 gst_object_unref(m_videoSinkBin); 259 260 m_videoSinkBin = 0; 260 261 } 262 #endif 261 263 262 264 if (m_playBin) { … … 498 500 return IntSize(); 499 501 500 int pixelAspectRatioNumerator, pixelAspectRatioDenominator;501 int displayWidth, displayHeight, displayAspectRatioGCD;502 int originalWidth = 0, originalHeight = 0;503 502 504 503 // TODO: handle possible clean aperture data. See … … 509 508 // Get the video PAR and original size, if this fails the 510 509 // video-sink has likely not yet negotiated its caps. 511 #ifdef GST_API_VERSION_1 512 GstVideoInfo info; 513 if (!gst_video_info_from_caps(&info, caps)) 510 int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride; 511 IntSize originalSize; 512 GstVideoFormat format; 513 if (!getVideoSizeAndFormatFromCaps(caps, originalSize, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride)) 514 514 return IntSize(); 515 515 516 originalWidth = GST_VIDEO_INFO_WIDTH(&info); 517 originalHeight = GST_VIDEO_INFO_HEIGHT(&info); 518 pixelAspectRatioNumerator = GST_VIDEO_INFO_PAR_N(&info); 519 pixelAspectRatioDenominator = GST_VIDEO_INFO_PAR_D(&info); 520 #else 521 // Get the video PAR and original size. 522 if (!GST_IS_CAPS(caps) || !gst_caps_is_fixed(caps) 523 || !gst_video_format_parse_caps(caps, 0, &originalWidth, &originalHeight) 524 || !gst_video_parse_caps_pixel_aspect_ratio(caps, &pixelAspectRatioNumerator, 525 &pixelAspectRatioDenominator)) 526 return IntSize(); 527 #endif 528 529 LOG_VERBOSE(Media, "Original video size: %dx%d", originalWidth, originalHeight); 516 LOG_VERBOSE(Media, "Original video size: %dx%d", originalSize.width(), originalSize.height()); 530 517 LOG_VERBOSE(Media, "Pixel aspect ratio: %d/%d", pixelAspectRatioNumerator, pixelAspectRatioDenominator); 531 518 532 519 // Calculate DAR based on PAR and video size. 533 displayWidth = originalWidth* pixelAspectRatioNumerator;534 displayHeight = originalHeight* pixelAspectRatioDenominator;520 int displayWidth = originalSize.width() * pixelAspectRatioNumerator; 521 int displayHeight = originalSize.height() * pixelAspectRatioDenominator; 535 522 536 523 // Divide display width and height by their GCD to avoid possible overflows. 537 displayAspectRatioGCD = greatestCommonDivisor(displayWidth, displayHeight);524 int displayAspectRatioGCD = greatestCommonDivisor(displayWidth, displayHeight); 538 525 displayWidth /= displayAspectRatioGCD; 539 526 displayHeight /= displayAspectRatioGCD; … … 541 528 // Apply DAR to original video size. This is the same behavior as in xvimagesink's setcaps function. 542 529 guint64 width = 0, height = 0; 543 if (!(original Height% displayHeight)) {530 if (!(originalSize.height() % displayHeight)) { 544 531 LOG_VERBOSE(Media, "Keeping video original height"); 545 width = gst_util_uint64_scale_int(original Height, displayWidth, displayHeight);546 height = static_cast<guint64>(original Height);547 } else if (!(original Width% displayWidth)) {532 width = gst_util_uint64_scale_int(originalSize.height(), displayWidth, displayHeight); 533 height = static_cast<guint64>(originalSize.height()); 534 } else if (!(originalSize.width() % displayWidth)) { 548 535 LOG_VERBOSE(Media, "Keeping video original width"); 549 height = gst_util_uint64_scale_int(original Width, displayHeight, displayWidth);550 width = static_cast<guint64>(original Width);536 height = gst_util_uint64_scale_int(originalSize.width(), displayHeight, displayWidth); 537 width = static_cast<guint64>(originalSize.width()); 551 538 } else { 552 539 LOG_VERBOSE(Media, "Approximating while keeping original video height"); 553 width = gst_util_uint64_scale_int(original Height, displayWidth, displayHeight);554 height = static_cast<guint64>(original Height);540 width = gst_util_uint64_scale_int(originalSize.height(), displayWidth, displayHeight); 541 height = static_cast<guint64>(originalSize.height()); 555 542 } 556 543 … … 958 945 while (!done) { 959 946 #ifdef GST_API_VERSION_1 960 GValue item = {0, };947 GValue item = G_VALUE_INIT; 961 948 switch (gst_iterator_next(iter, &item)) { 962 949 case GST_ITERATOR_OK: { … … 1482 1469 return; 1483 1470 1484 RefPtr<ImageGStreamer> gstImage = ImageGStreamer::createImage(m_buffer); 1471 GstCaps* caps = webkitGstGetPadCaps(m_videoSinkPad.get()); 1472 if (!caps) 1473 return; 1474 1475 RefPtr<ImageGStreamer> gstImage = ImageGStreamer::createImage(m_buffer, caps); 1485 1476 if (!gstImage) 1486 1477 return; 1487 1478 1488 1479 context->drawImage(reinterpret_cast<Image*>(gstImage->image().get()), ColorSpaceSRGB, 1489 rect, CompositeCopy, DoNotRespectImageOrientation, false);1480 rect, gstImage->rect(), CompositeCopy, DoNotRespectImageOrientation, false); 1490 1481 } 1491 1482 1492 1483 static HashSet<String> mimeTypeCache() 1493 1484 { 1494 1495 1485 initializeGStreamerAndRegisterWebKitElements(); 1496 1486 … … 1674 1664 g_signal_connect(m_playBin, "audio-changed", G_CALLBACK(mediaPlayerPrivateAudioChangedCallback), this); 1675 1665 1666 #ifndef GST_API_VERSION_1 1676 1667 m_webkitVideoSink = webkitVideoSinkNew(m_gstGWorld.get()); 1668 #else 1669 m_webkitVideoSink = webkitVideoSinkNew(); 1670 #endif 1677 1671 m_videoSinkPad = adoptGRef(gst_element_get_static_pad(m_webkitVideoSink, "sink")); 1678 1672 -
trunk/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.cpp
r118789 r120790 30 30 #include "VideoSinkGStreamer.h" 31 31 32 #include "GStreamerVersioning.h" 33 #include "IntSize.h" 32 34 #include <glib.h> 33 35 #include <gst/gst.h> 36 #ifdef GST_API_VERSION_1 37 #include <gst/video/gstvideometa.h> 38 #include <gst/video/gstvideopool.h> 39 #endif 34 40 #include <wtf/FastAllocBase.h> 35 41 36 42 // CAIRO_FORMAT_RGB24 used to render the video buffers is little/big endian dependant. 37 43 #if G_BYTE_ORDER == G_LITTLE_ENDIAN 44 #ifndef GST_API_VERSION_1 38 45 #define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_BGRA 39 46 #else 47 #define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_MAKE("{ BGRx, BGRA }") 48 #endif 49 #else 50 #ifndef GST_API_VERSION_1 40 51 #define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_xRGB ";" GST_VIDEO_CAPS_ARGB 52 #else 53 #define WEBKIT_VIDEO_SINK_PAD_CAPS GST_VIDEO_CAPS_MAKE("{ xRGB, ARGB }") 54 #endif 41 55 #endif 42 56 static GstStaticPadTemplate s_sinkTemplate = GST_STATIC_PAD_TEMPLATE("sink", GST_PAD_SINK, GST_PAD_ALWAYS, GST_STATIC_CAPS(WEBKIT_VIDEO_SINK_PAD_CAPS)); … … 63 77 GCond* dataCondition; 64 78 79 #ifdef GST_API_VERSION_1 80 GstVideoInfo info; 81 #endif 82 83 #ifndef GST_API_VERSION_1 65 84 WebCore::GStreamerGWorld* gstGWorld; 85 #endif 66 86 67 87 // If this is TRUE all processing should finish ASAP … … 92 112 sink->priv->bufferMutex = g_mutex_new(); 93 113 #endif 114 115 #ifdef GST_API_VERSION_1 116 gst_video_info_init(&sink->priv->info); 117 #endif 94 118 } 95 119 … … 130 154 } 131 155 156 #ifndef GST_API_VERSION_1 132 157 // Ignore buffers if the video is already in fullscreen using 133 158 // another sink. … … 136 161 return GST_FLOW_OK; 137 162 } 163 #endif 138 164 139 165 priv->buffer = gst_buffer_ref(buffer); 140 166 167 #ifndef GST_API_VERSION_1 141 168 // For the unlikely case where the buffer has no caps, the caps 142 169 // are implicitely the caps of the pad. This shouldn't happen. … … 147 174 148 175 GstCaps* caps = GST_BUFFER_CAPS(buffer); 176 #else 177 GstCaps* caps = gst_video_info_to_caps(&priv->info); 178 #endif 179 149 180 GstVideoFormat format; 150 int width, height; 151 if (UNLIKELY(!gst_video_format_parse_caps(caps, &format, &width, &height))) { 181 WebCore::IntSize size; 182 int pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride; 183 if (!getVideoSizeAndFormatFromCaps(caps, size, format, pixelAspectRatioNumerator, pixelAspectRatioDenominator, stride)) { 152 184 gst_buffer_unref(buffer); 185 #ifdef GST_API_VERSION_1 186 gst_caps_unref(caps); 187 #endif 153 188 g_mutex_unlock(priv->bufferMutex); 154 189 return GST_FLOW_ERROR; 155 190 } 191 192 #ifdef GST_API_VERSION_1 193 gst_caps_unref(caps); 194 #endif 156 195 157 196 // Cairo's ARGB has pre-multiplied alpha while GStreamer's doesn't. … … 163 202 // could be passed multiple times to this method (in theory). 164 203 165 GstBuffer* newBuffer = gst_buffer_try_new_and_alloc(GST_BUFFER_SIZE(buffer));204 GstBuffer* newBuffer = createGstBuffer(buffer); 166 205 167 206 // Check if allocation failed. … … 171 210 } 172 211 173 gst_buffer_copy_metadata(newBuffer, buffer, static_cast<GstBufferCopyFlags>(GST_BUFFER_COPY_ALL));174 175 212 // We don't use Color::premultipliedARGBFromColor() here because 176 213 // one function call per video pixel is just too expensive: 177 214 // For 720p/PAL for example this means 1280*720*25=23040000 178 215 // function calls per second! 216 #ifndef GST_API_VERSION_1 179 217 const guint8* source = GST_BUFFER_DATA(buffer); 180 218 guint8* destination = GST_BUFFER_DATA(newBuffer); 181 182 for (int x = 0; x < height; x++) { 183 for (int y = 0; y < width; y++) { 219 #else 220 GstMapInfo sourceInfo; 221 GstMapInfo destinationInfo; 222 gst_buffer_map(buffer, &sourceInfo, GST_MAP_READ); 223 const guint8* source = const_cast<guint8*>(sourceInfo.data); 224 gst_buffer_map(newBuffer, &destinationInfo, GST_MAP_WRITE); 225 guint8* destination = static_cast<guint8*>(destinationInfo.data); 226 #endif 227 228 for (int x = 0; x < size.height(); x++) { 229 for (int y = 0; y < size.width(); y++) { 184 230 #if G_BYTE_ORDER == G_LITTLE_ENDIAN 185 231 unsigned short alpha = source[3]; … … 200 246 } 201 247 248 #ifdef GST_API_VERSION_1 249 gst_buffer_unmap(buffer, &sourceInfo); 250 gst_buffer_unmap(newBuffer, &destinationInfo); 251 #endif 202 252 gst_buffer_unref(buffer); 203 253 buffer = priv->buffer = newBuffer; … … 294 344 } 295 345 346 #ifdef GST_API_VERSION_1 347 static gboolean webkitVideoSinkProposeAllocation(GstBaseSink* baseSink, GstQuery* query) 348 { 349 GstCaps* caps; 350 gst_query_parse_allocation(query, &caps, 0); 351 if (!caps) 352 return FALSE; 353 354 WebKitVideoSink* sink = WEBKIT_VIDEO_SINK(baseSink); 355 if (!gst_video_info_from_caps(&sink->priv->info, caps)) 356 return FALSE; 357 358 gst_query_add_allocation_meta(query, GST_VIDEO_META_API_TYPE); 359 gst_query_add_allocation_meta(query, GST_VIDEO_CROP_META_API_TYPE); 360 return TRUE; 361 } 362 #endif 363 364 #ifndef GST_API_VERSION_1 296 365 static void webkitVideoSinkMarshalVoidAndMiniObject(GClosure* closure, GValue* returnValue, guint parametersNumber, const GValue* parameterValues, gpointer invocationHint, gpointer marshalData) 297 366 { … … 314 383 callback(data1, gst_value_get_mini_object(parameterValues + 1), data2); 315 384 } 385 #endif 316 386 317 387 static void webkit_video_sink_class_init(WebKitVideoSinkClass* klass) … … 322 392 323 393 gst_element_class_add_pad_template(elementClass, gst_static_pad_template_get(&s_sinkTemplate)); 394 #ifdef GST_API_VERSION_1 395 gst_element_class_set_metadata(elementClass, 396 #else 324 397 gst_element_class_set_details_simple(elementClass, 398 #endif 325 399 "WebKit video sink", 326 400 "Sink/Video", "Sends video data from a GStreamer pipeline to a Cairo surface", … … 337 411 baseSinkClass->stop = webkitVideoSinkStop; 338 412 baseSinkClass->start = webkitVideoSinkStart; 413 #ifdef GST_API_VERSION_1 414 baseSinkClass->propose_allocation = webkitVideoSinkProposeAllocation; 415 #endif 339 416 340 417 webkitVideoSinkSignals[REPAINT_REQUESTED] = g_signal_new("repaint-requested", … … 344 421 0, // Accumulator 345 422 0, // Accumulator data 423 #ifndef GST_API_VERSION_1 346 424 webkitVideoSinkMarshalVoidAndMiniObject, 425 #else 426 g_cclosure_marshal_generic, 427 #endif 347 428 G_TYPE_NONE, // Return type 348 429 1, // Only one parameter … … 351 432 352 433 434 #ifndef GST_API_VERSION_1 353 435 GstElement* webkitVideoSinkNew(WebCore::GStreamerGWorld* gstGWorld) 354 436 { … … 357 439 return element; 358 440 } 441 #else 442 GstElement* webkitVideoSinkNew() 443 { 444 return GST_ELEMENT(g_object_new(WEBKIT_TYPE_VIDEO_SINK, 0)); 445 } 446 #endif 359 447 360 448 #endif // USE(GSTREAMER) -
trunk/Source/WebCore/platform/graphics/gstreamer/VideoSinkGStreamer.h
r118789 r120790 23 23 #if ENABLE(VIDEO) && USE(GSTREAMER) 24 24 25 #ifndef GST_API_VERSION_1 25 26 #include "GStreamerGWorld.h" 27 #endif 28 26 29 #include <glib-object.h> 27 30 #include <gst/video/gstvideosink.h> … … 59 62 GType webkit_video_sink_get_type() G_GNUC_CONST; 60 63 64 #ifndef GST_API_VERSION_1 61 65 GstElement* webkitVideoSinkNew(WebCore::GStreamerGWorld*); 66 #else 67 GstElement* webkitVideoSinkNew(); 68 #endif 62 69 63 70 #endif // USE(GSTREAMER) -
trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
r111354 r120790 854 854 855 855 if (gst_tag_list_is_empty(tags)) 856 #ifdef GST_API_VERSION_1 857 gst_tag_list_unref(tags); 858 #else 856 859 gst_tag_list_free(tags); 860 #endif 857 861 else 858 862 #ifdef GST_API_VERSION_1 859 gst_pad_push_event(GST_PAD_CAST(m_src->priv->srcpad), gst_event_new_tag( tags));863 gst_pad_push_event(GST_PAD_CAST(m_src->priv->srcpad), gst_event_new_tag("WebKitWebSrc", tags)); 860 864 #else 861 865 gst_element_found_tags_for_pad(GST_ELEMENT(m_src), m_src->priv->srcpad, tags); -
trunk/configure.ac
r120228 r120790 349 349 GSTREAMER_0_10_REQUIRED_VERSION=0.10 350 350 GSTREAMER_0_10_PLUGINS_BASE_REQUIRED_VERSION=0.10.30 351 GSTREAMER_1_0_REQUIRED_VERSION= 1.0351 GSTREAMER_1_0_REQUIRED_VERSION=0.11.90 352 352 GSTREAMER_1_0_PLUGINS_BASE_REQUIRED_VERSION=0.11.90 353 353
Note: See TracChangeset
for help on using the changeset viewer.