1 /* 2 * Copyright (C) 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 #ifndef SCREEN_CAPTURE_SERVICE_SERVER_H 17 #define SCREEN_CAPTURE_SERVICE_SERVER_H 18 19 #include <mutex> 20 #include <cstdlib> 21 #include <thread> 22 #include <string> 23 #include <memory> 24 #include <atomic> 25 #include <queue> 26 #include <vector> 27 #include <chrono> 28 29 #include "audio_capturer_wrapper.h" 30 #include "i_screen_capture_service.h" 31 #include "nocopyable.h" 32 #include "uri_helper.h" 33 #include "task_queue.h" 34 #include "accesstoken_kit.h" 35 #include "privacy_kit.h" 36 #include "ipc_skeleton.h" 37 #include "screen_capture.h" 38 #include "audio_capturer.h" 39 #include "nativetoken_kit.h" 40 #include "token_setproc.h" 41 #include "audio_info.h" 42 #include "surface.h" 43 #include "display_manager.h" 44 #include "screen_manager.h" 45 #include "i_recorder_service.h" 46 #include "recorder_server.h" 47 #include "notification_content.h" 48 #include "notification_helper.h" 49 #include "notification_request.h" 50 #include "notification_constant.h" 51 #include "notification_slot.h" 52 #include "incall_observer.h" 53 #include "account_observer.h" 54 #include "media_data_source.h" 55 #include "meta/meta.h" 56 #include "audio_stream_manager.h" 57 #include "screen_capture_monitor_server.h" 58 #include "json/json.h" 59 #include "tokenid_kit.h" 60 #include "window_manager.h" 61 #include "system_ability_status_change_stub.h" 62 #include "i_input_device_listener.h" 63 #include "input_manager.h" 64 65 namespace OHOS { 66 namespace Media { 67 using namespace Rosen; 68 using namespace AudioStandard; 69 using namespace OHOS::Notification; 70 using OHOS::Security::AccessToken::PrivacyKit; 71 72 class ScreenCaptureServer; 73 74 class NotificationSubscriber : public OHOS::Notification::NotificationLocalLiveViewSubscriber { 75 public: 76 void OnConnected() override; 77 void OnDisconnected() override; 78 void OnResponse(int32_t notificationId, 79 OHOS::sptr<OHOS::Notification::NotificationButtonOption> buttonOption) override; 80 void OnDied() override; 81 }; 82 83 enum VideoPermissionState : int32_t { 84 START_VIDEO = 0, 85 STOP_VIDEO = 1 86 }; 87 88 enum AVScreenCaptureState : int32_t { 89 CREATED = 0, 90 STARTING = 1, 91 STARTED = 2, 92 STOPPED = 3 93 }; 94 95 enum AVScreenCaptureMixMode : int32_t { 96 MIX_MODE = 0, 97 MIC_MODE = 1, 98 INNER_MODE = 2, 99 INVAILD_MODE = 3 100 }; 101 102 enum AVScreenCaptureAvType : int8_t { 103 INVALID_TYPE = -1, 104 AUDIO_TYPE = 0, 105 VIDEO_TYPE = 1, 106 AV_TYPE = 2 107 }; 108 109 enum AVScreenCaptureDataMode : int8_t { 110 BUFFER_MODE = 0, 111 SUFFACE_MODE = 1, 112 FILE_MODE = 2 113 }; 114 115 enum StopReason: int8_t { 116 NORMAL_STOPPED = 0, 117 RECEIVE_USER_PRIVACY_AUTHORITY_FAILED = 1, 118 POST_START_SCREENCAPTURE_HANDLE_FAILURE = 2, 119 REQUEST_USER_PRIVACY_AUTHORITY_FAILED = 3, 120 STOP_REASON_INVALID = 4 121 }; 122 123 struct SurfaceBufferEntry { SurfaceBufferEntrySurfaceBufferEntry124 SurfaceBufferEntry(sptr<OHOS::SurfaceBuffer> buf, int32_t fence, int64_t timeStamp, OHOS::Rect& damage) 125 : buffer(std::move(buf)), flushFence(fence), timeStamp(timeStamp), damageRect(damage) {} 126 ~SurfaceBufferEntry() noexcept = default; 127 128 sptr<OHOS::SurfaceBuffer> buffer; 129 int32_t flushFence; 130 int64_t timeStamp = 0; 131 OHOS::Rect damageRect = {0, 0, 0, 0}; 132 }; 133 134 struct StatisticalEventInfo { 135 int32_t errCode = 0; 136 std::string errMsg; 137 int32_t captureDuration = -1; 138 bool userAgree = false; 139 bool requireMic = false; 140 bool enableMic = false; 141 std::string videoResolution; 142 StopReason stopReason = StopReason::STOP_REASON_INVALID; 143 int32_t startLatency = -1; 144 }; 145 146 class ScreenCapBufferConsumerListener : public IBufferConsumerListener { 147 public: ScreenCapBufferConsumerListener(sptr<Surface> consumer,const std::shared_ptr<ScreenCaptureCallBack> & screenCaptureCb)148 ScreenCapBufferConsumerListener( 149 sptr<Surface> consumer, const std::shared_ptr<ScreenCaptureCallBack> &screenCaptureCb) 150 : consumer_(consumer), screenCaptureCb_(screenCaptureCb) {} 151 ~ScreenCapBufferConsumerListener(); 152 153 void OnBufferAvailable() override; 154 int32_t AcquireVideoBuffer(sptr<OHOS::SurfaceBuffer> &surfaceBuffer, int32_t &fence, int64_t ×tamp, 155 OHOS::Rect &damage); 156 int32_t ReleaseVideoBuffer(); 157 int32_t Release(); 158 159 private: 160 int32_t ReleaseBuffer(); 161 void ProcessVideoBufferCallBack(); 162 163 private: 164 std::mutex mutex_; 165 sptr<OHOS::Surface> consumer_ = nullptr; 166 std::shared_ptr<ScreenCaptureCallBack> screenCaptureCb_ = nullptr; 167 168 std::mutex bufferMutex_; 169 std::condition_variable bufferCond_; 170 std::queue<std::unique_ptr<SurfaceBufferEntry>> availBuffers_; 171 172 static constexpr uint32_t MAX_BUFFER_SIZE = 3; 173 static constexpr uint32_t OPERATION_TIMEOUT_IN_MS = 1000; // 1000ms 174 }; 175 176 class InputDeviceInfo : public MMI::InputDevice { 177 public: 178 InputDeviceInfo() = default; 179 180 virtual ~InputDeviceInfo() = default; 181 }; 182 183 class MouseChangeListener : public MMI::IInputDeviceListener { 184 public: 185 explicit MouseChangeListener(std::weak_ptr<ScreenCaptureServer> screenCaptureServer); 186 ~MouseChangeListener() = default; 187 int32_t GetDeviceInfo(int32_t deviceId, std::shared_ptr<InputDeviceInfo> deviceInfo); 188 189 void OnDeviceAdded(int32_t deviceId, const std::string &type) override; 190 void OnDeviceRemoved(int32_t deviceId, const std::string &type) override; 191 192 private: 193 std::weak_ptr<ScreenCaptureServer> screenCaptureServer_; 194 }; 195 196 class MMISystemAbilityListener : public SystemAbilityStatusChangeStub { 197 public: 198 explicit MMISystemAbilityListener(std::weak_ptr<ScreenCaptureServer> screenCaptureServer); 199 ~MMISystemAbilityListener() = default; 200 void OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override; 201 void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override; 202 203 private: 204 std::weak_ptr<ScreenCaptureServer> screenCaptureServer_; 205 }; 206 207 class ScreenCaptureObserverCallBack : public InCallObserverCallBack, public AccountObserverCallBack { 208 public: 209 explicit ScreenCaptureObserverCallBack(std::weak_ptr<ScreenCaptureServer> screenCaptureServer); 210 ~ScreenCaptureObserverCallBack() = default; 211 bool StopAndRelease(AVScreenCaptureStateCode state) override; 212 213 private: 214 std::weak_ptr<ScreenCaptureServer> screenCaptureServer_; 215 }; 216 217 class AudioDataSource : public IAudioDataSource { 218 public: AudioDataSource(AVScreenCaptureMixMode type,ScreenCaptureServer * screenCaptureServer)219 AudioDataSource(AVScreenCaptureMixMode type, ScreenCaptureServer* screenCaptureServer) : type_(type), 220 screenCaptureServer_(screenCaptureServer) {} 221 222 int32_t ReadAt(std::shared_ptr<AVBuffer> buffer, uint32_t length) override; 223 int32_t GetSize(int64_t &size) override; 224 int32_t RegisterAudioRendererEventListener(const int32_t clientPid, 225 const std::shared_ptr<AudioRendererStateChangeCallback> &callback); 226 int32_t UnregisterAudioRendererEventListener(const int32_t clientPid); 227 void SpeakerStateUpdate( 228 const std::vector<std::unique_ptr<AudioRendererChangeInfo>> &audioRendererChangeInfos); 229 bool HasSpeakerStream( 230 const std::vector<std::unique_ptr<AudioRendererChangeInfo>> &audioRendererChangeInfos); 231 void VoIPStateUpdate( 232 const std::vector<std::unique_ptr<AudioRendererChangeInfo>> &audioRendererChangeInfos); 233 void SetAppPid(int32_t appid); 234 void SetAppName(std::string appName); 235 int32_t GetAppPid(); 236 bool GetIsInVoIPCall(); 237 bool GetSpeakerAliveStatus(); 238 239 private: 240 int32_t MixModeBufferWrite(std::shared_ptr<AudioBuffer> &innerAudioBuffer, 241 std::shared_ptr<AudioBuffer> &micAudioBuffer, std::shared_ptr<AVMemory> &bufferMem); 242 int32_t appPid_ { 0 }; 243 std::string appName_; 244 bool speakerAliveStatus_ = true; 245 std::atomic<bool> isInVoIPCall_ = false; 246 std::mutex voipStatusChangeMutex_; 247 248 void MixAudio(char** srcData, char* mixData, int channels, int bufferSize); 249 250 AVScreenCaptureMixMode type_; 251 ScreenCaptureServer* screenCaptureServer_; 252 253 static constexpr int32_t ADS_LOG_SKIP_NUM = 1000; 254 }; 255 256 class PrivateWindowListenerInScreenCapture : public DisplayManager::IPrivateWindowListener { 257 public: 258 explicit PrivateWindowListenerInScreenCapture(std::weak_ptr<ScreenCaptureServer> screenCaptureServer); 259 ~PrivateWindowListenerInScreenCapture() = default; 260 void OnPrivateWindow(bool hasPrivate) override; 261 262 private: 263 std::weak_ptr<ScreenCaptureServer> screenCaptureServer_; 264 }; 265 266 class ScreenRendererAudioStateChangeCallback : public AudioRendererStateChangeCallback { 267 public: 268 void OnRendererStateChange(const std::vector<std::unique_ptr<AudioRendererChangeInfo>> &audioRendererChangeInfos); 269 void SetAudioSource(std::shared_ptr<AudioDataSource> audioSource); 270 void SetAppName(std::string appName); 271 private: 272 std::shared_ptr<AudioDataSource> audioSource_ = nullptr; 273 std::string appName_; 274 }; 275 276 class ScreenCaptureServer : public std::enable_shared_from_this<ScreenCaptureServer>, 277 public IScreenCaptureService, public NoCopyable { 278 public: 279 static std::shared_ptr<IScreenCaptureService> Create(); 280 static int32_t ReportAVScreenCaptureUserChoice(int32_t sessionId, const std::string &content); 281 static int32_t GetRunningScreenCaptureInstancePid(int32_t &pid); 282 static int32_t GetSpecificServer(int32_t sessionId, std::shared_ptr<ScreenCaptureServer> &server); 283 static void GetChoiceFromJson(Json::Value &root, const std::string &content, std::string key, std::string &value); 284 static void PrepareSelectWindow(Json::Value &root, std::shared_ptr<ScreenCaptureServer> &server); 285 ScreenCaptureServer(); 286 ~ScreenCaptureServer(); 287 288 int32_t SetCaptureMode(CaptureMode captureMode) override; 289 int32_t SetDataType(DataType dataType) override; 290 int32_t SetRecorderInfo(RecorderInfo recorderInfo) override; 291 int32_t SetOutputFile(int32_t outputFd) override; 292 int32_t InitAudioEncInfo(AudioEncInfo audioEncInfo) override; 293 int32_t InitAudioCap(AudioCaptureInfo audioInfo) override; 294 int32_t InitVideoEncInfo(VideoEncInfo videoEncInfo) override; 295 int32_t InitVideoCap(VideoCaptureInfo videoInfo) override; 296 int32_t StartScreenCapture(bool isPrivacyAuthorityEnabled) override; 297 int32_t StartScreenCaptureWithSurface(sptr<Surface> surface, bool isPrivacyAuthorityEnabled) override; 298 int32_t StopScreenCapture() override; 299 int32_t SetScreenCaptureCallback(const std::shared_ptr<ScreenCaptureCallBack> &callback) override; 300 int32_t AcquireAudioBuffer(std::shared_ptr<AudioBuffer> &audioBuffer, AudioCaptureSourceType type) override; 301 int32_t AcquireVideoBuffer(sptr<OHOS::SurfaceBuffer> &surfaceBuffer, int32_t &fence, 302 int64_t ×tamp, OHOS::Rect &damage) override; 303 int32_t ReleaseAudioBuffer(AudioCaptureSourceType type) override; 304 int32_t ReleaseVideoBuffer() override; 305 int32_t SetMicrophoneEnabled(bool isMicrophone) override; 306 bool GetMicWorkingState(); 307 int32_t SetCanvasRotation(bool canvasRotation) override; 308 int32_t ShowCursor(bool showCursor) override; 309 int32_t ResizeCanvas(int32_t width, int32_t height) override; 310 int32_t SkipPrivacyMode(std::vector<uint64_t> &windowIDsVec) override; 311 int32_t SetMaxVideoFrameRate(int32_t frameRate) override; 312 void Release() override; 313 int32_t ExcludeContent(ScreenCaptureContentFilter &contentFilter) override; 314 315 void SetSessionId(int32_t sessionId); 316 int32_t OnReceiveUserPrivacyAuthority(bool isAllowed); 317 int32_t StopScreenCaptureByEvent(AVScreenCaptureStateCode stateCode); 318 void UpdateMicrophoneEnabled(); 319 320 int32_t AcquireAudioBufferMix(std::shared_ptr<AudioBuffer> &innerAudioBuffer, 321 std::shared_ptr<AudioBuffer> &micAudioBuffer, AVScreenCaptureMixMode type); 322 int32_t ReleaseAudioBufferMix(AVScreenCaptureMixMode type); 323 int32_t ReleaseMicAudioBuffer(); 324 int32_t ReleaseInnerAudioBuffer(); 325 int32_t GetInnerAudioCaptureBufferSize(size_t &size); 326 int32_t GetMicAudioCaptureBufferSize(size_t &size); 327 int32_t OnVoIPStatusChanged(bool isInVoIPCall); 328 int32_t OnSpeakerAliveStatusChanged(bool speakerAliveStatus); 329 int32_t ShowCursorInner(); 330 void OnDMPrivateWindowChange(bool hasPrivate); 331 void SetMissionId(uint64_t missionId); 332 void SetDisplayId(uint64_t displayId); 333 bool IsTelInCallSkipList(); 334 void NotifyStateChange(AVScreenCaptureStateCode stateCode); 335 void NotifyDisplaySelected(uint64_t displayId); 336 void SetMouseChangeListener(std::shared_ptr<MouseChangeListener> listener); 337 std::shared_ptr<MouseChangeListener> GetMouseChangeListener(); 338 339 private: 340 int32_t StartScreenCaptureInner(bool isPrivacyAuthorityEnabled); 341 int32_t RegisterServerCallbacks(); 342 int32_t OnStartScreenCapture(); 343 void PostStartScreenCapture(bool isSuccess); 344 void PostStartScreenCaptureSuccessAction(); 345 int32_t InitRecorderInfo(std::shared_ptr<IRecorderService> &recorder, AudioCaptureInfo audioInfo); 346 int32_t InitRecorder(); 347 int32_t StartScreenCaptureFile(); 348 int32_t StartScreenCaptureStream(); 349 int32_t StartAudioCapture(); 350 int32_t StartStreamInnerAudioCapture(); 351 int32_t StartStreamMicAudioCapture(); 352 int32_t StartFileInnerAudioCapture(); 353 int32_t StartFileMicAudioCapture(); 354 int32_t StopMicAudioCapture(); 355 int32_t StartVideoCapture(); 356 int32_t StartHomeVideoCapture(); 357 int32_t StopScreenCaptureInner(AVScreenCaptureStateCode stateCode); 358 void PostStopScreenCapture(AVScreenCaptureStateCode stateCode); 359 int32_t StopAudioCapture(); 360 int32_t StopVideoCapture(); 361 int32_t StopScreenCaptureRecorder(); 362 int32_t CheckAllParams(); 363 int32_t CheckCaptureStreamParams(); 364 int32_t CheckCaptureFileParams(); 365 int32_t SetCanvasRotationInner(); 366 int32_t SkipPrivacyModeInner(); 367 int32_t SetScreenScaleMode(); 368 void InitAppInfo(); 369 void CloseFd(); 370 void ReleaseInner(); 371 void GetDumpFlag(); 372 int32_t SetMicrophoneOn(); 373 int32_t SetMicrophoneOff(); 374 375 VirtualScreenOption InitVirtualScreenOption(const std::string &name, sptr<OHOS::Surface> consumer); 376 int32_t GetMissionIds(std::vector<uint64_t> &missionIds); 377 int32_t MakeVirtualScreenMirrorForWindow(sptr<Rosen::Display> defaultDisplay, 378 std::vector<ScreenId> mirrorIds); 379 int32_t MakeVirtualScreenMirrorForHomeScreen(sptr<Rosen::Display> defaultDisplay, 380 std::vector<ScreenId> mirrorIds); 381 int32_t MakeVirtualScreenMirrorForSpecifiedScreen(sptr<Rosen::Display> defaultDisplay, 382 std::vector<ScreenId> mirrorIds); 383 int32_t MakeVirtualScreenMirror(); 384 int32_t CreateVirtualScreen(const std::string &name, sptr<OHOS::Surface> consumer); 385 int32_t PrepareVirtualScreenMirror(); 386 void DestroyVirtualScreen(); 387 388 bool CheckScreenCapturePermission(); 389 bool IsUserPrivacyAuthorityNeeded(); 390 bool UpdatePrivacyUsingPermissionState(VideoPermissionState state); 391 bool CheckPrivacyWindowSkipPermission(); 392 int32_t RequestUserPrivacyAuthority(); 393 int32_t StartPrivacyWindow(); 394 #ifdef PC_STANDARD 395 bool IsHopper(); 396 int32_t MakeVirtualScreenMirrorForHomeScreenForHopper(sptr<Rosen::Display> defaultDisplay, 397 std::vector<ScreenId> mirrorIds); 398 int32_t MakeVirtualScreenMirrorForSpecifiedScreenForHopper(sptr<Rosen::Display> defaultDisplay, 399 std::vector<ScreenId> mirrorIds); 400 #endif 401 #ifdef SUPPORT_SCREEN_CAPTURE_WINDOW_NOTIFICATION 402 int32_t TryStartNotification(); 403 #endif 404 int32_t StartNotification(); 405 std::shared_ptr<NotificationLocalLiveViewContent> GetLocalLiveViewContent(); 406 void UpdateLiveViewContent(); 407 std::shared_ptr<PixelMap> GetPixelMap(std::string path); 408 std::shared_ptr<PixelMap> GetPixelMapSvg(std::string path, int32_t width, int32_t height); 409 void ResSchedReportData(int64_t value, std::unordered_map<std::string, std::string> payload); 410 int64_t GetCurrentMillisecond(); 411 void SetMetaDataReport(); 412 void SetErrorInfo(int32_t errCode, const std::string &errMsg, StopReason stopReason, bool userAgree); 413 void SystemRecorderInterruptLatestRecorder(); 414 int32_t ReStartMicForVoIPStatusSwitch(); 415 void RegisterPrivateWindowListener(); 416 bool RegisterMMISystemAbilityListener(); 417 bool UnRegisterMMISystemAbilityListener(); 418 uint64_t GetDisplayIdOfWindows(uint64_t displayId); 419 int32_t RegisterMouseChangeListener(std::string type); 420 int32_t UnRegisterMouseChangeListener(std::string type); 421 422 private: 423 std::mutex mutex_; 424 std::mutex cbMutex_; 425 std::shared_ptr<ScreenCaptureObserverCallBack> screenCaptureObserverCb_ = nullptr; 426 std::shared_ptr<ScreenCaptureCallBack> screenCaptureCb_ = nullptr; 427 bool canvasRotation_ = false; 428 bool showCursor_ = true; 429 bool isMicrophoneOn_ = true; 430 bool isPrivacyAuthorityEnabled_ = false; 431 std::vector<uint64_t> surfaceIdList_ = {}; 432 433 int32_t sessionId_ = 0; 434 int32_t notificationId_ = 0; 435 std::string callingLabel_; 436 std::string liveViewText_; 437 std::atomic<int32_t> micCount_{0}; 438 int32_t density_ = 0; 439 int32_t capsuleVpSize_ = 18; 440 int32_t capsulePxSize_ = 0; 441 442 /* used for both CAPTURE STREAM and CAPTURE FILE */ 443 OHOS::AudioStandard::AppInfo appInfo_; 444 bool isScreenCaptureAuthority_ = false; 445 std::string appName_ = ""; 446 AVScreenCaptureConfig captureConfig_; 447 AVScreenCaptureAvType avType_ = AVScreenCaptureAvType::INVALID_TYPE; 448 AVScreenCaptureDataMode dataMode_ = AVScreenCaptureDataMode::BUFFER_MODE; 449 StatisticalEventInfo statisticalEventInfo_; 450 sptr<OHOS::Surface> consumer_ = nullptr; 451 bool isConsumerStart_ = false; 452 bool isDump_ = false; 453 ScreenId virtualScreenId_ = SCREEN_ID_INVALID; 454 ScreenId displayScreenId_ = SCREEN_ID_INVALID; 455 std::vector<uint64_t> missionIds_; 456 ScreenCaptureContentFilter contentFilter_; 457 AVScreenCaptureState captureState_ = AVScreenCaptureState::CREATED; 458 std::shared_ptr<NotificationLocalLiveViewContent> localLiveViewContent_; 459 int64_t startTime_ = 0; 460 sptr<ISystemAbilityStatusChange> mmiListener_ = nullptr; 461 std::shared_ptr<MouseChangeListener> mouseChangeListener_ = nullptr; 462 463 /* used for CAPTURE STREAM */ 464 sptr<IBufferConsumerListener> surfaceCb_ = nullptr; 465 sptr<OHOS::Surface> surface_ = nullptr; 466 bool isSurfaceMode_ = false; 467 std::shared_ptr<AudioCapturerWrapper> innerAudioCapture_; 468 std::shared_ptr<AudioCapturerWrapper> micAudioCapture_; 469 470 /* used for CAPTURE FILE */ 471 std::shared_ptr<IRecorderService> recorder_ = nullptr; 472 std::string url_; 473 OutputFormatType fileFormat_ = OutputFormatType::FORMAT_DEFAULT; 474 int32_t outputFd_ = -1; 475 int32_t audioSourceId_ = 0; 476 int32_t videoSourceId_ = 0; 477 std::shared_ptr<AudioDataSource> audioSource_ = nullptr; 478 /* used for DFX events */ 479 uint64_t instanceId_ = 0; 480 std::shared_ptr<ScreenRendererAudioStateChangeCallback> captureCallback_; 481 std::vector<uint64_t> skipPrivacyWindowIDsVec_; 482 sptr<DisplayManager::IPrivateWindowListener> displayListener_; 483 bool isCalledBySystemApp_ = false; 484 private: 485 static int32_t CheckAudioCapParam(const AudioCaptureInfo &audioCapInfo); 486 static int32_t CheckVideoCapParam(const VideoCaptureInfo &videoCapInfo); 487 static int32_t CheckAudioEncParam(const AudioEncInfo &audioEncInfo); 488 static int32_t CheckVideoEncParam(const VideoEncInfo &videoEncInfo); 489 static int32_t CheckAudioCapInfo(AudioCaptureInfo &audioCapInfo); 490 static int32_t CheckVideoCapInfo(VideoCaptureInfo &videoCapInfo); 491 static int32_t CheckAudioEncInfo(AudioEncInfo &audioEncInfo); 492 static int32_t CheckVideoEncInfo(VideoEncInfo &videoEncInfo); 493 static int32_t CheckCaptureMode(CaptureMode captureMode); 494 static int32_t CheckDataType(DataType dataType); 495 496 private: 497 static constexpr int32_t ROOT_UID = 0; 498 static constexpr int32_t AUDIO_BITRATE_MIN = 8000; 499 static constexpr int32_t AUDIO_BITRATE_MAX = 384000; 500 static constexpr int32_t VIDEO_BITRATE_MIN = 1; 501 static constexpr int32_t VIDEO_BITRATE_MAX = 30000000; 502 static constexpr int32_t VIDEO_FRAME_RATE_MIN = 1; 503 static constexpr int32_t VIDEO_FRAME_RATE_MAX = 60; 504 static constexpr int32_t VIDEO_FRAME_WIDTH_MAX = 10240; 505 static constexpr int32_t VIDEO_FRAME_HEIGHT_MAX = 4320; 506 static constexpr int32_t SESSION_ID_INVALID = -1; 507 static constexpr int32_t AV_SCREEN_CAPTURE_SESSION_UID = 1013; 508 }; 509 } // namespace Media 510 } // namespace OHOS 511 #endif // SCREEN_CAPTURE_SERVICE_SERVER_H 512