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, 2017 Metrological Group B.V. |
6 | * Copyright (C) 2015, 2016, 2017 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 | |
39 | #include "ContentType.h" |
40 | #include "MediaPlayerPrivateGStreamerMSE.h" |
41 | #include "SourceBufferPrivate.h" |
42 | #include "SourceBufferPrivateClient.h" |
43 | #include "WebKitMediaSourceGStreamer.h" |
44 | |
45 | namespace WebCore { |
46 | |
47 | class MediaSourceGStreamer; |
48 | |
49 | class SourceBufferPrivateGStreamer final : public SourceBufferPrivate { |
50 | |
51 | public: |
52 | static Ref<SourceBufferPrivateGStreamer> create(MediaSourceGStreamer*, Ref<MediaSourceClientGStreamerMSE>, const ContentType&); |
53 | virtual ~SourceBufferPrivateGStreamer() = default; |
54 | |
55 | void clearMediaSource() { m_mediaSource = nullptr; } |
56 | |
57 | void setClient(SourceBufferPrivateClient*) final; |
58 | void append(Vector<unsigned char>&&) final; |
59 | void abort() final; |
60 | void resetParserState() final; |
61 | void removedFromMediaSource() final; |
62 | MediaPlayer::ReadyState readyState() const final; |
63 | void setReadyState(MediaPlayer::ReadyState) final; |
64 | |
65 | void flush(const AtomicString&) final; |
66 | void enqueueSample(Ref<MediaSample>&&, const AtomicString&) final; |
67 | void allSamplesInTrackEnqueued(const AtomicString&) final; |
68 | bool isReadyForMoreSamples(const AtomicString&) final; |
69 | void setActive(bool) final; |
70 | void notifyClientWhenReadyForMoreSamples(const AtomicString&) final; |
71 | |
72 | void setReadyForMoreSamples(bool); |
73 | void notifyReadyForMoreSamples(); |
74 | |
75 | void didReceiveInitializationSegment(const SourceBufferPrivateClient::InitializationSegment&); |
76 | void didReceiveSample(MediaSample&); |
77 | void didReceiveAllPendingSamples(); |
78 | void appendParsingFailed(); |
79 | |
80 | ContentType type() const { return m_type; } |
81 | |
82 | private: |
83 | SourceBufferPrivateGStreamer(MediaSourceGStreamer*, Ref<MediaSourceClientGStreamerMSE>, const ContentType&); |
84 | friend class MediaSourceClientGStreamerMSE; |
85 | |
86 | MediaSourceGStreamer* m_mediaSource; |
87 | ContentType m_type; |
88 | Ref<MediaSourceClientGStreamerMSE> m_client; |
89 | SourceBufferPrivateClient* m_sourceBufferPrivateClient { nullptr }; |
90 | bool m_isReadyForMoreSamples = true; |
91 | bool m_notifyWhenReadyForMoreSamples = false; |
92 | AtomicString m_trackId; |
93 | }; |
94 | |
95 | } |
96 | |
97 | #endif |
98 | |