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 package android.media;
18 
19 import android.media.TranscodingSessionParcel;
20 import android.media.TranscodingRequestParcel;
21 
22 /**
23  * ITranscodingClient
24  *
25  * Interface for a client to communicate with MediaTranscodingService.
26  *
27  * {@hide}
28  */
29 interface ITranscodingClient {
30     /**
31      * Submits a transcoding request to MediaTranscodingService.
32      *
33      * @param request a TranscodingRequest contains transcoding configuration.
34      * @param session(output variable) a TranscodingSession generated by MediaTranscodingService.
35      * @return true if success, false otherwise.
36      */
submitRequest(in TranscodingRequestParcel request, out TranscodingSessionParcel session)37     boolean submitRequest(in TranscodingRequestParcel request,
38                           out TranscodingSessionParcel session);
39 
40     /**
41      * Cancels a transcoding session.
42      *
43      * @param sessionId a TranscodingSession generated by the MediaTranscodingService.
44      * @return true if succeeds, false otherwise.
45      */
cancelSession(in int sessionId)46     boolean cancelSession(in int sessionId);
47 
48     /**
49      * Queries the session detail associated with a sessionId.
50      *
51      * @param sessionId a TranscodingSession generated by the MediaTranscodingService.
52      * @param session(output variable) the TranscodingSession associated with the sessionId.
53      * @return true if succeeds, false otherwise.
54      */
getSessionWithId(in int sessionId, out TranscodingSessionParcel session)55     boolean getSessionWithId(in int sessionId, out TranscodingSessionParcel session);
56 
57     /**
58      * Add an additional client uid requesting a session.
59      *
60      * @sessionId the session id to which to add the additional client uid.
61      * @clientUid the additional client uid to be added.
62      * @return false if the session doesn't exist or the client is already requesting the
63      * session, true otherwise.
64      */
addClientUid(in int sessionId, int clientUid)65     boolean addClientUid(in int sessionId, int clientUid);
66 
67     /**
68      * Retrieves the (unsorted) list of all clients requesting a session.
69      *
70      * Note that if a session was submitted with offline priority (
71      * TranscodingSessionPriority::kUnspecified), it initially will not be considered requested
72      * by any particular client, because the client could go away any time after the submission.
73      * However, additional uids could be added via addClientUid() after the submission, which
74      * essentially make the request a real-time request instead of an offline request.
75      *
76      * @sessionId the session id for which to retrieve the client uid list.
77      * @clientUids array to hold the retrieved client uid list.
78      * @return false if the session doesn't exist, true otherwise.
79      */
80     @nullable
getClientUids(in int sessionId)81     int[] getClientUids(in int sessionId);
82 
83     /**
84     * Unregister the client with the MediaTranscodingService.
85     *
86     * Client will not be able to perform any more transcoding after unregister.
87     */
unregister()88     void unregister();
89 }
90