1/*
2 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in the
12 *    documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#ifndef MediaPlayerPrivateWinCE_h
28#define MediaPlayerPrivateWinCE_h
29
30#if ENABLE(VIDEO)
31
32#include <wtf/Forward.h>
33#include "MediaPlayerPrivate.h"
34#include "Timer.h"
35#include <wtf/OwnPtr.h>
36
37namespace WebCore {
38
39    class GraphicsContext;
40    class IntSize;
41    class IntRect;
42
43    class MediaPlayerPrivate : public MediaPlayerPrivateInterface {
44    public:
45        static void registerMediaEngine(MediaEngineRegistrar);
46
47        ~MediaPlayerPrivate();
48
49        IntSize naturalSize() const;
50        bool hasVideo() const;
51
52        void load(const String& url);
53        void cancelLoad();
54
55        void play();
56        void pause();
57
58        bool paused() const;
59        bool seeking() const;
60
61        float duration() const;
62        float currentTime() const;
63        void seek(float time);
64
65        void setRate(float);
66        void setVolume(float);
67
68        MediaPlayer::NetworkState networkState() const { return m_networkState; }
69        MediaPlayer::ReadyState readyState() const { return m_readyState; }
70
71        std::unique_ptr<PlatformTimeRanges> buffered() const;
72        float maxTimeSeekable() const;
73        // FIXME: bytesLoaded() should be replaced with didLoadingProgress() (by somebody who can find the implementation of this class).
74        unsigned bytesLoaded() const;
75        unsigned totalBytes() const;
76
77        void setVisible(bool);
78        void setSize(const IntSize&);
79
80        void loadStateChanged();
81        void didEnd();
82
83        void paint(GraphicsContext*, const IntRect&);
84
85    private:
86        MediaPlayerPrivate(MediaPlayer*);
87
88        void updateStates();
89        void doSeek();
90        void cancelSeek();
91        void seekTimerFired(Timer<MediaPlayerPrivate>*);
92        float maxTimeLoaded() const;
93        void sawUnsupportedTracks();
94
95        // engine support
96        static PassOwnPtr<MediaPlayerPrivateInterface> create(MediaPlayer*);
97        static void getSupportedTypes(HashSet<String>& types);
98        static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&);
99        static bool isAvailable();
100
101        virtual String engineDescription() const { return "WinCE"; }
102
103        MediaPlayer* m_player;
104        float m_seekTo;
105        float m_endTime;
106        Timer<MediaPlayerPrivate> m_seekTimer;
107        MediaPlayer::NetworkState m_networkState;
108        MediaPlayer::ReadyState m_readyState;
109        unsigned m_enabledTrackCount;
110        unsigned m_totalTrackCount;
111        bool m_hasUnsupportedTracks;
112        bool m_startedPlaying;
113        bool m_isStreaming;
114    };
115
116}
117
118#endif // ENABLE(VIDEO)
119
120#endif // MediaPlayerPrivateWinCE_h
121