2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Collabora Ltd. All rights reserved.
4 * Copyright (C) 2007 Alp Toker <alp@atoker.com>
5 * Copyright (C) 2009, 2010 Igalia S.L
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * aint with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
23 #ifndef MediaPlayerPrivateGStreamer_h
24 #define MediaPlayerPrivateGStreamer_h
25 #if ENABLE(VIDEO) && USE(GSTREAMER)
27 #include <wtf/Forward.h>
28 #include "MediaPlayerPrivate.h"
34 typedef struct _WebKitVideoSink WebKitVideoSink;
35 typedef struct _GstBuffer GstBuffer;
36 typedef struct _GstMessage GstMessage;
37 typedef struct _GstElement GstElement;
41 class GraphicsContext;
44 class GStreamerGWorld;
45 class MediaPlayerPrivateGStreamer;
47 class MediaPlayerPrivateGStreamer : public MediaPlayerPrivateInterface {
50 ~MediaPlayerPrivateGStreamer();
51 static void registerMediaEngine(MediaEngineRegistrar);
52 gboolean handleMessage(GstMessage*);
54 IntSize naturalSize() const;
55 bool hasVideo() const { return m_hasVideo; }
56 bool hasAudio() const { return m_hasAudio; }
58 void load(const String &url);
69 float duration() const;
70 float currentTime() const;
75 void setVolume(float);
77 void notifyPlayerOfVolumeChange();
79 bool supportsMuting() const;
82 void notifyPlayerOfMute();
84 void setPreload(MediaPlayer::Preload);
85 void fillTimerFired(Timer<MediaPlayerPrivateGStreamer>*);
87 MediaPlayer::NetworkState networkState() const;
88 MediaPlayer::ReadyState readyState() const;
90 PassRefPtr<TimeRanges> buffered() const;
91 float maxTimeSeekable() const;
92 unsigned bytesLoaded() const;
93 unsigned totalBytes() const;
95 void setVisible(bool);
96 void setSize(const IntSize&);
98 void loadStateChanged();
102 void durationChanged();
103 void loadingFailed(MediaPlayer::NetworkState);
105 void triggerRepaint(GstBuffer*);
107 void paint(GraphicsContext*, const IntRect&);
109 bool hasSingleSecurityOrigin() const;
111 bool supportsFullscreen() const;
112 PlatformMedia platformMedia() const;
116 void notifyPlayerOfVideo();
117 void notifyPlayerOfAudio();
119 void sourceChanged();
121 unsigned decodedFrameCount() const;
122 unsigned droppedFrameCount() const;
123 unsigned audioDecodedByteCount() const;
124 unsigned videoDecodedByteCount() const;
127 MediaPlayerPrivateGStreamer(MediaPlayer*);
129 static PassOwnPtr<MediaPlayerPrivateInterface> create(MediaPlayer*);
131 static void getSupportedTypes(HashSet<String>&);
132 static MediaPlayer::SupportsType supportsType(const String& type, const String& codecs);
133 static bool isAvailable();
135 void updateAudioSink();
137 float playbackPosition() const;
139 void cacheDuration();
141 float maxTimeLoaded() const;
143 void createGSTPlayBin();
144 bool changePipelineState(GstState state);
146 bool loadNextLocation();
147 void mediaLocationChanged(GstMessage*);
149 void processBufferingStats(GstMessage*);
152 MediaPlayer* m_player;
153 GstElement* m_playBin;
154 GstElement* m_webkitVideoSink;
155 GstElement* m_videoSinkBin;
156 GstElement* m_fpsSink;
157 GstElement* m_source;
162 MediaPlayer::NetworkState m_networkState;
163 MediaPlayer::ReadyState m_readyState;
164 mutable bool m_isStreaming;
167 GstStructure* m_mediaLocations;
168 int m_mediaLocationCurrentIndex;
169 bool m_resetPipeline;
173 float m_playbackRate;
175 gfloat m_mediaDuration;
176 bool m_startedBuffering;
177 Timer<MediaPlayerPrivateGStreamer> m_fillTimer;
178 float m_maxTimeLoaded;
179 int m_bufferingPercentage;
180 MediaPlayer::Preload m_preload;
182 bool m_mediaDurationKnown;
183 RefPtr<GStreamerGWorld> m_gstGWorld;
184 guint m_volumeTimerHandler;
185 guint m_muteTimerHandler;
188 guint m_audioTimerHandler;
189 guint m_videoTimerHandler;
190 GstElement* m_webkitAudioSink;
194 #endif // USE(GSTREAMER)