tagging audio streams and changing audio sink to pulseaudio
[profile/ivi/webkit-efl.git] / Source / WebCore / platform / graphics / MediaPlayerPrivate.h
1 /*
2  * Copyright (C) 2009, 2010, 2011 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24  */
25
26 #ifndef MediaPlayerPrivate_h
27 #define MediaPlayerPrivate_h
28
29 #if ENABLE(VIDEO)
30
31 #include "MediaPlayer.h"
32 #include "TimeRanges.h"
33 #include <wtf/Forward.h>
34
35 namespace WebCore {
36
37 class IntRect;
38 class IntSize;
39
40 class MediaPlayerPrivateInterface {
41 #if !ENABLE(TIZEN_INHERIT_REF_COUNT_TO_TEXTURE_MAPPER_LAYER)
42     WTF_MAKE_NONCOPYABLE(MediaPlayerPrivateInterface); WTF_MAKE_FAST_ALLOCATED;
43 #endif
44 public:
45     MediaPlayerPrivateInterface() { }
46     virtual ~MediaPlayerPrivateInterface() { }
47
48     virtual void load(const String& url) = 0;
49     virtual void cancelLoad() = 0;
50     
51     virtual void prepareToPlay() { }
52     virtual PlatformMedia platformMedia() const { return NoPlatformMedia; }
53 #if USE(ACCELERATED_COMPOSITING)
54     virtual PlatformLayer* platformLayer() const { return 0; }
55 #endif
56
57     virtual void play() = 0;
58     virtual void pause() = 0;    
59
60     virtual bool supportsFullscreen() const { return false; }
61     virtual bool supportsSave() const { return false; }
62     virtual bool supportsScanning() const { return false; }
63
64     virtual IntSize naturalSize() const = 0;
65
66     virtual bool hasVideo() const = 0;
67     virtual bool hasAudio() const = 0;
68
69     virtual void setVisible(bool) = 0;
70
71     virtual float duration() const = 0;
72
73     virtual float currentTime() const = 0;
74     virtual void seek(float time) = 0;
75     virtual bool seeking() const = 0;
76
77     virtual float startTime() const { return 0; }
78
79     virtual double initialTime() const { return 0; }
80
81     virtual void setRate(float) = 0;
82     virtual void setPreservesPitch(bool) { }
83
84     virtual bool paused() const = 0;
85
86     virtual void setVolume(float) = 0;
87
88     virtual bool supportsMuting() const { return false; }
89     virtual void setMuted(bool) { }
90
91     virtual bool hasClosedCaptions() const { return false; }    
92     virtual void setClosedCaptionsVisible(bool) { }
93
94     virtual MediaPlayer::NetworkState networkState() const = 0;
95     virtual MediaPlayer::ReadyState readyState() const = 0;
96
97     virtual PassRefPtr<TimeRanges> seekable() const { return maxTimeSeekable() ? TimeRanges::create(0, maxTimeSeekable()) : TimeRanges::create(); }
98     virtual float maxTimeSeekable() const = 0;
99     virtual PassRefPtr<TimeRanges> buffered() const = 0;
100
101     virtual bool didLoadingProgress() const = 0;
102
103     virtual void setSize(const IntSize&) = 0;
104
105     virtual void paint(GraphicsContext*, const IntRect&) = 0;
106
107     virtual void paintCurrentFrameInContext(GraphicsContext* c, const IntRect& r) { paint(c, r); }
108
109     virtual void setPreload(MediaPlayer::Preload) { };
110
111     virtual bool hasAvailableVideoFrame() const { return readyState() >= MediaPlayer::HaveCurrentData; }
112
113     virtual bool canLoadPoster() const { return false; }
114     virtual void setPoster(const String&) { }
115
116 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO)
117     virtual void deliverNotification(MediaPlayerProxyNotificationType) = 0;
118     virtual void setMediaPlayerProxy(WebMediaPlayerProxy*) = 0;
119     virtual void setControls(bool) { }
120 #endif
121
122 #if ENABLE(PLUGIN_PROXY_FOR_VIDEO) || USE(NATIVE_FULLSCREEN_VIDEO)
123     virtual void enterFullscreen() { }
124     virtual void exitFullscreen() { }
125 #endif
126
127 #if USE(NATIVE_FULLSCREEN_VIDEO)
128     virtual bool canEnterFullscreen() const { return false; }
129 #endif
130
131 #if USE(ACCELERATED_COMPOSITING)
132     // whether accelerated rendering is supported by the media engine for the current media.
133     virtual bool supportsAcceleratedRendering() const { return false; }
134     // called when the rendering system flips the into or out of accelerated rendering mode.
135     virtual void acceleratedRenderingStateChanged() { }
136 #endif
137
138     virtual bool hasSingleSecurityOrigin() const { return false; }
139
140     virtual bool didPassCORSAccessCheck() const { return false; }
141
142     virtual MediaPlayer::MovieLoadType movieLoadType() const { return MediaPlayer::Unknown; }
143
144     virtual void prepareForRendering() { }
145
146     // Time value in the movie's time scale. It is only necessary to override this if the media
147     // engine uses rational numbers to represent media time.
148     virtual float mediaTimeForTimeValue(float timeValue) const { return timeValue; }
149
150     // Overide this if it is safe for HTMLMediaElement to cache movie time and report
151     // 'currentTime' as [cached time + elapsed wall time]. Returns the maximum wall time
152     // it is OK to calculate movie time before refreshing the cached time.
153     virtual double maximumDurationToCacheMediaTime() const { return 0; }
154
155     virtual unsigned decodedFrameCount() const { return 0; }
156     virtual unsigned droppedFrameCount() const { return 0; }
157     virtual unsigned audioDecodedByteCount() const { return 0; }
158     virtual unsigned videoDecodedByteCount() const { return 0; }
159
160     void getSitesInMediaCache(Vector<String>&) { }
161     void clearMediaCache() { }
162     void clearMediaCacheForSite(const String&) { }
163
164     virtual void setPrivateBrowsingMode(bool) { }
165
166     virtual String engineDescription() const { return emptyString(); }
167
168 #if ENABLE(WEB_AUDIO)
169     virtual AudioSourceProvider* audioSourceProvider() { return 0; }
170 #endif
171
172 #if ENABLE(MEDIA_SOURCE)
173     virtual MediaPlayer::AddIdStatus sourceAddId(const String& id, const String& type, const Vector<String>& codecs) { return MediaPlayer::NotSupported; }
174     virtual PassRefPtr<TimeRanges> sourceBuffered(const String& id) { return TimeRanges::create(); }
175     virtual bool sourceRemoveId(const String& id) { return false; }
176     virtual bool sourceAppend(const String& id, const unsigned char* data, unsigned length) { return false; }
177     virtual bool sourceAbort(const String& id) { return false; }
178     virtual void sourceEndOfStream(MediaPlayer::EndOfStreamStatus) { };
179 #endif
180
181 #if ENABLE(ENCRYPTED_MEDIA)
182     virtual MediaPlayer::MediaKeyException addKey(const String& keySystem, const unsigned char* key, unsigned keyLength, const unsigned char* initData, unsigned initDataLength, const String& sessionId) { return MediaPlayer::KeySystemNotSupported; }
183     virtual MediaPlayer::MediaKeyException generateKeyRequest(const String& keySystem, const unsigned char* initData, unsigned initDataLength) { return MediaPlayer::KeySystemNotSupported; }
184     virtual MediaPlayer::MediaKeyException cancelKeyRequest(const String& keySystem, const String& sessionId) { return MediaPlayer::KeySystemNotSupported; }
185 #endif
186 };
187
188 }
189
190 #endif
191 #endif