| Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 1 | /* | 
 | 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 |  | 
 | 23 | namespace android { | 
 | 24 |  | 
| Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 25 | using Status = ::ndk::ScopedAStatus; | 
 | 26 | using ::aidl::android::media::BnMediaTranscodingService; | 
| Chong Zhang | 8e06263 | 2020-03-31 10:56:37 -0700 | [diff] [blame] | 27 | using ::aidl::android::media::ITranscodingClient; | 
| Chong Zhang | 182b06a | 2020-04-09 14:38:05 -0700 | [diff] [blame] | 28 | using ::aidl::android::media::ITranscodingClientCallback; | 
| hkuang | 48c365e | 2020-01-13 16:33:42 -0800 | [diff] [blame] | 29 | using ::aidl::android::media::TranscodingJobParcel; | 
 | 30 | using ::aidl::android::media::TranscodingRequestParcel; | 
| Chong Zhang | 182b06a | 2020-04-09 14:38:05 -0700 | [diff] [blame] | 31 | class TranscodingClientManager; | 
 | 32 | class TranscodingJobScheduler; | 
 | 33 | class TranscoderInterface; | 
| Chong Zhang | 7ae4e2f | 2020-04-17 15:24:34 -0700 | [diff] [blame] | 34 | class UidPolicyInterface; | 
| Chong Zhang | f907751 | 2020-09-21 21:02:06 -0700 | [diff] [blame] | 35 | class ResourcePolicyInterface; | 
| Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 36 |  | 
 | 37 | class MediaTranscodingService : public BnMediaTranscodingService { | 
 | 38 | public: | 
| hkuang | 9c04b8d | 2020-01-22 10:03:21 -0800 | [diff] [blame] | 39 |     static constexpr int32_t kInvalidJobId = -1; | 
 | 40 |     static constexpr int32_t kInvalidClientId = -1; | 
 | 41 |  | 
| Chong Zhang | 6646927 | 2020-06-04 16:51:55 -0700 | [diff] [blame] | 42 |     MediaTranscodingService(const std::shared_ptr<TranscoderInterface>& transcoder); | 
| Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 43 |     virtual ~MediaTranscodingService(); | 
 | 44 |  | 
 | 45 |     static void instantiate(); | 
 | 46 |  | 
 | 47 |     static const char* getServiceName() { return "media.transcoding"; } | 
 | 48 |  | 
| Chong Zhang | 182b06a | 2020-04-09 14:38:05 -0700 | [diff] [blame] | 49 |     Status registerClient(const std::shared_ptr<ITranscodingClientCallback>& in_callback, | 
 | 50 |                           const std::string& in_clientName, const std::string& in_opPackageName, | 
| Chong Zhang | 182b06a | 2020-04-09 14:38:05 -0700 | [diff] [blame] | 51 |                           std::shared_ptr<ITranscodingClient>* _aidl_return) override; | 
| Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 52 |  | 
| hkuang | 9c04b8d | 2020-01-22 10:03:21 -0800 | [diff] [blame] | 53 |     Status getNumOfClients(int32_t* _aidl_return) override; | 
 | 54 |  | 
| Chong Zhang | 182b06a | 2020-04-09 14:38:05 -0700 | [diff] [blame] | 55 |     virtual inline binder_status_t dump(int /*fd*/, const char** /*args*/, uint32_t /*numArgs*/); | 
| Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 56 |  | 
 | 57 | private: | 
| hkuang | 9c04b8d | 2020-01-22 10:03:21 -0800 | [diff] [blame] | 58 |     friend class MediaTranscodingServiceTest; | 
 | 59 |  | 
 | 60 |     mutable std::mutex mServiceLock; | 
 | 61 |  | 
| Chong Zhang | 6646927 | 2020-06-04 16:51:55 -0700 | [diff] [blame] | 62 |     std::shared_ptr<UidPolicyInterface> mUidPolicy; | 
| Chong Zhang | f907751 | 2020-09-21 21:02:06 -0700 | [diff] [blame] | 63 |     std::shared_ptr<ResourcePolicyInterface> mResourcePolicy; | 
| Chong Zhang | 182b06a | 2020-04-09 14:38:05 -0700 | [diff] [blame] | 64 |     std::shared_ptr<TranscodingJobScheduler> mJobScheduler; | 
 | 65 |     std::shared_ptr<TranscodingClientManager> mClientManager; | 
| Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 66 | }; | 
 | 67 |  | 
| Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 68 | }  // namespace android | 
 | 69 |  | 
 | 70 | #endif  // ANDROID_MEDIA_TRANSCODING_SERVICE_H |