Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef MOZILLA_MEDIASOURCEDECODER_H_
8 : #define MOZILLA_MEDIASOURCEDECODER_H_
9 :
10 : #include "mozilla/Atomics.h"
11 : #include "mozilla/Attributes.h"
12 : #include "nsCOMPtr.h"
13 : #include "nsError.h"
14 : #include "MediaDecoder.h"
15 : #include "MediaFormatReader.h"
16 :
17 : class nsIStreamListener;
18 :
19 : namespace mozilla {
20 :
21 : class MediaResource;
22 : class MediaDecoderStateMachine;
23 : class SourceBufferDecoder;
24 : class TrackBuffer;
25 : enum MSRangeRemovalAction : uint8_t;
26 : class MediaSourceDemuxer;
27 :
28 : namespace dom {
29 :
30 : class HTMLMediaElement;
31 : class MediaSource;
32 :
33 : } // namespace dom
34 :
35 0 : class MediaSourceDecoder : public MediaDecoder
36 : {
37 : public:
38 : explicit MediaSourceDecoder(MediaDecoderInit& aInit);
39 :
40 : MediaDecoderStateMachine* CreateStateMachine() override;
41 : nsresult Load(nsIPrincipal* aPrincipal);
42 : media::TimeIntervals GetSeekable() override;
43 : media::TimeIntervals GetBuffered() override;
44 :
45 : void Shutdown() override;
46 :
47 : void AttachMediaSource(dom::MediaSource* aMediaSource);
48 : void DetachMediaSource();
49 :
50 : void Ended(bool aEnded);
51 :
52 : // Return the duration of the video in seconds.
53 : double GetDuration() override;
54 :
55 : void SetInitialDuration(int64_t aDuration);
56 : void SetMediaSourceDuration(double aDuration);
57 :
58 0 : MediaSourceDemuxer* GetDemuxer()
59 : {
60 0 : return mDemuxer;
61 : }
62 :
63 : // Returns a string describing the state of the MediaSource internal
64 : // buffered data. Used for debugging purposes.
65 : void GetMozDebugReaderData(nsACString& aString) override;
66 :
67 : void AddSizeOfResources(ResourceSizes* aSizes) override;
68 :
69 : MediaDecoderOwner::NextFrameStatus NextFrameBufferedStatus() override;
70 : bool CanPlayThrough() override;
71 :
72 : void NotifyWaitingForKey() override;
73 :
74 : MediaEventSource<void>* WaitingForKeyEvent() override;
75 :
76 0 : bool IsMSE() const override { return true; }
77 :
78 : void NotifyInitDataArrived();
79 :
80 : private:
81 : void DoSetMediaSourceDuration(double aDuration);
82 : media::TimeInterval ClampIntervalToEnd(const media::TimeInterval& aInterval);
83 :
84 : // The owning MediaSource holds a strong reference to this decoder, and
85 : // calls Attach/DetachMediaSource on this decoder to set and clear
86 : // mMediaSource.
87 : dom::MediaSource* mMediaSource;
88 : RefPtr<MediaSourceDemuxer> mDemuxer;
89 : MediaEventProducer<void> mWaitingForKeyEvent;
90 :
91 : bool mEnded;
92 : };
93 :
94 : } // namespace mozilla
95 :
96 : #endif /* MOZILLA_MEDIASOURCEDECODER_H_ */
|