Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: talk/media/base/mediaengine.h

Issue 1587193006: Move talk/media to webrtc/media (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebased to b647aca12a884a13c1728118586245399b55fa3d (#11493) Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/media/base/mediacommon.h ('k') | talk/media/base/mediaengine.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * libjingle
3 * Copyright 2004 Google Inc.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28 #ifndef TALK_MEDIA_BASE_MEDIAENGINE_H_
29 #define TALK_MEDIA_BASE_MEDIAENGINE_H_
30
31 #if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
32 #include <CoreAudio/CoreAudio.h>
33 #endif
34
35 #include <string>
36 #include <vector>
37
38 #include "talk/media/base/codec.h"
39 #include "talk/media/base/mediachannel.h"
40 #include "talk/media/base/mediacommon.h"
41 #include "talk/media/base/videocapturer.h"
42 #include "talk/media/base/videocommon.h"
43 #include "talk/media/devices/devicemanager.h"
44 #include "webrtc/audio_state.h"
45 #include "webrtc/base/fileutils.h"
46 #include "webrtc/base/sigslotrepeater.h"
47
48 #if defined(GOOGLE_CHROME_BUILD) || defined(CHROMIUM_BUILD)
49 #define DISABLE_MEDIA_ENGINE_FACTORY
50 #endif
51
52 namespace webrtc {
53 class Call;
54 }
55
56 namespace cricket {
57
58 class VideoCapturer;
59
60 struct RtpCapabilities {
61 std::vector<RtpHeaderExtension> header_extensions;
62 };
63
64 // MediaEngineInterface is an abstraction of a media engine which can be
65 // subclassed to support different media componentry backends.
66 // It supports voice and video operations in the same class to facilitate
67 // proper synchronization between both media types.
68 class MediaEngineInterface {
69 public:
70 virtual ~MediaEngineInterface() {}
71
72 // Initialization
73 // Starts the engine.
74 virtual bool Init(rtc::Thread* worker_thread) = 0;
75 // Shuts down the engine.
76 virtual void Terminate() = 0;
77 // TODO(solenberg): Remove once VoE API refactoring is done.
78 virtual rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const = 0;
79
80 // MediaChannel creation
81 // Creates a voice media channel. Returns NULL on failure.
82 virtual VoiceMediaChannel* CreateChannel(
83 webrtc::Call* call,
84 const AudioOptions& options) = 0;
85 // Creates a video media channel, paired with the specified voice channel.
86 // Returns NULL on failure.
87 virtual VideoMediaChannel* CreateVideoChannel(
88 webrtc::Call* call,
89 const VideoOptions& options) = 0;
90
91 // Device configuration
92 // Gets the current speaker volume, as a value between 0 and 255.
93 virtual bool GetOutputVolume(int* level) = 0;
94 // Sets the current speaker volume, as a value between 0 and 255.
95 virtual bool SetOutputVolume(int level) = 0;
96
97 // Gets the current microphone level, as a value between 0 and 10.
98 virtual int GetInputLevel() = 0;
99
100 virtual const std::vector<AudioCodec>& audio_codecs() = 0;
101 virtual RtpCapabilities GetAudioCapabilities() = 0;
102 virtual const std::vector<VideoCodec>& video_codecs() = 0;
103 virtual RtpCapabilities GetVideoCapabilities() = 0;
104
105 // Starts AEC dump using existing file, a maximum file size in bytes can be
106 // specified. Logging is stopped just before the size limit is exceeded.
107 // If max_size_bytes is set to a value <= 0, no limit will be used.
108 virtual bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) = 0;
109
110 // Stops recording AEC dump.
111 virtual void StopAecDump() = 0;
112
113 // Starts RtcEventLog using existing file.
114 virtual bool StartRtcEventLog(rtc::PlatformFile file) = 0;
115
116 // Stops recording an RtcEventLog.
117 virtual void StopRtcEventLog() = 0;
118 };
119
120
121 #if !defined(DISABLE_MEDIA_ENGINE_FACTORY)
122 class MediaEngineFactory {
123 public:
124 typedef cricket::MediaEngineInterface* (*MediaEngineCreateFunction)();
125 // Creates a media engine, using either the compiled system default or the
126 // creation function specified in SetCreateFunction, if specified.
127 static MediaEngineInterface* Create();
128 // Sets the function used when calling Create. If unset, the compiled system
129 // default will be used. Returns the old create function, or NULL if one
130 // wasn't set. Likewise, NULL can be used as the |function| parameter to
131 // reset to the default behavior.
132 static MediaEngineCreateFunction SetCreateFunction(
133 MediaEngineCreateFunction function);
134 private:
135 static MediaEngineCreateFunction create_function_;
136 };
137 #endif
138
139 // CompositeMediaEngine constructs a MediaEngine from separate
140 // voice and video engine classes.
141 template<class VOICE, class VIDEO>
142 class CompositeMediaEngine : public MediaEngineInterface {
143 public:
144 virtual ~CompositeMediaEngine() {}
145 virtual bool Init(rtc::Thread* worker_thread) {
146 if (!voice_.Init(worker_thread))
147 return false;
148 video_.Init();
149 return true;
150 }
151 virtual void Terminate() {
152 voice_.Terminate();
153 }
154
155 virtual rtc::scoped_refptr<webrtc::AudioState> GetAudioState() const {
156 return voice_.GetAudioState();
157 }
158 virtual VoiceMediaChannel* CreateChannel(webrtc::Call* call,
159 const AudioOptions& options) {
160 return voice_.CreateChannel(call, options);
161 }
162 virtual VideoMediaChannel* CreateVideoChannel(webrtc::Call* call,
163 const VideoOptions& options) {
164 return video_.CreateChannel(call, options);
165 }
166
167 virtual bool GetOutputVolume(int* level) {
168 return voice_.GetOutputVolume(level);
169 }
170 virtual bool SetOutputVolume(int level) {
171 return voice_.SetOutputVolume(level);
172 }
173
174 virtual int GetInputLevel() {
175 return voice_.GetInputLevel();
176 }
177 virtual const std::vector<AudioCodec>& audio_codecs() {
178 return voice_.codecs();
179 }
180 virtual RtpCapabilities GetAudioCapabilities() {
181 return voice_.GetCapabilities();
182 }
183 virtual const std::vector<VideoCodec>& video_codecs() {
184 return video_.codecs();
185 }
186 virtual RtpCapabilities GetVideoCapabilities() {
187 return video_.GetCapabilities();
188 }
189
190 virtual bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) {
191 return voice_.StartAecDump(file, max_size_bytes);
192 }
193
194 virtual void StopAecDump() {
195 voice_.StopAecDump();
196 }
197
198 virtual bool StartRtcEventLog(rtc::PlatformFile file) {
199 return voice_.StartRtcEventLog(file);
200 }
201
202 virtual void StopRtcEventLog() { voice_.StopRtcEventLog(); }
203
204 protected:
205 VOICE voice_;
206 VIDEO video_;
207 };
208
209 enum DataChannelType {
210 DCT_NONE = 0,
211 DCT_RTP = 1,
212 DCT_SCTP = 2
213 };
214
215 class DataEngineInterface {
216 public:
217 virtual ~DataEngineInterface() {}
218 virtual DataMediaChannel* CreateChannel(DataChannelType type) = 0;
219 virtual const std::vector<DataCodec>& data_codecs() = 0;
220 };
221
222 } // namespace cricket
223
224 #endif // TALK_MEDIA_BASE_MEDIAENGINE_H_
OLDNEW
« no previous file with comments | « talk/media/base/mediacommon.h ('k') | talk/media/base/mediaengine.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698