| OLD | NEW | 
|---|
| 1 /* | 1 /* | 
| 2  *  Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2  *  Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 
| 3  * | 3  * | 
| 4  *  Use of this source code is governed by a BSD-style license | 4  *  Use of this source code is governed by a BSD-style license | 
| 5  *  that can be found in the LICENSE file in the root of the source | 5  *  that can be found in the LICENSE file in the root of the source | 
| 6  *  tree. An additional intellectual property rights grant can be found | 6  *  tree. An additional intellectual property rights grant can be found | 
| 7  *  in the file PATENTS.  All contributing project authors may | 7  *  in the file PATENTS.  All contributing project authors may | 
| 8  *  be found in the AUTHORS file in the root of the source tree. | 8  *  be found in the AUTHORS file in the root of the source tree. | 
| 9  */ | 9  */ | 
| 10 | 10 | 
| 11 #ifndef WEBRTC_MEDIA_ENGINE_WEBRTCVOE_H_ | 11 #ifndef WEBRTC_MEDIA_ENGINE_WEBRTCVOE_H_ | 
| 12 #define WEBRTC_MEDIA_ENGINE_WEBRTCVOE_H_ | 12 #define WEBRTC_MEDIA_ENGINE_WEBRTCVOE_H_ | 
| 13 | 13 | 
| 14 #include <memory> | 14 #include <memory> | 
| 15 | 15 | 
| 16 #include "webrtc/media/engine/webrtccommon.h" | 16 #include "webrtc/media/engine/webrtccommon.h" | 
| 17 | 17 | 
| 18 #include "webrtc/common_types.h" | 18 #include "webrtc/common_types.h" | 
| 19 #include "webrtc/modules/audio_device/include/audio_device.h" | 19 #include "webrtc/modules/audio_device/include/audio_device.h" | 
| 20 #include "webrtc/voice_engine/include/voe_base.h" | 20 #include "webrtc/voice_engine/include/voe_base.h" | 
| 21 #include "webrtc/voice_engine/include/voe_codec.h" | 21 #include "webrtc/voice_engine/include/voe_codec.h" | 
| 22 #include "webrtc/voice_engine/include/voe_errors.h" | 22 #include "webrtc/voice_engine/include/voe_errors.h" | 
| 23 #include "webrtc/voice_engine/include/voe_hardware.h" | 23 #include "webrtc/voice_engine/include/voe_hardware.h" | 
| 24 #include "webrtc/voice_engine/include/voe_volume_control.h" |  | 
| 25 | 24 | 
| 26 namespace cricket { | 25 namespace cricket { | 
| 27 // automatically handles lifetime of WebRtc VoiceEngine | 26 // automatically handles lifetime of WebRtc VoiceEngine | 
| 28 class scoped_voe_engine { | 27 class scoped_voe_engine { | 
| 29  public: | 28  public: | 
| 30   explicit scoped_voe_engine(webrtc::VoiceEngine* e) : ptr(e) {} | 29   explicit scoped_voe_engine(webrtc::VoiceEngine* e) : ptr(e) {} | 
| 31   // RTC_DCHECK, to ensure that there are no leaks at shutdown | 30   // RTC_DCHECK, to ensure that there are no leaks at shutdown | 
| 32   ~scoped_voe_engine() { | 31   ~scoped_voe_engine() { | 
| 33     if (ptr) { | 32     if (ptr) { | 
| 34       const bool success = webrtc::VoiceEngine::Delete(ptr); | 33       const bool success = webrtc::VoiceEngine::Delete(ptr); | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 71  private: | 70  private: | 
| 72   T* ptr; | 71   T* ptr; | 
| 73 }; | 72 }; | 
| 74 | 73 | 
| 75 // Utility class for aggregating the various WebRTC interface. | 74 // Utility class for aggregating the various WebRTC interface. | 
| 76 // Fake implementations can also be injected for testing. | 75 // Fake implementations can also be injected for testing. | 
| 77 class VoEWrapper { | 76 class VoEWrapper { | 
| 78  public: | 77  public: | 
| 79   VoEWrapper() | 78   VoEWrapper() | 
| 80       : engine_(webrtc::VoiceEngine::Create()), | 79       : engine_(webrtc::VoiceEngine::Create()), | 
| 81         base_(engine_), codec_(engine_), hw_(engine_), | 80         base_(engine_), codec_(engine_), hw_(engine_) { | 
| 82         volume_(engine_) { |  | 
| 83   } | 81   } | 
| 84   VoEWrapper(webrtc::VoEBase* base, | 82   VoEWrapper(webrtc::VoEBase* base, | 
| 85              webrtc::VoECodec* codec, | 83              webrtc::VoECodec* codec, | 
| 86              webrtc::VoEHardware* hw, | 84              webrtc::VoEHardware* hw) | 
| 87              webrtc::VoEVolumeControl* volume) |  | 
| 88       : engine_(NULL), | 85       : engine_(NULL), | 
| 89         base_(base), | 86         base_(base), | 
| 90         codec_(codec), | 87         codec_(codec), | 
| 91         hw_(hw), | 88         hw_(hw) { | 
| 92         volume_(volume) { |  | 
| 93   } | 89   } | 
| 94   ~VoEWrapper() {} | 90   ~VoEWrapper() {} | 
| 95   webrtc::VoiceEngine* engine() const { return engine_.get(); } | 91   webrtc::VoiceEngine* engine() const { return engine_.get(); } | 
| 96   webrtc::VoEBase* base() const { return base_.get(); } | 92   webrtc::VoEBase* base() const { return base_.get(); } | 
| 97   webrtc::VoECodec* codec() const { return codec_.get(); } | 93   webrtc::VoECodec* codec() const { return codec_.get(); } | 
| 98   webrtc::VoEHardware* hw() const { return hw_.get(); } | 94   webrtc::VoEHardware* hw() const { return hw_.get(); } | 
| 99   webrtc::VoEVolumeControl* volume() const { return volume_.get(); } |  | 
| 100   int error() { return base_->LastError(); } | 95   int error() { return base_->LastError(); } | 
| 101 | 96 | 
| 102  private: | 97  private: | 
| 103   scoped_voe_engine engine_; | 98   scoped_voe_engine engine_; | 
| 104   scoped_voe_ptr<webrtc::VoEBase> base_; | 99   scoped_voe_ptr<webrtc::VoEBase> base_; | 
| 105   scoped_voe_ptr<webrtc::VoECodec> codec_; | 100   scoped_voe_ptr<webrtc::VoECodec> codec_; | 
| 106   scoped_voe_ptr<webrtc::VoEHardware> hw_; | 101   scoped_voe_ptr<webrtc::VoEHardware> hw_; | 
| 107   scoped_voe_ptr<webrtc::VoEVolumeControl> volume_; |  | 
| 108 }; | 102 }; | 
| 109 }  // namespace cricket | 103 }  // namespace cricket | 
| 110 | 104 | 
| 111 #endif  // WEBRTC_MEDIA_ENGINE_WEBRTCVOE_H_ | 105 #endif  // WEBRTC_MEDIA_ENGINE_WEBRTCVOE_H_ | 
| OLD | NEW | 
|---|