• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-2023 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 "media_log.h"
17 
18 namespace OHOS {
19 namespace Media {
RecorderClient()20 Recorder::RecorderClient::RecorderClient()
21 {
22     impl_ = new (nothrow) RecorderImpl();
23 }
24 
~RecorderClient()25 Recorder::RecorderClient::~RecorderClient()
26 {
27     if (impl_ != nullptr) {
28         delete impl_;
29         impl_ = nullptr;
30     }
31 }
32 
SetVideoSource(VideoSourceType source,int32_t & sourceId)33 int32_t Recorder::RecorderClient::SetVideoSource(VideoSourceType source, int32_t &sourceId)
34 {
35     if (impl_ == nullptr) {
36         MEDIA_ERR_LOG("No operation object");
37         return -1;
38     }
39     return impl_->SetVideoSource(source, sourceId);
40 }
41 
SetVideoEncoder(int32_t sourceId,VideoCodecFormat encoder)42 int32_t Recorder::RecorderClient::SetVideoEncoder(int32_t sourceId, VideoCodecFormat encoder)
43 {
44     if (impl_ == nullptr) {
45         MEDIA_ERR_LOG("No operation object");
46         return -1;
47     }
48     return impl_->SetVideoEncoder(sourceId, encoder);
49 }
50 
SetVideoSize(int32_t sourceId,int32_t width,int32_t height)51 int32_t Recorder::RecorderClient::SetVideoSize(int32_t sourceId, int32_t width, int32_t height)
52 {
53     if (impl_ == nullptr) {
54         MEDIA_ERR_LOG("No operation object");
55         return -1;
56     }
57     return impl_->SetVideoSize(sourceId, width, height);
58 }
59 
SetVideoFrameRate(int32_t sourceId,int32_t frameRate)60 int32_t Recorder::RecorderClient::SetVideoFrameRate(int32_t sourceId, int32_t frameRate)
61 {
62     if (impl_ == nullptr) {
63         MEDIA_ERR_LOG("No operation object");
64         return -1;
65     }
66     return impl_->SetVideoFrameRate(sourceId, frameRate);
67 }
68 
SetVideoEncodingBitRate(int32_t sourceId,int32_t rate)69 int32_t Recorder::RecorderClient::SetVideoEncodingBitRate(int32_t sourceId, int32_t rate)
70 {
71     if (impl_ == nullptr) {
72         MEDIA_ERR_LOG("No operation object");
73         return -1;
74     }
75     return impl_->SetVideoEncodingBitRate(sourceId, rate);
76 }
77 
SetCaptureRate(int32_t sourceId,double fps)78 int32_t Recorder::RecorderClient::SetCaptureRate(int32_t sourceId, double fps)
79 {
80     if (impl_ == nullptr) {
81         MEDIA_ERR_LOG("No operation object");
82         return -1;
83     }
84     return impl_->SetCaptureRate(sourceId, fps);
85 }
86 
GetSurface(int32_t sourceId)87 std::shared_ptr<OHOS::Surface> Recorder::RecorderClient::GetSurface(int32_t sourceId)
88 {
89     if (impl_ == nullptr) {
90         MEDIA_ERR_LOG("No operation object");
91         return nullptr;
92     }
93     return impl_->GetSurface(sourceId);
94 }
95 
SetAudioSource(AudioSourceType source,int32_t & sourceId)96 int32_t Recorder::RecorderClient::SetAudioSource(AudioSourceType source, int32_t &sourceId)
97 {
98     if (impl_ == nullptr) {
99         MEDIA_ERR_LOG("No operation object");
100         return -1;
101     }
102     return impl_->SetAudioSource(source, sourceId);
103 }
104 
SetAudioEncoder(int32_t sourceId,AudioCodecFormat encoder)105 int32_t Recorder::RecorderClient::SetAudioEncoder(int32_t sourceId, AudioCodecFormat encoder)
106 {
107     if (impl_ == nullptr) {
108         MEDIA_ERR_LOG("No operation object");
109         return -1;
110     }
111     return impl_->SetAudioEncoder(sourceId, encoder);
112 }
113 
SetAudioSampleRate(int32_t sourceId,int32_t rate)114 int32_t Recorder::RecorderClient::SetAudioSampleRate(int32_t sourceId, int32_t rate)
115 {
116     if (impl_ == nullptr) {
117         MEDIA_ERR_LOG("No operation object");
118         return -1;
119     }
120     return impl_->SetAudioSampleRate(sourceId, rate);
121 }
122 
SetAudioChannels(int32_t sourceId,int32_t num)123 int32_t Recorder::RecorderClient::SetAudioChannels(int32_t sourceId, int32_t num)
124 {
125     if (impl_ == nullptr) {
126         MEDIA_ERR_LOG("No operation object");
127         return -1;
128     }
129     return impl_->SetAudioChannels(sourceId, num);
130 }
131 
SetAudioEncodingBitRate(int32_t sourceId,int32_t bitRate)132 int32_t Recorder::RecorderClient::SetAudioEncodingBitRate(int32_t sourceId, int32_t bitRate)
133 {
134     if (impl_ == nullptr) {
135         MEDIA_ERR_LOG("No operation object");
136         return -1;
137     }
138     return impl_->SetAudioEncodingBitRate(sourceId, bitRate);
139 }
140 
SetDataSource(DataSourceType source,int32_t & sourceId)141 int32_t Recorder::RecorderClient::SetDataSource(DataSourceType source, int32_t &sourceId)
142 {
143     if (impl_ == nullptr) {
144         MEDIA_ERR_LOG("No operation object");
145         return -1;
146     }
147     return impl_->SetDataSource(source, sourceId);
148 }
149 
SetMaxDuration(int32_t duration)150 int32_t Recorder::RecorderClient::SetMaxDuration(int32_t duration)
151 {
152     if (impl_ == nullptr) {
153         MEDIA_ERR_LOG("No operation object");
154         return -1;
155     }
156     return impl_->SetMaxDuration(duration);
157 }
158 
SetOutputFormat(OutputFormatType format)159 int32_t Recorder::RecorderClient::SetOutputFormat(OutputFormatType format)
160 {
161     if (impl_ == nullptr) {
162         MEDIA_ERR_LOG("No operation object");
163         return -1;
164     }
165     return impl_->SetOutputFormat(format);
166 }
167 
SetOutputPath(const string & path)168 int32_t Recorder::RecorderClient::SetOutputPath(const string &path)
169 {
170     if (impl_ == nullptr) {
171         MEDIA_ERR_LOG("No operation object");
172         return -1;
173     }
174     return impl_->SetOutputPath(path);
175 }
176 
SetOutputFile(int32_t fd)177 int32_t Recorder::RecorderClient::SetOutputFile(int32_t fd)
178 {
179     if (impl_ == nullptr) {
180         MEDIA_ERR_LOG("No operation object");
181         return -1;
182     }
183     return impl_->SetOutputFile(fd);
184 }
185 
SetNextOutputFile(int32_t fd)186 int32_t Recorder::RecorderClient::SetNextOutputFile(int32_t fd)
187 {
188     if (impl_ == nullptr) {
189         MEDIA_ERR_LOG("No operation object");
190         return -1;
191     }
192     return impl_->SetNextOutputFile(fd);
193 }
194 
SetMaxFileSize(int64_t size)195 int32_t Recorder::RecorderClient::SetMaxFileSize(int64_t size)
196 {
197     if (impl_ == nullptr) {
198         MEDIA_ERR_LOG("No operation object");
199         return -1;
200     }
201     return impl_->SetMaxFileSize(size);
202 }
203 
SetRecorderCallback(const std::shared_ptr<RecorderCallback> & callback)204 int32_t Recorder::RecorderClient::SetRecorderCallback(const std::shared_ptr<RecorderCallback> &callback)
205 {
206     if (impl_ == nullptr) {
207         MEDIA_ERR_LOG("No operation object");
208         return -1;
209     }
210     return impl_->SetRecorderCallback(callback);
211 }
212 
Prepare()213 int32_t Recorder::RecorderClient::Prepare()
214 {
215     if (impl_ == nullptr) {
216         MEDIA_ERR_LOG("No operation object");
217         return -1;
218     }
219     return impl_->Prepare();
220 }
221 
Start()222 int32_t Recorder::RecorderClient::Start()
223 {
224     if (impl_ == nullptr) {
225         MEDIA_ERR_LOG("No operation object");
226         return -1;
227     }
228     return impl_->Start();
229 }
230 
Pause()231 int32_t Recorder::RecorderClient::Pause()
232 {
233     if (impl_ == nullptr) {
234         MEDIA_ERR_LOG("No operation object");
235         return -1;
236     }
237     return impl_->Pause();
238 }
239 
Resume()240 int32_t Recorder::RecorderClient::Resume()
241 {
242     if (impl_ == nullptr) {
243         MEDIA_ERR_LOG("No operation object");
244         return -1;
245     }
246     return impl_->Resume();
247 }
248 
Stop(bool block)249 int32_t Recorder::RecorderClient::Stop(bool block)
250 {
251     if (impl_ == nullptr) {
252         MEDIA_ERR_LOG("No operation object");
253         return -1;
254     }
255     return impl_->Stop(block);
256 }
257 
Reset()258 int32_t Recorder::RecorderClient::Reset()
259 {
260     if (impl_ == nullptr) {
261         MEDIA_ERR_LOG("No operation object");
262         return -1;
263     }
264     return impl_->Reset();
265 }
266 
Release()267 int32_t Recorder::RecorderClient::Release()
268 {
269     if (impl_ == nullptr) {
270         MEDIA_ERR_LOG("No operation object");
271         return -1;
272     }
273     return impl_->Release();
274 }
275 
SetFileSplitDuration(FileSplitType type,int64_t timestamp,uint32_t duration)276 int32_t Recorder::RecorderClient::SetFileSplitDuration(FileSplitType type, int64_t timestamp, uint32_t duration)
277 {
278     if (impl_ == nullptr) {
279         MEDIA_ERR_LOG("No operation object");
280         return -1;
281     }
282     return impl_->SetFileSplitDuration(type, timestamp, duration);
283 }
284 
SetParameter(int32_t sourceId,const Format & format)285 int32_t Recorder::RecorderClient::SetParameter(int32_t sourceId, const Format &format)
286 {
287     if (impl_ == nullptr) {
288         MEDIA_ERR_LOG("No operation object");
289         return -1;
290     }
291     return impl_->SetParameter(sourceId, format);
292 }
293 } /* namespace Media */
294 } /* namespace OHOS */