| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2004 Google Inc. | 3 * Copyright 2004 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #ifndef TALK_MEDIA_BASE_MEDIAENGINE_H_ | 28 #ifndef TALK_MEDIA_BASE_MEDIAENGINE_H_ |
| 29 #define TALK_MEDIA_BASE_MEDIAENGINE_H_ | 29 #define TALK_MEDIA_BASE_MEDIAENGINE_H_ |
| 30 | 30 |
| 31 #ifdef OSX | 31 #ifdef OSX |
| 32 #include <CoreAudio/CoreAudio.h> | 32 #include <CoreAudio/CoreAudio.h> |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 #include <limits.h> | |
| 36 | |
| 37 #include <string> | 35 #include <string> |
| 38 #include <vector> | 36 #include <vector> |
| 39 | 37 |
| 40 #include "talk/media/base/codec.h" | 38 #include "talk/media/base/codec.h" |
| 41 #include "talk/media/base/mediachannel.h" | 39 #include "talk/media/base/mediachannel.h" |
| 42 #include "talk/media/base/mediacommon.h" | 40 #include "talk/media/base/mediacommon.h" |
| 43 #include "talk/media/base/videocapturer.h" | 41 #include "talk/media/base/videocapturer.h" |
| 44 #include "talk/media/base/videocommon.h" | 42 #include "talk/media/base/videocommon.h" |
| 45 #include "talk/media/base/voiceprocessor.h" | 43 #include "talk/media/base/voiceprocessor.h" |
| 46 #include "talk/media/devices/devicemanager.h" | 44 #include "talk/media/devices/devicemanager.h" |
| 47 #include "webrtc/base/fileutils.h" | 45 #include "webrtc/base/fileutils.h" |
| 48 #include "webrtc/base/sigslotrepeater.h" | 46 #include "webrtc/base/sigslotrepeater.h" |
| 49 | 47 |
| 50 #if defined(GOOGLE_CHROME_BUILD) || defined(CHROMIUM_BUILD) | 48 #if defined(GOOGLE_CHROME_BUILD) || defined(CHROMIUM_BUILD) |
| 51 #define DISABLE_MEDIA_ENGINE_FACTORY | 49 #define DISABLE_MEDIA_ENGINE_FACTORY |
| 52 #endif | 50 #endif |
| 53 | 51 |
| 52 namespace webrtc { |
| 53 class Call; |
| 54 class VoiceEngine; |
| 55 } |
| 56 |
| 54 namespace cricket { | 57 namespace cricket { |
| 55 | 58 |
| 56 class VideoCapturer; | 59 class VideoCapturer; |
| 57 | 60 |
| 58 // MediaEngineInterface is an abstraction of a media engine which can be | 61 // MediaEngineInterface is an abstraction of a media engine which can be |
| 59 // subclassed to support different media componentry backends. | 62 // subclassed to support different media componentry backends. |
| 60 // It supports voice and video operations in the same class to facilitate | 63 // It supports voice and video operations in the same class to facilitate |
| 61 // proper synchronization between both media types. | 64 // proper synchronization between both media types. |
| 62 class MediaEngineInterface { | 65 class MediaEngineInterface { |
| 63 public: | 66 public: |
| 64 // Default value to be used for SetAudioDelayOffset(). | 67 // Default value to be used for SetAudioDelayOffset(). |
| 65 static const int kDefaultAudioDelayOffset; | 68 static const int kDefaultAudioDelayOffset; |
| 66 | 69 |
| 67 virtual ~MediaEngineInterface() {} | 70 virtual ~MediaEngineInterface() {} |
| 68 | 71 |
| 69 // Initialization | 72 // Initialization |
| 70 // Starts the engine. | 73 // Starts the engine. |
| 71 virtual bool Init(rtc::Thread* worker_thread) = 0; | 74 virtual bool Init(rtc::Thread* worker_thread) = 0; |
| 72 // Shuts down the engine. | 75 // Shuts down the engine. |
| 73 virtual void Terminate() = 0; | 76 virtual void Terminate() = 0; |
| 74 // Returns what the engine is capable of, as a set of Capabilities, above. | 77 // Returns what the engine is capable of, as a set of Capabilities, above. |
| 75 virtual int GetCapabilities() = 0; | 78 virtual int GetCapabilities() = 0; |
| 79 // TODO(solenberg): Remove once VoE API refactoring is done. |
| 80 virtual webrtc::VoiceEngine* GetVoE() = 0; |
| 76 | 81 |
| 77 // MediaChannel creation | 82 // MediaChannel creation |
| 78 // Creates a voice media channel. Returns NULL on failure. | 83 // Creates a voice media channel. Returns NULL on failure. |
| 79 virtual VoiceMediaChannel* CreateChannel(const AudioOptions& options) = 0; | 84 virtual VoiceMediaChannel* CreateChannel( |
| 85 webrtc::Call* call, |
| 86 const AudioOptions& options) = 0; |
| 80 // Creates a video media channel, paired with the specified voice channel. | 87 // Creates a video media channel, paired with the specified voice channel. |
| 81 // Returns NULL on failure. | 88 // Returns NULL on failure. |
| 82 virtual VideoMediaChannel* CreateVideoChannel( | 89 virtual VideoMediaChannel* CreateVideoChannel( |
| 83 const VideoOptions& options, | 90 webrtc::Call* call, |
| 84 VoiceMediaChannel* voice_media_channel) = 0; | 91 const VideoOptions& options) = 0; |
| 85 | 92 |
| 86 // Configuration | 93 // Configuration |
| 87 // Gets global audio options. | 94 // Gets global audio options. |
| 88 virtual AudioOptions GetAudioOptions() const = 0; | 95 virtual AudioOptions GetAudioOptions() const = 0; |
| 89 // Sets global audio options. "options" are from AudioOptions, above. | 96 // Sets global audio options. "options" are from AudioOptions, above. |
| 90 virtual bool SetAudioOptions(const AudioOptions& options) = 0; | 97 virtual bool SetAudioOptions(const AudioOptions& options) = 0; |
| 91 // Sets the value used by the echo canceller to offset delay values obtained | 98 // Sets the value used by the echo canceller to offset delay values obtained |
| 92 // from the OS. | 99 // from the OS. |
| 93 virtual bool SetAudioDelayOffset(int offset) = 0; | 100 virtual bool SetAudioDelayOffset(int offset) = 0; |
| 94 // Sets the default (maximum) codec/resolution and encoder option to capture | 101 // Sets the default (maximum) codec/resolution and encoder option to capture |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 private: | 162 private: |
| 156 static MediaEngineCreateFunction create_function_; | 163 static MediaEngineCreateFunction create_function_; |
| 157 }; | 164 }; |
| 158 #endif | 165 #endif |
| 159 | 166 |
| 160 // CompositeMediaEngine constructs a MediaEngine from separate | 167 // CompositeMediaEngine constructs a MediaEngine from separate |
| 161 // voice and video engine classes. | 168 // voice and video engine classes. |
| 162 template<class VOICE, class VIDEO> | 169 template<class VOICE, class VIDEO> |
| 163 class CompositeMediaEngine : public MediaEngineInterface { | 170 class CompositeMediaEngine : public MediaEngineInterface { |
| 164 public: | 171 public: |
| 165 CompositeMediaEngine() : video_(&voice_) {} | |
| 166 virtual ~CompositeMediaEngine() {} | 172 virtual ~CompositeMediaEngine() {} |
| 167 virtual bool Init(rtc::Thread* worker_thread) { | 173 virtual bool Init(rtc::Thread* worker_thread) { |
| 168 if (!voice_.Init(worker_thread)) | 174 if (!voice_.Init(worker_thread)) |
| 169 return false; | 175 return false; |
| 170 video_.Init(); | 176 video_.Init(); |
| 171 return true; | 177 return true; |
| 172 } | 178 } |
| 173 virtual void Terminate() { | 179 virtual void Terminate() { |
| 174 voice_.Terminate(); | 180 voice_.Terminate(); |
| 175 } | 181 } |
| 176 | 182 |
| 177 virtual int GetCapabilities() { | 183 virtual int GetCapabilities() { |
| 178 return (voice_.GetCapabilities() | video_.GetCapabilities()); | 184 return (voice_.GetCapabilities() | video_.GetCapabilities()); |
| 179 } | 185 } |
| 180 virtual VoiceMediaChannel* CreateChannel(const AudioOptions& options) { | 186 virtual webrtc::VoiceEngine* GetVoE() { |
| 181 return voice_.CreateChannel(options); | 187 return voice_.GetVoE(); |
| 182 } | 188 } |
| 183 virtual VideoMediaChannel* CreateVideoChannel(const VideoOptions& options, | 189 virtual VoiceMediaChannel* CreateChannel(webrtc::Call* call, |
| 184 VoiceMediaChannel* channel) { | 190 const AudioOptions& options) { |
| 185 return video_.CreateChannel(options, channel); | 191 return voice_.CreateChannel(call, options); |
| 192 } |
| 193 virtual VideoMediaChannel* CreateVideoChannel(webrtc::Call* call, |
| 194 const VideoOptions& options) { |
| 195 return video_.CreateChannel(call, options); |
| 186 } | 196 } |
| 187 | 197 |
| 188 virtual AudioOptions GetAudioOptions() const { | 198 virtual AudioOptions GetAudioOptions() const { |
| 189 return voice_.GetOptions(); | 199 return voice_.GetOptions(); |
| 190 } | 200 } |
| 191 virtual bool SetAudioOptions(const AudioOptions& options) { | 201 virtual bool SetAudioOptions(const AudioOptions& options) { |
| 192 return voice_.SetOptions(options); | 202 return voice_.SetOptions(options); |
| 193 } | 203 } |
| 194 virtual bool SetAudioDelayOffset(int offset) { | 204 virtual bool SetAudioDelayOffset(int offset) { |
| 195 return voice_.SetDelayOffset(offset); | 205 return voice_.SetDelayOffset(offset); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 class DataEngineInterface { | 347 class DataEngineInterface { |
| 338 public: | 348 public: |
| 339 virtual ~DataEngineInterface() {} | 349 virtual ~DataEngineInterface() {} |
| 340 virtual DataMediaChannel* CreateChannel(DataChannelType type) = 0; | 350 virtual DataMediaChannel* CreateChannel(DataChannelType type) = 0; |
| 341 virtual const std::vector<DataCodec>& data_codecs() = 0; | 351 virtual const std::vector<DataCodec>& data_codecs() = 0; |
| 342 }; | 352 }; |
| 343 | 353 |
| 344 } // namespace cricket | 354 } // namespace cricket |
| 345 | 355 |
| 346 #endif // TALK_MEDIA_BASE_MEDIAENGINE_H_ | 356 #endif // TALK_MEDIA_BASE_MEDIAENGINE_H_ |
| OLD | NEW |