-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMediaEngine.h
108 lines (84 loc) · 2.91 KB
/
MediaEngine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef MEDIAENGINE_H_
#define MEDIAENGINE_H_
#include "nsDOMMediaStream.h"
#include "MediaStreamGraph.h"
namespace mozilla {
/**
* Abstract interface for managing audio and video devices. Each platform
* must implement a concrete class that will map these classes and methods
* to the appropriate backend. For example, on Desktop platforms, these will
* correspond to equivalent webrtc (GIPS) calls, and on B2G they will map to
* a Gonk interface.
*/
class MediaEngineVideoSource;
class MediaEngineAudioSource;
class MediaEngine
{
public:
virtual ~MediaEngine() {};
/* Populate an array of video sources in the nsTArray. Also include devices
* that are currently unavailable. */
virtual void EnumerateVideoDevices(nsTArray<nsRefPtr<MediaEngineVideoSource> >*) = 0;
/* Populate an array of audio sources in the nsTArray. Also include devices
* that are currently unavailable. */
virtual void EnumerateAudioDevices(nsTArray<nsRefPtr<MediaEngineAudioSource> >*) = 0;
};
/**
* Common abstract base class for audio and video sources.
*/
class MediaEngineSource : public nsISupports
{
public:
virtual ~MediaEngineSource() {};
/* Populate the human readable name of this device in the nsAString */
virtual void GetName(nsAString&) = 0;
/* Populate the UUID of this device in the nsAString */
virtual void GetUUID(nsAString&) = 0;
/* This call reserves but does not start the device. */
virtual already_AddRefed<nsDOMMediaStream> Allocate() = 0;
/* Release the device back to the system. */
virtual nsresult Deallocate() = 0;
/* Start the device and add the track to the provided SourceMediaStream, with
* the provided TrackID. You may start appending data to the track
* immediately after. */
virtual nsresult Start(SourceMediaStream*, TrackID) = 0;
/* Stop the device and release the corresponding MediaStream */
virtual nsresult Stop() = 0;
/* It is an error to call Start() before an Allocate(), and Stop() before
* a Start(). Only Allocate() may be called after a Deallocate(). */
};
/**
* Video source and friends.
*/
enum MediaEngineVideoCodecType {
kVideoCodecH263,
kVideoCodecVP8,
kVideoCodecI420
};
struct MediaEngineVideoOptions {
PRUint32 mWidth;
PRUint32 mHeight;
PRUint32 mMaxFPS;
MediaEngineVideoCodecType codecType;
};
class MediaEngineVideoSource : public MediaEngineSource
{
public:
virtual ~MediaEngineVideoSource() {};
/* Return a MediaEngineVideoOptions struct with appropriate values for all
* fields. */
virtual MediaEngineVideoOptions GetOptions() = 0;
};
/**
* Audio source and friends.
*/
class MediaEngineAudioSource : public MediaEngineSource
{
public:
virtual ~MediaEngineAudioSource() {};
};
}
#endif /* MEDIAENGINE_H_ */