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

Commit 9e0ad027 authored by jiabin's avatar jiabin
Browse files

Add key for haptic channel count in metadata.

This key could be useful to query if a file contains haptic channels or
not.

Test: test with files (not) containing haptic channels
Bug: 128012181
Change-Id: I5f0a9ca9fde23ce7d6f48921acc9a1074a6a1601
parent 76e348fc
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1280,7 +1280,7 @@ void MyOggExtractor::parseFileMetaData() {
        //ALOGI("comment #%d: '%s'", i + 1, mVc.user_comments[i]);
    }

    AMediaFormat_getInt32(mFileMeta, "haptic", &mHapticChannelCount);
    AMediaFormat_getInt32(mFileMeta, AMEDIAFORMAT_KEY_HAPTIC_CHANNEL_COUNT, &mHapticChannelCount);
}

void MyOggExtractor::setChannelMask(int channelCount) {
@@ -1297,6 +1297,8 @@ void MyOggExtractor::setChannelMask(int channelCount) {
            const audio_channel_mask_t channelMask = audio_channel_out_mask_from_count(
                    audioChannelCount) | hapticChannelMask;
            AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_CHANNEL_MASK, channelMask);
            AMediaFormat_setInt32(
                    mMeta, AMEDIAFORMAT_KEY_HAPTIC_CHANNEL_COUNT, mHapticChannelCount);
        }
    } else {
        AMediaFormat_setInt32(mMeta, AMEDIAFORMAT_KEY_CHANNEL_MASK,
+1 −0
Original line number Diff line number Diff line
@@ -65,6 +65,7 @@ static const char *AMediaFormatKeyGroupInt32[] = {
    AMEDIAFORMAT_KEY_FLAC_COMPRESSION_LEVEL,
    AMEDIAFORMAT_KEY_GRID_COLUMNS,
    AMEDIAFORMAT_KEY_GRID_ROWS,
    AMEDIAFORMAT_KEY_HAPTIC_CHANNEL_COUNT,
    AMEDIAFORMAT_KEY_HEIGHT,
    AMEDIAFORMAT_KEY_INTRA_REFRESH_PERIOD,
    AMEDIAFORMAT_KEY_IS_ADTS,
+3 −4
Original line number Diff line number Diff line
@@ -309,7 +309,6 @@ static void extractAlbumArt(
void parseVorbisComment(
        AMediaFormat *fileMeta, const char *comment, size_t commentLength) {
    // Haptic tag is only kept here as it will only be used in extractor to generate channel mask.
    const char* const haptic = "haptic";
    struct {
        const char *const mTag;
        const char *mKey;
@@ -330,7 +329,7 @@ void parseVorbisComment(
        { "LYRICIST", AMEDIAFORMAT_KEY_LYRICIST },
        { "METADATA_BLOCK_PICTURE", AMEDIAFORMAT_KEY_ALBUMART },
        { "ANDROID_LOOP", AMEDIAFORMAT_KEY_LOOP },
        { "ANDROID_HAPTIC", haptic },
        { "ANDROID_HAPTIC", AMEDIAFORMAT_KEY_HAPTIC_CHANNEL_COUNT },
    };

        for (size_t j = 0; j < sizeof(kMap) / sizeof(kMap[0]); ++j) {
@@ -346,12 +345,12 @@ void parseVorbisComment(
                    if (!strcasecmp(&comment[tagLen + 1], "true")) {
                        AMediaFormat_setInt32(fileMeta, AMEDIAFORMAT_KEY_LOOP, 1);
                    }
                } else if (kMap[j].mKey == haptic) {
                } else if (kMap[j].mKey == AMEDIAFORMAT_KEY_HAPTIC_CHANNEL_COUNT) {
                    char *end;
                    errno = 0;
                    const int hapticChannelCount = strtol(&comment[tagLen + 1], &end, 10);
                    if (errno == 0) {
                        AMediaFormat_setInt32(fileMeta, haptic, hapticChannelCount);
                        AMediaFormat_setInt32(fileMeta, kMap[j].mKey, hapticChannelCount);
                    } else {
                        ALOGE("Error(%d) when parsing haptic channel count", errno);
                    }
+10 −0
Original line number Diff line number Diff line
@@ -967,6 +967,11 @@ status_t convertMetaDataToMessage(
        if (meta->findInt32(kKeyPcmEncoding, &pcmEncoding)) {
            msg->setInt32("pcm-encoding", pcmEncoding);
        }

        int32_t hapticChannelCount;
        if (meta->findInt32(kKeyHapticChannelCount, &hapticChannelCount)) {
            msg->setInt32("haptic-channel-count", hapticChannelCount);
        }
    }

    int32_t maxInputSize;
@@ -1708,6 +1713,11 @@ void convertMessageToMetaData(const sp<AMessage> &msg, sp<MetaData> &meta) {
        if (msg->findInt32("pcm-encoding", &pcmEncoding)) {
            meta->setInt32(kKeyPcmEncoding, pcmEncoding);
        }

        int32_t hapticChannelCount;
        if (msg->findInt32("haptic-channel-count", &hapticChannelCount)) {
            meta->setInt32(kKeyHapticChannelCount, hapticChannelCount);
        }
    }

    int32_t maxInputSize;
+2 −0
Original line number Diff line number Diff line
@@ -238,6 +238,8 @@ enum {
    kKeyOpaqueCSD0       = 'csd0',
    kKeyOpaqueCSD1       = 'csd1',
    kKeyOpaqueCSD2       = 'csd2',

    kKeyHapticChannelCount = 'hapC',
};

enum {
Loading