| 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, 2016 Igalia S.L |
| 6 | * Copyright (C) 2015 Sebastian Dröge <sebastian@centricular.com> |
| 7 | * Copyright (C) 2015, 2016 Metrological Group B.V. |
| 8 | * |
| 9 | * This library is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU Library General Public |
| 11 | * License as published by the Free Software Foundation; either |
| 12 | * version 2 of the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This library is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * Library General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Library General Public License |
| 20 | * aint with this library; see the file COPYING.LIB. If not, write to |
| 21 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 22 | * Boston, MA 02110-1301, USA. |
| 23 | */ |
| 24 | |
| 25 | #pragma once |
| 26 | |
| 27 | #if ENABLE(VIDEO) && USE(GSTREAMER) && ENABLE(MEDIA_SOURCE) |
| 28 | |
| 29 | #include "GStreamerCommon.h" |
| 30 | #include "MediaPlayerPrivateGStreamer.h" |
| 31 | #include "MediaSample.h" |
| 32 | #include "MediaSourceGStreamer.h" |
| 33 | #include "WebKitMediaSourceGStreamer.h" |
| 34 | |
| 35 | namespace WebCore { |
| 36 | |
| 37 | class MediaSourceClientGStreamerMSE; |
| 38 | class AppendPipeline; |
| 39 | class PlaybackPipeline; |
| 40 | |
| 41 | class MediaPlayerPrivateGStreamerMSE : public MediaPlayerPrivateGStreamer { |
| 42 | WTF_MAKE_NONCOPYABLE(MediaPlayerPrivateGStreamerMSE); WTF_MAKE_FAST_ALLOCATED; |
| 43 | |
| 44 | friend class MediaSourceClientGStreamerMSE; |
| 45 | |
| 46 | public: |
| 47 | explicit MediaPlayerPrivateGStreamerMSE(MediaPlayer*); |
| 48 | virtual ~MediaPlayerPrivateGStreamerMSE(); |
| 49 | |
| 50 | static void registerMediaEngine(MediaEngineRegistrar); |
| 51 | |
| 52 | void load(const String&) override; |
| 53 | void load(const String&, MediaSourcePrivateClient*) override; |
| 54 | |
| 55 | void setDownloadBuffering() override { }; |
| 56 | |
| 57 | bool isLiveStream() const override { return false; } |
| 58 | MediaTime currentMediaTime() const override; |
| 59 | |
| 60 | void pause() override; |
| 61 | bool seeking() const override; |
| 62 | void seek(const MediaTime&) override; |
| 63 | void configurePlaySink() override; |
| 64 | bool changePipelineState(GstState) override; |
| 65 | |
| 66 | void durationChanged() override; |
| 67 | MediaTime durationMediaTime() const override; |
| 68 | |
| 69 | void setRate(float) override; |
| 70 | std::unique_ptr<PlatformTimeRanges> buffered() const override; |
| 71 | MediaTime maxMediaTimeSeekable() const override; |
| 72 | |
| 73 | void sourceSetup(GstElement*) override; |
| 74 | |
| 75 | void setReadyState(MediaPlayer::ReadyState); |
| 76 | void waitForSeekCompleted(); |
| 77 | void seekCompleted(); |
| 78 | MediaSourcePrivateClient* mediaSourcePrivateClient() { return m_mediaSource.get(); } |
| 79 | |
| 80 | void markEndOfStream(MediaSourcePrivate::EndOfStreamStatus); |
| 81 | |
| 82 | void trackDetected(RefPtr<AppendPipeline>, RefPtr<WebCore::TrackPrivateBase>, bool firstTrackDetected); |
| 83 | void notifySeekNeedsDataForTime(const MediaTime&); |
| 84 | |
| 85 | void blockDurationChanges(); |
| 86 | void unblockDurationChanges(); |
| 87 | |
| 88 | private: |
| 89 | static void getSupportedTypes(HashSet<String, ASCIICaseInsensitiveHash>&); |
| 90 | static MediaPlayer::SupportsType supportsType(const MediaEngineSupportParameters&); |
| 91 | |
| 92 | // FIXME: Reduce code duplication. |
| 93 | void updateStates() override; |
| 94 | |
| 95 | bool doSeek(const MediaTime&, float, GstSeekFlags) override; |
| 96 | bool doSeek(); |
| 97 | void maybeFinishSeek(); |
| 98 | void updatePlaybackRate() override; |
| 99 | void asyncStateChangeDone() override; |
| 100 | |
| 101 | // FIXME: Implement videoPlaybackQualityMetrics. |
| 102 | bool isTimeBuffered(const MediaTime&) const; |
| 103 | |
| 104 | bool isMediaSource() const override { return true; } |
| 105 | |
| 106 | void setMediaSourceClient(Ref<MediaSourceClientGStreamerMSE>); |
| 107 | RefPtr<MediaSourceClientGStreamerMSE> mediaSourceClient(); |
| 108 | |
| 109 | HashMap<RefPtr<SourceBufferPrivateGStreamer>, RefPtr<AppendPipeline>> m_appendPipelinesMap; |
| 110 | bool m_eosMarked = false; |
| 111 | mutable bool m_eosPending = false; |
| 112 | bool m_gstSeekCompleted = true; |
| 113 | RefPtr<MediaSourcePrivateClient> m_mediaSource; |
| 114 | RefPtr<MediaSourceClientGStreamerMSE> m_mediaSourceClient; |
| 115 | MediaTime m_mediaTimeDuration; |
| 116 | bool m_mseSeekCompleted = true; |
| 117 | bool m_areDurationChangesBlocked = false; |
| 118 | bool m_shouldReportDurationWhenUnblocking = false; |
| 119 | RefPtr<PlaybackPipeline> m_playbackPipeline; |
| 120 | }; |
| 121 | |
| 122 | } // namespace WebCore |
| 123 | |
| 124 | #endif // USE(GSTREAMER) |
| 125 | |