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

Commit 609850df authored by jiabin's avatar jiabin
Browse files

Support query active microphones in MediaRecorder.

This is part of device enumeration. With the new add API, developer
could get the active microphones information for each channel.

Bug: 64038649
Test: Run cts and check the print log.
Change-Id: I01941d8d1ca0f49d0af48210ef8b1149de31676a
parent 653cc0ab
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ enum {
    SET_INPUT_DEVICE,
    GET_ROUTED_DEVICE_ID,
    ENABLE_AUDIO_DEVICE_CALLBACK,
    GET_ACTIVE_MICROPHONES,

};

@@ -391,6 +392,21 @@ public:
        }
        return reply.readInt32();
    }

    status_t getActiveMicrophones(std::vector<media::MicrophoneInfo>* activeMicrophones)
    {
        ALOGV("getActiveMicrophones");
        Parcel data, reply;
        data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
        status_t status = remote()->transact(GET_ACTIVE_MICROPHONES, data, &reply);
        if (status != OK
                || (status = (status_t)reply.readInt32()) != NO_ERROR) {
            return status;
        }
        status = reply.readParcelableVector(activeMicrophones);
        return status;
    }

};

IMPLEMENT_META_INTERFACE(MediaRecorder, "android.media.IMediaRecorder");
@@ -631,6 +647,19 @@ status_t BnMediaRecorder::onTransact(
                reply->writeInt32(BAD_VALUE);
            }
            return NO_ERROR;
        } break;
        case GET_ACTIVE_MICROPHONES: {
            ALOGV("GET_ACTIVE_MICROPHONES");
            CHECK_INTERFACE(IMediaRecorder, data, reply);
            std::vector<media::MicrophoneInfo> activeMicrophones;
            status_t status = getActiveMicrophones(&activeMicrophones);
            reply->writeInt32(status);
            if (status != NO_ERROR) {
                return NO_ERROR;
            }
            reply->writeParcelableVector(activeMicrophones);
            return NO_ERROR;

        }
        default:
            return BBinder::onTransact(code, data, reply, flags);
+5 −0
Original line number Diff line number Diff line
@@ -19,7 +19,9 @@
#define ANDROID_IMEDIARECORDER_H

#include <binder/IInterface.h>
#include <media/MicrophoneInfo.h>
#include <system/audio.h>
#include <vector>

namespace android {

@@ -69,6 +71,9 @@ public:
    virtual status_t setInputDevice(audio_port_handle_t deviceId) = 0;
    virtual status_t getRoutedDeviceId(audio_port_handle_t *deviceId) = 0;
    virtual status_t enableAudioDeviceCallback(bool enabled) = 0;
    virtual status_t getActiveMicrophones(
                        std::vector<media::MicrophoneInfo>* activeMicrophones) = 0;

};

// ----------------------------------------------------------------------------
+6 −0
Original line number Diff line number Diff line
@@ -19,10 +19,13 @@
#define MEDIA_RECORDER_BASE_H_

#include <media/AudioSystem.h>
#include <media/MicrophoneInfo.h>
#include <media/mediarecorder.h>

#include <system/audio.h>

#include <vector>

namespace android {

class ICameraRecordingProxy;
@@ -67,6 +70,9 @@ struct MediaRecorderBase {
    virtual status_t getRoutedDeviceId(audio_port_handle_t* deviceId) = 0;
    virtual void setAudioDeviceCallback(const sp<AudioSystem::AudioDeviceCallback>& callback) = 0;
    virtual status_t enableAudioDeviceCallback(bool enabled) = 0;
    virtual status_t getActiveMicrophones(
                        std::vector<media::MicrophoneInfo>* activeMicrophones) = 0;



protected:
+2 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
#include <utils/Errors.h>
#include <media/IMediaRecorderClient.h>
#include <media/IMediaDeathNotifier.h>
#include <media/MicrophoneInfo.h>

namespace android {

@@ -258,6 +259,7 @@ public:
    status_t    setInputDevice(audio_port_handle_t deviceId);
    status_t    getRoutedDeviceId(audio_port_handle_t *deviceId);
    status_t    enableAudioDeviceCallback(bool enabled);
    status_t    getActiveMicrophones(std::vector<media::MicrophoneInfo>* activeMicrophones);

private:
    void                    doCleanUp();
+11 −0
Original line number Diff line number Diff line
@@ -829,4 +829,15 @@ status_t MediaRecorder::enableAudioDeviceCallback(bool enabled)
    return mMediaRecorder->enableAudioDeviceCallback(enabled);
}

status_t MediaRecorder::getActiveMicrophones(std::vector<media::MicrophoneInfo>* activeMicrophones)
{
    ALOGV("getActiveMicrophones");

    if (mMediaRecorder == NULL) {
        ALOGE("media recorder is not initialized yet");
        return INVALID_OPERATION;
    }
    return mMediaRecorder->getActiveMicrophones(activeMicrophones);
}

} // namespace android
Loading