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> |
hkuang | 9c04b8d | 2020-01-22 10:03:21 -0800 | [diff] [blame] | 22 | #include <media/TranscodingClientManager.h> |
Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 23 | |
| 24 | namespace android { |
| 25 | |
Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 26 | using Status = ::ndk::ScopedAStatus; |
| 27 | using ::aidl::android::media::BnMediaTranscodingService; |
| 28 | using ::aidl::android::media::ITranscodingServiceClient; |
hkuang | 48c365e | 2020-01-13 16:33:42 -0800 | [diff] [blame] | 29 | using ::aidl::android::media::TranscodingJobParcel; |
| 30 | using ::aidl::android::media::TranscodingRequestParcel; |
Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 31 | |
| 32 | class MediaTranscodingService : public BnMediaTranscodingService { |
| 33 | public: |
hkuang | 9c04b8d | 2020-01-22 10:03:21 -0800 | [diff] [blame] | 34 | static constexpr int32_t kInvalidJobId = -1; |
| 35 | static constexpr int32_t kInvalidClientId = -1; |
| 36 | |
Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 37 | MediaTranscodingService(); |
| 38 | virtual ~MediaTranscodingService(); |
| 39 | |
| 40 | static void instantiate(); |
| 41 | |
| 42 | static const char* getServiceName() { return "media.transcoding"; } |
| 43 | |
| 44 | Status registerClient(const std::shared_ptr<ITranscodingServiceClient>& in_client, |
hkuang | 48c365e | 2020-01-13 16:33:42 -0800 | [diff] [blame] | 45 | const std::string& in_opPackageName, int32_t in_clientUid, |
| 46 | int32_t in_clientPid, int32_t* _aidl_return) override; |
Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 47 | |
| 48 | Status unregisterClient(int32_t clientId, bool* _aidl_return) override; |
| 49 | |
hkuang | 9c04b8d | 2020-01-22 10:03:21 -0800 | [diff] [blame] | 50 | Status getNumOfClients(int32_t* _aidl_return) override; |
| 51 | |
hkuang | 48c365e | 2020-01-13 16:33:42 -0800 | [diff] [blame] | 52 | Status submitRequest(int32_t in_clientId, const TranscodingRequestParcel& in_request, |
| 53 | TranscodingJobParcel* out_job, int32_t* _aidl_return) override; |
Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 54 | |
| 55 | Status cancelJob(int32_t in_clientId, int32_t in_jobId, bool* _aidl_return) override; |
| 56 | |
hkuang | 48c365e | 2020-01-13 16:33:42 -0800 | [diff] [blame] | 57 | Status getJobWithId(int32_t in_jobId, TranscodingJobParcel* out_job, |
| 58 | bool* _aidl_return) override; |
Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 59 | |
| 60 | virtual inline binder_status_t dump(int /*fd*/, const char** /*args*/, uint32_t /*numArgs*/); |
| 61 | |
| 62 | private: |
hkuang | 9c04b8d | 2020-01-22 10:03:21 -0800 | [diff] [blame] | 63 | friend class MediaTranscodingServiceTest; |
| 64 | |
| 65 | mutable std::mutex mServiceLock; |
| 66 | |
hkuang | 5172cab | 2020-01-31 12:40:28 -0800 | [diff] [blame] | 67 | TranscodingClientManager& mTranscodingClientManager; |
Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 68 | }; |
| 69 | |
Hangyu Kuang | 71b9fb4 | 2019-11-27 10:33:32 -0800 | [diff] [blame] | 70 | } // namespace android |
| 71 | |
| 72 | #endif // ANDROID_MEDIA_TRANSCODING_SERVICE_H |