1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <common.h>
17
18 using namespace OHOS::AudioStandard;
19
SetRecordState(SLRecordItf self,SLuint32 state)20 static SLresult SetRecordState(SLRecordItf self, SLuint32 state)
21 {
22 if (self == nullptr) {
23 return SL_RESULT_PARAMETER_INVALID;
24 }
25 IRecord *thiz = (IRecord *)self;
26 AudioCapturerAdapter::GetInstance()->SetCaptureStateAdapter(thiz->mId, state);
27 return SL_RESULT_SUCCESS;
28 }
29
GetRecordState(SLRecordItf self,SLuint32 * pState)30 static SLresult GetRecordState(SLRecordItf self, SLuint32 *pState)
31 {
32 if (self == nullptr) {
33 return SL_RESULT_PARAMETER_INVALID;
34 }
35 IRecord *thiz = (IRecord *)self;
36 AudioCapturerAdapter::GetInstance()->GetCaptureStateAdapter(thiz->mId, pState);
37 return SL_RESULT_SUCCESS;
38 }
39
SetDurationLimit(SLRecordItf self,SLmillisecond msec)40 static SLresult SetDurationLimit(SLRecordItf self, SLmillisecond msec)
41 {
42 return SL_RESULT_FEATURE_UNSUPPORTED;
43 }
44
GetPosition(SLRecordItf self,SLmillisecond * pMsec)45 static SLresult GetPosition(SLRecordItf self, SLmillisecond *pMsec)
46 {
47 return SL_RESULT_FEATURE_UNSUPPORTED;
48 }
49
RegisterCallback(SLRecordItf self,slRecordCallback callback,void * pContext)50 static SLresult RegisterCallback(SLRecordItf self, slRecordCallback callback, void *pContext)
51 {
52 return SL_RESULT_FEATURE_UNSUPPORTED;
53 }
54
SetCallbackEventsMask(SLRecordItf self,SLuint32 eventFlags)55 static SLresult SetCallbackEventsMask(SLRecordItf self, SLuint32 eventFlags)
56 {
57 return SL_RESULT_FEATURE_UNSUPPORTED;
58 }
59
GetCallbackEventsMask(SLRecordItf self,SLuint32 * pEventFlags)60 static SLresult GetCallbackEventsMask(SLRecordItf self, SLuint32 *pEventFlags)
61 {
62 return SL_RESULT_FEATURE_UNSUPPORTED;
63 }
64
SetMarkerPosition(SLRecordItf self,SLmillisecond mSec)65 static SLresult SetMarkerPosition(SLRecordItf self, SLmillisecond mSec)
66 {
67 return SL_RESULT_FEATURE_UNSUPPORTED;
68 }
69
ClearMarkerPosition(SLRecordItf self)70 static SLresult ClearMarkerPosition(SLRecordItf self)
71 {
72 return SL_RESULT_FEATURE_UNSUPPORTED;
73 }
74
GetMarkerPosition(SLRecordItf self,SLmillisecond * pMsec)75 static SLresult GetMarkerPosition(SLRecordItf self, SLmillisecond *pMsec)
76 {
77 return SL_RESULT_FEATURE_UNSUPPORTED;
78 }
79
SetPositionUpdatePeriod(SLRecordItf self,SLmillisecond mSec)80 static SLresult SetPositionUpdatePeriod(SLRecordItf self, SLmillisecond mSec)
81 {
82 return SL_RESULT_FEATURE_UNSUPPORTED;
83 }
84
GetPositionUpdatePeriod(SLRecordItf self,SLmillisecond * pMsec)85 static SLresult GetPositionUpdatePeriod(SLRecordItf self, SLmillisecond *pMsec)
86 {
87 return SL_RESULT_FEATURE_UNSUPPORTED;
88 }
89
90 static const struct SLRecordItf_ RecordItf = {
91 SetRecordState,
92 GetRecordState,
93 SetDurationLimit,
94 GetPosition,
95 RegisterCallback,
96 SetCallbackEventsMask,
97 GetCallbackEventsMask,
98 SetMarkerPosition,
99 ClearMarkerPosition,
100 GetMarkerPosition,
101 SetPositionUpdatePeriod,
102 GetPositionUpdatePeriod
103 };
104
IRecordInit(void * self,SLuint32 id)105 void IRecordInit(void *self, SLuint32 id)
106 {
107 IRecord *thiz = (IRecord *)self;
108 thiz->mItf = &RecordItf;
109 thiz->mState = SL_RECORDSTATE_STOPPED;
110 thiz->mId = id;
111 }
112