| 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 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 if (ptr) { | 37 if (ptr) { |
| 38 VERIFY(webrtc::VoiceEngine::Delete(ptr)); | 38 VERIFY(webrtc::VoiceEngine::Delete(ptr)); |
| 39 ptr = NULL; | 39 ptr = NULL; |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 webrtc::VoiceEngine* get() const { return ptr; } | 42 webrtc::VoiceEngine* get() const { return ptr; } |
| 43 private: | 43 private: |
| 44 webrtc::VoiceEngine* ptr; | 44 webrtc::VoiceEngine* ptr; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 // scoped_ptr class to handle obtaining and releasing WebRTC interface pointers | 47 // unique_ptr-like class to handle obtaining and releasing WebRTC interface |
| 48 // pointers. |
| 48 template<class T> | 49 template<class T> |
| 49 class scoped_voe_ptr { | 50 class scoped_voe_ptr { |
| 50 public: | 51 public: |
| 51 explicit scoped_voe_ptr(const scoped_voe_engine& e) | 52 explicit scoped_voe_ptr(const scoped_voe_engine& e) |
| 52 : ptr(T::GetInterface(e.get())) {} | 53 : ptr(T::GetInterface(e.get())) {} |
| 53 explicit scoped_voe_ptr(T* p) : ptr(p) {} | 54 explicit scoped_voe_ptr(T* p) : ptr(p) {} |
| 54 ~scoped_voe_ptr() { if (ptr) ptr->Release(); } | 55 ~scoped_voe_ptr() { if (ptr) ptr->Release(); } |
| 55 T* operator->() const { return ptr; } | 56 T* operator->() const { return ptr; } |
| 56 T* get() const { return ptr; } | 57 T* get() const { return ptr; } |
| 57 | 58 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 scoped_voe_ptr<webrtc::VoEBase> base_; | 111 scoped_voe_ptr<webrtc::VoEBase> base_; |
| 111 scoped_voe_ptr<webrtc::VoECodec> codec_; | 112 scoped_voe_ptr<webrtc::VoECodec> codec_; |
| 112 scoped_voe_ptr<webrtc::VoEHardware> hw_; | 113 scoped_voe_ptr<webrtc::VoEHardware> hw_; |
| 113 scoped_voe_ptr<webrtc::VoENetwork> network_; | 114 scoped_voe_ptr<webrtc::VoENetwork> network_; |
| 114 scoped_voe_ptr<webrtc::VoERTP_RTCP> rtp_; | 115 scoped_voe_ptr<webrtc::VoERTP_RTCP> rtp_; |
| 115 scoped_voe_ptr<webrtc::VoEVolumeControl> volume_; | 116 scoped_voe_ptr<webrtc::VoEVolumeControl> volume_; |
| 116 }; | 117 }; |
| 117 } // namespace cricket | 118 } // namespace cricket |
| 118 | 119 |
| 119 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVOE_H_ | 120 #endif // WEBRTC_MEDIA_ENGINE_WEBRTCVOE_H_ |
| OLD | NEW |