Changeset 99977 in webkit
- Timestamp:
- Nov 11, 2011 8:35:13 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r99968 r99977 1 2011-11-10 Philippe Normand <pnormand@igalia.com> 2 3 [GStreamer] GstCaps and GstPad RefPtr implementation 4 https://bugs.webkit.org/show_bug.cgi?id=72023 5 6 Reviewed by Martin Robinson. 7 8 Smart pointer implementations for GstCaps and GstPad and them 9 in the media player code. 10 11 * platform/graphics/gstreamer/GRefPtrGStreamer.cpp: 12 (WTF::GstPad): 13 (WTF::GstCaps): 14 * platform/graphics/gstreamer/GRefPtrGStreamer.h: 15 * platform/graphics/gstreamer/GStreamerGWorld.cpp: 16 (WebCore::GStreamerGWorld::enterFullscreen): 17 (WebCore::GStreamerGWorld::exitFullscreen): 18 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: 19 (WebCore::MediaPlayerPrivateGStreamer::naturalSize): 20 (WebCore::MediaPlayerPrivateGStreamer::totalBytes): 21 (WebCore::MediaPlayerPrivateGStreamer::createGSTPlayBin): 22 * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp: 23 (webkit_web_src_init): 24 (StreamingClient::didReceiveResponse): 25 1 26 2011-11-11 Sheriff Bot <webkit.review.bot@gmail.com> 2 27 -
trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp
r95901 r99977 29 29 { 30 30 if (ptr) 31 gst_object_ref (ptr);31 gst_object_ref_sink(ptr); 32 32 return ptr; 33 33 } … … 39 39 } 40 40 41 template <> GstPad* refGPtr<GstPad>(GstPad* ptr) 42 { 43 if (ptr) 44 gst_object_ref_sink(GST_OBJECT(ptr)); 45 return ptr; 46 } 47 48 template <> void derefGPtr<GstPad>(GstPad* ptr) 49 { 50 if (ptr) 51 gst_object_unref(GST_OBJECT(ptr)); 52 } 53 54 template <> GstCaps* refGPtr<GstCaps>(GstCaps* ptr) 55 { 56 if (ptr) 57 gst_caps_ref(ptr); 58 return ptr; 59 } 60 61 template <> void derefGPtr<GstCaps>(GstCaps* ptr) 62 { 63 if (ptr) 64 gst_caps_unref(ptr); 65 } 66 41 67 } 42 68 #endif // USE(GSTREAMER) -
trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h
r95901 r99977 25 25 26 26 typedef struct _GstElement GstElement; 27 typedef struct _GstPad GstPad; 28 typedef struct _GstCaps GstCaps; 27 29 28 30 namespace WTF { … … 31 33 template<> void derefGPtr<GstElement>(GstElement* ptr); 32 34 35 template<> GstPad* refGPtr<GstPad>(GstPad* ptr); 36 template<> void derefGPtr<GstPad>(GstPad* ptr); 37 38 template<> GstCaps* refGPtr<GstCaps>(GstCaps* ptr); 39 template<> void derefGPtr<GstCaps>(GstCaps* ptr); 40 33 41 } 34 42 -
trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerGWorld.cpp
r98924 r99977 93 93 videoSink = adoptGRef(sinkPtr); 94 94 95 G stElement* tee = gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoTee");95 GRefPtr<GstElement> tee = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoTee")); 96 96 97 97 // Add and link a queue, ffmpegcolorspace, videoscale and sink in the bin. … … 104 104 105 105 // Link a new src pad from tee to queue. 106 GstPad* srcPad = gst_element_get_request_pad(tee, "src%d"); 107 GstPad* sinkPad = gst_element_get_static_pad(queue, "sink"); 108 gst_pad_link(srcPad, sinkPad); 109 gst_object_unref(GST_OBJECT(sinkPad)); 110 111 m_dynamicPadName.set(gst_pad_get_name(srcPad)); 106 GRefPtr<GstPad> srcPad = adoptGRef(gst_element_get_request_pad(tee.get(), "src%d")); 107 GRefPtr<GstPad> sinkPad = adoptGRef(gst_element_get_static_pad(queue, "sink")); 108 gst_pad_link(srcPad.get(), sinkPad.get()); 109 110 m_dynamicPadName.set(gst_pad_get_name(srcPad.get())); 112 111 113 112 // Synchronize the new elements with pipeline state. If it's … … 122 121 gst_element_set_state(colorspace, state); 123 122 gst_element_set_state(queue, state); 124 gst_object_unref(tee);125 123 126 124 // Query the current media segment informations and send them towards … … 132 130 if (!queryResult) { 133 131 gst_query_unref(query); 134 gst_object_unref(GST_OBJECT(srcPad));135 132 return true; 136 133 } … … 146 143 147 144 GstEvent* event = gst_event_new_new_segment(FALSE, rate, format, startValue, stopValue, position); 148 gst_pad_push_event(srcPad , event);145 gst_pad_push_event(srcPad.get(), event); 149 146 150 147 gst_query_unref(query); 151 gst_object_unref(GST_OBJECT(srcPad));152 148 return true; 153 149 } … … 165 161 videoSink = adoptGRef(sinkPtr); 166 162 167 G stElement* tee = gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoTee");168 G stElement* platformVideoSink = gst_bin_get_by_name(GST_BIN(videoSink.get()), "platformVideoSink");169 G stElement* queue = gst_bin_get_by_name(GST_BIN(videoSink.get()), "queue");170 G stElement* colorspace = gst_bin_get_by_name(GST_BIN(videoSink.get()), "colorspace");171 G stElement* videoScale = gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoScale");163 GRefPtr<GstElement> tee = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoTee")); 164 GRefPtr<GstElement> platformVideoSink = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "platformVideoSink")); 165 GRefPtr<GstElement> queue = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "queue")); 166 GRefPtr<GstElement> colorspace = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "colorspace")); 167 GRefPtr<GstElement> videoScale = adoptGRef(gst_bin_get_by_name(GST_BIN(videoSink.get()), "videoScale")); 172 168 173 169 // Get pads to unlink and remove. 174 G stPad* srcPad = gst_element_get_static_pad(tee, m_dynamicPadName.get());175 G stPad* sinkPad = gst_element_get_static_pad(queue, "sink");170 GRefPtr<GstPad> srcPad = adoptGRef(gst_element_get_static_pad(tee.get(), m_dynamicPadName.get())); 171 GRefPtr<GstPad> sinkPad = adoptGRef(gst_element_get_static_pad(queue.get(), "sink")); 176 172 177 173 // Block data flow towards the pipeline branch to remove. No need … … 179 175 GstState state; 180 176 gst_element_get_state(m_pipeline, &state, 0, 0); 181 if (state < GST_STATE_PLAYING || gst_pad_set_blocked(srcPad , true)) {177 if (state < GST_STATE_PLAYING || gst_pad_set_blocked(srcPad.get(), true)) { 182 178 183 179 // Unlink and release request pad. 184 gst_pad_unlink(srcPad , sinkPad);185 gst_element_release_request_pad(tee , srcPad);180 gst_pad_unlink(srcPad.get(), sinkPad.get()); 181 gst_element_release_request_pad(tee.get(), srcPad.get()); 186 182 187 183 // Unlink, remove and cleanup queue, ffmpegcolorspace, videoScale and sink. 188 gst_element_unlink_many(queue , colorspace, videoScale, platformVideoSink, NULL);189 gst_bin_remove_many(GST_BIN(videoSink.get()), queue , colorspace, videoScale, platformVideoSink, NULL);190 gst_element_set_state(platformVideoSink , GST_STATE_NULL);191 gst_element_set_state(videoScale , GST_STATE_NULL);192 gst_element_set_state(colorspace , GST_STATE_NULL);193 gst_element_set_state(queue , GST_STATE_NULL);184 gst_element_unlink_many(queue.get(), colorspace.get(), videoScale.get(), platformVideoSink.get(), NULL); 185 gst_bin_remove_many(GST_BIN(videoSink.get()), queue.get(), colorspace.get(), videoScale.get(), platformVideoSink.get(), NULL); 186 gst_element_set_state(platformVideoSink.get(), GST_STATE_NULL); 187 gst_element_set_state(videoScale.get(), GST_STATE_NULL); 188 gst_element_set_state(colorspace.get(), GST_STATE_NULL); 189 gst_element_set_state(queue.get(), GST_STATE_NULL); 194 190 } 195 191 196 gst_object_unref(GST_OBJECT(srcPad));197 gst_object_unref(GST_OBJECT(sinkPad));198 199 gst_object_unref(queue);200 gst_object_unref(colorspace);201 gst_object_unref(videoScale);202 gst_object_unref(platformVideoSink);203 204 gst_object_unref(tee);205 192 m_dynamicPadName.clear(); 206 193 } -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
r98924 r99977 482 482 return IntSize(); 483 483 484 G stPad* pad = gst_element_get_static_pad(m_webkitVideoSink, "sink");484 GRefPtr<GstPad> pad = adoptGRef(gst_element_get_static_pad(m_webkitVideoSink, "sink")); 485 485 if (!pad) 486 486 return IntSize(); 487 487 488 488 guint64 width = 0, height = 0; 489 GstCaps* caps = GST_PAD_CAPS(pad );489 GstCaps* caps = GST_PAD_CAPS(pad.get()); 490 490 int pixelAspectRatioNumerator, pixelAspectRatioDenominator; 491 491 int displayWidth, displayHeight, displayAspectRatioGCD; … … 497 497 // https://bugzilla.gnome.org/show_bug.cgi?id=596326 498 498 499 // Get the video PAR and original size. 499 // Get the video PAR and original size, if this fails the 500 // video-sink has likely not yet negotiated its caps. 500 501 if (!GST_IS_CAPS(caps) || !gst_caps_is_fixed(caps) 501 502 || !gst_video_format_parse_caps(caps, 0, &originalWidth, &originalHeight) 502 503 || !gst_video_parse_caps_pixel_aspect_ratio(caps, &pixelAspectRatioNumerator, 503 &pixelAspectRatioDenominator)) { 504 gst_object_unref(GST_OBJECT(pad)); 505 // The video-sink has likely not yet negotiated its caps. 504 &pixelAspectRatioDenominator)) 506 505 return IntSize(); 507 }508 509 gst_object_unref(GST_OBJECT(pad));510 506 511 507 LOG_VERBOSE(Media, "Original video size: %dx%d", originalWidth, originalHeight); … … 940 936 switch (gst_iterator_next(iter, &data)) { 941 937 case GST_ITERATOR_OK: { 942 G stPad* pad = GST_PAD_CAST(data);938 GRefPtr<GstPad> pad = adoptGRef(GST_PAD_CAST(data)); 943 939 gint64 padLength = 0; 944 if (gst_pad_query_duration(pad , &fmt, &padLength)940 if (gst_pad_query_duration(pad.get(), &fmt, &padLength) 945 941 && padLength > length) 946 942 length = padLength; 947 gst_object_unref(pad);948 943 break; 949 944 } … … 1709 1704 1710 1705 // Link a new src pad from tee to queue1. 1711 GstPad* srcPad = gst_element_get_request_pad(videoTee, "src%d"); 1712 GstPad* sinkPad = gst_element_get_static_pad(queue, "sink"); 1713 gst_pad_link(srcPad, sinkPad); 1714 gst_object_unref(GST_OBJECT(srcPad)); 1715 gst_object_unref(GST_OBJECT(sinkPad)); 1706 GRefPtr<GstPad> srcPad = adoptGRef(gst_element_get_request_pad(videoTee, "src%d")); 1707 GRefPtr<GstPad> sinkPad = adoptGRef(gst_element_get_static_pad(queue, "sink")); 1708 gst_pad_link(srcPad.get(), sinkPad.get()); 1716 1709 1717 1710 GstElement* actualVideoSink = 0; … … 1751 1744 1752 1745 // Add a ghostpad to the bin so it can proxy to tee. 1753 GstPad* pad = gst_element_get_static_pad(videoTee, "sink"); 1754 gst_element_add_pad(m_videoSinkBin, gst_ghost_pad_new("sink", pad)); 1755 gst_object_unref(GST_OBJECT(pad)); 1746 GRefPtr<GstPad> pad = adoptGRef(gst_element_get_static_pad(videoTee, "sink")); 1747 gst_element_add_pad(m_videoSinkBin, gst_ghost_pad_new("sink", pad.get())); 1756 1748 1757 1749 // Set the bin as video sink of playbin. 1758 1750 g_object_set(m_playBin, "video-sink", m_videoSinkBin, NULL); 1759 1751 1760 1761 pad = gst_element_get_static_pad(m_webkitVideoSink, "sink"); 1762 if (pad) { 1763 g_signal_connect(pad, "notify::caps", G_CALLBACK(mediaPlayerPrivateVideoSinkCapsChangedCallback), this); 1764 gst_object_unref(GST_OBJECT(pad)); 1765 } 1752 pad = adoptGRef(gst_element_get_static_pad(m_webkitVideoSink, "sink")); 1753 if (pad) 1754 g_signal_connect(pad.get(), "notify::caps", G_CALLBACK(mediaPlayerPrivateVideoSinkCapsChangedCallback), this); 1766 1755 1767 1756 } -
trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp
r96942 r99977 214 214 { 215 215 GstPadTemplate* padTemplate = gst_static_pad_template_get(&srcTemplate); 216 GstPad* targetpad;217 216 WebKitWebSrcPrivate* priv = WEBKIT_WEB_SRC_GET_PRIVATE(src); 218 217 … … 233 232 234 233 235 targetpad = gst_element_get_static_pad(GST_ELEMENT(priv->appsrc), "src"); 236 priv->srcpad = gst_ghost_pad_new_from_template("src", targetpad, padTemplate); 237 gst_object_unref(targetpad); 234 GRefPtr<GstPad> targetPad = adoptGRef(gst_element_get_static_pad(GST_ELEMENT(priv->appsrc), "src")); 235 priv->srcpad = gst_ghost_pad_new_from_template("src", targetPad.get(), padTemplate); 238 236 239 237 gst_element_add_pad(GST_ELEMENT(src), priv->srcpad); … … 733 731 734 732 if (endptr && *endptr == '\0' && icyMetaInt > 0) { 735 GstCaps* caps = gst_caps_new_simple("application/x-icy", "metadata-interval", G_TYPE_INT, (gint) icyMetaInt, NULL); 736 737 gst_app_src_set_caps(priv->appsrc, caps); 738 gst_caps_unref(caps); 733 GRefPtr<GstCaps> caps = adoptGRef(gst_caps_new_simple("application/x-icy", "metadata-interval", G_TYPE_INT, (gint) icyMetaInt, NULL)); 734 735 gst_app_src_set_caps(priv->appsrc, caps.get()); 739 736 } 740 737 }
Note: See TracChangeset
for help on using the changeset viewer.