Chong Zhang | 6d58e4b | 2020-03-31 09:41:10 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2020 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_TRANSCODER_INTERFACE_H |
| 18 | #define ANDROID_MEDIA_TRANSCODER_INTERFACE_H |
| 19 | |
Chong Zhang | 6646927 | 2020-06-04 16:51:55 -0700 | [diff] [blame] | 20 | #include <aidl/android/media/ITranscodingClientCallback.h> |
Chong Zhang | 6d58e4b | 2020-03-31 09:41:10 -0700 | [diff] [blame] | 21 | #include <aidl/android/media/TranscodingErrorCode.h> |
Chong Zhang | 00feca2 | 2020-05-08 15:02:06 -0700 | [diff] [blame] | 22 | #include <aidl/android/media/TranscodingRequestParcel.h> |
Chong Zhang | 3fa408f | 2020-04-30 11:04:28 -0700 | [diff] [blame] | 23 | #include <media/TranscodingDefs.h> |
Chong Zhang | 6d58e4b | 2020-03-31 09:41:10 -0700 | [diff] [blame] | 24 | |
| 25 | namespace android { |
| 26 | |
Chong Zhang | 6646927 | 2020-06-04 16:51:55 -0700 | [diff] [blame] | 27 | using ::aidl::android::media::ITranscodingClientCallback; |
Chong Zhang | 6d58e4b | 2020-03-31 09:41:10 -0700 | [diff] [blame] | 28 | using ::aidl::android::media::TranscodingErrorCode; |
Chong Zhang | 00feca2 | 2020-05-08 15:02:06 -0700 | [diff] [blame] | 29 | using ::aidl::android::media::TranscodingRequestParcel; |
Chong Zhang | 7522218 | 2020-04-29 14:43:42 -0700 | [diff] [blame] | 30 | class TranscoderCallbackInterface; |
Chong Zhang | 6d58e4b | 2020-03-31 09:41:10 -0700 | [diff] [blame] | 31 | |
Chong Zhang | bc06248 | 2020-10-14 16:43:53 -0700 | [diff] [blame] | 32 | // Interface for the controller to call the transcoder to take actions. |
Chong Zhang | 6d58e4b | 2020-03-31 09:41:10 -0700 | [diff] [blame] | 33 | class TranscoderInterface { |
| 34 | public: |
Chong Zhang | 7522218 | 2020-04-29 14:43:42 -0700 | [diff] [blame] | 35 | virtual void setCallback(const std::shared_ptr<TranscoderCallbackInterface>& cb) = 0; |
Chong Zhang | bc06248 | 2020-10-14 16:43:53 -0700 | [diff] [blame] | 36 | virtual void start(ClientIdType clientId, SessionIdType sessionId, |
Chong Zhang | 6646927 | 2020-06-04 16:51:55 -0700 | [diff] [blame] | 37 | const TranscodingRequestParcel& request, |
| 38 | const std::shared_ptr<ITranscodingClientCallback>& clientCallback) = 0; |
Chong Zhang | bc06248 | 2020-10-14 16:43:53 -0700 | [diff] [blame] | 39 | virtual void pause(ClientIdType clientId, SessionIdType sessionId) = 0; |
| 40 | virtual void resume(ClientIdType clientId, SessionIdType sessionId, |
Chong Zhang | b55c545 | 2020-06-26 14:32:12 -0700 | [diff] [blame] | 41 | const TranscodingRequestParcel& request, |
| 42 | const std::shared_ptr<ITranscodingClientCallback>& clientCallback) = 0; |
Chong Zhang | bc06248 | 2020-10-14 16:43:53 -0700 | [diff] [blame] | 43 | virtual void stop(ClientIdType clientId, SessionIdType sessionId) = 0; |
Chong Zhang | 6d58e4b | 2020-03-31 09:41:10 -0700 | [diff] [blame] | 44 | |
| 45 | protected: |
| 46 | virtual ~TranscoderInterface() = default; |
| 47 | }; |
| 48 | |
Chong Zhang | bc06248 | 2020-10-14 16:43:53 -0700 | [diff] [blame] | 49 | // Interface for the transcoder to notify the controller of the status of |
| 50 | // the currently running session, or temporary loss of transcoding resources. |
Chong Zhang | 6d58e4b | 2020-03-31 09:41:10 -0700 | [diff] [blame] | 51 | class TranscoderCallbackInterface { |
| 52 | public: |
| 53 | // TODO(chz): determine what parameters are needed here. |
Chong Zhang | bc06248 | 2020-10-14 16:43:53 -0700 | [diff] [blame] | 54 | virtual void onStarted(ClientIdType clientId, SessionIdType sessionId) = 0; |
| 55 | virtual void onPaused(ClientIdType clientId, SessionIdType sessionId) = 0; |
| 56 | virtual void onResumed(ClientIdType clientId, SessionIdType sessionId) = 0; |
| 57 | virtual void onFinish(ClientIdType clientId, SessionIdType sessionId) = 0; |
| 58 | virtual void onError(ClientIdType clientId, SessionIdType sessionId, |
| 59 | TranscodingErrorCode err) = 0; |
| 60 | virtual void onProgressUpdate(ClientIdType clientId, SessionIdType sessionId, |
| 61 | int32_t progress) = 0; |
Chong Zhang | 6d58e4b | 2020-03-31 09:41:10 -0700 | [diff] [blame] | 62 | |
| 63 | // Called when transcoding becomes temporarily inaccessible due to loss of resource. |
Chong Zhang | bc06248 | 2020-10-14 16:43:53 -0700 | [diff] [blame] | 64 | // If there is any session currently running, it will be paused. When resource contention |
| 65 | // is solved, the controller should call TranscoderInterface's to either start a new session, |
| 66 | // or resume a paused session. |
Chong Zhang | effd896 | 2020-12-02 14:29:09 -0800 | [diff] [blame] | 67 | virtual void onResourceLost(ClientIdType clientId, SessionIdType sessionId) = 0; |
Chong Zhang | 6d58e4b | 2020-03-31 09:41:10 -0700 | [diff] [blame] | 68 | |
| 69 | protected: |
| 70 | virtual ~TranscoderCallbackInterface() = default; |
| 71 | }; |
| 72 | |
| 73 | } // namespace android |
| 74 | #endif // ANDROID_MEDIA_TRANSCODER_INTERFACE_H |