1 | /* |
2 | * Copyright (C) 2013-2017 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 | #pragma once |
27 | |
28 | #if ENABLE(MEDIA_SOURCE) |
29 | |
30 | #include "SourceBufferPrivate.h" |
31 | |
32 | namespace WebCore { |
33 | |
34 | class AudioTrackPrivate; |
35 | class InbandTextTrackPrivate; |
36 | class MockInitializationBox; |
37 | class MockMediaSourcePrivate; |
38 | class MockSampleBox; |
39 | class TimeRanges; |
40 | class VideoTrackPrivate; |
41 | |
42 | class MockSourceBufferPrivate final : public SourceBufferPrivate { |
43 | public: |
44 | static Ref<MockSourceBufferPrivate> create(MockMediaSourcePrivate*); |
45 | virtual ~MockSourceBufferPrivate(); |
46 | |
47 | void clearMediaSource() { m_mediaSource = nullptr; } |
48 | |
49 | bool hasVideo() const; |
50 | bool hasAudio() const; |
51 | |
52 | MediaTime fastSeekTimeForMediaTime(const MediaTime&, const MediaTime& negativeThreshold, const MediaTime& positiveThreshold); |
53 | |
54 | private: |
55 | explicit MockSourceBufferPrivate(MockMediaSourcePrivate*); |
56 | |
57 | // SourceBufferPrivate overrides |
58 | void setClient(SourceBufferPrivateClient*) final; |
59 | void append(Vector<unsigned char>&&) final; |
60 | void abort() final; |
61 | void resetParserState() final; |
62 | void removedFromMediaSource() final; |
63 | MediaPlayer::ReadyState readyState() const final; |
64 | void setReadyState(MediaPlayer::ReadyState) final; |
65 | bool canSwitchToType(const ContentType&) final; |
66 | |
67 | void flush(const AtomicString&) final { m_enqueuedSamples.clear(); } |
68 | void enqueueSample(Ref<MediaSample>&&, const AtomicString&) final; |
69 | bool isReadyForMoreSamples(const AtomicString&) final { return true; } |
70 | void setActive(bool) final; |
71 | |
72 | Vector<String> enqueuedSamplesForTrackID(const AtomicString&) final; |
73 | |
74 | void didReceiveInitializationSegment(const MockInitializationBox&); |
75 | void didReceiveSample(const MockSampleBox&); |
76 | |
77 | #if !RELEASE_LOG_DISABLED |
78 | const Logger& sourceBufferLogger() const final; |
79 | const void* sourceBufferLogIdentifier() final; |
80 | #endif |
81 | |
82 | MockMediaSourcePrivate* m_mediaSource; |
83 | SourceBufferPrivateClient* m_client; |
84 | Vector<String> m_enqueuedSamples; |
85 | |
86 | Vector<char> m_inputBuffer; |
87 | }; |
88 | |
89 | } |
90 | |
91 | #endif // ENABLE(MEDIA_SOURCE) && USE(AVFOUNDATION) |
92 | |