Changeset 28792 in webkit
- Timestamp:
- Dec 16, 2007 8:08:39 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r28791 r28792 1 2007-12-16 Alp Toker <alp@atoker.com> 2 3 Reviewed by Maciej. 4 5 http://bugs.webkit.org/show_bug.cgi?id=16356 6 [GTK] Integrate GStreamer video with the graphics backend 7 8 Integrate the GStreamer media backend with the Cairo graphics backend. 9 There are still some issues: Data is copied more often than necessary, 10 and repaint() is not called, causing transformed video not to update 11 sometimes. 12 13 * WebCore.pro: 14 * platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp: 15 (WebCore::MediaPlayerPrivate::MediaPlayerPrivate): 16 (WebCore::MediaPlayerPrivate::~MediaPlayerPrivate): 17 (WebCore::MediaPlayerPrivate::currentTime): 18 (WebCore::MediaPlayerPrivate::setEndTime): 19 (WebCore::MediaPlayerPrivate::seeking): 20 (WebCore::MediaPlayerPrivate::naturalSize): 21 (WebCore::MediaPlayerPrivate::setMuted): 22 (WebCore::MediaPlayerPrivate::setRect): 23 (WebCore::MediaPlayerPrivate::setVisible): 24 (WebCore::MediaPlayerPrivate::repaint): 25 (WebCore::MediaPlayerPrivate::paint): 26 (WebCore::MediaPlayerPrivate::createGSTPlayBin): 27 * platform/graphics/gtk/MediaPlayerPrivateGStreamer.h: 28 * platform/graphics/gtk/VideoSinkGStreamer.cpp: Added. 29 (webkit_video_sink_base_init): 30 (webkit_video_sink_init): 31 (webkit_video_sink_idle_func): 32 (webkit_video_sink_render): 33 (webkit_video_sink_set_caps): 34 (webkit_video_sink_dispose): 35 (webkit_video_sink_finalize): 36 (webkit_video_sink_set_property): 37 (webkit_video_sink_get_property): 38 (webkit_video_sink_stop): 39 (webkit_video_sink_class_init): 40 (webkit_video_sink_new): 41 (webkit_video_sink_set_surface): 42 (plugin_init): 43 * platform/graphics/gtk/VideoSinkGStreamer.h: Added. 44 1 45 2007-12-16 Mark Rowe <mrowe@apple.com> 2 46 -
trunk/WebCore/WebCore.pro
r28779 r28792 1112 1112 gtk-port { 1113 1113 SOURCES += \ 1114 platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp 1114 platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp \ 1115 platform/graphics/gtk/VideoSinkGStreamer.cpp 1115 1116 1116 1117 PKGCONFIG += gstreamer-0.10 gstreamer-plugins-base-0.10 gnome-vfs-2.0 -
trunk/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp
r28664 r28792 2 2 * Copyright (C) 2007 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2007 Collabora Ltd. All rights reserved. 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 4 5 * 5 6 * This library is free software; you can redistribute it and/or … … 24 25 25 26 #include "MediaPlayerPrivateGStreamer.h" 26 27 #include "CString.h" 27 #include "VideoSinkGStreamer.h" 28 28 29 #include "CString.h" 29 30 #include "GraphicsContext.h" … … 117 118 , m_startedPlaying(false) 118 119 , m_isStreaming(false) 119 { 120 , m_rect(IntRect()) 121 , m_visible(true) 122 { 123 124 static bool gstInitialized = false; 120 125 // FIXME: We should pass the arguments from the command line 121 gst_init(0, NULL); 126 if (!gstInitialized) { 127 gst_init(0, NULL); 128 gstInitialized = true; 129 } 130 131 // FIXME: The size shouldn't be fixed here, this is just a quick hack. 132 m_surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 640, 480); 122 133 } 123 134 124 135 MediaPlayerPrivate::~MediaPlayerPrivate() 125 136 { 126 gst_element_set_state(m_playBin, GST_STATE_NULL); 127 gst_object_unref(GST_OBJECT(m_playBin)); 137 if (m_surface) 138 cairo_surface_destroy(m_surface); 139 140 if (m_playBin) { 141 gst_element_set_state(m_playBin, GST_STATE_NULL); 142 gst_object_unref(GST_OBJECT(m_playBin)); 143 } 128 144 } 129 145 … … 193 209 194 210 float ret; 195 GstQuery* query; 196 gboolean res; 197 198 query = gst_query_new_position(GST_FORMAT_TIME); 199 res = gst_element_query(m_playBin, query); 200 if (res) { 211 212 GstQuery* query = gst_query_new_position(GST_FORMAT_TIME); 213 if (gst_element_query(m_playBin, query)) { 201 214 gint64 position; 202 215 gst_query_parse_position(query, NULL, &position); … … 208 221 } 209 222 gst_query_unref(query); 223 210 224 return ret; 211 225 } … … 243 257 LOG_VERBOSE(Media, "setEndTime: %" GST_TIME_FORMAT, GST_TIME_ARGS(end)); 244 258 // FIXME: What happens when the seeked position is not available? 245 if (!gst_element_seek( 259 if (!gst_element_seek(m_playBin, m_rate, 246 260 GST_FORMAT_TIME, 247 261 (GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE), … … 274 288 bool MediaPlayerPrivate::seeking() const 275 289 { 276 return false; ;290 return false; 277 291 } 278 292 … … 280 294 IntSize MediaPlayerPrivate::naturalSize() 281 295 { 296 if (!hasVideo()) 297 return IntSize(); 298 282 299 int x = 0, y = 0; 283 if (hasVideo()) { 284 GstPad* pad = NULL; 285 pad = gst_element_get_pad(m_videoSink, "sink"); 286 if (pad) 287 gst_video_get_size(GST_PAD(pad), &x, &y); 288 } 300 if (GstPad* pad = gst_element_get_static_pad(m_videoSink, "sink")) { 301 gst_video_get_size(GST_PAD(pad), &x, &y); 302 gst_object_unref(GST_OBJECT(pad)); 303 } 304 289 305 return IntSize(x, y); 290 306 } … … 307 323 void MediaPlayerPrivate::setMuted(bool b) 308 324 { 309 if (!m_playBin) 325 if (!m_playBin) 310 326 return; 311 327 … … 538 554 } 539 555 540 void MediaPlayerPrivate::setRect(const IntRect& r) 541 { 542 notImplemented(); 543 } 544 545 void MediaPlayerPrivate::setVisible(bool b) 546 { 547 notImplemented(); 548 } 549 550 void MediaPlayerPrivate::paint(GraphicsContext* p, const IntRect& r) 556 void MediaPlayerPrivate::setRect(const IntRect& rect) 557 { 558 m_rect = rect; 559 } 560 561 void MediaPlayerPrivate::setVisible(bool visible) 562 { 563 m_visible = visible; 564 } 565 566 void MediaPlayerPrivate::repaint() 567 { 568 m_player->repaint(); 569 } 570 571 void MediaPlayerPrivate::paint(GraphicsContext* context, const IntRect& rect) 572 { 573 if (context->paintingDisabled()) 574 return; 575 576 if (!m_visible) 577 return; 578 579 //TODO: m_rect vs rect? 580 cairo_t* cr = context->platformContext(); 581 582 cairo_save(cr); 583 cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); 584 cairo_translate(cr, rect.x(), rect.y()); 585 cairo_rectangle(cr, 0, 0, rect.width(), rect.height()); 586 cairo_set_source_surface(cr, m_surface, 0, 0); 587 cairo_fill(cr); 588 cairo_restore(cr); 589 } 590 591 void MediaPlayerPrivate::getSupportedTypes(HashSet<String>& types) 551 592 { 552 593 // FIXME: do the real thing 553 if (p->paintingDisabled())554 return;555 // For now draw a placeholder rectangle556 p->drawRect(r);557 }558 559 void MediaPlayerPrivate::getSupportedTypes(HashSet<String>& types)560 {561 // FIXME: do the real thing562 594 notImplemented(); 563 595 types.add(String("video/x-theora+ogg")); … … 566 598 void MediaPlayerPrivate::createGSTPlayBin(String url) 567 599 { 568 GstElement* audioSink; 569 GstBus* bus; 570 600 ASSERT(!m_playBin); 571 601 m_playBin = gst_element_factory_make("playbin", "play"); 572 602 573 bus = gst_pipeline_get_bus(GST_PIPELINE(m_playBin)); 574 603 GstBus* bus = gst_pipeline_get_bus(GST_PIPELINE(m_playBin)); 575 604 gst_bus_add_signal_watch(bus); 576 577 605 g_signal_connect(bus, "message::error", G_CALLBACK(mediaPlayerPrivateErrorCallback), this); 578 606 g_signal_connect(bus, "message::eos", G_CALLBACK(mediaPlayerPrivateEOSCallback), this); 579 607 g_signal_connect(bus, "message::state-changed", G_CALLBACK(mediaPlayerPrivateStateCallback), this); 580 608 g_signal_connect(bus, "message::buffering", G_CALLBACK(mediaPlayerPrivateBufferingCallback), this); 581 582 609 gst_object_unref(bus); 583 610 584 611 g_object_set(G_OBJECT(m_playBin), "uri", url.utf8().data(), NULL); 585 audioSink = gst_element_factory_make("gconfaudiosink", NULL); 586 m_videoSink = gst_element_factory_make("gconfvideosink", NULL); 612 613 GstElement* audioSink = gst_element_factory_make("gconfaudiosink", NULL); 614 m_videoSink = webkit_video_sink_new(m_surface); 587 615 588 616 g_object_set(m_playBin, "audio-sink", audioSink, NULL); -
trunk/WebCore/platform/graphics/gtk/MediaPlayerPrivateGStreamer.h
r28664 r28792 2 2 * Copyright (C) 2007 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2007 Collabora Ltd. All rights reserved. 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 4 5 * 5 6 * This library is free software; you can redistribute it and/or … … 26 27 #include "MediaPlayer.h" 27 28 #include "Timer.h" 28 #include "wtf/Noncopyable.h"29 29 30 30 #include <gtk/gtk.h> … … 52 52 53 53 public: 54 MediaPlayerPrivate(MediaPlayer* m);54 MediaPlayerPrivate(MediaPlayer*); 55 55 ~MediaPlayerPrivate(); 56 56 … … 69 69 float duration(); 70 70 float currentTime() const; 71 void seek(float time);72 void setEndTime(float time);71 void seek(float); 72 void setEndTime(float); 73 73 74 74 void setRate(float); … … 88 88 89 89 void setVisible(bool); 90 void setRect(const IntRect& r);90 void setRect(const IntRect&); 91 91 92 92 void loadStateChanged(); … … 98 98 void loadingFailed(); 99 99 100 void paint(GraphicsContext* p, const IntRect& r); 101 static void getSupportedTypes(HashSet<String>& types); 100 void repaint(); 101 void paint(GraphicsContext*, const IntRect&); 102 static void getSupportedTypes(HashSet<String>&); 102 103 103 104 private: … … 124 125 bool m_startedPlaying; 125 126 bool m_isStreaming; 127 IntRect m_rect; 128 bool m_visible; 129 cairo_surface_t* m_surface; 126 130 }; 127 131 }
Note: See TracChangeset
for help on using the changeset viewer.