blob: 0fe686423bcf30d1aff766b8a621197cafc001a0 [file] [log] [blame]
Hangyu Kuang71b9fb42019-11-27 10:33:32 -08001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_MEDIA_TRANSCODING_SERVICE_H
18#define ANDROID_MEDIA_TRANSCODING_SERVICE_H
19
20#include <aidl/android/media/BnMediaTranscodingService.h>
21#include <binder/IServiceManager.h>
22
23namespace android {
24
Hangyu Kuang71b9fb42019-11-27 10:33:32 -080025using Status = ::ndk::ScopedAStatus;
26using ::aidl::android::media::BnMediaTranscodingService;
Chong Zhang8e062632020-03-31 10:56:37 -070027using ::aidl::android::media::ITranscodingClient;
Chong Zhang182b06a2020-04-09 14:38:05 -070028using ::aidl::android::media::ITranscodingClientCallback;
hkuang48c365e2020-01-13 16:33:42 -080029using ::aidl::android::media::TranscodingJobParcel;
30using ::aidl::android::media::TranscodingRequestParcel;
Chong Zhang182b06a2020-04-09 14:38:05 -070031class TranscodingClientManager;
32class TranscodingJobScheduler;
33class TranscoderInterface;
Chong Zhang7ae4e2f2020-04-17 15:24:34 -070034class UidPolicyInterface;
Chong Zhangf9077512020-09-21 21:02:06 -070035class ResourcePolicyInterface;
Hangyu Kuang71b9fb42019-11-27 10:33:32 -080036
37class MediaTranscodingService : public BnMediaTranscodingService {
38public:
hkuang9c04b8d2020-01-22 10:03:21 -080039 static constexpr int32_t kInvalidJobId = -1;
40 static constexpr int32_t kInvalidClientId = -1;
41
Chong Zhang66469272020-06-04 16:51:55 -070042 MediaTranscodingService(const std::shared_ptr<TranscoderInterface>& transcoder);
Hangyu Kuang71b9fb42019-11-27 10:33:32 -080043 virtual ~MediaTranscodingService();
44
45 static void instantiate();
46
47 static const char* getServiceName() { return "media.transcoding"; }
48
Chong Zhang182b06a2020-04-09 14:38:05 -070049 Status registerClient(const std::shared_ptr<ITranscodingClientCallback>& in_callback,
50 const std::string& in_clientName, const std::string& in_opPackageName,
Chong Zhang182b06a2020-04-09 14:38:05 -070051 std::shared_ptr<ITranscodingClient>* _aidl_return) override;
Hangyu Kuang71b9fb42019-11-27 10:33:32 -080052
hkuang9c04b8d2020-01-22 10:03:21 -080053 Status getNumOfClients(int32_t* _aidl_return) override;
54
Chong Zhang182b06a2020-04-09 14:38:05 -070055 virtual inline binder_status_t dump(int /*fd*/, const char** /*args*/, uint32_t /*numArgs*/);
Hangyu Kuang71b9fb42019-11-27 10:33:32 -080056
57private:
hkuang9c04b8d2020-01-22 10:03:21 -080058 friend class MediaTranscodingServiceTest;
59
60 mutable std::mutex mServiceLock;
61
Chong Zhang66469272020-06-04 16:51:55 -070062 std::shared_ptr<UidPolicyInterface> mUidPolicy;
Chong Zhangf9077512020-09-21 21:02:06 -070063 std::shared_ptr<ResourcePolicyInterface> mResourcePolicy;
Chong Zhang182b06a2020-04-09 14:38:05 -070064 std::shared_ptr<TranscodingJobScheduler> mJobScheduler;
65 std::shared_ptr<TranscodingClientManager> mClientManager;
Hangyu Kuang71b9fb42019-11-27 10:33:32 -080066};
67
Hangyu Kuang71b9fb42019-11-27 10:33:32 -080068} // namespace android
69
70#endif // ANDROID_MEDIA_TRANSCODING_SERVICE_H