|
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_dom_SourceBufferList_h_ |
|
8 #define mozilla_dom_SourceBufferList_h_ |
|
9 |
|
10 #include "SourceBuffer.h" |
|
11 #include "js/RootingAPI.h" |
|
12 #include "mozilla/Assertions.h" |
|
13 #include "mozilla/Attributes.h" |
|
14 #include "mozilla/DOMEventTargetHelper.h" |
|
15 #include "nsAutoPtr.h" |
|
16 #include "nsCycleCollectionNoteChild.h" |
|
17 #include "nsCycleCollectionParticipant.h" |
|
18 #include "nsISupports.h" |
|
19 #include "nsTArray.h" |
|
20 |
|
21 struct JSContext; |
|
22 class JSObject; |
|
23 |
|
24 namespace mozilla { |
|
25 |
|
26 class ErrorResult; |
|
27 template <typename T> class AsyncEventRunner; |
|
28 |
|
29 namespace dom { |
|
30 |
|
31 class MediaSource; |
|
32 |
|
33 class SourceBufferList MOZ_FINAL : public DOMEventTargetHelper |
|
34 { |
|
35 public: |
|
36 /** WebIDL Methods. */ |
|
37 SourceBuffer* IndexedGetter(uint32_t aIndex, bool& aFound); |
|
38 |
|
39 uint32_t Length(); |
|
40 /** End WebIDL methods. */ |
|
41 |
|
42 NS_DECL_ISUPPORTS_INHERITED |
|
43 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(SourceBufferList, |
|
44 DOMEventTargetHelper) |
|
45 |
|
46 explicit SourceBufferList(MediaSource* aMediaSource); |
|
47 |
|
48 MediaSource* GetParentObject() const; |
|
49 |
|
50 JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
|
51 |
|
52 // Append a SourceBuffer and fire "addsourcebuffer" at the list. |
|
53 void Append(SourceBuffer* aSourceBuffer); |
|
54 |
|
55 // Remove a SourceBuffer and fire "removesourcebuffer" at the list. |
|
56 void Remove(SourceBuffer* aSourceBuffer); |
|
57 |
|
58 // Returns true if aSourceBuffer is present in the list. |
|
59 bool Contains(SourceBuffer* aSourceBuffer); |
|
60 |
|
61 // Remove all SourceBuffers and fire a single "removesourcebuffer" at the list. |
|
62 void Clear(); |
|
63 |
|
64 // True if list has zero entries. |
|
65 bool IsEmpty(); |
|
66 |
|
67 // Returns true if updating is true on any SourceBuffers in the list. |
|
68 bool AnyUpdating(); |
|
69 |
|
70 // Calls Remove(aStart, aEnd) on each SourceBuffer in the list. Aborts on |
|
71 // first error, with result returned in aRv. |
|
72 void Remove(double aStart, double aEnd, ErrorResult& aRv); |
|
73 |
|
74 // Mark all SourceBuffers input buffers as ended. |
|
75 void Ended(); |
|
76 |
|
77 // Evicts data for the given time range from each SourceBuffer in the list. |
|
78 void Evict(double aStart, double aEnd); |
|
79 |
|
80 // Returns true if all SourceBuffers in the list contain data for the given time. |
|
81 bool AllContainsTime(double aTime); |
|
82 |
|
83 private: |
|
84 friend class AsyncEventRunner<SourceBufferList>; |
|
85 void DispatchSimpleEvent(const char* aName); |
|
86 void QueueAsyncSimpleEvent(const char* aName); |
|
87 |
|
88 nsRefPtr<MediaSource> mMediaSource; |
|
89 nsTArray<nsRefPtr<SourceBuffer> > mSourceBuffers; |
|
90 }; |
|
91 |
|
92 } // namespace dom |
|
93 |
|
94 } // namespace mozilla |
|
95 #endif /* mozilla_dom_SourceBufferList_h_ */ |