Tizen 2.0 Release
[framework/osp/media.git] / src / FMediaVoipAudioSessionManager.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License)
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 #include <FBase.h>
19 #include <FBaseSysLog.h>
20 #include <FSec_AccessController.h>
21 #include <FMediaAudioManagerTypes.h>
22 #include <FMediaVoipAudioSessionManager.h>
23 #include "FMedia_VoipAudioSessionManagerImpl.h"
24
25 using namespace Tizen::Base;
26 using namespace Tizen::Base::Collection;
27 using namespace Tizen::Base::Runtime;
28 using namespace Tizen::Security;
29
30 namespace Tizen { namespace Media
31 {
32
33
34 VoipAudioSessionManager::VoipAudioSessionManager()
35 {
36         __pVoipAudioSessionManagerImpl = _VoipAudioSessionManagerImpl::GetInstance();
37 }
38
39 VoipAudioSessionManager::~VoipAudioSessionManager()
40 {
41         if (__pVoipAudioSessionManagerImpl != null)
42         {
43                 __pVoipAudioSessionManagerImpl = null;
44         }
45 }
46
47 VoipAudioSessionManager*
48 VoipAudioSessionManager::GetInstance(void)
49 {
50         result r = E_SUCCESS;
51
52         r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_VOIPSESSION);
53         SysTryCatch(NID_MEDIA,  r == E_SUCCESS, , E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
54
55         static VoipAudioSessionManager voipSessionManager;
56         return (&voipSessionManager);
57
58 CATCH:
59         return null;
60 }
61
62 result
63 VoipAudioSessionManager::EnterCallSession(void)
64 {
65         result r = E_SUCCESS;
66
67         r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_VOIPSESSION);
68         SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
69
70         return __pVoipAudioSessionManagerImpl->EnterCallSession();
71 }
72
73
74 result
75 VoipAudioSessionManager::ExitCallSession(void)
76 {
77         result r = E_SUCCESS;
78
79         r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_VOIPSESSION);
80         SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
81
82         return __pVoipAudioSessionManagerImpl->ExitCallSession();
83 }
84
85 result
86 VoipAudioSessionManager::SetCallSessionMode(VoipAudioSessionMode mode)
87 {
88         result r = E_SUCCESS;
89
90         r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_VOIPSESSION);
91         SysTryReturn(NID_MEDIA,  r == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
92
93         return __pVoipAudioSessionManagerImpl->SetCallSessionMode(mode);
94 }
95
96 VoipAudioSessionMode
97 VoipAudioSessionManager::GetCallSessionMode(void) const
98 {
99         result r = E_SUCCESS;
100
101         r = _AccessController::CheckUserPrivilege(_PRV_AUDIOMANAGER_VOIPSESSION);
102         SysTryCatch(NID_MEDIA,  r == E_SUCCESS, , E_PRIVILEGE_DENIED, "[E_PRIVILEGE_DENIED] This application does not have the privilege to call this method.");
103
104         return __pVoipAudioSessionManagerImpl->GetCallSessionMode();
105
106 CATCH:
107         return (VoipAudioSessionMode) -1;
108 }
109
110 };
111 };