| 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 20 matching lines...) Expand all Loading... |
| 31 #include "talk/media/webrtc/webrtccommon.h" | 31 #include "talk/media/webrtc/webrtccommon.h" |
| 32 #include "webrtc/base/common.h" | 32 #include "webrtc/base/common.h" |
| 33 | 33 |
| 34 #include "webrtc/common_types.h" | 34 #include "webrtc/common_types.h" |
| 35 #include "webrtc/modules/audio_device/include/audio_device.h" | 35 #include "webrtc/modules/audio_device/include/audio_device.h" |
| 36 #include "webrtc/voice_engine/include/voe_audio_processing.h" | 36 #include "webrtc/voice_engine/include/voe_audio_processing.h" |
| 37 #include "webrtc/voice_engine/include/voe_base.h" | 37 #include "webrtc/voice_engine/include/voe_base.h" |
| 38 #include "webrtc/voice_engine/include/voe_codec.h" | 38 #include "webrtc/voice_engine/include/voe_codec.h" |
| 39 #include "webrtc/voice_engine/include/voe_dtmf.h" | 39 #include "webrtc/voice_engine/include/voe_dtmf.h" |
| 40 #include "webrtc/voice_engine/include/voe_errors.h" | 40 #include "webrtc/voice_engine/include/voe_errors.h" |
| 41 #include "webrtc/voice_engine/include/voe_external_media.h" | |
| 42 #include "webrtc/voice_engine/include/voe_file.h" | |
| 43 #include "webrtc/voice_engine/include/voe_hardware.h" | 41 #include "webrtc/voice_engine/include/voe_hardware.h" |
| 44 #include "webrtc/voice_engine/include/voe_neteq_stats.h" | |
| 45 #include "webrtc/voice_engine/include/voe_network.h" | 42 #include "webrtc/voice_engine/include/voe_network.h" |
| 46 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" | 43 #include "webrtc/voice_engine/include/voe_rtp_rtcp.h" |
| 47 #include "webrtc/voice_engine/include/voe_video_sync.h" | |
| 48 #include "webrtc/voice_engine/include/voe_volume_control.h" | 44 #include "webrtc/voice_engine/include/voe_volume_control.h" |
| 49 | 45 |
| 50 namespace cricket { | 46 namespace cricket { |
| 51 // automatically handles lifetime of WebRtc VoiceEngine | 47 // automatically handles lifetime of WebRtc VoiceEngine |
| 52 class scoped_voe_engine { | 48 class scoped_voe_engine { |
| 53 public: | 49 public: |
| 54 explicit scoped_voe_engine(webrtc::VoiceEngine* e) : ptr(e) {} | 50 explicit scoped_voe_engine(webrtc::VoiceEngine* e) : ptr(e) {} |
| 55 // VERIFY, to ensure that there are no leaks at shutdown | 51 // VERIFY, to ensure that there are no leaks at shutdown |
| 56 ~scoped_voe_engine() { if (ptr) VERIFY(webrtc::VoiceEngine::Delete(ptr)); } | 52 ~scoped_voe_engine() { if (ptr) VERIFY(webrtc::VoiceEngine::Delete(ptr)); } |
| 57 // Releases the current pointer. | 53 // Releases the current pointer. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 T* ptr; | 85 T* ptr; |
| 90 }; | 86 }; |
| 91 | 87 |
| 92 // Utility class for aggregating the various WebRTC interface. | 88 // Utility class for aggregating the various WebRTC interface. |
| 93 // Fake implementations can also be injected for testing. | 89 // Fake implementations can also be injected for testing. |
| 94 class VoEWrapper { | 90 class VoEWrapper { |
| 95 public: | 91 public: |
| 96 VoEWrapper() | 92 VoEWrapper() |
| 97 : engine_(webrtc::VoiceEngine::Create()), processing_(engine_), | 93 : engine_(webrtc::VoiceEngine::Create()), processing_(engine_), |
| 98 base_(engine_), codec_(engine_), dtmf_(engine_), | 94 base_(engine_), codec_(engine_), dtmf_(engine_), |
| 99 hw_(engine_), neteq_(engine_), network_(engine_), | 95 hw_(engine_), network_(engine_), |
| 100 rtp_(engine_), sync_(engine_), volume_(engine_) { | 96 rtp_(engine_), volume_(engine_) { |
| 101 } | 97 } |
| 102 VoEWrapper(webrtc::VoEAudioProcessing* processing, | 98 VoEWrapper(webrtc::VoEAudioProcessing* processing, |
| 103 webrtc::VoEBase* base, | 99 webrtc::VoEBase* base, |
| 104 webrtc::VoECodec* codec, | 100 webrtc::VoECodec* codec, |
| 105 webrtc::VoEDtmf* dtmf, | 101 webrtc::VoEDtmf* dtmf, |
| 106 webrtc::VoEHardware* hw, | 102 webrtc::VoEHardware* hw, |
| 107 webrtc::VoENetEqStats* neteq, | |
| 108 webrtc::VoENetwork* network, | 103 webrtc::VoENetwork* network, |
| 109 webrtc::VoERTP_RTCP* rtp, | 104 webrtc::VoERTP_RTCP* rtp, |
| 110 webrtc::VoEVideoSync* sync, | |
| 111 webrtc::VoEVolumeControl* volume) | 105 webrtc::VoEVolumeControl* volume) |
| 112 : engine_(NULL), | 106 : engine_(NULL), |
| 113 processing_(processing), | 107 processing_(processing), |
| 114 base_(base), | 108 base_(base), |
| 115 codec_(codec), | 109 codec_(codec), |
| 116 dtmf_(dtmf), | 110 dtmf_(dtmf), |
| 117 hw_(hw), | 111 hw_(hw), |
| 118 neteq_(neteq), | |
| 119 network_(network), | 112 network_(network), |
| 120 rtp_(rtp), | 113 rtp_(rtp), |
| 121 sync_(sync), | |
| 122 volume_(volume) { | 114 volume_(volume) { |
| 123 } | 115 } |
| 124 ~VoEWrapper() {} | 116 ~VoEWrapper() {} |
| 125 webrtc::VoiceEngine* engine() const { return engine_.get(); } | 117 webrtc::VoiceEngine* engine() const { return engine_.get(); } |
| 126 webrtc::VoEAudioProcessing* processing() const { return processing_.get(); } | 118 webrtc::VoEAudioProcessing* processing() const { return processing_.get(); } |
| 127 webrtc::VoEBase* base() const { return base_.get(); } | 119 webrtc::VoEBase* base() const { return base_.get(); } |
| 128 webrtc::VoECodec* codec() const { return codec_.get(); } | 120 webrtc::VoECodec* codec() const { return codec_.get(); } |
| 129 webrtc::VoEDtmf* dtmf() const { return dtmf_.get(); } | 121 webrtc::VoEDtmf* dtmf() const { return dtmf_.get(); } |
| 130 webrtc::VoEHardware* hw() const { return hw_.get(); } | 122 webrtc::VoEHardware* hw() const { return hw_.get(); } |
| 131 webrtc::VoENetEqStats* neteq() const { return neteq_.get(); } | |
| 132 webrtc::VoENetwork* network() const { return network_.get(); } | 123 webrtc::VoENetwork* network() const { return network_.get(); } |
| 133 webrtc::VoERTP_RTCP* rtp() const { return rtp_.get(); } | 124 webrtc::VoERTP_RTCP* rtp() const { return rtp_.get(); } |
| 134 webrtc::VoEVideoSync* sync() const { return sync_.get(); } | |
| 135 webrtc::VoEVolumeControl* volume() const { return volume_.get(); } | 125 webrtc::VoEVolumeControl* volume() const { return volume_.get(); } |
| 136 int error() { return base_->LastError(); } | 126 int error() { return base_->LastError(); } |
| 137 | 127 |
| 138 private: | 128 private: |
| 139 scoped_voe_engine engine_; | 129 scoped_voe_engine engine_; |
| 140 scoped_voe_ptr<webrtc::VoEAudioProcessing> processing_; | 130 scoped_voe_ptr<webrtc::VoEAudioProcessing> processing_; |
| 141 scoped_voe_ptr<webrtc::VoEBase> base_; | 131 scoped_voe_ptr<webrtc::VoEBase> base_; |
| 142 scoped_voe_ptr<webrtc::VoECodec> codec_; | 132 scoped_voe_ptr<webrtc::VoECodec> codec_; |
| 143 scoped_voe_ptr<webrtc::VoEDtmf> dtmf_; | 133 scoped_voe_ptr<webrtc::VoEDtmf> dtmf_; |
| 144 scoped_voe_ptr<webrtc::VoEHardware> hw_; | 134 scoped_voe_ptr<webrtc::VoEHardware> hw_; |
| 145 scoped_voe_ptr<webrtc::VoENetEqStats> neteq_; | |
| 146 scoped_voe_ptr<webrtc::VoENetwork> network_; | 135 scoped_voe_ptr<webrtc::VoENetwork> network_; |
| 147 scoped_voe_ptr<webrtc::VoERTP_RTCP> rtp_; | 136 scoped_voe_ptr<webrtc::VoERTP_RTCP> rtp_; |
| 148 scoped_voe_ptr<webrtc::VoEVideoSync> sync_; | |
| 149 scoped_voe_ptr<webrtc::VoEVolumeControl> volume_; | 137 scoped_voe_ptr<webrtc::VoEVolumeControl> volume_; |
| 150 }; | 138 }; |
| 151 | 139 |
| 152 // Adds indirection to static WebRtc functions, allowing them to be mocked. | 140 // Adds indirection to static WebRtc functions, allowing them to be mocked. |
| 153 class VoETraceWrapper { | 141 class VoETraceWrapper { |
| 154 public: | 142 public: |
| 155 virtual ~VoETraceWrapper() {} | 143 virtual ~VoETraceWrapper() {} |
| 156 | 144 |
| 157 virtual int SetTraceFilter(const unsigned int filter) { | 145 virtual int SetTraceFilter(const unsigned int filter) { |
| 158 return webrtc::VoiceEngine::SetTraceFilter(filter); | 146 return webrtc::VoiceEngine::SetTraceFilter(filter); |
| 159 } | 147 } |
| 160 virtual int SetTraceFile(const char* fileNameUTF8) { | 148 virtual int SetTraceFile(const char* fileNameUTF8) { |
| 161 return webrtc::VoiceEngine::SetTraceFile(fileNameUTF8); | 149 return webrtc::VoiceEngine::SetTraceFile(fileNameUTF8); |
| 162 } | 150 } |
| 163 virtual int SetTraceCallback(webrtc::TraceCallback* callback) { | 151 virtual int SetTraceCallback(webrtc::TraceCallback* callback) { |
| 164 return webrtc::VoiceEngine::SetTraceCallback(callback); | 152 return webrtc::VoiceEngine::SetTraceCallback(callback); |
| 165 } | 153 } |
| 166 }; | 154 }; |
| 167 | 155 |
| 168 } // namespace cricket | 156 } // namespace cricket |
| 169 | 157 |
| 170 #endif // TALK_MEDIA_WEBRTCVOE_H_ | 158 #endif // TALK_MEDIA_WEBRTCVOE_H_ |
| OLD | NEW |