1 | /* |
2 | * Copyright (C) 2013 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 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 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 MockMediaPlayerMediaSource_h |
27 | #define MockMediaPlayerMediaSource_h |
28 | |
29 | #if ENABLE(MEDIA_SOURCE) |
30 | |
31 | #include "MediaPlayerPrivate.h" |
32 | #include <wtf/Logger.h> |
33 | #include <wtf/MediaTime.h> |
34 | |
35 | namespace WebCore { |
36 | |
37 | class MediaSource; |
38 | class MockMediaSourcePrivate; |
39 | |
40 | class MockMediaPlayerMediaSource : public MediaPlayerPrivateInterface { |
41 | public: |
42 | explicit MockMediaPlayerMediaSource(MediaPlayer*); |
43 | |
44 | // MediaPlayer Engine Support |
45 | WEBCORE_EXPORT static void registerMediaEngine(MediaEngineRegistrar); |
46 | static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>& types); |
47 | static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&); |
48 | |
49 | virtual ~MockMediaPlayerMediaSource(); |
50 | |
51 | void advanceCurrentTime(); |
52 | void updateDuration(const MediaTime&); |
53 | |
54 | MediaPlayer::ReadyState readyState() const override; |
55 | void setReadyState(MediaPlayer::ReadyState); |
56 | void setNetworkState(MediaPlayer::NetworkState); |
57 | void waitForSeekCompleted(); |
58 | void seekCompleted(); |
59 | |
60 | #if !RELEASE_LOG_DISABLED |
61 | const void* mediaPlayerLogIdentifier() { return m_player->mediaPlayerLogIdentifier(); } |
62 | const Logger& mediaPlayerLogger() { return m_player->mediaPlayerLogger(); } |
63 | #endif |
64 | |
65 | private: |
66 | // MediaPlayerPrivate Overrides |
67 | void load(const String& url) override; |
68 | void load(const String& url, MediaSourcePrivateClient*) override; |
69 | #if ENABLE(MEDIA_STREAM) |
70 | void load(MediaStreamPrivate&) override { } |
71 | #endif |
72 | void cancelLoad() override; |
73 | void play() override; |
74 | void pause() override; |
75 | FloatSize naturalSize() const override; |
76 | bool hasVideo() const override; |
77 | bool hasAudio() const override; |
78 | void setVisible(bool) override; |
79 | bool seeking() const override; |
80 | bool paused() const override; |
81 | MediaPlayer::NetworkState networkState() const override; |
82 | MediaTime maxMediaTimeSeekable() const override; |
83 | std::unique_ptr<PlatformTimeRanges> buffered() const override; |
84 | bool didLoadingProgress() const override; |
85 | void setSize(const IntSize&) override; |
86 | void paint(GraphicsContext&, const FloatRect&) override; |
87 | MediaTime currentMediaTime() const override; |
88 | MediaTime durationMediaTime() const override; |
89 | void seekWithTolerance(const MediaTime&, const MediaTime&, const MediaTime&) override; |
90 | Optional<VideoPlaybackQualityMetrics> videoPlaybackQualityMetrics() override; |
91 | |
92 | MediaPlayer* m_player; |
93 | RefPtr<MockMediaSourcePrivate> m_mediaSourcePrivate; |
94 | |
95 | MediaTime m_currentTime; |
96 | MediaTime m_duration; |
97 | MediaPlayer::ReadyState m_readyState; |
98 | MediaPlayer::NetworkState m_networkState; |
99 | bool m_playing; |
100 | bool m_seekCompleted; |
101 | }; |
102 | |
103 | } |
104 | |
105 | #endif // ENABLE(MEDIA_SOURCE) |
106 | |
107 | #endif // MockMediaPlayerMediaSource_h |
108 | |
109 | |