blob: 6268aa500f74201224087c2311acf6cc9e863f46 [file] [log] [blame]
Chong Zhang6d58e4b2020-03-31 09:41:10 -07001/*
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 Zhang66469272020-06-04 16:51:55 -070020#include <aidl/android/media/ITranscodingClientCallback.h>
Chong Zhang6d58e4b2020-03-31 09:41:10 -070021#include <aidl/android/media/TranscodingErrorCode.h>
Chong Zhang00feca22020-05-08 15:02:06 -070022#include <aidl/android/media/TranscodingRequestParcel.h>
Chong Zhang3fa408f2020-04-30 11:04:28 -070023#include <media/TranscodingDefs.h>
Chong Zhang6d58e4b2020-03-31 09:41:10 -070024
25namespace android {
26
Chong Zhang66469272020-06-04 16:51:55 -070027using ::aidl::android::media::ITranscodingClientCallback;
Chong Zhang6d58e4b2020-03-31 09:41:10 -070028using ::aidl::android::media::TranscodingErrorCode;
Chong Zhang00feca22020-05-08 15:02:06 -070029using ::aidl::android::media::TranscodingRequestParcel;
Chong Zhang75222182020-04-29 14:43:42 -070030class TranscoderCallbackInterface;
Chong Zhang6d58e4b2020-03-31 09:41:10 -070031
Chong Zhangbc062482020-10-14 16:43:53 -070032// Interface for the controller to call the transcoder to take actions.
Chong Zhang6d58e4b2020-03-31 09:41:10 -070033class TranscoderInterface {
34public:
Chong Zhang75222182020-04-29 14:43:42 -070035 virtual void setCallback(const std::shared_ptr<TranscoderCallbackInterface>& cb) = 0;
Chong Zhangbc062482020-10-14 16:43:53 -070036 virtual void start(ClientIdType clientId, SessionIdType sessionId,
Chong Zhang66469272020-06-04 16:51:55 -070037 const TranscodingRequestParcel& request,
38 const std::shared_ptr<ITranscodingClientCallback>& clientCallback) = 0;
Chong Zhangbc062482020-10-14 16:43:53 -070039 virtual void pause(ClientIdType clientId, SessionIdType sessionId) = 0;
40 virtual void resume(ClientIdType clientId, SessionIdType sessionId,
Chong Zhangb55c5452020-06-26 14:32:12 -070041 const TranscodingRequestParcel& request,
42 const std::shared_ptr<ITranscodingClientCallback>& clientCallback) = 0;
Chong Zhangbc062482020-10-14 16:43:53 -070043 virtual void stop(ClientIdType clientId, SessionIdType sessionId) = 0;
Chong Zhang6d58e4b2020-03-31 09:41:10 -070044
45protected:
46 virtual ~TranscoderInterface() = default;
47};
48
Chong Zhangbc062482020-10-14 16:43:53 -070049// Interface for the transcoder to notify the controller of the status of
50// the currently running session, or temporary loss of transcoding resources.
Chong Zhang6d58e4b2020-03-31 09:41:10 -070051class TranscoderCallbackInterface {
52public:
53 // TODO(chz): determine what parameters are needed here.
Chong Zhangbc062482020-10-14 16:43:53 -070054 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 Zhang6d58e4b2020-03-31 09:41:10 -070062
63 // Called when transcoding becomes temporarily inaccessible due to loss of resource.
Chong Zhangbc062482020-10-14 16:43:53 -070064 // 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 Zhangeffd8962020-12-02 14:29:09 -080067 virtual void onResourceLost(ClientIdType clientId, SessionIdType sessionId) = 0;
Chong Zhang6d58e4b2020-03-31 09:41:10 -070068
69protected:
70 virtual ~TranscoderCallbackInterface() = default;
71};
72
73} // namespace android
74#endif // ANDROID_MEDIA_TRANSCODER_INTERFACE_H