| 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; | 
| Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 35 |  | 
|  | 36 | class MediaTranscodingService : public BnMediaTranscodingService { | 
|  | 37 | public: | 
| hkuang | 9c04b8d | 2020-01-22 10:03:21 -0800 | [diff] [blame] | 38 | static constexpr int32_t kInvalidJobId = -1; | 
|  | 39 | static constexpr int32_t kInvalidClientId = -1; | 
|  | 40 |  | 
| Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 41 | MediaTranscodingService(); | 
| Chong Zhang | 182b06a | 2020-04-09 14:38:05 -0700 | [diff] [blame] | 42 | MediaTranscodingService(const std::shared_ptr<TranscoderInterface>& transcoder, | 
| Chong Zhang | 7ae4e2f | 2020-04-17 15:24:34 -0700 | [diff] [blame] | 43 | const std::shared_ptr<UidPolicyInterface>& uidPolicy); | 
| Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 44 | virtual ~MediaTranscodingService(); | 
|  | 45 |  | 
|  | 46 | static void instantiate(); | 
|  | 47 |  | 
|  | 48 | static const char* getServiceName() { return "media.transcoding"; } | 
|  | 49 |  | 
| Chong Zhang | 182b06a | 2020-04-09 14:38:05 -0700 | [diff] [blame] | 50 | Status registerClient(const std::shared_ptr<ITranscodingClientCallback>& in_callback, | 
|  | 51 | const std::string& in_clientName, const std::string& in_opPackageName, | 
|  | 52 | int32_t in_clientUid, int32_t in_clientPid, | 
|  | 53 | std::shared_ptr<ITranscodingClient>* _aidl_return) override; | 
| Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 54 |  | 
| hkuang | 9c04b8d | 2020-01-22 10:03:21 -0800 | [diff] [blame] | 55 | Status getNumOfClients(int32_t* _aidl_return) override; | 
|  | 56 |  | 
| Chong Zhang | 182b06a | 2020-04-09 14:38:05 -0700 | [diff] [blame] | 57 | 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] | 58 |  | 
|  | 59 | private: | 
| hkuang | 9c04b8d | 2020-01-22 10:03:21 -0800 | [diff] [blame] | 60 | friend class MediaTranscodingServiceTest; | 
|  | 61 |  | 
|  | 62 | mutable std::mutex mServiceLock; | 
|  | 63 |  | 
| 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 |