1 /*
2 * Copyright (c) 2021-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 "hcapture_session.h"
17
18 #include "camera_util.h"
19 #include "camera_log.h"
20 #include "surface.h"
21 #include "ipc_skeleton.h"
22 #include "metadata_utils.h"
23 #include "bundle_mgr_interface.h"
24 #include "iservice_registry.h"
25 #include "system_ability_definition.h"
26
27 using namespace OHOS::AppExecFwk;
28 using namespace OHOS::AAFwk;
29
30 namespace OHOS {
31 namespace CameraStandard {
32 static std::map<int32_t, sptr<HCaptureSession>> session_;
33 static std::mutex sessionLock_;
34 static std::map<CaptureSessionState, std::string> sessionState_ = {
35 {CaptureSessionState::SESSION_INIT, "Init"},
36 {CaptureSessionState::SESSION_CONFIG_INPROGRESS, "Config_In-progress"},
37 {CaptureSessionState::SESSION_CONFIG_COMMITTED, "Committed"}
38 };
GetClientBundle(int uid)39 static std::string GetClientBundle(int uid)
40 {
41 std::string bundleName = "";
42 auto samgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
43 if (samgr == nullptr) {
44 MEDIA_ERR_LOG("Get ability manager failed");
45 return bundleName;
46 }
47
48 sptr<IRemoteObject> object = samgr->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
49 if (object == nullptr) {
50 MEDIA_DEBUG_LOG("object is NULL.");
51 return bundleName;
52 }
53
54 sptr<AppExecFwk::IBundleMgr> bms = iface_cast<AppExecFwk::IBundleMgr>(object);
55 if (bms == nullptr) {
56 MEDIA_DEBUG_LOG("bundle manager service is NULL.");
57 return bundleName;
58 }
59
60 auto result = bms->GetBundleNameForUid(uid, bundleName);
61 if (!result) {
62 MEDIA_ERR_LOG("GetBundleNameForUid fail");
63 return "";
64 }
65 MEDIA_INFO_LOG("bundle name is %{public}s ", bundleName.c_str());
66
67 return bundleName;
68 }
69
HCaptureSession(sptr<HCameraHostManager> cameraHostManager,sptr<StreamOperatorCallback> streamOperatorCb,const uint32_t callingTokenId)70 HCaptureSession::HCaptureSession(sptr<HCameraHostManager> cameraHostManager,
71 sptr<StreamOperatorCallback> streamOperatorCb, const uint32_t callingTokenId)
72 : cameraHostManager_(cameraHostManager), streamOperatorCallback_(streamOperatorCb),
73 sessionCallback_(nullptr)
74 {
75 pid_ = IPCSkeleton::GetCallingPid();
76 uid_ = IPCSkeleton::GetCallingUid();
77 MEDIA_DEBUG_LOG("HCaptureSession: camera stub services(%{public}zu) pid(%{public}d).", session_.size(), pid_);
78 std::map<int32_t, sptr<HCaptureSession>> oldSessions;
79 for (auto it = session_.begin(); it != session_.end(); it++) {
80 sptr<HCaptureSession> session = it->second;
81 oldSessions[it->first] = session;
82 }
83 for (auto it = oldSessions.begin(); it != oldSessions.end(); it++) {
84 if (it->second != nullptr) {
85 sptr<HCaptureSession> session = it->second;
86 sptr<HCameraDevice> disconnectDevice;
87 int32_t rc = session->GetCameraDevice(disconnectDevice);
88 if (rc == CAMERA_OK) {
89 disconnectDevice->OnError(DEVICE_PREEMPT, 0);
90 }
91 session->Release(it->first);
92 MEDIA_ERR_LOG("currently multi-session not supported, release session for pid(%{public}d)", it->first);
93 }
94 }
95 std::lock_guard<std::mutex> lock(sessionLock_);
96 session_[pid_] = this;
97 callerToken_ = callingTokenId;
98 MEDIA_DEBUG_LOG("HCaptureSession: camera stub services(%{public}zu).", session_.size());
99 }
100
~HCaptureSession()101 HCaptureSession::~HCaptureSession()
102 {}
103
BeginConfig()104 int32_t HCaptureSession::BeginConfig()
105 {
106 CAMERA_SYNC_TRACE;
107 if (curState_ == CaptureSessionState::SESSION_CONFIG_INPROGRESS) {
108 MEDIA_ERR_LOG("HCaptureSession::BeginConfig Already in config inprogress state!");
109 return CAMERA_INVALID_STATE;
110 }
111 std::lock_guard<std::mutex> lock(sessionLock_);
112 prevState_ = curState_;
113 curState_ = CaptureSessionState::SESSION_CONFIG_INPROGRESS;
114 tempCameraDevices_.clear();
115 tempStreams_.clear();
116 deletedStreamIds_.clear();
117 return CAMERA_OK;
118 }
119
AddInput(sptr<ICameraDeviceService> cameraDevice)120 int32_t HCaptureSession::AddInput(sptr<ICameraDeviceService> cameraDevice)
121 {
122 CAMERA_SYNC_TRACE;
123 sptr<HCameraDevice> localCameraDevice = nullptr;
124
125 if (cameraDevice == nullptr) {
126 MEDIA_ERR_LOG("HCaptureSession::AddInput cameraDevice is null");
127 return CAMERA_INVALID_ARG;
128 }
129 std::lock_guard<std::mutex> lock(sessionLock_);
130 if (curState_ != CaptureSessionState::SESSION_CONFIG_INPROGRESS) {
131 MEDIA_ERR_LOG("HCaptureSession::AddInput Need to call BeginConfig before adding input");
132 return CAMERA_INVALID_STATE;
133 }
134 if (!tempCameraDevices_.empty() || (cameraDevice_ != nullptr && !cameraDevice_->IsReleaseCameraDevice())) {
135 MEDIA_ERR_LOG("HCaptureSession::AddInput Only one input is supported");
136 return CAMERA_INVALID_SESSION_CFG;
137 }
138 localCameraDevice = static_cast<HCameraDevice*>(cameraDevice.GetRefPtr());
139 if (cameraDevice_ == localCameraDevice && cameraDevice_ != nullptr) {
140 cameraDevice_->SetReleaseCameraDevice(false);
141 } else {
142 tempCameraDevices_.emplace_back(localCameraDevice);
143 CAMERA_SYSEVENT_STATISTIC(CreateMsg("CaptureSession::AddInput"));
144 }
145
146 sptr<IStreamOperator> streamOperator;
147 int32_t rc = localCameraDevice->GetStreamOperator(streamOperatorCallback_, streamOperator);
148 if (rc != CAMERA_OK) {
149 MEDIA_ERR_LOG("HCaptureSession::GetCameraDevice GetStreamOperator returned %{public}d", rc);
150 localCameraDevice->Close();
151 return rc;
152 }
153 return CAMERA_OK;
154 }
155
AddOutputStream(sptr<HStreamCommon> stream)156 int32_t HCaptureSession::AddOutputStream(sptr<HStreamCommon> stream)
157 {
158 std::lock_guard<std::mutex> lock(sessionLock_);
159 if (stream == nullptr) {
160 MEDIA_ERR_LOG("HCaptureSession::AddOutputStream stream is null");
161 return CAMERA_INVALID_ARG;
162 }
163 if (curState_ != CaptureSessionState::SESSION_CONFIG_INPROGRESS) {
164 MEDIA_ERR_LOG("HCaptureSession::AddOutputStream Need to call BeginConfig before adding output");
165 return CAMERA_INVALID_STATE;
166 }
167 if (std::find(tempStreams_.begin(), tempStreams_.end(), stream) != tempStreams_.end()) {
168 MEDIA_ERR_LOG("HCaptureSession::AddOutputStream Adding same output multiple times in tempStreams_");
169 return CAMERA_INVALID_SESSION_CFG;
170 }
171 int32_t rc = FindRepeatStream(stream);
172 if (rc != STREAM_NOT_FOUNT) {
173 return rc;
174 }
175 if (stream) {
176 stream->SetReleaseStream(false);
177 }
178 tempStreams_.emplace_back(stream);
179 return CAMERA_OK;
180 }
FindRepeatStream(sptr<HStreamCommon> stream)181 int32_t HCaptureSession::FindRepeatStream(sptr<HStreamCommon> stream)
182 {
183 std::lock_guard<std::mutex> lock(streamsLock_);
184 auto it = std::find(streams_.begin(), streams_.end(), stream);
185 if (it != streams_.end()) {
186 if (stream && stream->IsReleaseStream()) {
187 stream->SetReleaseStream(false);
188 auto it2 = std::find(deletedStreamIds_.begin(), deletedStreamIds_.end(), stream->GetStreamId());
189 if (it2 != deletedStreamIds_.end()) {
190 deletedStreamIds_.erase(it2);
191 }
192 return CAMERA_OK;
193 } else {
194 MEDIA_ERR_LOG("HCaptureSession::AddOutputStream Adding same output multiple times in streams_");
195 return CAMERA_INVALID_SESSION_CFG;
196 }
197 }
198 return STREAM_NOT_FOUNT;
199 }
200
AddOutput(StreamType streamType,sptr<IStreamCommon> stream)201 int32_t HCaptureSession::AddOutput(StreamType streamType, sptr<IStreamCommon> stream)
202 {
203 int32_t rc = CAMERA_INVALID_ARG;
204 if (stream == nullptr) {
205 MEDIA_ERR_LOG("HCaptureSession::AddOutput stream is null");
206 return rc;
207 }
208 // Temp hack to fix the library linking issue
209 sptr<Surface> captureSurface = Surface::CreateSurfaceAsConsumer();
210
211 if (streamType == StreamType::CAPTURE) {
212 rc = AddOutputStream(static_cast<HStreamCapture *>(stream.GetRefPtr()));
213 } else if (streamType == StreamType::REPEAT) {
214 rc = AddOutputStream(static_cast<HStreamRepeat *>(stream.GetRefPtr()));
215 } else if (streamType == StreamType::METADATA) {
216 rc = AddOutputStream(static_cast<HStreamMetadata *>(stream.GetRefPtr()));
217 }
218 CAMERA_SYSEVENT_STATISTIC(CreateMsg("CaptureSession::AddOutput with %d", streamType));
219 MEDIA_INFO_LOG("CaptureSession::AddOutput with with %{public}d, rc = %{public}d", streamType, rc);
220 return rc;
221 }
222
RemoveInput(sptr<ICameraDeviceService> cameraDevice)223 int32_t HCaptureSession::RemoveInput(sptr<ICameraDeviceService> cameraDevice)
224 {
225 if (cameraDevice == nullptr) {
226 MEDIA_ERR_LOG("HCaptureSession::RemoveInput cameraDevice is null");
227 return CAMERA_INVALID_ARG;
228 }
229 if (curState_ != CaptureSessionState::SESSION_CONFIG_INPROGRESS) {
230 MEDIA_ERR_LOG("HCaptureSession::RemoveInput Need to call BeginConfig before removing input");
231 return CAMERA_INVALID_STATE;
232 }
233 std::lock_guard<std::mutex> lock(sessionLock_);
234 sptr<HCameraDevice> localCameraDevice;
235 localCameraDevice = static_cast<HCameraDevice*>(cameraDevice.GetRefPtr());
236 auto it = std::find(tempCameraDevices_.begin(), tempCameraDevices_.end(), localCameraDevice);
237 if (it != tempCameraDevices_.end()) {
238 tempCameraDevices_.erase(it);
239 } else if (cameraDevice_ != nullptr && cameraDevice_ == localCameraDevice) {
240 cameraDevice_->SetReleaseCameraDevice(true);
241 } else {
242 MEDIA_ERR_LOG("HCaptureSession::RemoveInput Invalid camera device");
243 return CAMERA_INVALID_SESSION_CFG;
244 }
245 CAMERA_SYSEVENT_STATISTIC(CreateMsg("CaptureSession::RemoveInput"));
246 return CAMERA_OK;
247 }
248
RemoveOutputStream(sptr<HStreamCommon> stream)249 int32_t HCaptureSession::RemoveOutputStream(sptr<HStreamCommon> stream)
250 {
251 if (stream == nullptr) {
252 MEDIA_ERR_LOG("HCaptureSession::RemoveOutputStream stream is null");
253 return CAMERA_INVALID_ARG;
254 }
255 if (curState_ != CaptureSessionState::SESSION_CONFIG_INPROGRESS) {
256 MEDIA_ERR_LOG("HCaptureSession::RemoveOutputStream Need to call BeginConfig before removing output");
257 return CAMERA_INVALID_STATE;
258 }
259 auto it = std::find(tempStreams_.begin(), tempStreams_.end(), stream);
260 if (it != tempStreams_.end()) {
261 tempStreams_.erase(it);
262 } else {
263 std::lock_guard<std::mutex> lock(streamsLock_);
264 it = std::find(streams_.begin(), streams_.end(), stream);
265 if (it != streams_.end()) {
266 if (stream && !stream->IsReleaseStream()) {
267 deletedStreamIds_.emplace_back(stream->GetStreamId());
268 stream->SetReleaseStream(true);
269 }
270 } else {
271 MEDIA_ERR_LOG("HCaptureSession::RemoveOutputStream Invalid output");
272 return CAMERA_INVALID_SESSION_CFG;
273 }
274 }
275 return CAMERA_OK;
276 }
277
RemoveOutput(StreamType streamType,sptr<IStreamCommon> stream)278 int32_t HCaptureSession::RemoveOutput(StreamType streamType, sptr<IStreamCommon> stream)
279 {
280 int32_t rc = CAMERA_INVALID_ARG;
281 if (stream == nullptr) {
282 MEDIA_ERR_LOG("HCaptureSession::RemoveOutput stream is null");
283 return rc;
284 }
285 std::lock_guard<std::mutex> lock(sessionLock_);
286 if (streamType == StreamType::CAPTURE) {
287 rc = RemoveOutputStream(static_cast<HStreamCapture *>(stream.GetRefPtr()));
288 } else if (streamType == StreamType::REPEAT) {
289 rc = RemoveOutputStream(static_cast<HStreamRepeat *>(stream.GetRefPtr()));
290 } else if (streamType == StreamType::METADATA) {
291 rc = RemoveOutputStream(static_cast<HStreamMetadata *>(stream.GetRefPtr()));
292 }
293 CAMERA_SYSEVENT_STATISTIC(CreateMsg("CaptureSession::RemoveOutput with %d", streamType));
294 return rc;
295 }
296
ValidateSessionInputs()297 int32_t HCaptureSession::ValidateSessionInputs()
298 {
299 if (tempCameraDevices_.empty() && (cameraDevice_ == nullptr || cameraDevice_->IsReleaseCameraDevice())) {
300 MEDIA_ERR_LOG("HCaptureSession::ValidateSessionInputs No inputs present");
301 return CAMERA_INVALID_SESSION_CFG;
302 }
303 return CAMERA_OK;
304 }
305
ValidateSessionOutputs()306 int32_t HCaptureSession::ValidateSessionOutputs()
307 {
308 if (tempStreams_.size() + streams_.size() - deletedStreamIds_.size() == 0) {
309 MEDIA_ERR_LOG("HCaptureSession::ValidateSessionOutputs No outputs present");
310 return CAMERA_INVALID_SESSION_CFG;
311 }
312 return CAMERA_OK;
313 }
314
GetCameraDevice(sptr<HCameraDevice> & device)315 int32_t HCaptureSession::GetCameraDevice(sptr<HCameraDevice> &device)
316 {
317 if (cameraDevice_ != nullptr && !cameraDevice_->IsReleaseCameraDevice()) {
318 MEDIA_DEBUG_LOG("HCaptureSession::GetCameraDevice Camera device has not changed");
319 device = cameraDevice_;
320 return CAMERA_OK;
321 } else if (!tempCameraDevices_.empty()) {
322 device = tempCameraDevices_[0];
323 return CAMERA_OK;
324 }
325
326 MEDIA_ERR_LOG("HCaptureSession::GetCameraDevice Failed because don't have camera device");
327 return CAMERA_INVALID_STATE;
328 }
329
GetCurrentStreamInfos(sptr<HCameraDevice> & device,std::shared_ptr<OHOS::Camera::CameraMetadata> & deviceSettings,std::vector<StreamInfo> & streamInfos)330 int32_t HCaptureSession::GetCurrentStreamInfos(sptr<HCameraDevice> &device,
331 std::shared_ptr<OHOS::Camera::CameraMetadata> &deviceSettings,
332 std::vector<StreamInfo> &streamInfos)
333 {
334 int32_t rc;
335 int32_t streamId = streamId_;
336 bool isNeedLink;
337 StreamInfo curStreamInfo;
338 sptr<IStreamOperator> streamOperator;
339 if (device != nullptr) {
340 streamOperator = device->GetStreamOperator();
341 }
342 isNeedLink = (device != cameraDevice_);
343 std::lock_guard<std::mutex> lock(streamsLock_);
344 sptr<HStreamCommon> curStream;
345 for (auto item = streams_.begin(); item != streams_.end(); ++item) {
346 curStream = *item;
347 if (curStream && curStream->IsReleaseStream()) {
348 continue;
349 }
350 if (curStream && isNeedLink) {
351 rc = curStream->LinkInput(streamOperator, deviceSettings, streamId);
352 if (rc != CAMERA_OK) {
353 MEDIA_ERR_LOG("HCaptureSession::GetCurrentStreamInfos() Failed to link Output, %{public}d", rc);
354 return rc;
355 }
356 streamId++;
357 }
358 if (curStream) {
359 curStream->SetStreamInfo(curStreamInfo);
360 }
361 streamInfos.push_back(curStreamInfo);
362 }
363 if (streamId != streamId_) {
364 streamId_ = streamId;
365 }
366 return CAMERA_OK;
367 }
368
CreateAndCommitStreams(sptr<HCameraDevice> & device,std::shared_ptr<OHOS::Camera::CameraMetadata> & deviceSettings,std::vector<StreamInfo> & streamInfos)369 int32_t HCaptureSession::CreateAndCommitStreams(sptr<HCameraDevice> &device,
370 std::shared_ptr<OHOS::Camera::CameraMetadata> &deviceSettings,
371 std::vector<StreamInfo> &streamInfos)
372 {
373 CamRetCode hdiRc = HDI::Camera::V1_0::NO_ERROR;
374 StreamInfo curStreamInfo;
375 sptr<IStreamOperator> streamOperator;
376 if (device != nullptr) {
377 streamOperator = device->GetStreamOperator();
378 }
379 if (streamOperator != nullptr && !streamInfos.empty()) {
380 hdiRc = (CamRetCode)(streamOperator->CreateStreams(streamInfos));
381 } else {
382 MEDIA_INFO_LOG("HCaptureSession::CreateAndCommitStreams(), No new streams to create");
383 }
384 if (streamOperator != nullptr && hdiRc == HDI::Camera::V1_0::NO_ERROR) {
385 std::vector<uint8_t> setting;
386 OHOS::Camera::MetadataUtils::ConvertMetadataToVec(deviceSettings, setting);
387 hdiRc = (CamRetCode)(streamOperator->CommitStreams(NORMAL, setting));
388 if (hdiRc != HDI::Camera::V1_0::NO_ERROR) {
389 MEDIA_ERR_LOG("HCaptureSession::CreateAndCommitStreams(), Failed to commit %{public}d", hdiRc);
390 std::vector<int32_t> streamIds;
391 for (auto item = streamInfos.begin(); item != streamInfos.end(); ++item) {
392 curStreamInfo = *item;
393 streamIds.emplace_back(curStreamInfo.streamId_);
394 }
395 if (!streamIds.empty() && streamOperator->ReleaseStreams(streamIds) != HDI::Camera::V1_0::NO_ERROR) {
396 MEDIA_ERR_LOG("HCaptureSession::CreateAndCommitStreams(), Failed to release streams");
397 }
398 }
399 }
400 return HdiToServiceError(hdiRc);
401 }
402
CheckAndCommitStreams(sptr<HCameraDevice> & device,std::shared_ptr<OHOS::Camera::CameraMetadata> & deviceSettings,std::vector<StreamInfo> & allStreamInfos,std::vector<StreamInfo> & newStreamInfos)403 int32_t HCaptureSession::CheckAndCommitStreams(sptr<HCameraDevice> &device,
404 std::shared_ptr<OHOS::Camera::CameraMetadata> &deviceSettings,
405 std::vector<StreamInfo> &allStreamInfos,
406 std::vector<StreamInfo> &newStreamInfos)
407 {
408 return CreateAndCommitStreams(device, deviceSettings, newStreamInfos);
409 }
410
DeleteReleasedStream()411 void HCaptureSession::DeleteReleasedStream()
412 {
413 auto matchFunction = [](const auto& curStream) { return curStream->IsReleaseStream();};
414 captureStreams_.erase(std::remove_if(captureStreams_.begin(), captureStreams_.end(), matchFunction),
415 captureStreams_.end());
416 repeatStreams_.erase(std::remove_if(repeatStreams_.begin(), repeatStreams_.end(), matchFunction),
417 repeatStreams_.end());
418 metadataStreams_.erase(std::remove_if(metadataStreams_.begin(), metadataStreams_.end(), matchFunction),
419 metadataStreams_.end());
420 {
421 std::lock_guard<std::mutex> lock(streamsLock_);
422 sptr<HStreamCommon> curStream;
423 for (auto item = streams_.begin(); item != streams_.end(); ++item) {
424 curStream = *item;
425 if (curStream && curStream->IsReleaseStream()) {
426 curStream->Release();
427 streams_.erase(item--);
428 }
429 }
430 }
431 }
432
RestorePreviousState(sptr<HCameraDevice> & device,bool isCreateReleaseStreams)433 void HCaptureSession::RestorePreviousState(sptr<HCameraDevice> &device, bool isCreateReleaseStreams)
434 {
435 std::vector<StreamInfo> streamInfos;
436 StreamInfo streamInfo;
437 std::shared_ptr<OHOS::Camera::CameraMetadata> settings;
438 sptr<HStreamCommon> curStream;
439
440 MEDIA_DEBUG_LOG("HCaptureSession::RestorePreviousState, Restore to previous state");
441 {
442 std::lock_guard<std::mutex> lock(streamsLock_);
443 for (auto item = streams_.begin(); item != streams_.end(); ++item) {
444 curStream = *item;
445 if (curStream && isCreateReleaseStreams && curStream->IsReleaseStream()) {
446 curStream->SetStreamInfo(streamInfo);
447 streamInfos.push_back(streamInfo);
448 }
449 if (curStream) {
450 curStream->SetReleaseStream(false);
451 }
452 }
453 }
454 for (auto item = tempStreams_.begin(); item != tempStreams_.end(); ++item) {
455 curStream = *item;
456 if (curStream) {
457 curStream->Release();
458 }
459 }
460 tempStreams_.clear();
461 deletedStreamIds_.clear();
462 tempCameraDevices_.clear();
463 if (device != nullptr) {
464 device->SetReleaseCameraDevice(false);
465 if (isCreateReleaseStreams) {
466 settings = device->GetSettings();
467 if (settings != nullptr) {
468 CreateAndCommitStreams(device, settings, streamInfos);
469 }
470 }
471 }
472 curState_ = prevState_;
473 }
474
UpdateSessionConfig(sptr<HCameraDevice> & device)475 void HCaptureSession::UpdateSessionConfig(sptr<HCameraDevice> &device)
476 {
477 DeleteReleasedStream();
478 deletedStreamIds_.clear();
479 {
480 std::lock_guard<std::mutex> lock(streamsLock_);
481 sptr<HStreamCommon> curStream;
482 for (auto item = tempStreams_.begin(); item != tempStreams_.end(); ++item) {
483 curStream = *item;
484 if (curStream && curStream->GetStreamType() == StreamType::REPEAT) {
485 repeatStreams_.emplace_back(curStream);
486 } else if (curStream && curStream->GetStreamType() == StreamType::CAPTURE) {
487 captureStreams_.emplace_back(curStream);
488 } else if (curStream && curStream->GetStreamType() == StreamType::METADATA) {
489 metadataStreams_.emplace_back(curStream);
490 }
491 streams_.emplace_back(curStream);
492 }
493 }
494 tempStreams_.clear();
495 if (streamOperatorCallback_ == nullptr) {
496 MEDIA_ERR_LOG("HCaptureSession::UpdateSessionConfig streamOperatorCallback_ is nullptr");
497 return;
498 }
499 streamOperatorCallback_->SetCaptureSession(this);
500 cameraDevice_ = device;
501 curState_ = CaptureSessionState::SESSION_CONFIG_COMMITTED;
502 }
503
HandleCaptureOuputsConfig(sptr<HCameraDevice> & device)504 int32_t HCaptureSession::HandleCaptureOuputsConfig(sptr<HCameraDevice> &device)
505 {
506 int32_t rc;
507 int32_t streamId;
508 std::vector<StreamInfo> newStreamInfos;
509 std::vector<StreamInfo> allStreamInfos;
510 StreamInfo curStreamInfo;
511 std::shared_ptr<OHOS::Camera::CameraMetadata> settings;
512 sptr<IStreamOperator> streamOperator;
513 sptr<HStreamCommon> curStream;
514 if (device != nullptr) {
515 settings = device->GetSettings();
516 }
517 if (device == nullptr || settings == nullptr) {
518 return CAMERA_UNKNOWN_ERROR;
519 }
520
521 rc = GetCurrentStreamInfos(device, settings, allStreamInfos);
522 if (rc != CAMERA_OK) {
523 MEDIA_ERR_LOG("HCaptureSession::HandleCaptureOuputsConfig() Failed to get streams info, %{public}d", rc);
524 return rc;
525 }
526
527 if (cameraDevice_ != device) {
528 newStreamInfos = allStreamInfos;
529 }
530
531 streamOperator = device->GetStreamOperator();
532 streamId = streamId_;
533 for (auto item = tempStreams_.begin(); item != tempStreams_.end(); ++item) {
534 curStream = *item;
535 if (curStream == nullptr) {
536 MEDIA_ERR_LOG("HCaptureSession::HandleCaptureOuputsConfig() curStream is null");
537 return CAMERA_UNKNOWN_ERROR;
538 }
539 if (curStream) {
540 rc = curStream->LinkInput(streamOperator, settings, streamId);
541 if (rc != CAMERA_OK) {
542 MEDIA_ERR_LOG("HCaptureSession::HandleCaptureOuputsConfig() Failed to link Output, %{public}d", rc);
543 return rc;
544 }
545 }
546 if (curStream) {
547 curStream->SetStreamInfo(curStreamInfo);
548 }
549 newStreamInfos.push_back(curStreamInfo);
550 allStreamInfos.push_back(curStreamInfo);
551 streamId++;
552 }
553
554 rc = CheckAndCommitStreams(device, settings, allStreamInfos, newStreamInfos);
555 if (rc == CAMERA_OK) {
556 streamId_ = streamId;
557 }
558 return rc;
559 }
560
CommitConfig()561 int32_t HCaptureSession::CommitConfig()
562 {
563 sptr<HCameraDevice> device = nullptr;
564
565 if (curState_ != CaptureSessionState::SESSION_CONFIG_INPROGRESS) {
566 MEDIA_ERR_LOG("HCaptureSession::CommitConfig() Need to call BeginConfig before committing configuration");
567 return CAMERA_INVALID_STATE;
568 }
569
570 std::lock_guard<std::mutex> lock(sessionLock_);
571 int32_t rc = ValidateSessionInputs();
572 if (rc != CAMERA_OK) {
573 return rc;
574 }
575 rc = ValidateSessionOutputs();
576 if (rc != CAMERA_OK) {
577 return rc;
578 }
579
580 rc = GetCameraDevice(device);
581 if ((rc == CAMERA_OK) && (device == cameraDevice_) && !deletedStreamIds_.empty()) {
582 rc = HdiToServiceError((CamRetCode)(device->GetStreamOperator()->ReleaseStreams(deletedStreamIds_)));
583 }
584
585 if (rc != CAMERA_OK) {
586 MEDIA_ERR_LOG("HCaptureSession::CommitConfig() Failed to commit config. camera device rc: %{public}d", rc);
587 if (device != nullptr && device != cameraDevice_) {
588 device->Close();
589 }
590 RestorePreviousState(cameraDevice_, false);
591 return rc;
592 }
593
594 rc = HandleCaptureOuputsConfig(device);
595 if (rc != CAMERA_OK) {
596 MEDIA_ERR_LOG("HCaptureSession::CommitConfig() Failed to commit config. rc: %{public}d", rc);
597 if (device != nullptr && device != cameraDevice_) {
598 device->Close();
599 }
600 RestorePreviousState(cameraDevice_, !deletedStreamIds_.empty());
601 return rc;
602 }
603 if (device != nullptr) {
604 int32_t pid = IPCSkeleton::GetCallingPid();
605 int32_t uid = IPCSkeleton::GetCallingUid();
606 POWERMGR_SYSEVENT_CAMERA_CONNECT(pid, uid, device->GetCameraId().c_str(),
607 GetClientBundle(uid));
608 }
609
610 if (cameraDevice_ != nullptr && device != cameraDevice_) {
611 cameraDevice_->Close();
612 cameraDevice_ = nullptr;
613 }
614 UpdateSessionConfig(device);
615 return rc;
616 }
617
GetSessionState(CaptureSessionState & sessionState)618 int32_t HCaptureSession::GetSessionState(CaptureSessionState &sessionState)
619 {
620 int32_t rc = CAMERA_OK;
621 sessionState = curState_;
622 return rc;
623 }
624
Start()625 int32_t HCaptureSession::Start()
626 {
627 uint32_t callerToken = IPCSkeleton::GetCallingTokenID();
628 if (callerToken_ != callerToken) {
629 MEDIA_ERR_LOG("Failed to Start Session, createSession token is : %{public}d, now token is %{public}d",
630 callerToken_, callerToken);
631 return CAMERA_OPERATION_NOT_ALLOWED;
632 }
633 if (curState_ != CaptureSessionState::SESSION_CONFIG_COMMITTED) {
634 MEDIA_ERR_LOG("HCaptureSession::Start(), Invalid session state: %{public}d", curState_);
635 return CAMERA_INVALID_STATE;
636 }
637 std::lock_guard<std::mutex> lock(sessionLock_);
638 if (IsValidTokenId(callerToken)) {
639 if (!Security::AccessToken::PrivacyKit::IsAllowedUsingPermission(callerToken, OHOS_PERMISSION_CAMERA)) {
640 MEDIA_ERR_LOG("Start session is not allowed!");
641 return CAMERA_ALLOC_ERROR;
642 }
643 StartUsingPermissionCallback(callerToken, OHOS_PERMISSION_CAMERA);
644 RegisterPermissionCallback(callerToken, OHOS_PERMISSION_CAMERA);
645 }
646 sptr<HStreamRepeat> curStreamRepeat;
647 int32_t rc = CAMERA_OK;
648 for (auto item = repeatStreams_.begin(); item != repeatStreams_.end(); ++item) {
649 curStreamRepeat = static_cast<HStreamRepeat *>((*item).GetRefPtr());
650 if (!curStreamRepeat->IsVideo()) {
651 rc = curStreamRepeat->Start();
652 if (rc != CAMERA_OK) {
653 MEDIA_ERR_LOG("HCaptureSession::Start(), Failed to start preview, rc: %{public}d", rc);
654 break;
655 }
656 }
657 }
658 return rc;
659 }
660
Stop()661 int32_t HCaptureSession::Stop()
662 {
663 int32_t rc = CAMERA_OK;
664 sptr<HStreamRepeat> curStreamRepeat;
665 if (curState_ != CaptureSessionState::SESSION_CONFIG_COMMITTED) {
666 return CAMERA_INVALID_STATE;
667 }
668 std::lock_guard<std::mutex> lock(sessionLock_);
669 for (auto item = repeatStreams_.begin(); item != repeatStreams_.end(); ++item) {
670 curStreamRepeat = static_cast<HStreamRepeat *>((*item).GetRefPtr());
671 if (!curStreamRepeat->IsVideo()) {
672 rc = curStreamRepeat->Stop();
673 if (rc != CAMERA_OK) {
674 MEDIA_ERR_LOG("HCaptureSession::Stop(), Failed to stop preview, rc: %{public}d", rc);
675 break;
676 }
677 }
678 }
679
680 return rc;
681 }
682
ClearCaptureSession(pid_t pid)683 void HCaptureSession::ClearCaptureSession(pid_t pid)
684 {
685 MEDIA_DEBUG_LOG("ClearCaptureSession: camera stub services(%{public}zu) pid(%{public}d).", session_.size(), pid);
686 auto it = session_.find(pid);
687 if (it != session_.end()) {
688 session_.erase(it);
689 }
690 MEDIA_DEBUG_LOG("ClearCaptureSession: camera stub services(%{public}zu).", session_.size());
691 }
692
ReleaseStreams()693 void HCaptureSession::ReleaseStreams()
694 {
695 std::vector<int32_t> streamIds;
696 {
697 std::lock_guard<std::mutex> lock(streamsLock_);
698 sptr<HStreamCommon> curStream;
699 for (auto item = streams_.begin(); item != streams_.end(); ++item) {
700 curStream = *item;
701 if (curStream) {
702 streamIds.emplace_back(curStream->GetStreamId());
703 curStream->Release();
704 }
705 }
706 streams_.clear();
707 }
708 repeatStreams_.clear();
709 captureStreams_.clear();
710 metadataStreams_.clear();
711 if ((cameraDevice_ != nullptr) && (cameraDevice_->GetStreamOperator() != nullptr) && !streamIds.empty()) {
712 cameraDevice_->GetStreamOperator()->ReleaseStreams(streamIds);
713 }
714 }
715
ReleaseInner()716 int32_t HCaptureSession::ReleaseInner()
717 {
718 MEDIA_INFO_LOG("HCaptureSession::ReleaseInner enter");
719 return Release(pid_);
720 }
721
Release(pid_t pid)722 int32_t HCaptureSession::Release(pid_t pid)
723 {
724 std::lock_guard<std::mutex> lock(sessionLock_);
725 MEDIA_INFO_LOG("HCaptureSession::Release pid(%{public}d).", pid);
726 uint32_t callerToken = IPCSkeleton::GetCallingTokenID();
727 if (callerToken_ != callerToken) {
728 MEDIA_ERR_LOG("Failed to Release Session, createSession token is : %{public}d, now token is %{public}d",
729 callerToken_, callerToken);
730 return CAMERA_OPERATION_NOT_ALLOWED;
731 }
732 auto it = session_.find(pid);
733 if (it == session_.end()) {
734 MEDIA_DEBUG_LOG("HCaptureSession::Release session for pid(%{public}d) already released.", pid);
735 return CAMERA_OK;
736 }
737 ReleaseStreams();
738 tempCameraDevices_.clear();
739 if (streamOperatorCallback_ != nullptr) {
740 streamOperatorCallback_->SetCaptureSession(nullptr);
741 streamOperatorCallback_ = nullptr;
742 }
743 if (cameraDevice_ != nullptr) {
744 cameraDevice_->Close();
745 POWERMGR_SYSEVENT_CAMERA_DISCONNECT(cameraDevice_->GetCameraId().c_str());
746 cameraDevice_ = nullptr;
747 }
748 if (IsValidTokenId(callerToken)) {
749 StopUsingPermissionCallback(callerToken, OHOS_PERMISSION_CAMERA);
750 UnregisterPermissionCallback(callerToken);
751 }
752 tempStreams_.clear();
753 ClearCaptureSession(pid);
754 sessionCallback_ = nullptr;
755 cameraHostManager_ = nullptr;
756 return CAMERA_OK;
757 }
758
RegisterPermissionCallback(const uint32_t callingTokenId,const std::string permissionName)759 void HCaptureSession::RegisterPermissionCallback(const uint32_t callingTokenId, const std::string permissionName)
760 {
761 Security::AccessToken::PermStateChangeScope scopeInfo;
762 scopeInfo.permList = {permissionName};
763 scopeInfo.tokenIDs = {callingTokenId};
764 callbackPtr_ = std::make_shared<PermissionStatusChangeCb>(scopeInfo);
765 callbackPtr_->SetCaptureSession(this);
766 MEDIA_DEBUG_LOG("after tokenId:%{public}d register", callingTokenId);
767 int32_t res = Security::AccessToken::AccessTokenKit::RegisterPermStateChangeCallback(callbackPtr_);
768 if (res != CAMERA_OK) {
769 MEDIA_ERR_LOG("RegisterPermStateChangeCallback failed.");
770 }
771 }
772
UnregisterPermissionCallback(const uint32_t callingTokenId)773 void HCaptureSession::UnregisterPermissionCallback(const uint32_t callingTokenId)
774 {
775 if (callbackPtr_ == nullptr) {
776 MEDIA_ERR_LOG("callbackPtr_ is null.");
777 return;
778 }
779 int32_t res = Security::AccessToken::AccessTokenKit::UnRegisterPermStateChangeCallback(callbackPtr_);
780 if (res != CAMERA_OK) {
781 MEDIA_ERR_LOG("UnRegisterPermStateChangeCallback failed.");
782 }
783 if (callbackPtr_) {
784 callbackPtr_->SetCaptureSession(nullptr);
785 callbackPtr_ = nullptr;
786 }
787 MEDIA_DEBUG_LOG("after tokenId:%{public}d unregister", callingTokenId);
788 }
789
DestroyStubObjectForPid(pid_t pid)790 void HCaptureSession::DestroyStubObjectForPid(pid_t pid)
791 {
792 MEDIA_DEBUG_LOG("camera stub services(%{public}zu) pid(%{public}d).", session_.size(), pid);
793 sptr<HCaptureSession> session;
794
795 auto it = session_.find(pid);
796 if (it != session_.end()) {
797 if (it->second != nullptr) {
798 session = it->second;
799 session->Release(pid);
800 }
801 }
802 MEDIA_DEBUG_LOG("camera stub services(%{public}zu).", session_.size());
803 }
804
SetCallback(sptr<ICaptureSessionCallback> & callback)805 int32_t HCaptureSession::SetCallback(sptr<ICaptureSessionCallback> &callback)
806 {
807 if (callback == nullptr) {
808 MEDIA_ERR_LOG("HCaptureSession::SetCallback callback is null");
809 return CAMERA_INVALID_ARG;
810 }
811
812 sessionCallback_ = callback;
813 return CAMERA_OK;
814 }
815
GetSessionState()816 std::string HCaptureSession::GetSessionState()
817 {
818 std::map<CaptureSessionState, std::string>::const_iterator iter =
819 sessionState_.find(curState_);
820 if (iter != sessionState_.end()) {
821 return iter->second;
822 }
823 return nullptr;
824 }
825
CameraSessionSummary(std::string & dumpString)826 void HCaptureSession::CameraSessionSummary(std::string& dumpString)
827 {
828 dumpString += "# Number of Camera clients:[" + std::to_string(session_.size()) + "]:\n";
829 }
830
dumpSessions(std::string & dumpString)831 void HCaptureSession::dumpSessions(std::string& dumpString)
832 {
833 for (auto it = session_.begin(); it != session_.end(); it++) {
834 if (it->second != nullptr) {
835 sptr<HCaptureSession> session = it->second;
836 dumpString += "No. of sessions for client:[" + std::to_string(1) + "]:\n";
837 session->dumpSessionInfo(dumpString);
838 }
839 }
840 }
841
dumpSessionInfo(std::string & dumpString)842 void HCaptureSession::dumpSessionInfo(std::string& dumpString)
843 {
844 dumpString += "Client pid:[" + std::to_string(pid_)
845 + "] Client uid:[" + std::to_string(uid_) + "]:\n";
846 dumpString += "session state:[" + GetSessionState() + "]:\n";
847 if (cameraDevice_ != nullptr) {
848 dumpString += "session Camera Id:[" + cameraDevice_->GetCameraId() + "]:\n";
849 dumpString += "session Camera release status:["
850 + std::to_string(cameraDevice_->IsReleaseCameraDevice()) + "]:\n";
851 }
852 for (const auto& stream : captureStreams_) {
853 stream->DumpStreamInfo(dumpString);
854 }
855 for (const auto& stream : repeatStreams_) {
856 stream->DumpStreamInfo(dumpString);
857 }
858 for (const auto& stream : metadataStreams_) {
859 stream->DumpStreamInfo(dumpString);
860 }
861 }
862
StartUsingPermissionCallback(const uint32_t callingTokenId,const std::string permissionName)863 void HCaptureSession::StartUsingPermissionCallback(const uint32_t callingTokenId, const std::string permissionName)
864 {
865 cameraUseCallbackPtr_ = std::make_shared<CameraUseStateChangeCb>();
866 cameraUseCallbackPtr_->SetCaptureSession(this);
867 MEDIA_DEBUG_LOG("after StartUsingPermissionCallback tokenId:%{public}d", callingTokenId);
868 int32_t res = Security::AccessToken::PrivacyKit::StartUsingPermission(
869 callingTokenId, permissionName, cameraUseCallbackPtr_);
870 if (res != CAMERA_OK) {
871 MEDIA_ERR_LOG("StartUsingPermissionCallback failed.");
872 }
873 }
874
StopUsingPermissionCallback(const uint32_t callingTokenId,const std::string permissionName)875 void HCaptureSession::StopUsingPermissionCallback(const uint32_t callingTokenId, const std::string permissionName)
876 {
877 MEDIA_DEBUG_LOG("enter StopUsingPermissionCallback tokenId:%{public}d", callingTokenId);
878 int32_t res = Security::AccessToken::PrivacyKit::StopUsingPermission(callingTokenId, permissionName);
879 if (res != CAMERA_OK) {
880 MEDIA_ERR_LOG("StopUsingPermissionCallback failed.");
881 }
882 if (cameraUseCallbackPtr_) {
883 cameraUseCallbackPtr_->SetCaptureSession(nullptr);
884 cameraUseCallbackPtr_ = nullptr;
885 }
886 }
887
~PermissionStatusChangeCb()888 PermissionStatusChangeCb::~PermissionStatusChangeCb()
889 {
890 captureSession_ = nullptr;
891 }
892
SetCaptureSession(sptr<HCaptureSession> captureSession)893 void PermissionStatusChangeCb::SetCaptureSession(sptr<HCaptureSession> captureSession)
894 {
895 captureSession_ = captureSession;
896 }
897
PermStateChangeCallback(Security::AccessToken::PermStateChangeInfo & result)898 void PermissionStatusChangeCb::PermStateChangeCallback(Security::AccessToken::PermStateChangeInfo& result)
899 {
900 auto item = captureSession_.promote();
901 if ((result.PermStateChangeType == 0) && (item != nullptr)) {
902 item->ReleaseInner();
903 }
904 };
905
~CameraUseStateChangeCb()906 CameraUseStateChangeCb::~CameraUseStateChangeCb()
907 {
908 captureSession_ = nullptr;
909 }
910
SetCaptureSession(sptr<HCaptureSession> captureSession)911 void CameraUseStateChangeCb::SetCaptureSession(sptr<HCaptureSession> captureSession)
912 {
913 captureSession_ = captureSession;
914 }
915
StateChangeNotify(Security::AccessToken::AccessTokenID tokenId,bool isShowing)916 void CameraUseStateChangeCb::StateChangeNotify(Security::AccessToken::AccessTokenID tokenId, bool isShowing)
917 {
918 const int32_t delayProcessTime = 200000;
919 usleep(delayProcessTime);
920 MEDIA_INFO_LOG("enter CameraUseStateChangeNotify tokenId:%{public}d", tokenId);
921 auto item = captureSession_.promote();
922 if ((isShowing == false) && (item != nullptr)) {
923 item->ReleaseInner();
924 }
925 };
926
927
StreamOperatorCallback(sptr<HCaptureSession> session)928 StreamOperatorCallback::StreamOperatorCallback(sptr<HCaptureSession> session)
929 {
930 captureSession_ = session;
931 }
932
~StreamOperatorCallback()933 StreamOperatorCallback::~StreamOperatorCallback()
934 {
935 captureSession_ = nullptr;
936 }
937
GetStreamByStreamID(int32_t streamId)938 sptr<HStreamCommon> StreamOperatorCallback::GetStreamByStreamID(int32_t streamId)
939 {
940 sptr<HStreamCommon> result = nullptr;
941 if (captureSession_ != nullptr) {
942 std::lock_guard<std::mutex> lock(captureSession_->streamsLock_);
943 sptr<HStreamCommon> curStream;
944 for (auto item = captureSession_->streams_.begin(); item != captureSession_->streams_.end(); ++item) {
945 curStream = *item;
946 if (curStream && curStream->GetStreamId() == streamId) {
947 result = curStream;
948 break;
949 }
950 }
951 }
952 return result;
953 }
954
OnCaptureStarted(int32_t captureId,const std::vector<int32_t> & streamIds)955 int32_t StreamOperatorCallback::OnCaptureStarted(int32_t captureId,
956 const std::vector<int32_t> &streamIds)
957 {
958 sptr<HStreamCommon> curStream;
959
960 for (auto item = streamIds.begin(); item != streamIds.end(); ++item) {
961 curStream = GetStreamByStreamID(*item);
962 if (curStream == nullptr) {
963 MEDIA_ERR_LOG("StreamOperatorCallback::OnCaptureStarted StreamId: %{public}d not found", *item);
964 return CAMERA_INVALID_ARG;
965 } else if (curStream->GetStreamType() == StreamType::REPEAT) {
966 static_cast<HStreamRepeat *>(curStream.GetRefPtr())->OnFrameStarted();
967 } else if (curStream->GetStreamType() == StreamType::CAPTURE) {
968 static_cast<HStreamCapture *>(curStream.GetRefPtr())->OnCaptureStarted(captureId);
969 }
970 }
971 return CAMERA_OK;
972 }
973
OnCaptureEnded(int32_t captureId,const std::vector<CaptureEndedInfo> & infos)974 int32_t StreamOperatorCallback::OnCaptureEnded(int32_t captureId, const std::vector<CaptureEndedInfo>& infos)
975 {
976 sptr<HStreamCommon> curStream;
977 CaptureEndedInfo captureInfo;
978
979 for (auto item = infos.begin(); item != infos.end(); ++item) {
980 captureInfo = *item;
981 curStream = GetStreamByStreamID(captureInfo.streamId_);
982 if (curStream == nullptr) {
983 MEDIA_ERR_LOG("StreamOperatorCallback::OnCaptureEnded StreamId: %{public}d not found."
984 " Framecount: %{public}d", captureInfo.streamId_, captureInfo.frameCount_);
985 return CAMERA_INVALID_ARG;
986 } else if (curStream->GetStreamType() == StreamType::REPEAT) {
987 static_cast<HStreamRepeat *>(curStream.GetRefPtr())->OnFrameEnded(captureInfo.frameCount_);
988 } else if (curStream->GetStreamType() == StreamType::CAPTURE) {
989 static_cast<HStreamCapture *>(curStream.GetRefPtr())->OnCaptureEnded(captureId, captureInfo.frameCount_);
990 }
991 }
992 return CAMERA_OK;
993 }
994
OnCaptureError(int32_t captureId,const std::vector<CaptureErrorInfo> & infos)995 int32_t StreamOperatorCallback::OnCaptureError(int32_t captureId, const std::vector<CaptureErrorInfo>& infos)
996 {
997 sptr<HStreamCommon> curStream;
998 CaptureErrorInfo errInfo;
999
1000 for (auto item = infos.begin(); item != infos.end(); ++item) {
1001 errInfo = *item;
1002 curStream = GetStreamByStreamID(errInfo.streamId_);
1003 if (curStream == nullptr) {
1004 MEDIA_ERR_LOG("StreamOperatorCallback::OnCaptureError StreamId: %{public}d not found."
1005 " Error: %{public}d", errInfo.streamId_, errInfo.error_);
1006 return CAMERA_INVALID_ARG;
1007 } else if (curStream->GetStreamType() == StreamType::REPEAT) {
1008 static_cast<HStreamRepeat *>(curStream.GetRefPtr())->OnFrameError(errInfo.error_);
1009 } else if (curStream->GetStreamType() == StreamType::CAPTURE) {
1010 static_cast<HStreamCapture *>(curStream.GetRefPtr())->OnCaptureError(captureId, errInfo.error_);
1011 }
1012 }
1013 return CAMERA_OK;
1014 }
1015
OnFrameShutter(int32_t captureId,const std::vector<int32_t> & streamIds,uint64_t timestamp)1016 int32_t StreamOperatorCallback::OnFrameShutter(int32_t captureId,
1017 const std::vector<int32_t> &streamIds,
1018 uint64_t timestamp)
1019 {
1020 sptr<HStreamCommon> curStream;
1021
1022 for (auto item = streamIds.begin(); item != streamIds.end(); ++item) {
1023 curStream = GetStreamByStreamID(*item);
1024 if ((curStream != nullptr) && (curStream->GetStreamType() == StreamType::CAPTURE)) {
1025 static_cast<HStreamCapture *>(curStream.GetRefPtr())->OnFrameShutter(captureId, timestamp);
1026 } else {
1027 MEDIA_ERR_LOG("StreamOperatorCallback::OnFrameShutter StreamId: %{public}d not found", *item);
1028 return CAMERA_INVALID_ARG;
1029 }
1030 }
1031 return CAMERA_OK;
1032 }
1033
SetCaptureSession(sptr<HCaptureSession> captureSession)1034 void StreamOperatorCallback::SetCaptureSession(sptr<HCaptureSession> captureSession)
1035 {
1036 captureSession_ = captureSession;
1037 }
1038 } // namespace CameraStandard
1039 } // namespace OHOS
1040