1 /* This Source Code Form is subject to the terms of the Mozilla Public
2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
4 
5 #ifndef MEDIA_ENGINE_WRAPPER_H_
6 #define MEDIA_ENGINE_WRAPPER_H_
7 
8 #include <mozilla/Scoped.h>
9 
10 namespace mozilla {
11 /**
12  * A Custom scoped template to release a resoure of Type T
13  * with a function of Type F
14  * ScopedCustomReleasePtr<webrtc::VoENetwork> ptr =
15  *               webrtc::VoENetwork->GetInterface(voiceEngine);
16  *
17  */
18 template <typename T>
19 struct ScopedCustomReleaseTraits0 {
20   typedef T* type;
emptyScopedCustomReleaseTraits021   static T* empty() { return nullptr; }
releaseScopedCustomReleaseTraits022   static void release(T* ptr) {
23     if (ptr) {
24       (ptr)->Release();
25     }
26   }
27 };
28 
29 SCOPED_TEMPLATE(ScopedCustomReleasePtr, ScopedCustomReleaseTraits0)
30 }  // namespace mozilla
31 
32 #endif
33