1/*
2 * Copyright (C) 2016 Metrological Group B.V.
3 * Copyright (C) 2016 Igalia S.L
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * aint with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#pragma once
22
23#if ENABLE(VIDEO) && USE(GSTREAMER) && ENABLE(MEDIA_SOURCE)
24
25// PlaybackPipeline is (sort of) a friend class of WebKitMediaSourceGStreamer.
26
27#include "WebKitMediaSourceGStreamer.h"
28#include "WebKitMediaSourceGStreamerPrivate.h"
29
30#include <gst/gst.h>
31#include <wtf/Condition.h>
32#include <wtf/glib/GRefPtr.h>
33
34namespace WTF {
35template<> GRefPtr<WebKitMediaSrc> adoptGRef(WebKitMediaSrc*);
36template<> WebKitMediaSrc* refGPtr<WebKitMediaSrc>(WebKitMediaSrc*);
37template<> void derefGPtr<WebKitMediaSrc>(WebKitMediaSrc*);
38};
39
40namespace WebCore {
41
42class ContentType;
43class SourceBufferPrivateGStreamer;
44class MediaSourceGStreamer;
45
46class PlaybackPipeline: public RefCounted<PlaybackPipeline> {
47public:
48 static Ref<PlaybackPipeline> create()
49 {
50 return adoptRef(*new PlaybackPipeline());
51 }
52
53 virtual ~PlaybackPipeline() = default;
54
55 void setWebKitMediaSrc(WebKitMediaSrc*);
56 WebKitMediaSrc* webKitMediaSrc();
57
58 MediaSourcePrivate::AddStatus addSourceBuffer(RefPtr<SourceBufferPrivateGStreamer>);
59 void removeSourceBuffer(RefPtr<SourceBufferPrivateGStreamer>);
60 void attachTrack(RefPtr<SourceBufferPrivateGStreamer>, RefPtr<TrackPrivateBase>, GstCaps*);
61 void reattachTrack(RefPtr<SourceBufferPrivateGStreamer>, RefPtr<TrackPrivateBase>, GstCaps*);
62 void notifyDurationChanged();
63
64 // From MediaSourceGStreamer.
65 void markEndOfStream(MediaSourcePrivate::EndOfStreamStatus);
66
67 // From SourceBufferPrivateGStreamer.
68 void flush(AtomicString);
69 void enqueueSample(Ref<MediaSample>&&);
70 void allSamplesInTrackEnqueued(const AtomicString&);
71
72 GstElement* pipeline();
73private:
74 PlaybackPipeline() = default;
75 GRefPtr<WebKitMediaSrc> m_webKitMediaSrc;
76};
77
78} // namespace WebCore.
79
80#endif // USE(GSTREAMER)
81