Commit 98501fcd authored by kov@webkit.org's avatar kov@webkit.org

2009-07-30 Antonio Gomes <antonio.gomes@openbossa.org>

        Reviewed by Gustavo Noronha.

        [Gtk] Code cleanup in MediaPlayerPrivateGStreamer.cpp|h and VideoSinkGStreamer.cpp|h (Part 1)
        https://bugs.webkit.org/show_bug.cgi?id=27651

        Fixed many code style issues pointed by WebKitTools/Scripts/modules/cpplint.py
        No functionality change at all.

        * platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp:
        * platform/graphics/gtk/MediaPlayerPrivateGStreamer.h:
        * platform/graphics/gtk/VideoSinkGStreamer.cpp:
        * platform/graphics/gtk/VideoSinkGStreamer.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@46587 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b360c5f8
2009-07-30 Antonio Gomes <antonio.gomes@openbossa.org>
Reviewed by Gustavo Noronha.
[Gtk] Code cleanup in MediaPlayerPrivateGStreamer.cpp|h and VideoSinkGStreamer.cpp|h (Part 1)
https://bugs.webkit.org/show_bug.cgi?id=27651
Fixed many code style issues pointed by WebKitTools/Scripts/modules/cpplint.py
No functionality change at all.
* platform/graphics/gtk/MediaPlayerPrivateGStreamer.cpp:
* platform/graphics/gtk/MediaPlayerPrivateGStreamer.h:
* platform/graphics/gtk/VideoSinkGStreamer.cpp:
* platform/graphics/gtk/VideoSinkGStreamer.h:
2009-07-30 Jakub Wieczorek <faw217@gmail.com>
Reviewed by Simon Hausmann.
......
......@@ -24,7 +24,6 @@
#if ENABLE(VIDEO)
#include "MediaPlayerPrivateGStreamer.h"
#include "VideoSinkGStreamer.h"
#include "CString.h"
#include "GraphicsContext.h"
......@@ -34,8 +33,8 @@
#include "MediaPlayer.h"
#include "NotImplemented.h"
#include "ScrollView.h"
#include "VideoSinkGStreamer.h"
#include "Widget.h"
#include <wtf/GOwnPtr.h>
#include <gdk/gdkx.h>
#include <gst/base/gstbasesrc.h>
......@@ -45,6 +44,7 @@
#include <gst/video/video.h>
#include <limits>
#include <math.h>
#include <wtf/GOwnPtr.h>
using namespace std;
......@@ -52,8 +52,7 @@ namespace WebCore {
gboolean mediaPlayerPrivateErrorCallback(GstBus* bus, GstMessage* message, gpointer data)
{
if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_ERROR)
{
if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_ERROR) {
GOwnPtr<GError> err;
GOwnPtr<gchar> debug;
......@@ -71,8 +70,7 @@ gboolean mediaPlayerPrivateErrorCallback(GstBus* bus, GstMessage* message, gpoin
gboolean mediaPlayerPrivateEOSCallback(GstBus* bus, GstMessage* message, gpointer data)
{
if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_EOS)
{
if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_EOS) {
LOG_VERBOSE(Media, "End of Stream");
MediaPlayerPrivate* mp = reinterpret_cast<MediaPlayerPrivate*>(data);
mp->didEnd();
......@@ -82,8 +80,7 @@ gboolean mediaPlayerPrivateEOSCallback(GstBus* bus, GstMessage* message, gpointe
gboolean mediaPlayerPrivateStateCallback(GstBus* bus, GstMessage* message, gpointer data)
{
if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_STATE_CHANGED)
{
if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_STATE_CHANGED) {
MediaPlayerPrivate* mp = reinterpret_cast<MediaPlayerPrivate*>(data);
mp->updateStates();
}
......@@ -92,8 +89,7 @@ gboolean mediaPlayerPrivateStateCallback(GstBus* bus, GstMessage* message, gpoin
gboolean mediaPlayerPrivateBufferingCallback(GstBus* bus, GstMessage* message, gpointer data)
{
if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_BUFFERING)
{
if (GST_MESSAGE_TYPE(message) == GST_MESSAGE_BUFFERING) {
gint percent = 0;
gst_message_parse_buffering(message, &percent);
LOG_VERBOSE(Media, "Buffering %d", percent);
......@@ -106,8 +102,8 @@ static void mediaPlayerPrivateRepaintCallback(WebKitVideoSink*, MediaPlayerPriva
playerPrivate->repaint();
}
MediaPlayerPrivateInterface* MediaPlayerPrivate::create(MediaPlayer* player)
{
MediaPlayerPrivateInterface* MediaPlayerPrivate::create(MediaPlayer* player)
{
return new MediaPlayerPrivate(player);
}
......@@ -137,7 +133,7 @@ MediaPlayerPrivate::MediaPlayerPrivate(MediaPlayer* player)
static bool gstInitialized = false;
// FIXME: We should pass the arguments from the command line
if (!gstInitialized) {
gst_init(0, NULL);
gst_init(0, 0);
gstInitialized = true;
}
......@@ -229,7 +225,7 @@ float MediaPlayerPrivate::currentTime() const
GstQuery* query = gst_query_new_position(GST_FORMAT_TIME);
if (gst_element_query(m_playBin, query)) {
gint64 position;
gst_query_parse_position(query, NULL, &position);
gst_query_parse_position(query, 0, &position);
ret = (float) (position / 1000000000.0);
LOG_VERBOSE(Media, "Position %" GST_TIME_FORMAT, GST_TIME_ARGS(position));
} else {
......@@ -277,7 +273,7 @@ void MediaPlayerPrivate::setEndTime(float time)
GST_FORMAT_TIME,
(GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_ACCURATE),
GST_SEEK_TYPE_SET, start,
GST_SEEK_TYPE_SET, end ))
GST_SEEK_TYPE_SET, end))
LOG_VERBOSE(Media, "Seek to %f failed", time);
}
}
......@@ -345,9 +341,9 @@ void MediaPlayerPrivate::setMuted(bool b)
if (b) {
g_object_get(G_OBJECT(m_playBin), "volume", &m_volume, NULL);
g_object_set(G_OBJECT(m_playBin), "volume", (double)0.0, NULL);
} else {
} else
g_object_set(G_OBJECT(m_playBin), "volume", m_volume, NULL);
}
}
void MediaPlayerPrivate::setRate(float rate)
......@@ -465,10 +461,10 @@ void MediaPlayerPrivate::updateStates()
if (!m_playBin)
return;
GstStateChangeReturn ret = gst_element_get_state (m_playBin,
GstStateChangeReturn ret = gst_element_get_state(m_playBin,
&state, &pending, 250 * GST_NSECOND);
switch(ret) {
switch (ret) {
case GST_STATE_CHANGE_SUCCESS:
LOG_VERBOSE(Media, "State: %s, pending: %s",
gst_element_state_get_name(state),
......@@ -476,14 +472,14 @@ void MediaPlayerPrivate::updateStates()
if (state == GST_STATE_READY) {
m_readyState = MediaPlayer::HaveEnoughData;
} else if (state == GST_STATE_PAUSED) {
} else if (state == GST_STATE_PAUSED)
m_readyState = MediaPlayer::HaveEnoughData;
}
m_networkState = MediaPlayer::Loaded;
g_object_get(m_playBin, "source", &m_source, NULL);
if (!m_source)
LOG_VERBOSE(Media, "m_source is NULL");
LOG_VERBOSE(Media, "m_source is 0");
break;
case GST_STATE_CHANGE_ASYNC:
LOG_VERBOSE(Media, "Async: State: %s, pending: %s",
......@@ -498,9 +494,9 @@ void MediaPlayerPrivate::updateStates()
gst_element_state_get_name(pending));
if (state == GST_STATE_READY) {
m_readyState = MediaPlayer::HaveFutureData;
} else if (state == GST_STATE_PAUSED) {
} else if (state == GST_STATE_PAUSED)
m_readyState = MediaPlayer::HaveCurrentData;
}
m_networkState = MediaPlayer::Loading;
break;
default:
......@@ -632,7 +628,7 @@ void MediaPlayerPrivate::createGSTPlayBin(String url)
g_object_set(G_OBJECT(m_playBin), "uri", url.utf8().data(), NULL);
GstElement* audioSink = gst_element_factory_make("gconfaudiosink", NULL);
GstElement* audioSink = gst_element_factory_make("gconfaudiosink", 0);
m_videoSink = webkit_video_sink_new(m_surface);
g_object_set(m_playBin, "audio-sink", audioSink, NULL);
......
......@@ -44,96 +44,93 @@ namespace WebCore {
gboolean mediaPlayerPrivateEOSCallback(GstBus* bus, GstMessage* message, gpointer data);
gboolean mediaPlayerPrivateStateCallback(GstBus* bus, GstMessage* message, gpointer data);
class MediaPlayerPrivate : public MediaPlayerPrivateInterface
{
friend gboolean mediaPlayerPrivateErrorCallback(GstBus* bus, GstMessage* message, gpointer data);
friend gboolean mediaPlayerPrivateEOSCallback(GstBus* bus, GstMessage* message, gpointer data);
friend gboolean mediaPlayerPrivateStateCallback(GstBus* bus, GstMessage* message, gpointer data);
public:
static void registerMediaEngine(MediaEngineRegistrar);
~MediaPlayerPrivate();
IntSize naturalSize() const;
bool hasVideo() const;
void load(const String &url);
void cancelLoad();
void play();
void pause();
bool paused() const;
bool seeking() const;
float duration() const;
float currentTime() const;
void seek(float);
void setEndTime(float);
void setRate(float);
void setVolume(float);
void setMuted(bool);
int dataRate() const;
MediaPlayer::NetworkState networkState() const;
MediaPlayer::ReadyState readyState() const;
float maxTimeBuffered() const;
float maxTimeSeekable() const;
unsigned bytesLoaded() const;
bool totalBytesKnown() const;
unsigned totalBytes() const;
void setVisible(bool);
void setSize(const IntSize&);
void loadStateChanged();
void rateChanged();
void sizeChanged();
void timeChanged();
void volumeChanged();
void didEnd();
void loadingFailed();
void repaint();
void paint(GraphicsContext*, const IntRect&);
private:
MediaPlayerPrivate(MediaPlayer*);
static MediaPlayerPrivateInterface* create(MediaPlayer* player);
static void getSupportedTypes(HashSet<String>&);
static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs);
static bool isAvailable() { return true; }
void updateStates();
void cancelSeek();
void endPointTimerFired(Timer<MediaPlayerPrivate>*);
float maxTimeLoaded() const;
void startEndPointTimerIfNeeded();
void createGSTPlayBin(String url);
private:
MediaPlayer* m_player;
GstElement* m_playBin;
GstElement* m_videoSink;
GstElement* m_source;
float m_rate;
float m_endTime;
bool m_isEndReached;
double m_volume;
MediaPlayer::NetworkState m_networkState;
MediaPlayer::ReadyState m_readyState;
bool m_startedPlaying;
mutable bool m_isStreaming;
IntSize m_size;
bool m_visible;
cairo_surface_t* m_surface;
class MediaPlayerPrivate : public MediaPlayerPrivateInterface {
friend gboolean mediaPlayerPrivateErrorCallback(GstBus* bus, GstMessage* message, gpointer data);
friend gboolean mediaPlayerPrivateEOSCallback(GstBus* bus, GstMessage* message, gpointer data);
friend gboolean mediaPlayerPrivateStateCallback(GstBus* bus, GstMessage* message, gpointer data);
public:
static void registerMediaEngine(MediaEngineRegistrar);
~MediaPlayerPrivate();
IntSize naturalSize() const;
bool hasVideo() const;
void load(const String &url);
void cancelLoad();
void play();
void pause();
bool paused() const;
bool seeking() const;
float duration() const;
float currentTime() const;
void seek(float);
void setEndTime(float);
void setRate(float);
void setVolume(float);
void setMuted(bool);
int dataRate() const;
MediaPlayer::NetworkState networkState() const;
MediaPlayer::ReadyState readyState() const;
float maxTimeBuffered() const;
float maxTimeSeekable() const;
unsigned bytesLoaded() const;
bool totalBytesKnown() const;
unsigned totalBytes() const;
void setVisible(bool);
void setSize(const IntSize&);
void loadStateChanged();
void rateChanged();
void sizeChanged();
void timeChanged();
void volumeChanged();
void didEnd();
void loadingFailed();
void repaint();
void paint(GraphicsContext*, const IntRect&);
private:
MediaPlayerPrivate(MediaPlayer*);
static MediaPlayerPrivateInterface* create(MediaPlayer* player);
static void getSupportedTypes(HashSet<String>&);
static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs);
static bool isAvailable() { return true; }
void updateStates();
void cancelSeek();
void endPointTimerFired(Timer<MediaPlayerPrivate>*);
float maxTimeLoaded() const;
void startEndPointTimerIfNeeded();
void createGSTPlayBin(String url);
private:
MediaPlayer* m_player;
GstElement* m_playBin;
GstElement* m_videoSink;
GstElement* m_source;
float m_rate;
float m_endTime;
bool m_isEndReached;
double m_volume;
MediaPlayer::NetworkState m_networkState;
MediaPlayer::ReadyState m_readyState;
bool m_startedPlaying;
mutable bool m_isStreaming;
IntSize m_size;
bool m_visible;
cairo_surface_t* m_surface;
};
}
......
......@@ -40,10 +40,10 @@ GST_DEBUG_CATEGORY_STATIC(webkit_video_sink_debug);
#define GST_CAT_DEFAULT webkit_video_sink_debug
static GstElementDetails webkit_video_sink_details =
GST_ELEMENT_DETAILS((gchar*) "WebKit video sink",
(gchar*) "Sink/Video",
(gchar*) "Sends video data from a GStreamer pipeline to a Cairo surface",
(gchar*) "Alp Toker <alp@atoker.com>");
GST_ELEMENT_DETAILS((gchar*) "WebKit video sink",
(gchar*) "Sink/Video",
(gchar*) "Sends video data from a GStreamer pipeline to a Cairo surface",
(gchar*) "Alp Toker <alp@atoker.com>");
enum {
REPAINT_REQUESTED,
......@@ -70,10 +70,10 @@ struct _WebKitVideoSinkPrivate {
};
#define _do_init(bla) \
GST_DEBUG_CATEGORY_INIT (webkit_video_sink_debug, \
"webkitsink", \
0, \
"webkit video sink")
GST_DEBUG_CATEGORY_INIT(webkit_video_sink_debug, \
"webkitsink", \
0, \
"webkit video sink")
GST_BOILERPLATE_FULL(WebKitVideoSink,
webkit_video_sink,
......@@ -110,11 +110,11 @@ webkit_video_sink_idle_func(gpointer data)
return FALSE;
buffer = (GstBuffer*)g_async_queue_try_pop(priv->async_queue);
if (buffer == NULL || G_UNLIKELY(!GST_IS_BUFFER(buffer)))
if (!buffer || G_UNLIKELY(!GST_IS_BUFFER(buffer)))
return FALSE;
// TODO: consider priv->rgb_ordering?
cairo_surface_t* src = cairo_image_surface_create_for_data(GST_BUFFER_DATA(buffer), CAIRO_FORMAT_RGB24, priv->width, priv->height, (4 * priv->width + 3) & ~ 3);
cairo_surface_t* src = cairo_image_surface_create_for_data(GST_BUFFER_DATA(buffer), CAIRO_FORMAT_RGB24, priv->width, priv->height, (4 * priv->width + 3) & ~3);
// TODO: We copy the data twice right now. This could be easily improved.
cairo_t* cr = cairo_create(priv->surface);
......@@ -139,7 +139,7 @@ webkit_video_sink_render(GstBaseSink* bsink, GstBuffer* buffer)
WebKitVideoSinkPrivate* priv = sink->priv;
g_async_queue_push(priv->async_queue, gst_buffer_ref(buffer));
g_idle_add_full(G_PRIORITY_HIGH_IDLE, webkit_video_sink_idle_func, sink, NULL);
g_idle_add_full(G_PRIORITY_HIGH_IDLE, webkit_video_sink_idle_func, sink, 0);
return GST_FLOW_OK;
}
......@@ -168,7 +168,7 @@ webkit_video_sink_set_caps(GstBaseSink* bsink, GstCaps* caps)
ret = gst_structure_get_int(structure, "width", &width);
ret &= gst_structure_get_int(structure, "height", &height);
fps = gst_structure_get_value(structure, "framerate");
ret &= (fps != NULL);
ret &= (fps != 0);
par = gst_structure_get_value(structure, "pixel-aspect-ratio");
......@@ -202,12 +202,12 @@ webkit_video_sink_dispose(GObject* object)
if (priv->surface) {
cairo_surface_destroy(priv->surface);
priv->surface = NULL;
priv->surface = 0;
}
if (priv->async_queue) {
g_async_queue_unref(priv->async_queue);
priv->async_queue = NULL;
priv->async_queue = 0;
}
G_OBJECT_CLASS(parent_class)->dispose(object);
......@@ -260,7 +260,7 @@ webkit_video_sink_stop(GstBaseSink* base_sink)
g_async_queue_lock(priv->async_queue);
/* Remove all remaining objects from the queue */
while(GstBuffer* buffer = (GstBuffer*)g_async_queue_try_pop_unlocked(priv->async_queue))
while (GstBuffer* buffer = (GstBuffer*)g_async_queue_try_pop_unlocked(priv->async_queue))
gst_buffer_unref(buffer);
g_async_queue_unlock(priv->async_queue);
......@@ -291,8 +291,8 @@ webkit_video_sink_class_init(WebKitVideoSinkClass* klass)
G_TYPE_FROM_CLASS(klass),
(GSignalFlags)(G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION),
0,
NULL,
NULL,
0,
0,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
......@@ -314,7 +314,7 @@ webkit_video_sink_class_init(WebKitVideoSinkClass* klass)
GstElement*
webkit_video_sink_new(cairo_surface_t* surface)
{
return (GstElement*)g_object_new(WEBKIT_TYPE_VIDEO_SINK, "surface", surface, NULL);
return (GstElement*)g_object_new(WEBKIT_TYPE_VIDEO_SINK, "surface", surface, 0);
}
void
......
......@@ -29,54 +29,52 @@ G_BEGIN_DECLS
#define WEBKIT_TYPE_VIDEO_SINK webkit_video_sink_get_type()
#define WEBKIT_VIDEO_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
WEBKIT_TYPE_VIDEO_SINK, WebKitVideoSink))
(G_TYPE_CHECK_INSTANCE_CAST((obj), \
WEBKIT_TYPE_VIDEO_SINK, WebKitVideoSink))
#define WEBKIT_VIDEO_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
WEBKIT_TYPE_VIDEO_SINK, WebKitVideoSinkClass))
(G_TYPE_CHECK_CLASS_CAST((klass), \
WEBKIT_TYPE_VIDEO_SINK, WebKitVideoSinkClass))
#define WEBKIT_IS_VIDEO_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
WEBKIT_TYPE_VIDEO_SINK))
(G_TYPE_CHECK_INSTANCE_TYPE((obj), \
WEBKIT_TYPE_VIDEO_SINK))
#define WEBKIT_IS_VIDEO_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
WEBKIT_TYPE_VIDEO_SINK))
(G_TYPE_CHECK_CLASS_TYPE((klass), \
WEBKIT_TYPE_VIDEO_SINK))
#define WEBKIT_VIDEO_SINK_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
WEBKIT_TYPE_VIDEO_SINK, WebKitVideoSinkClass))
(G_TYPE_INSTANCE_GET_CLASS((obj), \
WEBKIT_TYPE_VIDEO_SINK, WebKitVideoSinkClass))
typedef struct _WebKitVideoSink WebKitVideoSink;
typedef struct _WebKitVideoSinkClass WebKitVideoSinkClass;
typedef struct _WebKitVideoSinkPrivate WebKitVideoSinkPrivate;
struct _WebKitVideoSink
{
/*< private >*/
GstBaseSink parent;
WebKitVideoSinkPrivate *priv;
struct _WebKitVideoSink {
/*< private >*/
GstBaseSink parent;
WebKitVideoSinkPrivate *priv;
};
struct _WebKitVideoSinkClass
{
/*< private >*/
GstBaseSinkClass parent_class;
/* Future padding */
void (* _webkit_reserved1) (void);
void (* _webkit_reserved2) (void);
void (* _webkit_reserved3) (void);
void (* _webkit_reserved4) (void);
void (* _webkit_reserved5) (void);
void (* _webkit_reserved6) (void);
struct _WebKitVideoSinkClass {
/*< private >*/
GstBaseSinkClass parent_class;
/* Future padding */
void (* _webkit_reserved1)(void);
void (* _webkit_reserved2)(void);
void (* _webkit_reserved3)(void);
void (* _webkit_reserved4)(void);
void (* _webkit_reserved5)(void);
void (* _webkit_reserved6)(void);
};
GType webkit_video_sink_get_type (void) G_GNUC_CONST;
GstElement *webkit_video_sink_new (cairo_surface_t *surface);
GType webkit_video_sink_get_type(void) G_GNUC_CONST;
GstElement *webkit_video_sink_new(cairo_surface_t *surface);
void webkit_video_sink_set_surface (WebKitVideoSink *sink, cairo_surface_t *surface);
void webkit_video_sink_set_surface(WebKitVideoSink *sink, cairo_surface_t *surface);
G_END_DECLS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment