• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 AVCODEC_SERVER_H
17 #define AVCODEC_SERVER_H
18 
19 #include "avcodec_server_manager.h"
20 #include "avcodec_service_stub.h"
21 #include "nocopyable.h"
22 #include "system_ability.h"
23 
24 namespace OHOS {
25 namespace MediaAVCodec {
26 class AVCodecServer : public SystemAbility, public AVCodecServiceStub {
27     DECLARE_SYSTEM_ABILITY(AVCodecServer);
28 public:
29     explicit AVCodecServer(int32_t systemAbilityId, bool runOnCreate = true);
30     ~AVCodecServer();
31 
32     // IStandardAVCodecService override
33     int32_t GetSubSystemAbility(IStandardAVCodecService::AVCodecSystemAbility subSystemId,
34                                 const sptr<IRemoteObject> &listener, sptr<IRemoteObject> &stubObject) override;
35     int32_t SuspendFreeze(const std::vector<pid_t> &pidList) override;
36     int32_t SuspendActive(const std::vector<pid_t> &pidList) override;
37     int32_t SuspendActiveAll() override;
38 
39 protected:
40     // SystemAbility override
41     void OnDump() override;
42     void OnStart() override;
43     int32_t OnIdle(const SystemAbilityOnDemandReason& idleReason) override;
44     void OnStop() override;
45     std::optional<AVCodecServerManager::StubType> SwitchSystemId(
46         IStandardAVCodecService::AVCodecSystemAbility subSystemId);
47     int32_t Dump(int32_t fd, const std::vector<std::u16string> &args) override;
48 
49 private:
50     void OnAddSystemAbility(int32_t systemAbilityId, const std::string &deviceId) override;
51 
52     std::mutex stateMutex_;
53 };
54 } // namespace MediaAVCodec
55 } // namespace OHOS
56 #endif // AVCODEC_SERVER_H