/*
 * Copyright (C) 2016 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.hardware.tv.input@1.0;

import ITvInputCallback;

interface ITvInput {
    /**
     * Sets a callback for events.
     *
     * Note that initially no device is available in the client side, so the
     * implementation must notify all the currently available devices including
     * static devices via callback once callback is set.
     *
     * @param callback Callback object to pass events.
     */
    @entry
    @exit
    @callflow(next={"getStreamConfigurations"})
    setCallback(ITvInputCallback callback);

    /**
     * Gets stream configurations for a specific device.
     *
     * The configs object is valid only until the next
     * STREAM_CONFIGURATIONS_CHANGED event.
     *
     * @param deviceId Device ID for the configurations.
     * @return result OK upon success. Otherwise,
     *         INVALID_ARGUMENTS if the given device ID is not valid.
     * @return configurations An array of available configurations.
     */
    @callflow(next={"openStream", "getStreamConfigurations", "closeStream"})
    getStreamConfigurations(int32_t deviceId)
            generates (Result result, vec<TvStreamConfig> configurations);

    /**
     * Opens a specific stream in a device.
     *
     * @param deviceId Device ID for the steam to open.
     * @param streamId Steam ID for the steam to open. Must be one of the
     *         stream IDs returned from getStreamConfigurations().
     * @return result OK upon success. Otherwise,
     *         INVALID_ARGUMENTS if any of given IDs are not valid;
     *         INVALID_STATE if the stream with the given ID is already open;
     *         NO_RESOURCE if the client must close other streams to open the
     *                 stream.
     * @return sidebandStream handle for sideband stream.
     */
    @callflow(next={"closeStream", "getStreamConfigurations", "openStream"})
    openStream(int32_t deviceId, int32_t streamId)
            generates (Result result, handle sidebandStream);

    /**
     * Closes a specific stream in a device.
     *
     * @param deviceId Device ID for the steam to open.
     * @param streamId Steam ID for the steam to open.
     * @return result OK upon success. Otherwise,
     *         INVALID_ARGUMENTS if any of given IDs are not valid;
     *         INVALID_STATE if the stream with the given ID is not open.
     */
    @callflow(next={"getStreamConfigurations", "openStream", "closeStream"})
    closeStream(int32_t deviceId, int32_t streamId) generates (Result result);
};