1 | /* |
2 | * Copyright (C) 2013 Google Inc. All rights reserved. |
3 | * Copyright (C) 2013 Orange |
4 | * Copyright (C) 2014 Sebastian Dröge <sebastian@centricular.com> |
5 | * Copyright (C) 2015, 2016 Metrological Group B.V. |
6 | * Copyright (C) 2015, 2016 Igalia, S.L |
7 | * |
8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions are |
10 | * met: |
11 | * |
12 | * * Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. |
14 | * * Redistributions in binary form must reproduce the above |
15 | * copyright notice, this list of conditions and the following disclaimer |
16 | * in the documentation and/or other materials provided with the |
17 | * distribution. |
18 | * * Neither the name of Google Inc. nor the names of its |
19 | * contributors may be used to endorse or promote products derived from |
20 | * this software without specific prior written permission. |
21 | * |
22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
25 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
26 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
27 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
28 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
29 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
30 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
31 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
32 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
33 | */ |
34 | |
35 | #pragma once |
36 | |
37 | #if ENABLE(MEDIA_SOURCE) && USE(GSTREAMER) |
38 | #include "MediaSourcePrivate.h" |
39 | |
40 | #include <wtf/Forward.h> |
41 | #include <wtf/HashSet.h> |
42 | |
43 | typedef struct _WebKitMediaSrc WebKitMediaSrc; |
44 | |
45 | namespace WebCore { |
46 | |
47 | class SourceBufferPrivateGStreamer; |
48 | class MediaSourceClientGStreamerMSE; |
49 | class MediaPlayerPrivateGStreamerMSE; |
50 | class PlatformTimeRanges; |
51 | |
52 | // FIXME: Should this be called MediaSourcePrivateGStreamer? |
53 | class MediaSourceGStreamer final : public MediaSourcePrivate { |
54 | public: |
55 | static void open(MediaSourcePrivateClient&, MediaPlayerPrivateGStreamerMSE&); |
56 | virtual ~MediaSourceGStreamer(); |
57 | |
58 | MediaSourceClientGStreamerMSE& client() { return m_client.get(); } |
59 | AddStatus addSourceBuffer(const ContentType&, RefPtr<SourceBufferPrivate>&) override; |
60 | void removeSourceBuffer(SourceBufferPrivate*); |
61 | |
62 | void durationChanged() override; |
63 | void markEndOfStream(EndOfStreamStatus) override; |
64 | void unmarkEndOfStream() override; |
65 | |
66 | MediaPlayer::ReadyState readyState() const override; |
67 | void setReadyState(MediaPlayer::ReadyState) override; |
68 | |
69 | void waitForSeekCompleted() override; |
70 | void seekCompleted() override; |
71 | |
72 | void sourceBufferPrivateDidChangeActiveState(SourceBufferPrivateGStreamer*, bool); |
73 | |
74 | std::unique_ptr<PlatformTimeRanges> buffered(); |
75 | |
76 | private: |
77 | MediaSourceGStreamer(MediaSourcePrivateClient&, MediaPlayerPrivateGStreamerMSE&); |
78 | |
79 | HashSet<RefPtr<SourceBufferPrivateGStreamer>> m_sourceBuffers; |
80 | HashSet<SourceBufferPrivateGStreamer*> m_activeSourceBuffers; |
81 | Ref<MediaSourceClientGStreamerMSE> m_client; |
82 | Ref<MediaSourcePrivateClient> m_mediaSource; |
83 | MediaPlayerPrivateGStreamerMSE& m_playerPrivate; |
84 | }; |
85 | |
86 | } |
87 | |
88 | #endif |
89 | |