1/* 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 6 * 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. 11 * 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. 16 * 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. 21 */ 22 23#ifndef MediaPlayerPrivateGStreamerBase_h 24#define MediaPlayerPrivateGStreamerBase_h 25#if ENABLE(VIDEO) && USE(GSTREAMER) 26 27#include "GRefPtrGStreamer.h" 28#include "MediaPlayerPrivate.h" 29 30#include <glib.h> 31 32#include <wtf/Forward.h> 33#include <wtf/gobject/GMainLoopSource.h> 34 35#if USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS) 36#include "TextureMapperPlatformLayer.h" 37#endif 38 39typedef struct _GstBuffer GstBuffer; 40typedef struct _GstElement GstElement; 41typedef struct _GstMessage GstMessage; 42typedef struct _GstStreamVolume GstStreamVolume; 43typedef struct _WebKitVideoSink WebKitVideoSink; 44 45namespace WebCore { 46 47class GraphicsContext; 48class IntSize; 49class IntRect; 50 51class MediaPlayerPrivateGStreamerBase : public MediaPlayerPrivateInterface 52#if USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS) 53 , public TextureMapperPlatformLayer 54#endif 55{ 56 57public: 58 virtual ~MediaPlayerPrivateGStreamerBase(); 59 60 IntSize naturalSize() const; 61 62 void setVolume(float); 63 float volume() const; 64 void volumeChanged(); 65 void notifyPlayerOfVolumeChange(); 66 67 bool supportsMuting() const { return true; } 68 void setMuted(bool); 69 bool muted() const; 70 void muteChanged(); 71 void notifyPlayerOfMute(); 72 73 MediaPlayer::NetworkState networkState() const; 74 MediaPlayer::ReadyState readyState() const; 75 76 void setVisible(bool) { } 77 void setSize(const IntSize&); 78 void sizeChanged(); 79 80 void triggerRepaint(GstBuffer*); 81 void paint(GraphicsContext*, const IntRect&); 82 83 virtual bool hasSingleSecurityOrigin() const { return true; } 84 virtual float maxTimeLoaded() const { return 0.0; } 85 86 bool supportsFullscreen() const; 87 PlatformMedia platformMedia() const; 88 89 MediaPlayer::MovieLoadType movieLoadType() const; 90 virtual bool isLiveStream() const = 0; 91 92 MediaPlayer* mediaPlayer() const { return m_player; } 93 94 unsigned decodedFrameCount() const; 95 unsigned droppedFrameCount() const; 96 unsigned audioDecodedByteCount() const; 97 unsigned videoDecodedByteCount() const; 98 99#if USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS) 100 virtual PlatformLayer* platformLayer() const { return const_cast<MediaPlayerPrivateGStreamerBase*>(this); } 101 virtual bool supportsAcceleratedRendering() const { return true; } 102 virtual void paintToTextureMapper(TextureMapper*, const FloatRect&, const TransformationMatrix&, float); 103#endif 104 105protected: 106 MediaPlayerPrivateGStreamerBase(MediaPlayer*); 107 virtual GstElement* createVideoSink(); 108 GRefPtr<GstCaps> currentVideoSinkCaps() const; 109 110 void setStreamVolumeElement(GstStreamVolume*); 111 virtual GstElement* createAudioSink() { return 0; } 112 virtual GstElement* audioSink() const { return 0; } 113 114 MediaPlayer* m_player; 115 GRefPtr<GstStreamVolume> m_volumeElement; 116 GRefPtr<GstElement> m_webkitVideoSink; 117 GRefPtr<GstElement> m_fpsSink; 118 MediaPlayer::ReadyState m_readyState; 119 MediaPlayer::NetworkState m_networkState; 120 IntSize m_size; 121 GMutex* m_bufferMutex; 122 GstBuffer* m_buffer; 123 GMainLoopSource m_volumeTimerHandler; 124 GMainLoopSource m_muteTimerHandler; 125 unsigned long m_repaintHandler; 126 unsigned long m_volumeSignalHandler; 127 unsigned long m_muteSignalHandler; 128 mutable IntSize m_videoSize; 129#if USE(TEXTURE_MAPPER_GL) && !USE(COORDINATED_GRAPHICS) 130 PassRefPtr<BitmapTexture> updateTexture(TextureMapper*); 131#endif 132}; 133} 134 135#endif // USE(GSTREAMER) 136#endif 137