1/*
2 *  Copyright (C) 2010 Igalia S.L
3 *
4 *  This library is free software; you can redistribute it and/or
5 *  modify it under the terms of the GNU Library General Public
6 *  License as published by the Free Software Foundation; either
7 *  version 2 of the License, or (at your option) any later version.
8 *
9 *  This library is distributed in the hope that it will be useful,
10 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 *  Library General Public License for more details.
13 *
14 *  You should have received a copy of the GNU Library General Public License
15 *  along with this library; see the file COPYING.LIB.  If not, write to
16 *  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 *  Boston, MA 02110-1301, USA.
18 */
19
20#ifndef FullscreenVideoController_h
21#define FullscreenVideoController_h
22
23#if ENABLE(VIDEO)
24
25#include "GRefPtr.h"
26#include "GStreamerGWorld.h"
27#include "HTMLMediaElement.h"
28#include <wtf/RefPtr.h>
29
30class FullscreenVideoController {
31    WTF_MAKE_NONCOPYABLE(FullscreenVideoController);
32public:
33    FullscreenVideoController();
34    virtual ~FullscreenVideoController();
35
36    void setMediaElement(WebCore::HTMLMediaElement*);
37    WebCore::HTMLMediaElement* mediaElement() const { return m_mediaElement.get(); }
38
39    void gtkConfigure(GdkEventConfigure* event);
40
41    void enterFullscreen();
42    void exitFullscreen();
43
44    void exitOnUserRequest();
45    void togglePlay();
46    void beginSeek();
47    void doSeek();
48    void endSeek();
49
50    void hideHud();
51    void showHud(bool);
52    gboolean updateHudProgressBar();
53
54    float volume() const;
55    void setVolume(float);
56    void volumeChanged();
57    void muteChanged();
58
59private:
60    bool canPlay() const;
61    void play();
62    void pause();
63    void playStateChanged();
64
65    bool muted() const;
66
67    float currentTime() const;
68    void setCurrentTime(float);
69
70    float duration() const;
71    float percentLoaded() const;
72
73    void createHud();
74    void updateHudPosition();
75
76    RefPtr<WebCore::HTMLMediaElement> m_mediaElement;
77    RefPtr<WebCore::GStreamerGWorld> m_gstreamerGWorld;
78
79    guint m_hudTimeoutId;
80    guint m_progressBarUpdateId;
81    guint m_progressBarFillUpdateId;
82    guint m_hscaleUpdateId;
83    guint m_volumeUpdateId;
84    bool m_seekLock;
85    GtkWidget* m_window;
86    GtkWidget* m_hudWindow;
87    GtkAction* m_playPauseAction;
88    GtkAction* m_exitFullscreenAction;
89    GtkWidget* m_timeHScale;
90    GtkWidget* m_timeLabel;
91    GtkWidget* m_volumeButton;
92};
93
94#endif
95
96#endif // FullscreenVideoController_h
97