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

Commit 9526c2ff authored by Sunny Kapdi's avatar Sunny Kapdi Committed by Pavlin Radoslavov
Browse files

Bluetooth: A2DP offload HIDL

Interface for Bluetooth A2DP offload feature.

Bug: 72242910
Test: Manual; TestTracker/148125
Change-Id: I3649800dfe3e1a2d66b76859be87e01ee58d2de0
(cherry picked from commit 4e95d81e)
parent 4cd374a6
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
// This file is autogenerated by hidl-gen -Landroidbp.

hidl_interface {
    name: "android.hardware.bluetooth.a2dp@1.0",
    root: "android.hardware",
    vndk: {
        enabled: true,
    },
    srcs: [
        "types.hal",
        "IBluetoothAudioHost.hal",
        "IBluetoothAudioOffload.hal",
    ],
    interfaces: [
        "android.hidl.base@1.0",
    ],
    types: [
        "BitsPerSample",
        "ChannelMode",
        "CodecConfiguration",
        "CodecType",
        "SampleRate",
        "Status",
    ],
    gen_java: false,
}
+61 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.bluetooth.a2dp@1.0;

/**
 * HAL interface for Bluetooth A2DP Offload functionality where
 * the encoding of the A2DP data packets is offloaded to platform
 * specific encoders. The A2DP control path is maintained in the
 * Bluetooth stack.
 *
 * This interface is from HAL server to HAL client.
 *
 * The HAL server must call into the IBluetoothAudioHost to initiate
 * the start, suspend and stop of the streaming operation. These
 * calls return immediately and the results, if any, are send over
 * the IBluetoothAudioOffload interface.
 */

interface IBluetoothAudioHost {
    /**
     * Invoked when the start stream is requested from HAL server
     * to HAL client. This indicates that the HAL server
     * has initialized the platform for streaming use case, and the
     * HAL client can proceed with the streaming procedure. The
     * result of the operation must be provided by the HAL
     * client using the IBluetoothAudioOffload interface.
     */
    oneway startStream();

    /**
     * Invoked when the suspend stream is requested from HAL server
     * to HAL client. This indicates that the HAL server
     * wants to suspend the streaming procedure. The result of the
     * operation must be provided by the HAL client using the
     * IBluetoothAudioOffload interface.
     */
    oneway suspendStream();

    /**
     * Invoked when the stop stream is requested from HAL server
     * to HAL client. This indicates that the HAL server wants to
     * stop and reset the streaming procedure. There is no result
     * provided by the HAL client for this call.
     */
    oneway stopStream();

};
+85 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.bluetooth.a2dp@1.0;

import IBluetoothAudioHost;

/**
 * HAL interface for Bluetooth A2DP Offload functionality where
 * the encoding of the A2DP data packets is offloaded to platform
 * specific encoders. The A2DP control path is maintained in the
 * Bluetooth stack.
 *
 * This interface is from HAL client to HAL server.
 *
 * The HAL client must provide the handle of IBluetoothAudioHost as well
 * as codec configuration to the HAL server, when its connected to an
 * active A2DP Sink device. HAL Server, based on the feedback from the Audio
 * framework must call into the commands provided by the IBluetoothAudioHost.
 * HAL client must call into IBluetoothAudioOffload to provide the status of
 * these commands. Once the device becomes inactive, the HAL client must
 * call the endSession to terminate the session with the HAL server.
 */
interface IBluetoothAudioOffload {

    /**
     * Indicates that the HAL client is connected to an A2DP Sink device
     * and is ready to stream audio. This function is also used to register
     * the BluetoothAudioHost interface and the provide the current negotiated
     * codec.
     *
     * |endSession| must be called to unregister the interface.
     *
     * @param hostIf interface used to request stream control
     * @param codecConfig Codec configuration as negotiated with the A2DP Sink
     *    device
     * @return status one of the following
     *    SUCCESS if HAL server successfully initializes the platform with the
     *        given codec configuration
     *    UNSUPPORTED_CODEC_CONFIGURATION if HAL server cannot initialize the
     *        platform with the given codec configuration
     *    FAILURE if HAL server cannot initialize the platform for any other
     *        reason
     */
    startSession(IBluetoothAudioHost hostIf, CodecConfiguration codecConfig) generates (Status status);

    /**
     * Updates status for start stream request. The HAL client may need
     * to communicate to Bluetooth Controller and remote Sink device, in which
     * case it must update with PENDING status. Once the operation is
     * completed, it must return with either SUCCESS or FAILURE.
     *
     * @param status SUCCESS, FAILURE or PENDING
     */
    oneway streamStarted(Status status);

    /**
     * Updates status for suspend stream request. The HAL client may need
     * to communicate to Bluetooth Controller and remote device, in which case
     * it must update with PENDING status. Once the operation is completed, it
     * must return with either SUCCESS or FAILURE.
     *
     * @param status SUCCESS, FAILURE or PENDING
     */
    oneway streamSuspended(Status status);

    /**
     * Ends the current A2DP offload session and unregisters the
     * BluetoothAudioHost interface.
     */
    oneway endSession();
};
+14 −0
Original line number Diff line number Diff line
cc_library_shared {
    name: "android.hardware.bluetooth.a2dp@1.0-impl",
    relative_install_path: "hw",
    vendor: true,
    srcs: [
        "BluetoothAudioOffload.cpp",
    ],
    shared_libs: [
        "libhidlbase",
        "libhidltransport",
        "libutils",
        "android.hardware.bluetooth.a2dp@1.0",
    ],
}
+74 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2018 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.
 */

#include "BluetoothAudioOffload.h"

namespace android {
namespace hardware {
namespace bluetooth {
namespace a2dp {
namespace V1_0 {
namespace implementation {

IBluetoothAudioOffload* HIDL_FETCH_IBluetoothAudioOffload(const char* /* name */) {
    return new BluetoothAudioOffload();
}

// Methods from ::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioOffload follow.
Return<::android::hardware::bluetooth::a2dp::V1_0::Status> BluetoothAudioOffload::startSession(
    const sp<::android::hardware::bluetooth::a2dp::V1_0::IBluetoothAudioHost>& hostIf __unused,
    const ::android::hardware::bluetooth::a2dp::V1_0::CodecConfiguration& codecConfig __unused) {
    /**
     * Initialize the audio platform if codecConfiguration is supported.
     * Save the the IBluetoothAudioHost interface, so that it can be used
     * later to send stream control commands to the HAL client, based on
     * interaction with Audio framework.
     */
    return ::android::hardware::bluetooth::a2dp::V1_0::Status::FAILURE;
}

Return<void> BluetoothAudioOffload::streamStarted(
    ::android::hardware::bluetooth::a2dp::V1_0::Status status __unused) {
    /**
     * Streaming on control path has started,
     * HAL server should start the streaming on data path.
     */
    return Void();
}

Return<void> BluetoothAudioOffload::streamSuspended(
    ::android::hardware::bluetooth::a2dp::V1_0::Status status __unused) {
    /**
     * Streaming on control path has suspend,
     * HAL server should suspend the streaming on data path.
     */
    return Void();
}

Return<void> BluetoothAudioOffload::endSession() {
    /**
     * Cleanup the audio platform as remote A2DP Sink device is no
     * longer active
     */
    return Void();
}

}  // namespace implementation
}  // namespace V1_0
}  // namespace a2dp
}  // namespace bluetooth
}  // namespace hardware
}  // namespace android
Loading