1 /* 2 * Copyright (c) 2021-2025 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 #ifndef OHOS_CAMERA_CAMERA_MANAGER_H 17 #define OHOS_CAMERA_CAMERA_MANAGER_H 18 19 #include <cstdint> 20 #include <iostream> 21 #include <memory> 22 #include <mutex> 23 #include <refbase.h> 24 #include <thread> 25 #include <unordered_map> 26 #include <utility> 27 #include <vector> 28 #include <unordered_map> 29 30 #include "camera_stream_info_parse.h" 31 #include "control_center_session.h" 32 #include "deferred_proc_session/deferred_photo_proc_session.h" 33 #include "deferred_proc_session/deferred_video_proc_session.h" 34 #include "hcamera_listener_stub.h" 35 #include "camera_service_callback_stub.h" 36 #include "camera_mute_service_callback_stub.h" 37 #include "control_center_status_callback_stub.h" 38 #include "fold_service_callback_stub.h" 39 #include "icontrol_center_status_callback.h" 40 #include "torch_service_callback_stub.h" 41 #include "camera_service_proxy.h" 42 #include "icamera_device_service.h" 43 #include "icamera_service_callback.h" 44 #include "input/camera_death_recipient.h" 45 #include "input/camera_device.h" 46 #include "input/camera_info.h" 47 #include "input/camera_input.h" 48 #include "istream_common.h" 49 #include "istream_repeat.h" 50 #include "output/camera_output_capability.h" 51 #include "output/metadata_output.h" 52 #include "output/photo_output.h" 53 #include "output/preview_output.h" 54 #include "output/video_output.h" 55 #include "safe_map.h" 56 #include "session/mech_session.h" 57 #include "color_space_info_parse.h" 58 59 namespace OHOS { 60 namespace CameraStandard { 61 enum CameraDeviceStatus { 62 CAMERA_DEVICE_STATUS_UNAVAILABLE = 0, 63 CAMERA_DEVICE_STATUS_AVAILABLE 64 }; 65 66 enum FlashlightStatus { 67 FLASHLIGHT_STATUS_OFF = 0, 68 FLASHLIGHT_STATUS_ON, 69 FLASHLIGHT_STATUS_UNAVAILABLE 70 }; 71 72 enum TorchMode { 73 TORCH_MODE_OFF = 0, 74 TORCH_MODE_ON, 75 TORCH_MODE_AUTO 76 }; 77 78 struct CameraStatusInfo { 79 sptr<CameraInfo> cameraInfo; 80 sptr<CameraDevice> cameraDevice; 81 CameraStatus cameraStatus; 82 std::string bundleName; 83 }; 84 85 struct TorchStatusInfo { 86 bool isTorchAvailable; 87 bool isTorchActive; 88 float torchLevel; 89 }; 90 91 struct FoldStatusInfo { 92 FoldStatus foldStatus; 93 std::vector<sptr<CameraDevice>> supportedCameras; 94 }; 95 96 typedef enum OutputCapStreamType { 97 PREVIEW = 0, 98 VIDEO_STREAM = 1, 99 STILL_CAPTURE = 2, 100 POST_VIEW = 3, 101 ANALYZE = 4, 102 CUSTOM = 5, 103 DEPTH = 6 104 } OutputCapStreamType; 105 106 class CameraManagerCallback { 107 public: 108 CameraManagerCallback() = default; 109 virtual ~CameraManagerCallback() = default; 110 virtual void OnCameraStatusChanged(const CameraStatusInfo &cameraStatusInfo) const = 0; 111 virtual void OnFlashlightStatusChanged(const std::string &cameraID, const FlashStatus flashStatus) const = 0; 112 }; 113 114 class CameraMuteListener { 115 public: 116 CameraMuteListener() = default; 117 virtual ~CameraMuteListener() = default; 118 virtual void OnCameraMute(bool muteMode) const = 0; 119 }; 120 121 class ControlCenterStatusListener { 122 public: 123 ControlCenterStatusListener() = default; 124 virtual ~ControlCenterStatusListener() = default; 125 virtual void OnControlCenterStatusChanged(bool status) const = 0; 126 }; 127 128 class TorchListener { 129 public: 130 TorchListener() = default; 131 virtual ~TorchListener() = default; 132 virtual void OnTorchStatusChange(const TorchStatusInfo &torchStatusInfo) const = 0; 133 }; 134 135 class FoldListener { 136 public: 137 FoldListener() = default; 138 virtual ~FoldListener() = default; 139 virtual void OnFoldStatusChanged(const FoldStatusInfo &foldStatusInfo) const = 0; 140 }; 141 142 class TorchServiceListenerManager; 143 class CameraStatusListenerManager; 144 class CameraMuteListenerManager; 145 class ControlCenterStatusListenerManager; 146 class FoldStatusListenerManager; 147 class CameraManager : public RefBase { 148 public: 149 virtual ~CameraManager(); 150 /** 151 * @brief Get camera manager instance. 152 * 153 * @return Returns pointer to camera manager instance. 154 */ 155 static sptr<CameraManager>& GetInstance(); 156 157 /** 158 * @brief Get all available cameras. 159 * 160 * @return Returns vector of cameraDevice of available camera. 161 */ 162 std::vector<sptr<CameraDevice>> GetSupportedCameras(); 163 164 /** 165 * @brief Get support modes. 166 * 167 * @return Returns array the mode of current CameraDevice. 168 */ 169 std::vector<SceneMode> GetSupportedModes(sptr<CameraDevice>& camera); 170 171 /** 172 * @brief Get extend output capaility of the mode of the given camera from cameraDevice. 173 * 174 * @param Camera device for which extend capability need to be fetched. 175 * @return Returns vector the ability of the mode of cameraDevice of available camera from cameraDevice. 176 */ 177 sptr<CameraOutputCapability> GetSupportedOutputCapability(sptr<CameraDevice>& cameraDevice, int32_t modeName = 0); 178 179 /** 180 * @brief Create camera input instance with provided camera position and type. 181 * 182 * @param The cameraDevice for which input has to be created. 183 * @return Returns pointer to camera input instance. 184 */ 185 186 sptr<CameraInput> CreateCameraInput(CameraPosition position, CameraType cameraType); 187 188 /** 189 * @brief Create camera input instance with provided camera position and type. 190 * 191 * @param The cameraDevice for which input has to be created. 192 * @param Returns pointer to camera input instance. 193 * @return Returns error code. 194 */ 195 int CreateCameraInput(CameraPosition position, CameraType cameraType, sptr<CameraInput>* pCameraInput); 196 197 /** 198 * @brief Create camera input instance. 199 * 200 * @param The cameraDevice for which input has to be created. 201 * @return Returns pointer to camera input instance. 202 */ 203 sptr<CameraInput> CreateCameraInput(sptr<CameraDevice>& camera); 204 205 /** 206 * @brief Create camera input instance. 207 * 208 * @param The cameraDevice for which input has to be created. 209 * @param Returns pointer to camera input instance. 210 * @return Returns error code. 211 */ 212 int CreateCameraInput(sptr<CameraDevice>& camera, sptr<CameraInput>* pCameraInput); 213 214 /** 215 * @brief Get all available cameras. 216 * 217 * @return Returns vector of cameraInfo of available camera. 218 */ 219 [[deprecated]] std::vector<sptr<CameraInfo>> GetCameras(); 220 221 /** 222 * @brief Create camera input instance. 223 * 224 * @param The cameraInfo for which input has to be created. 225 * @return Returns pointer to camera input instance. 226 */ 227 [[deprecated]] sptr<CameraInput> CreateCameraInput(sptr<CameraInfo>& camera); 228 229 /** 230 * @brief Create capture session. 231 * 232 * @return Returns pointer to capture session. 233 */ 234 sptr<CaptureSession> CreateCaptureSession(); 235 236 /** 237 * @brief Create capture session. 238 * 239 * @return Returns pointer to capture session. 240 */ 241 sptr<CaptureSession> CreateCaptureSession(SceneMode mode); 242 243 /** 244 * @brief Create capture session from hcamera service. 245 * 246 * @return Returns error code. 247 */ 248 int32_t CreateCaptureSessionFromService(sptr<ICaptureSession>& session, SceneMode mode); 249 250 /** 251 * @brief Create capture session. 252 * 253 * @param pCaptureSession pointer to capture session. 254 * @param mode Target mode 255 * @return Returns error code. 256 */ 257 int32_t CreateCaptureSession(sptr<CaptureSession>& pCaptureSession, SceneMode mode); 258 259 /** 260 * @brief Create capture session. 261 * 262 * @param pCaptureSession pointer to capture session. 263 * @return Returns error code. 264 */ 265 int32_t CreateCaptureSession(sptr<CaptureSession>* pCaptureSession); 266 267 /** 268 * @brief Create photo output instance using surfaceProducer. 269 * 270 * @param The surfaceProducer to be used for photo output. 271 * @return Returns pointer to photo output instance. 272 */ 273 sptr<PhotoOutput> CreatePhotoOutput(Profile& profile, sptr<IBufferProducer>& surfaceProducer); 274 275 /** 276 * @brief Create deferred photo processing session. 277 * 278 * @return Returns pointer to capture session. 279 */ 280 static sptr<DeferredPhotoProcSession> CreateDeferredPhotoProcessingSession(int userId, 281 std::shared_ptr<IDeferredPhotoProcSessionCallback> callback); 282 283 /** 284 * @brief Create deferred photo processing session. 285 * 286 * @param Returns pointer to capture session. 287 * @return Returns error code. 288 */ 289 static int CreateDeferredPhotoProcessingSession(int userId, 290 std::shared_ptr<IDeferredPhotoProcSessionCallback> callback, 291 sptr<DeferredPhotoProcSession> *pDeferredPhotoProcSession); 292 293 /** 294 * @brief Create deferred video processing session. 295 * 296 * @return Returns pointer to capture session. 297 */ 298 static sptr<DeferredVideoProcSession> CreateDeferredVideoProcessingSession(int userId, 299 std::shared_ptr<IDeferredVideoProcSessionCallback> callback); 300 301 /** 302 * @brief Create deferred video processing session. 303 * 304 * @param Returns pointer to capture session. 305 * @return Returns error code. 306 */ 307 static int CreateDeferredVideoProcessingSession(int userId, 308 std::shared_ptr<IDeferredVideoProcSessionCallback> callback, 309 sptr<DeferredVideoProcSession> *pDeferredVideoProcSession); 310 311 /** 312 * @brief Create mech session. 313 * 314 * @return Returns pointer to mech session. 315 */ 316 sptr<MechSession> CreateMechSession(int userId); 317 318 /** 319 * @brief Create Create mech session. 320 * 321 * @param pMechSession pointer to mech session instance. 322 * @return Returns error code. 323 */ 324 int CreateMechSession(int userId, sptr<MechSession> *pMechSession); 325 326 /** 327 * @brief Get the support of mech. 328 * 329 * @return Returns true is supported, false is not supported. 330 */ 331 bool IsMechSupported(); 332 333 /** 334 * @brief Create photo output instance. 335 * 336 * @param profile photo profile. 337 * @param surfaceProducer photo buffer surfaceProducer. 338 * @param pPhotoOutput pointer to photo output instance. 339 * @return Returns error code. 340 */ 341 int CreatePhotoOutput(Profile& profile, sptr<IBufferProducer>& surfaceProducer, sptr<PhotoOutput>* pPhotoOutput); 342 343 /** 344 * @brief Create photo output instance. 345 * 346 * @param profile photo profile. 347 * @param surfaceProducer photo buffer surfaceProducer. 348 * @param pPhotoOutput pointer to photo output instance. 349 * @param photoSurface photo buffer surface. 350 * @return Returns error code. 351 */ 352 int CreatePhotoOutput(Profile &profile, sptr<IBufferProducer> &surfaceProducer, sptr<PhotoOutput> *pPhotoOutput, 353 sptr<Surface> photoSurface); 354 355 /** 356 * @brief Create photo output instance. 357 * 358 * @param profile photo profile. 359 * @param pPhotoOutput pointer to photo output instance. 360 * @return Returns error code. 361 */ 362 int CreatePhotoOutput(Profile &profile, sptr<PhotoOutput> *pPhotoOutput); 363 364 /** 365 * @brief Create photo output instance without profile. 366 * 367 * @param surfaceProducer photo buffer surfaceProducer. 368 * @param pPhotoOutput pointer to photo output instance. 369 * @return Returns error code. 370 */ 371 int CreatePhotoOutputWithoutProfile(sptr<IBufferProducer> surfaceProducer, sptr<PhotoOutput>* pPhotoOutput); 372 373 /** 374 * @brief Create photo output instance without profile. 375 * 376 * @param surfaceProducer photo buffer surfaceProducer. 377 * @param pPhotoOutput pointer to photo output instance. 378 * @param photoSurface photo buffer surface. 379 * @return Returns error code. 380 */ 381 int CreatePhotoOutputWithoutProfile(sptr<IBufferProducer> surfaceProducer, sptr<PhotoOutput>* pPhotoOutput, 382 sptr<Surface> photoSurface); 383 384 /** 385 * @brief Create photo output instance without profile. 386 * 387 * @param pPhotoOutput pointer to photo output instance. 388 * @return Returns error code. 389 */ 390 int CreatePhotoOutputWithoutProfile(sptr<PhotoOutput>* pPhotoOutput); 391 392 /** 393 * @brief Create photo output instance using surfaceProducer. 394 * 395 * @param The surfaceProducer to be used for photo output. 396 * @return Returns pointer to photo output instance. 397 */ 398 [[deprecated]] sptr<PhotoOutput> CreatePhotoOutput(sptr<IBufferProducer>& surfaceProducer); 399 400 /** 401 * @brief Create photo output instance using IBufferProducer. 402 * 403 * @param The IBufferProducer to be used for photo output. 404 * @param The format to be used for photo capture. 405 * @return Returns pointer to photo output instance. 406 */ 407 [[deprecated]] sptr<PhotoOutput> CreatePhotoOutput( 408 const sptr<OHOS::IBufferProducer> &surfaceProducer, int32_t format); 409 410 /** 411 * @brief Create video output instance using surface. 412 * 413 * @param The surface to be used for video output. 414 * @return Returns pointer to video output instance. 415 */ 416 sptr<VideoOutput> CreateVideoOutput(VideoProfile& profile, sptr<Surface>& surface); 417 418 /** 419 * @brief Create video output instance using surface. 420 * 421 * @param The surface to be used for video output. 422 * @param Returns pointer to video output instance. 423 * @return Returns error code. 424 */ 425 int CreateVideoOutput(VideoProfile& profile, sptr<Surface>& surface, sptr<VideoOutput>* pVideoOutput); 426 427 /** 428 * @brief Create video output instance without profile. 429 * 430 * @param surface video buffer surface. 431 * @param pVideoOutput pointer to video output instance. 432 * @return Returns error code. 433 */ 434 int CreateVideoOutputWithoutProfile(sptr<Surface> surface, sptr<VideoOutput>* pVideoOutput); 435 436 /** 437 * @brief Create video output instance using surface. 438 * 439 * @param The surface to be used for video output. 440 * @return Returns pointer to video output instance. 441 */ 442 [[deprecated]] sptr<VideoOutput> CreateVideoOutput(sptr<Surface>& surface); 443 444 /** 445 * @brief Create video output instance using IBufferProducer. 446 * 447 * @param The IBufferProducer to be used for video output. 448 * @param The format to be used for video capture. 449 * @return Returns pointer to video output instance. 450 */ 451 [[deprecated]] sptr<VideoOutput> CreateVideoOutput(const sptr<OHOS::IBufferProducer>& producer, int32_t format); 452 453 /** 454 * @brief Create preview output instance using surface. 455 * 456 * @param The surface to be used for preview. 457 * @return Returns pointer to preview output instance. 458 */ 459 sptr<PreviewOutput> CreatePreviewOutput(Profile& profile, sptr<Surface> surface); 460 461 /** 462 * @brief Create preview output instance. 463 * 464 * @param profile preview profile. 465 * @param surface preview buffer surface. 466 * @param pPhotoOutput pointer to photo preview instance. 467 * @return Returns error code. 468 */ 469 int CreatePreviewOutput(Profile& profile, sptr<Surface> surface, sptr<PreviewOutput>* pPreviewOutput); 470 471 /** 472 * @brief Create preview output instance without profile. 473 * 474 * @param surface preview buffer surface. 475 * @param pPhotoOutput pointer to photo preview instance. 476 * @return Returns error code. 477 */ 478 int CreatePreviewOutputWithoutProfile(sptr<Surface> surface, sptr<PreviewOutput>* pPreviewOutput); 479 480 /** 481 * @brief Create preview output instance using surface. 482 * 483 * @param The surface to be used for preview. 484 * @return Returns pointer to preview output instance. 485 */ 486 [[deprecated]] sptr<PreviewOutput> CreatePreviewOutput(sptr<Surface> surface); 487 488 /** 489 * @brief Create preview output instance using IBufferProducer. 490 * 491 * @param The IBufferProducer to be used for preview output. 492 * @param The format to be used for preview. 493 * @return Returns pointer to video preview instance. 494 */ 495 [[deprecated]] sptr<PreviewOutput> CreatePreviewOutput(const sptr<OHOS::IBufferProducer>& producer, int32_t format); 496 497 /** 498 * @brief Create preview output instance using surface. 499 * 500 * @param The surface to be used for preview. 501 * @return Returns pointer to preview output instance. 502 */ 503 sptr<PreviewOutput> CreateDeferredPreviewOutput(Profile& profile); 504 505 /** 506 * @brief Create preview output instance using surface. 507 * 508 * @param The surface to be used for preview. 509 * @param Returns pointer to preview output instance. 510 * @return Returns error code. 511 */ 512 int CreateDeferredPreviewOutput(Profile& profile, sptr<PreviewOutput>* pPreviewOutput); 513 514 /** 515 * @brief Create preview output instance using surface 516 * with custom width and height. 517 * 518 * @param The surface to be used for preview. 519 * @param preview width. 520 * @param preview height. 521 * @return Returns pointer to preview output instance. 522 */ 523 [[deprecated]] sptr<PreviewOutput> CreateCustomPreviewOutput(sptr<Surface> surface, int32_t width, int32_t height); 524 525 /** 526 * @brief Create preview output instance using IBufferProducer 527 * with custom width and height. 528 * 529 * @param The IBufferProducer to be used for preview output. 530 * @param The format to be used for preview. 531 * @param preview width. 532 * @param preview height. 533 * @return Returns pointer to preview output instance. 534 */ 535 [[deprecated]] sptr<PreviewOutput> CreateCustomPreviewOutput( 536 const sptr<OHOS::IBufferProducer>& producer, int32_t format, int32_t width, int32_t height); 537 538 /** 539 * @brief Create metadata output instance. 540 * 541 * @return Returns pointer to metadata output instance. 542 */ 543 sptr<MetadataOutput> CreateMetadataOutput(); 544 545 /** 546 * @brief Create metadata output instance. 547 * 548 * @param Returns pointer to metadata output instance. 549 * @return Returns error code. 550 */ 551 int CreateMetadataOutput(sptr<MetadataOutput>& pMetadataOutput); 552 553 /** 554 * @brief Get stream depth data from service. 555 * 556 * @param depthProfile depth profile. 557 * @param surfaceProducer depth data buffer surfaceProducer. 558 * @param streamDepthData pointer to depth data stream. 559 * @return Returns error code. 560 */ 561 int GetStreamDepthDataFromService(DepthProfile& depthProfile, sptr<IBufferProducer> &surfaceProducer, 562 sptr<IStreamDepthData>& streamDepthData); 563 564 /** 565 * @brief Create metadata output instance. 566 * 567 * @param Returns pointer to metadata output instance. 568 * @return Returns error code. 569 */ 570 int CreateMetadataOutput(sptr<MetadataOutput>& pMetadataOutput, 571 std::vector<MetadataObjectType> metadataObjectTypes); 572 573 /** 574 * @brief Register camera status listener. 575 * 576 * @param listener CameraManagerCallback pointer. 577 */ 578 void SetCallback(std::shared_ptr<CameraManagerCallback> listener); 579 580 /** 581 * @brief Register camera status listener. 582 * 583 * @param listener CameraManagerCallback pointer. 584 */ 585 void RegisterCameraStatusCallback(std::shared_ptr<CameraManagerCallback> listener); 586 587 /** 588 * @brief Unregister camera status listener. 589 * 590 * @param listener CameraManagerCallback pointer. 591 */ 592 void UnregisterCameraStatusCallback(std::shared_ptr<CameraManagerCallback> listener); 593 594 /** 595 * @brief Get the camera status listener manager. 596 * 597 * @return CameraStatusListenerManager pointer is set by application. 598 */ 599 sptr<CameraStatusListenerManager> GetCameraStatusListenerManager(); 600 601 /** 602 * @brief Get cameraDevice of specific camera id. 603 * 604 * @param std::string camera id. 605 * @return Returns pointer to cameraDevice of given Id if found else return nullptr. 606 */ 607 sptr<CameraDevice> GetCameraDeviceFromId(std::string cameraId); 608 609 /** 610 * @brief check if control center active 611 * 612 * @return Returns true is active, false is not active. 613 */ 614 bool IsControlCenterActive(); 615 616 /** 617 * @brief create the ControlCenterSession instance. 618 * 619 * @return Returns the instance of ControlCenterSession. 620 */ 621 int32_t CreateControlCenterSession(sptr<ControlCenterSession>& pControlCenterSession); 622 623 /** 624 * @brief Get cameraInfo of specific camera id. 625 * 626 * @param std::string camera id. 627 * @return Returns pointer to cameraInfo of given Id if found else return nullptr. 628 */ 629 [[deprecated]] sptr<CameraInfo> GetCameraInfo(std::string cameraId); 630 631 /** 632 * @brief Get the support of camera mute mode. 633 * 634 * @return Returns true is supported, false is not supported. 635 */ 636 bool IsCameraMuteSupported(); 637 638 /** 639 * @brief Get camera mute mode. 640 * 641 * @return Returns true is in mute, else is not in mute. 642 */ 643 bool IsCameraMuted(); 644 645 /** 646 * @brief Mute the camera 647 * 648 * @return. 649 */ 650 void MuteCamera(bool muteMode); 651 652 /** 653 * @brief Mute the camera, and the mute mode can be persisting; 654 * 655 * @param PolicyType policyType. 656 * @param bool muteMode. 657 * @return. 658 */ 659 int32_t MuteCameraPersist(PolicyType policyType, bool muteMode); 660 661 /** 662 * @brief Register camera mute listener 663 * 664 * @param listener The mute listener object. 665 * 666 */ 667 void RegisterCameraMuteListener(std::shared_ptr<CameraMuteListener> listener); 668 669 /** 670 * @brief Unregister camera mute listener 671 * 672 * @param listener The mute listener object. 673 * @return. 674 */ 675 void UnregisterCameraMuteListener(std::shared_ptr<CameraMuteListener> listener); 676 677 /** 678 * @brief Register control center status listener 679 * 680 * @param listener The control center status listener object. 681 * 682 */ 683 void RegisterControlCenterStatusListener(std::shared_ptr<ControlCenterStatusListener> listener); 684 685 /** 686 * @brief Unregister control center status listener 687 * 688 * @param listener The control center status object. 689 * @return. 690 */ 691 void UnregisterControlCenterStatusListener(std::shared_ptr<ControlCenterStatusListener> listener); 692 693 /** 694 * @brief Get the ControlCenterStatusListenerManager. 695 * 696 * @return ControlCenterStatusListenerManager. 697 */ 698 sptr<ControlCenterStatusListenerManager> GetControlCenterStatusListenerManager(); 699 700 /** 701 * @brief Set control center frame condition. 702 * 703 * @param frameCondition The control center frame condition. 704 * @return. 705 */ 706 void SetControlCenterFrameCondition(bool frameCondition); 707 708 /** 709 * @brief Set control center resolution condition. 710 * 711 * @param resolutionCondition The control center resolution condition. 712 * @return. 713 */ 714 void SetControlCenterResolutionCondition(bool resolutionCondition); 715 716 /** 717 * @brief Set control center position condition. 718 * 719 * @param positionCondition The control center position condition. 720 * @return. 721 */ 722 void SetControlCenterPositionCondition(bool positionCondition); 723 724 /** 725 * @brief Update control center precondition. 726 * 727 * @return. 728 */ 729 void UpdateControlCenterPrecondition(); 730 731 /** 732 * @brief Get control center precondition. 733 * 734 * @return Returns control center precondition. 735 */ 736 bool GetControlCenterPrecondition(); 737 738 /** 739 * @brief Set if control center supported. 740 * 741 * @param isSupported The control center isSupported. 742 * @return. 743 */ 744 void SetIsControlCenterSupported(bool isSupported); 745 746 /** 747 * @brief Get if control center supported. 748 * 749 * @return Returns if control center supported. 750 */ 751 bool GetIsControlCenterSupported(); 752 753 /** 754 * @brief Get the camera mute listener manager. 755 * 756 * @return CameraMuteListenerManager point. 757 */ 758 sptr<CameraMuteListenerManager> GetCameraMuteListenerManager(); 759 760 /** 761 * @brief prelaunch the camera 762 * 763 * @return Server error code. 764 */ 765 int32_t PrelaunchCamera(int32_t flag = -1); 766 767 /** 768 * @brief reset rss priority 769 * 770 * @return Server error code. 771 */ 772 int32_t ResetRssPriority(); 773 774 /** 775 * @brief Pre-switch camera 776 * 777 * @return Server error code. 778 */ 779 int32_t PreSwitchCamera(const std::string cameraId); 780 781 /** 782 * @brief set prelaunch config 783 * 784 * @return. 785 */ 786 int32_t SetPrelaunchConfig(std::string cameraId, RestoreParamTypeOhos restoreParamType, int activeTime, 787 EffectParam effectParam); 788 789 /** 790 * @brief Get the support of camera pre launch mode. 791 * 792 * @return Returns true is supported, false is not supported. 793 */ 794 bool IsPrelaunchSupported(sptr<CameraDevice> camera); 795 796 /** 797 * @brief Register torch listener 798 * 799 * @param TorchListener listener object. 800 * @return. 801 */ 802 void RegisterTorchListener(std::shared_ptr<TorchListener> listener); 803 804 /** 805 * @brief Unregister torch listener 806 * 807 * @param TorchListener listener object. 808 * @return. 809 */ 810 void UnregisterTorchListener(std::shared_ptr<TorchListener> listener); 811 812 /** 813 * @brief Get the TorchServiceListenerManager. 814 * 815 * @return TorchServiceListenerManager. 816 */ 817 sptr<TorchServiceListenerManager> GetTorchServiceListenerManager(); 818 819 /** 820 * @brief Register fold status listener 821 * 822 * @param listener The fold listener object. 823 * @return. 824 */ 825 void RegisterFoldListener(std::shared_ptr<FoldListener> listener); 826 827 /** 828 * @brief Unregister fold status listener 829 * 830 * @param listener The fold listener object. 831 * @return. 832 */ 833 void UnregisterFoldListener(std::shared_ptr<FoldListener> listener); 834 835 /** 836 * @brief Get the FoldStatusListenerManager. 837 * 838 * @return FoldStatusListenerManager. 839 */ 840 sptr<FoldStatusListenerManager> GetFoldStatusListenerManager(); 841 842 /** 843 * @brief check device if support torch 844 * 845 * @return Returns true is supported, false is not supported. 846 */ 847 bool IsTorchSupported(); 848 849 /** 850 * @brief check mode if device can support 851 * 852 * @return Returns true is supported, false is not supported. 853 */ 854 bool IsTorchModeSupported(TorchMode mode); 855 856 /** 857 * @brief get current torchmode 858 * 859 * @return Returns current torchmode 860 */ 861 TorchMode GetTorchMode(); 862 863 /** 864 * @brief set torch mode 865 * 866 * @return. 867 */ 868 int32_t SetTorchMode(TorchMode mode); 869 870 /** 871 * @brief update torch mode 872 * 873 */ 874 void UpdateTorchMode(TorchMode mode); 875 876 /** 877 * @brief set cameramanager null 878 * 879 */ 880 void SetCameraManagerNull(); 881 882 /** 883 * @brief Get storageSize. 884 * 885 * @return Returns camera storage. 886 */ 887 int32_t GetCameraStorageSize(int64_t& storage); 888 889 int32_t RequireMemorySize(int32_t memSize); 890 891 int32_t CreatePreviewOutputStream( 892 sptr<IStreamRepeat>& streamPtr, Profile& profile, const sptr<OHOS::IBufferProducer>& producer); 893 894 int32_t CreateVideoOutputStream( 895 sptr<IStreamRepeat>& streamPtr, Profile& profile, const sptr<OHOS::IBufferProducer>& producer); 896 897 int32_t CreatePhotoOutputStream( 898 sptr<IStreamCapture>& streamPtr, Profile& profile, const sptr<OHOS::IBufferProducer>& producer); 899 900 int32_t CreatePhotoOutputStream(sptr<IStreamCapture>& streamPtr, Profile& profile); 901 /** 902 * @brief clear remote stub obj. 903 * 904 */ 905 int32_t DestroyStubObj(); 906 907 static const std::string surfaceFormat; 908 909 void OnCameraServerAlive(); 910 911 virtual bool GetIsFoldable(); 912 913 virtual FoldStatus GetFoldStatus(); 914 ClearCameraDeviceListCache()915 inline void ClearCameraDeviceListCache() 916 { 917 std::lock_guard<std::mutex> lock(cameraDeviceListMutex_); 918 cameraDeviceList_.clear(); 919 } 920 ClearCameraDeviceAbilitySupportMap()921 inline void ClearCameraDeviceAbilitySupportMap() 922 { 923 std::lock_guard<std::mutex> lock(cameraDeviceAbilitySupportMapMutex_); 924 cameraDeviceAbilitySupportMap_.clear(); 925 } 926 RemoveCameraDeviceFromCache(const std::string & cameraId)927 inline void RemoveCameraDeviceFromCache(const std::string& cameraId) 928 { 929 std::lock_guard<std::mutex> lock(cameraDeviceListMutex_); 930 cameraDeviceList_.erase(std::remove_if(cameraDeviceList_.begin(), cameraDeviceList_.end(), 931 [&cameraId](const auto& cameraDevice) { return cameraDevice->GetID() == cameraId; }), 932 cameraDeviceList_.end()); 933 } 934 935 void GetCameraOutputStatus(int32_t pid, int32_t &status); 936 int CreateCameraDevice(std::string cameraId, sptr<ICameraDeviceService> *pICameraDeviceService); GetServiceProxy()937 inline sptr<ICameraService> GetServiceProxy() 938 { 939 std::lock_guard<std::mutex> lock(serviceProxyMutex_); 940 return serviceProxyPrivate_; 941 } 942 std::vector<sptr<CameraDevice>> GetSupportedCamerasWithFoldStatus(); 943 944 struct ProfilesWrapper { 945 std::vector<Profile> photoProfiles = {}; 946 std::vector<Profile> previewProfiles = {}; 947 std::vector<VideoProfile> vidProfiles = {}; 948 }; 949 950 void ProcessModeAndOutputCapability(std::vector<std::vector<SceneMode>> &modes, 951 std::vector<SceneMode> modeofThis, std::vector<std::vector<sptr<CameraOutputCapability>>> &outputCapabilities, 952 std::vector<sptr<CameraOutputCapability>> outputCapabilitiesofThis); 953 void GetCameraConcurrentInfos(std::vector<sptr<CameraDevice>> cameraDeviceArrray, 954 std::vector<bool> cameraConcurrentType, std::vector<std::vector<SceneMode>> &modes, 955 std::vector<std::vector<sptr<CameraOutputCapability>>> &outputCapabilities); 956 void GetMetadataInfos(camera_metadata_item_t item, 957 std::vector<SceneMode> &modeofThis, std::vector<sptr<CameraOutputCapability>> &outputCapabilitiesofThis, 958 shared_ptr<OHOS::Camera::CameraMetadata> &cameraAbility); 959 void SetCameraOutputCapabilityofthis(sptr<CameraOutputCapability> &cameraOutputCapability, 960 ProfilesWrapper &profilesWrapper, int32_t modeName, 961 shared_ptr<OHOS::Camera::CameraMetadata> &cameraAbility); 962 bool GetConcurrentType(std::vector<sptr<CameraDevice>> cameraDeviceArrray, 963 std::vector<bool> &cameraConcurrentType); 964 bool CheckConcurrentExecution(std::vector<sptr<CameraDevice>> cameraDeviceArrray); 965 bool CheckCameraConcurrentId(std::unordered_map<std::string, int32_t> &idmap, 966 std::vector<std::string> &cameraIdv); 967 void ParsingCameraConcurrentLimted(camera_metadata_item_t &item, 968 std::vector<SceneMode> &mode, std::vector<sptr<CameraOutputCapability>> &outputCapabilitiesofThis, 969 shared_ptr<OHOS::Camera::CameraMetadata> &cameraAbility, sptr<CameraDevice>cameraDevNow); 970 void GetMetadataInfosfordouble(camera_metadata_item_t &item, double* originInfo, uint32_t i, 971 std::vector<SceneMode> &modeofThis, std::vector<sptr<CameraOutputCapability>> &outputCapabilitiesofThis, 972 shared_ptr<OHOS::Camera::CameraMetadata> &cameraAbility); 973 void GetSpecInfofordouble(double* originInfo, uint32_t start, uint32_t end, ProfileLevelInfo &modeInfo); 974 void GetStreamInfofordouble(double* originInfo, uint32_t start, uint32_t end, SpecInfo &specInfo); 975 void GetDetailInfofordouble(double* originInfo, uint32_t start, uint32_t end, StreamInfo &streamInfo); 976 void GetAbilityStructofConcurrentLimted(std::vector<int32_t> &vec, double* originInfo, int length); 977 void GetAbilityStructofConcurrentLimtedfloat(std::vector<float> &vec, double* originInfo, int length); 978 std::vector<dmDeviceInfo> GetDmDeviceInfo(); 979 CameraConcurrentLimtedCapability limtedCapabilitySave_; 980 std::unordered_map<std::string, CameraConcurrentLimtedCapability> cameraConLimCapMap_; 981 void FindConcurrentLimtedEnd(double* originInfo, int32_t i, int32_t count, int32_t &countl); 982 friend int CameraInput::Open(int32_t cameraConcurrentType); 983 std::string GetFoldScreenType(); 984 bool GetIsInWhiteList(); 985 void SaveOldCameraId(std::string realCameraId, std::string oldCameraId); 986 std::string GetOldCameraIdfromReal(std::string realCameraId); 987 void SaveOldMeta(std::string cameraId, std::shared_ptr<OHOS::Camera::CameraMetadata> metadata); 988 std::shared_ptr<OHOS::Camera::CameraMetadata> GetOldMeta(std::string cameraId); 989 void SetOldMetatoInput(sptr<CameraDevice>& cameraObj, std::shared_ptr<OHOS::Camera::CameraMetadata> metadata); GetCameraDeviceList()990 inline std::vector<sptr<CameraDevice>> GetCameraDeviceList() 991 { 992 std::lock_guard<std::mutex> lock(cameraDeviceListMutex_); 993 if (cameraDeviceList_.empty()) { 994 cameraDeviceList_ = GetCameraDeviceListFromServer(); 995 } 996 return cameraDeviceList_; 997 } 998 std::string GetBundleName(); 999 protected: 1000 // Only for UT CameraManager(sptr<ICameraService> serviceProxy)1001 explicit CameraManager(sptr<ICameraService> serviceProxy) : serviceProxyPrivate_(serviceProxy) 1002 { 1003 // Construct method add mutex lock is not necessary. Ignore g_instanceMutex. 1004 CameraManager::g_cameraManager = this; 1005 } 1006 1007 private: 1008 1009 enum CameraAbilitySupportCacheKey { 1010 CAMERA_ABILITY_SUPPORT_TORCH, 1011 CAMERA_ABILITY_SUPPORT_MUTE, 1012 CAMERA_ABILITY_SUPPORT_MECH, 1013 }; 1014 1015 explicit CameraManager(); 1016 void InitCameraManager(); 1017 int32_t SetCameraServiceCallback(sptr<ICameraServiceCallback>& callback); 1018 int32_t UnSetCameraServiceCallback(); 1019 1020 int32_t SetCameraMuteServiceCallback(sptr<ICameraMuteServiceCallback>& callback); 1021 int32_t UnSetCameraMuteServiceCallback(); 1022 1023 int32_t SetTorchServiceCallback(sptr<ITorchServiceCallback>& callback); 1024 int32_t UnSetTorchServiceCallback(); 1025 1026 int32_t SetFoldServiceCallback(sptr<IFoldServiceCallback>& callback); 1027 int32_t UnSetFoldServiceCallback(); 1028 1029 int32_t SetControlCenterStatusCallback(sptr<IControlCenterStatusCallback>& callback); 1030 int32_t UnSetControlCenterStatusCallback(); 1031 1032 int32_t CreateMetadataOutputInternal(sptr<MetadataOutput>& pMetadataOutput, 1033 const std::vector<MetadataObjectType>& metadataObjectTypes = {}); 1034 1035 sptr<CaptureSession> CreateCaptureSessionImpl(SceneMode mode, sptr<ICaptureSession> session); 1036 int32_t CreateListenerObject(); 1037 void CameraServerDied(pid_t pid); 1038 int32_t AddServiceProxyDeathRecipient(); 1039 void RemoveServiceProxyDeathRecipient(); 1040 sptr<CameraOutputCapability> ParseSupportedOutputCapability(sptr<CameraDevice>& camera, int32_t modeName = 0, 1041 std::shared_ptr<OHOS::Camera::CameraMetadata> cameraAbility = nullptr); 1042 void ParseProfileLevel( 1043 ProfilesWrapper& profilesWrapper, const int32_t modeName, const camera_metadata_item_t& item); 1044 void CreateProfileLevel4StreamType(ProfilesWrapper& profilesWrapper, int32_t specId, StreamInfo& streamInfo); 1045 void CreateProfile4StreamType(ProfilesWrapper& profilesWrapper, OutputCapStreamType streamType, uint32_t modeIndex, 1046 uint32_t streamIndex, ExtendInfo extendInfo); 1047 static const std::unordered_map<camera_format_t, CameraFormat> metaToFwCameraFormat_; 1048 static const std::unordered_map<CameraFormat, camera_format_t> fwToMetaCameraFormat_; 1049 static const std::unordered_map<DepthDataAccuracyType, DepthDataAccuracy> metaToFwDepthDataAccuracy_; 1050 void ParseExtendCapability( 1051 ProfilesWrapper& profilesWrapper, const int32_t modeName, const camera_metadata_item_t& item); 1052 void ParseBasicCapability(ProfilesWrapper& profilesWrapper, std::shared_ptr<OHOS::Camera::CameraMetadata> metadata, 1053 const camera_metadata_item_t& item); 1054 void CreateDepthProfile4StreamType(OutputCapStreamType streamType, uint32_t modeIndex, 1055 uint32_t streamIndex, ExtendInfo extendInfo); 1056 void CreateProfile4StreamType(OutputCapStreamType streamType, uint32_t modeIndex, 1057 uint32_t streamIndex, ExtendInfo extendInfo); 1058 void ParseExtendCapability(const int32_t modeName, const camera_metadata_item_t& item); 1059 void ParseBasicCapability( 1060 std::shared_ptr<OHOS::Camera::CameraMetadata> metadata, const camera_metadata_item_t& item); 1061 void ParseDepthCapability(const int32_t modeName, const camera_metadata_item_t& item); 1062 void AlignVideoFpsProfile(std::vector<sptr<CameraDevice>>& cameraObjList); 1063 void SetProfile(sptr<CameraDevice>& cameraObj, std::shared_ptr<OHOS::Camera::CameraMetadata> metadata); 1064 SceneMode GetFallbackConfigMode(SceneMode profileMode, ProfilesWrapper& profilesWrapper); 1065 void ParseCapability(ProfilesWrapper& profilesWrapper, sptr<CameraDevice>& camera, const int32_t modeName, 1066 camera_metadata_item_t& item, std::shared_ptr<OHOS::Camera::CameraMetadata> metadata); 1067 camera_format_t GetCameraMetadataFormat(CameraFormat format); 1068 1069 dmDeviceInfo GetDmDeviceInfo(const std::string& cameraId, const std::vector<dmDeviceInfo>& dmDeviceInfoList); 1070 int32_t SetTorchLevel(float level); 1071 int32_t ValidCreateOutputStream(Profile& profile, const sptr<OHOS::IBufferProducer>& producer); 1072 int32_t SubscribeSystemAbility(); 1073 int32_t UnSubscribeSystemAbility(); 1074 void ReportEvent(const string& cameraId); 1075 int32_t RefreshServiceProxy(); 1076 std::vector<sptr<CameraDevice>> GetCameraDeviceListFromServer(); 1077 bool IsSystemApp(); 1078 vector<CameraFormat> GetSupportPhotoFormat(const int32_t modeName, 1079 std::shared_ptr<OHOS::Camera::CameraMetadata> metadata); 1080 void FillSupportPhotoFormats(std::vector<Profile>& profiles); 1081 void FillSupportPreviewFormats(std::vector<Profile>& previewProfiles); SetServiceProxy(sptr<ICameraService> proxy)1082 inline void SetServiceProxy(sptr<ICameraService> proxy) 1083 { 1084 std::lock_guard<std::mutex> lock(serviceProxyMutex_); 1085 serviceProxyPrivate_ = proxy; 1086 } 1087 IsCameraDeviceListCached()1088 inline bool IsCameraDeviceListCached() 1089 { 1090 std::lock_guard<std::mutex> lock(cameraDeviceListMutex_); 1091 return !cameraDeviceList_.empty(); 1092 } 1093 CacheCameraDeviceAbilitySupportValue(CameraAbilitySupportCacheKey key,bool value)1094 inline void CacheCameraDeviceAbilitySupportValue(CameraAbilitySupportCacheKey key, bool value) 1095 { 1096 std::lock_guard<std::mutex> lock(cameraDeviceAbilitySupportMapMutex_); 1097 cameraDeviceAbilitySupportMap_[key] = value; 1098 } 1099 GetCameraDeviceAbilitySupportValue(CameraAbilitySupportCacheKey key,bool & value)1100 inline bool GetCameraDeviceAbilitySupportValue(CameraAbilitySupportCacheKey key, bool& value) 1101 { 1102 std::lock_guard<std::mutex> lock(cameraDeviceAbilitySupportMapMutex_); 1103 auto it = cameraDeviceAbilitySupportMap_.find(key); 1104 if (it == cameraDeviceAbilitySupportMap_.end()) { 1105 return false; 1106 } 1107 value = it->second; 1108 return true; 1109 } 1110 GetInnerCamera()1111 inline sptr<CameraDevice> GetInnerCamera() 1112 { 1113 std::lock_guard<std::mutex> lock(innerCameraMutex_); 1114 return innerCamera_; 1115 } 1116 SetInnerCamera(sptr<CameraDevice> cameraDevice)1117 inline void SetInnerCamera(sptr<CameraDevice> cameraDevice) 1118 { 1119 std::lock_guard<std::mutex> lock(innerCameraMutex_); 1120 innerCamera_ = cameraDevice; 1121 } 1122 1123 void CheckWhiteList(); 1124 std::mutex cameraDeviceListMutex_; 1125 std::mutex innerCameraMutex_; 1126 std::vector<sptr<CameraDevice>> cameraDeviceList_ = {}; 1127 1128 std::mutex cameraDeviceAbilitySupportMapMutex_; 1129 std::unordered_map<CameraAbilitySupportCacheKey, bool> cameraDeviceAbilitySupportMap_; 1130 1131 std::mutex serviceProxyMutex_; 1132 sptr<ICameraService> serviceProxyPrivate_; 1133 std::mutex deathRecipientMutex_; 1134 sptr<CameraDeathRecipient> deathRecipient_ = nullptr; 1135 1136 static sptr<CameraManager> g_cameraManager; 1137 static std::mutex g_instanceMutex; 1138 1139 sptr<CameraMuteListenerManager> cameraMuteListenerManager_ = sptr<CameraMuteListenerManager>::MakeSptr(); 1140 sptr<ControlCenterStatusListenerManager> controlCenterStatusListenerManager_ = 1141 sptr<ControlCenterStatusListenerManager>::MakeSptr(); 1142 sptr<TorchServiceListenerManager> torchServiceListenerManager_ = sptr<TorchServiceListenerManager>::MakeSptr(); 1143 sptr<CameraStatusListenerManager> cameraStatusListenerManager_ = sptr<CameraStatusListenerManager>::MakeSptr(); 1144 sptr<FoldStatusListenerManager> foldStatusListenerManager_ = sptr<FoldStatusListenerManager>::MakeSptr(); 1145 1146 std::map<std::string, dmDeviceInfo> distributedCamInfoAndId_; 1147 1148 std::map<std::string, std::vector<Profile>> modePhotoProfiles_ = {}; 1149 std::map<std::string, std::vector<Profile>> modePreviewProfiles_ = {}; 1150 std::vector<DepthProfile> depthProfiles_ = {}; 1151 1152 std::vector<CameraFormat> photoFormats_ = {}; 1153 sptr<CameraInput> cameraInput_; 1154 TorchMode torchMode_ = TorchMode::TORCH_MODE_OFF; 1155 std::mutex saListenerMuxtex_; 1156 sptr<IRemoteBroker> saListener_ = nullptr; 1157 std::string foldScreenType_; 1158 bool isSystemApp_ = false; 1159 bool isInWhiteList_ = false; 1160 std::string bundleName_ = ""; 1161 std::string curBundleName_ = ""; 1162 sptr<CameraDevice> innerCamera_ = nullptr; 1163 FoldStatus preFoldStatus = FoldStatus::UNKNOWN_FOLD; 1164 std::unordered_map<std::string, std::shared_ptr<OHOS::Camera::CameraMetadata>> cameraOldCamera_; 1165 std::unordered_map<std::string, std::string>realtoVirtual_; 1166 bool controlCenterFrameCondition_ = true; 1167 bool controlCenterResolutionCondition_ = true; 1168 bool controlCenterPositionCondition_ = true; 1169 bool controlCenterPrecondition_ = true; 1170 bool isControlCenterSupported_ = true; 1171 }; 1172 1173 class CameraManagerGetter { 1174 public: 1175 void SetCameraManager(wptr<CameraManager> cameraManager); 1176 sptr<CameraManager> GetCameraManager(); 1177 1178 private: 1179 wptr<CameraManager> cameraManager_ = nullptr; 1180 }; 1181 1182 class CameraStatusListenerManager : public CameraManagerGetter, 1183 public CameraServiceCallbackStub, 1184 public CameraListenerManager<CameraManagerCallback> { 1185 public: 1186 int32_t OnCameraStatusChanged( 1187 const std::string& cameraId, const int32_t status, const std::string& bundleName) override; 1188 int32_t OnFlashlightStatusChanged(const std::string& cameraId, const int32_t status) override; 1189 GetCachedCameraStatus()1190 inline std::vector<std::shared_ptr<CameraStatusInfo>> GetCachedCameraStatus() 1191 { 1192 std::lock_guard<std::mutex> lock(cachedCameraStatusMutex_); 1193 std::vector<std::shared_ptr<CameraStatusInfo>> infoList = {}; 1194 for (auto& it : cachedCameraStatus_) { 1195 if (it.second != nullptr) { 1196 infoList.emplace_back(it.second); 1197 } 1198 } 1199 return infoList; 1200 } GetCachedFlashStatus()1201 inline std::vector<std::pair<std::string, FlashStatus>> GetCachedFlashStatus() 1202 { 1203 std::lock_guard<std::mutex> lock(cachedFlashStatusMutex_); 1204 std::vector<std::pair<std::string, FlashStatus>> statusList = {}; 1205 for (auto& it : cachedFlashStatus_) { 1206 statusList.emplace_back(it); 1207 } 1208 return statusList; 1209 } 1210 1211 bool CheckCameraStatusValid(sptr<CameraDevice> cameraInfo); 1212 1213 private: CacheCameraStatus(const std::string & cameraId,std::shared_ptr<CameraStatusInfo> statusInfo)1214 inline void CacheCameraStatus(const std::string& cameraId, std::shared_ptr<CameraStatusInfo> statusInfo) 1215 { 1216 std::lock_guard<std::mutex> lock(cachedCameraStatusMutex_); 1217 cachedCameraStatus_[cameraId] = statusInfo; 1218 } 1219 CacheFlashStatus(const std::string & cameraId,const FlashStatus status)1220 inline void CacheFlashStatus(const std::string& cameraId, const FlashStatus status) 1221 { 1222 std::lock_guard<std::mutex> lock(cachedFlashStatusMutex_); 1223 cachedFlashStatus_[cameraId] = status; 1224 } 1225 1226 std::mutex cachedCameraStatusMutex_; 1227 unordered_map<string, std::shared_ptr<CameraStatusInfo>> cachedCameraStatus_; 1228 std::mutex cachedFlashStatusMutex_; 1229 unordered_map<string, FlashStatus> cachedFlashStatus_; 1230 }; 1231 1232 class TorchServiceListenerManager : public CameraManagerGetter, 1233 public TorchServiceCallbackStub, 1234 public CameraListenerManager<TorchListener> { 1235 public: 1236 int32_t OnTorchStatusChange(const TorchStatus status) override; 1237 GetCachedTorchStatus()1238 inline TorchStatusInfo GetCachedTorchStatus() 1239 { 1240 return cachedTorchStatus_; 1241 } 1242 1243 private: 1244 TorchStatusInfo cachedTorchStatus_ = {}; 1245 }; 1246 1247 class CameraMuteListenerManager : public CameraManagerGetter, 1248 public CameraMuteServiceCallbackStub, 1249 public CameraListenerManager<CameraMuteListener> { 1250 public: 1251 int32_t OnCameraMute(bool muteMode) override; 1252 }; 1253 1254 class ControlCenterStatusListenerManager : public CameraManagerGetter, 1255 public ControlCenterStatusCallbackStub, 1256 public CameraListenerManager<ControlCenterStatusListener> { 1257 public: 1258 int32_t OnControlCenterStatusChanged(bool status) override; 1259 }; 1260 1261 class FoldStatusListenerManager : public CameraManagerGetter, 1262 public FoldServiceCallbackStub, 1263 public CameraListenerManager<FoldListener> { 1264 public: 1265 int32_t OnFoldStatusChanged(const FoldStatus status) override; 1266 }; 1267 } // namespace CameraStandard 1268 } // namespace OHOS 1269 #endif // OHOS_CAMERA_CAMERA_MANAGER_H 1270