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_CONTROLLER_CLIENT_INTERFACE_H 18 #define ANDROID_MEDIA_CONTROLLER_CLIENT_INTERFACE_H 19 20 #include <aidl/android/media/ITranscodingClientCallback.h> 21 #include <aidl/android/media/TranscodingRequestParcel.h> 22 #include <media/TranscodingDefs.h> 23 24 namespace android { 25 26 using ::aidl::android::media::ITranscodingClientCallback; 27 using ::aidl::android::media::TranscodingRequestParcel; 28 29 // Interface for a client to call the controller to schedule or retrieve 30 // the status of a session. 31 class ControllerClientInterface { 32 public: 33 /** 34 * Submits one request to the controller. 35 * 36 * Returns true on success and false on failure. This call will fail is a session identified 37 * by <clientId, sessionId> already exists. 38 */ 39 virtual bool submit(ClientIdType clientId, SessionIdType sessionId, uid_t callingUid, 40 uid_t clientUid, const TranscodingRequestParcel& request, 41 const std::weak_ptr<ITranscodingClientCallback>& clientCallback) = 0; 42 43 /** 44 * Cancels a session identified by <clientId, sessionId>. 45 * 46 * If sessionId is negative (<0), all sessions with a specified priority (that's not 47 * TranscodingSessionPriority::kUnspecified) will be cancelled. Otherwise, only the single 48 * session <clientId, sessionId> will be cancelled. 49 * 50 * Returns false if a single session is being cancelled but it doesn't exist. Returns 51 * true otherwise. 52 */ 53 virtual bool cancel(ClientIdType clientId, SessionIdType sessionId) = 0; 54 55 /** 56 * Retrieves information about a session. 57 * 58 * Returns true and the session if it exists, and false otherwise. 59 */ 60 virtual bool getSession(ClientIdType clientId, SessionIdType sessionId, 61 TranscodingRequestParcel* request) = 0; 62 63 /** 64 * Add an additional client uid requesting the session identified by <clientId, sessionId>. 65 * 66 * Returns false if the session doesn't exist, or the client is already requesting the 67 * session. Returns true otherwise. 68 */ 69 virtual bool addClientUid(ClientIdType clientId, SessionIdType sessionId, uid_t clientUid); 70 71 /** 72 * Retrieves the (unsorted) list of all clients requesting the session identified by 73 * <clientId, sessionId>. 74 * 75 * Note that if a session was submitted with offline priority ( 76 * TranscodingSessionPriority::kUnspecified), it initially will not be considered requested 77 * by any particular client, because the client could go away any time after the submission. 78 * However, additional uids could be added via addClientUid() after the submission, which 79 * essentially make the request a real-time request instead of an offline request. 80 * 81 * Returns false if the session doesn't exist. Returns true otherwise. 82 */ 83 virtual bool getClientUids(ClientIdType clientId, SessionIdType sessionId, 84 std::vector<int32_t>* out_clientUids); 85 86 protected: 87 virtual ~ControllerClientInterface() = default; 88 }; 89 90 } // namespace android 91 #endif // ANDROID_MEDIA_CONTROLLER_CLIENT_INTERFACE_H 92