Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 06069a56 authored by Hangyu Kuang's avatar Hangyu Kuang
Browse files

MediaTranscodingService: Add AIDL interface for MediaTranscodingService.

There are a lot of TODOs now in the code and they will be addressed
in the next few CLs. .

Bug: 145233472
Test: Build and Compile

Change-Id: I27d96b18ebca6f07bc24e4124fb48b0e79d387d2
parent d2572133
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
// AIDL interfaces of MediaTranscoding.
aidl_interface {
    name: "mediatranscoding_aidl_interface",
    local_include_dir: "aidl",
    srcs: [
        "aidl/android/media/IMediaTranscodingService.aidl",
        "aidl/android/media/ITranscodingServiceClient.aidl",
        "aidl/android/media/TranscodingErrorCode.aidl",
        "aidl/android/media/TranscodingType.aidl",
        "aidl/android/media/TranscodingVideoCodecType.aidl",
        "aidl/android/media/TranscodingJob.aidl",
        "aidl/android/media/TranscodingRequest.aidl",
        "aidl/android/media/TranscodingResult.aidl",
    ],
}
+3 −0
Original line number Diff line number Diff line
akersten@google.com
hkuang@google.com
lnilsson@google.com
+81 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2019, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media;

import android.media.TranscodingJob;
import android.media.TranscodingRequest;
import android.media.ITranscodingServiceClient;

/**
 * Binder interface for MediaTranscodingService.
 *
 * {@hide}
 */
interface IMediaTranscodingService {
    /**
     * Register the client with the MediaTranscodingService.
     *
     * Client must call this function to register itself with the service in order to perform
     * transcoding. This function will return a unique positive Id assigned by the service.
     * Client should save this Id and use it for all the transaction with the service.
     *
     * @param client interface for the MediaTranscodingService to call the client.
     * @return a unique positive Id assigned to the client by the service, -1  means failed to
     * register.
     */
    int registerClient(in ITranscodingServiceClient client);

    /**
    * Unregister the client with the MediaTranscodingService.
    *
    * Client will not be able to perform any more transcoding after unregister.
    *
    * @param clientId assigned Id of the client.
    * @return true if succeeds, false otherwise.
    */
    boolean unregisterClient(in int clientId);

    /**
     * Submits a transcoding request to MediaTranscodingService.
     *
     * @param clientId assigned Id of the client.
     * @param request a TranscodingRequest contains transcoding configuration.
     * @param job(output variable) a TranscodingJob generated by the MediaTranscodingService.
     * @return a unique positive jobId generated by the MediaTranscodingService, -1 means failure.
     */
    int submitRequest(in int clientId,
                      in TranscodingRequest request,
                      out TranscodingJob job);

    /**
     * Cancels a transcoding job.
     *
     * @param clientId assigned id of the client.
     * @param jobId a TranscodingJob generated by the MediaTranscodingService.
     * @return true if succeeds, false otherwise.
     */
    boolean cancelJob(in int clientId, in int jobId);

    /**
     * Queries the job detail associated with a jobId.
     *
     * @param jobId a TranscodingJob generated by the MediaTranscodingService.
     * @param job(output variable) the TranscodingJob associated with the jobId.
     * @return true if succeeds, false otherwise.
     */
    boolean getJobWithId(in int jobId, out TranscodingJob job);
}
+75 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2019, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media;

import android.media.TranscodingErrorCode;
import android.media.TranscodingJob;
import android.media.TranscodingResult;

/**
 * ITranscodingServiceClient interface for the MediaTranscodingervice to communicate with the
 * client.
 *
 * {@hide}
 */
//TODO(hkuang): Implement the interface.
interface ITranscodingServiceClient {
    /**
     * Retrieves the name of the client.
     */
    @utf8InCpp String getName();

    /**
    * Called when the transcoding associated with the jobId finished.
    *
    * @param jobId jobId assigned by the MediaTranscodingService upon receiving request.
    * @param result contains the transcoded file stats and other transcoding metrics if requested.
    */
    oneway void onTranscodingFinished(in int jobId, in TranscodingResult result);

    /**
    * Called when the transcoding associated with the jobId failed.
    *
    * @param jobId jobId assigned by the MediaTranscodingService upon receiving request.
    * @param errorCode error code that indicates the error.
    */
    oneway void onTranscodingFailed(in int jobId, in TranscodingErrorCode errorCode);

    /**
    * Called when the transcoding configuration associated with the jobId gets updated, i.e. wait
    * number in the job queue.
    *
    * <p> This will only be called if client set requestUpdate to be true in the TranscodingRequest
    * submitted to the MediaTranscodingService.
    *
    * @param jobId jobId assigned by the MediaTranscodingService upon receiving request.
    * @param oldAwaitNumber previous number of jobs ahead of current job.
    * @param newAwaitNumber updated number of jobs ahead of current job.
    */
    oneway void onAwaitNumberOfJobsChanged(in int jobId, in int oldAwaitNumber, in int newAwaitNumber);

    /**
    * Called when there is an update on the progress of the TranscodingJob.
    *
    * <p> This will only be called if client set requestUpdate to be true in the TranscodingRequest
    * submitted to the MediaTranscodingService.
    *
    * @param jobId jobId assigned by the MediaTranscodingService upon receiving request.
    * @param progress an integer number ranging from 0 ~ 100 inclusive.
    */
    oneway void onProgressUpdate(in int jobId, in int progress);
}
+33 −0
Original line number Diff line number Diff line
/**
 * Copyright (c) 2019, The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.media;

/**
 * Type enums of video transcoding errors.
 *
 * {@hide}
 */
@Backing(type = "int")
enum TranscodingErrorCode {
    kUnknown = 0,
    kUnsupported = 1,
    kDecoderError = 2,
    kEncoderError = 3,
    kExtractorError = 4,
    kMuxerError = 5,
    kInvalidBitstream = 6
}
 No newline at end of file
Loading