• 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 CODEC_SERVICE_STUB_H
17 #define CODEC_SERVICE_STUB_H
18 
19 #include <map>
20 #include <shared_mutex>
21 #include "avcodec_death_recipient.h"
22 #include "codec_server.h"
23 #include "i_standard_codec_listener.h"
24 #include "i_standard_codec_service.h"
25 #include "nocopyable.h"
26 
27 namespace OHOS {
28 namespace MediaAVCodec {
29 class CodecServiceStub : public IRemoteStub<IStandardCodecService>, public NoCopyable {
30 public:
31     static sptr<CodecServiceStub> Create();
32     virtual ~CodecServiceStub();
33 
34     int OnRemoteRequest(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override;
35     using CodecStubFunc = int32_t(CodecServiceStub::*)(MessageParcel &data, MessageParcel &reply);
36     int32_t SetListenerObject(const sptr<IRemoteObject> &object) override;
37 
38     int32_t Init(AVCodecType type, bool isMimeType, const std::string &name) override;
39     int32_t Configure(const Format &format) override;
40     int32_t Start() override;
41     int32_t Stop() override;
42     int32_t Flush() override;
43     int32_t Reset() override;
44     int32_t Release() override;
45     int32_t NotifyEos() override;
46     sptr<Surface> CreateInputSurface() override;
47     int32_t SetOutputSurface(sptr<Surface> surface) override;
48     int32_t QueueInputBuffer(uint32_t index, AVCodecBufferInfo info, AVCodecBufferFlag flag) override;
49     int32_t QueueInputBuffer(uint32_t index) override;
50     int32_t GetOutputFormat(Format &format) override;
51     int32_t ReleaseOutputBuffer(uint32_t index, bool render) override;
52     int32_t SetParameter(const Format &format) override;
53     int32_t GetInputFormat(Format &format) override;
54 
55     int32_t DestroyStub() override;
56 #ifdef SUPPORT_DRM
57     int32_t SetDecryptConfig(const sptr<DrmStandard::IMediaKeySessionService> &keySession,
58         const bool svpFlag) override;
59 #endif
60     int32_t DumpInfo(int32_t fd);
61     int32_t SetClientInfo(int32_t clientPid, int32_t clientUid);
62 
63 private:
64     CodecServiceStub();
65     int32_t InitStub();
66     int32_t SetListenerObject(MessageParcel &data, MessageParcel &reply);
67     int32_t Init(MessageParcel &data, MessageParcel &reply);
68     int32_t Configure(MessageParcel &data, MessageParcel &reply);
69     int32_t Start(MessageParcel &data, MessageParcel &reply);
70     int32_t Stop(MessageParcel &data, MessageParcel &reply);
71     int32_t Flush(MessageParcel &data, MessageParcel &reply);
72     int32_t Reset(MessageParcel &data, MessageParcel &reply);
73     int32_t Release(MessageParcel &data, MessageParcel &reply);
74     int32_t NotifyEos(MessageParcel &data, MessageParcel &reply);
75     int32_t CreateInputSurface(MessageParcel &data, MessageParcel &reply);
76     int32_t SetOutputSurface(MessageParcel &data, MessageParcel &reply);
77     int32_t QueueInputBuffer(MessageParcel &data, MessageParcel &reply);
78     int32_t GetOutputFormat(MessageParcel &data, MessageParcel &reply);
79     int32_t ReleaseOutputBuffer(MessageParcel &data, MessageParcel &reply);
80     int32_t SetParameter(MessageParcel &data, MessageParcel &reply);
81     int32_t GetInputFormat(MessageParcel &data, MessageParcel &reply);
82     int32_t DestroyStub(MessageParcel &data, MessageParcel &reply);
83 #ifdef SUPPORT_DRM
84     int32_t SetDecryptConfig(MessageParcel &data, MessageParcel &reply);
85 #endif
86     int32_t InnerRelease();
87 
88     std::shared_ptr<ICodecService> codecServer_ = nullptr;
89     std::map<uint32_t, CodecStubFunc> recFuncs_;
90     std::shared_mutex mutex_;
91     sptr<IStandardCodecListener> listener_ = nullptr;
92 };
93 } // namespace MediaAVCodec
94 } // namespace OHOS
95 #endif // CODEC_SERVICE_STUB_H
96