Line data Source code
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 :
11 :
12 : namespace mozilla
13 : {
14 : /**
15 : * A Custom scoped template to release a resoure of Type T
16 : * with a function of Type F
17 : * ScopedCustomReleasePtr<webrtc::VoENetwork> ptr =
18 : * webrtc::VoENetwork->GetInterface(voiceEngine);
19 : *
20 : */
21 : template<typename T>
22 : struct ScopedCustomReleaseTraits0
23 : {
24 : typedef T* type;
25 12 : static T* empty() { return nullptr; }
26 0 : static void release(T* ptr)
27 : {
28 0 : if(ptr)
29 : {
30 0 : (ptr)->Release();
31 : }
32 0 : }
33 : };
34 :
35 12 : SCOPED_TEMPLATE(ScopedCustomReleasePtr, ScopedCustomReleaseTraits0)
36 : }//namespace
37 :
38 :
39 : #endif
|