1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef MEDIAENGINE_H_
6 #define MEDIAENGINE_H_
7 
8 #include "DOMMediaStream.h"
9 #include "MediaEventSource.h"
10 #include "MediaTrackGraph.h"
11 #include "MediaTrackConstraints.h"
12 #include "mozilla/dom/MediaStreamTrackBinding.h"
13 #include "mozilla/dom/VideoStreamTrack.h"
14 #include "mozilla/RefPtr.h"
15 #include "mozilla/ThreadSafeWeakPtr.h"
16 
17 namespace mozilla {
18 
19 namespace dom {
20 class Blob;
21 }  // namespace dom
22 
23 class AllocationHandle;
24 class MediaEngineSource;
25 
26 enum MediaSinkEnum {
27   Speaker,
28   Other,
29 };
30 
31 enum { kVideoTrack = 1, kAudioTrack = 2, kTrackCount };
32 
33 class MediaEngine {
34  public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaEngine)35   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaEngine)
36   NS_DECL_OWNINGTHREAD
37 
38   void AssertIsOnOwningThread() const { NS_ASSERT_OWNINGTHREAD(MediaEngine); }
39 
40   /**
41    * Populate an array of sources of the requested type in the nsTArray.
42    * Also include devices that are currently unavailable.
43    */
44   virtual void EnumerateDevices(uint64_t aWindowId, dom::MediaSourceEnum,
45                                 MediaSinkEnum,
46                                 nsTArray<RefPtr<MediaDevice>>*) = 0;
47 
48   virtual void Shutdown() = 0;
49 
SetFakeDeviceChangeEventsEnabled(bool aEnable)50   virtual void SetFakeDeviceChangeEventsEnabled(bool aEnable) {}
51 
52   virtual MediaEventSource<void>& DeviceListChangeEvent() = 0;
53 
54  protected:
55   virtual ~MediaEngine() = default;
56 };
57 
58 }  // namespace mozilla
59 
60 #endif /* MEDIAENGINE_H_ */
61