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

Commit a2537344 authored by Ravi Kumar Alamanda's avatar Ravi Kumar Alamanda Committed by Ricardo Cerqueira
Browse files

frameworks/base: Add support for QCELP/EVRC non-tunnel encoding in SF



Add support for QCELP and EVRC formats non-tunnel mode encoding
in StageFright using hardware accelerated encoders.

Patchset 1: Add QCOM_HARDWARE ifdefs.
Patchset 2: Fix ifdef derp.
Patchset 3: Fix endif derp, change omx-core include to vendor/qcom.

Conflicts:

	media/libstagefright/Android.mk
	media/libstagefright/OMXCodec.cpp

Change-Id: I179030d71a9598ddddcf754e963fbed1e1357024
Signed-off-by: default avatarEvan McClain <aeroevan@gmail.com>
parent 256fcc6a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -10851,9 +10851,13 @@ package android.media {
  public final class MediaRecorder.AudioEncoder {
    field public static final int AAC = 3; // 0x3
    field public static final int AAC_PLUS = 4; // 0x4
    field public static final int AMR_NB = 1; // 0x1
    field public static final int AMR_WB = 2; // 0x2
    field public static final int DEFAULT = 0; // 0x0
    field public static final int EAAC_PLUS = 5; // 0x5
    field public static final int EVRC = 6; // 0x6
    field public static final int QCELP = 7; // 0x7
  }
  public final class MediaRecorder.AudioSource {
@@ -10880,8 +10884,10 @@ package android.media {
    field public static final int AMR_WB = 4; // 0x4
    field public static final int DEFAULT = 0; // 0x0
    field public static final int MPEG_4 = 2; // 0x2
    field public static final int QCP = 9; // 0x9
    field public static final int RAW_AMR = 3; // 0x3
    field public static final int THREE_GPP = 1; // 0x1
    field public static final int THREE_GPP2 = 10; // 0xa
  }
  public final class MediaRecorder.VideoEncoder {
+3 −0
Original line number Diff line number Diff line
@@ -459,6 +459,9 @@ private:
    static VideoEncoderCap* createDefaultH264VideoEncoderCap();
#endif
    static AudioEncoderCap* createDefaultAmrNBEncoderCap();
#ifdef QCOM_HARDWARE
    static AudioEncoderCap* createDefaultAacEncoderCap();
#endif

    static int findTagForName(const NameToTagMap *map, size_t nMappings, const char *name);

+9 −0
Original line number Diff line number Diff line
@@ -67,6 +67,11 @@ enum output_format {
    /* H.264/AAC data encapsulated in MPEG2/TS */
    OUTPUT_FORMAT_MPEG2TS = 8,

#ifdef QCOM_HARDWARE
    OUTPUT_FORMAT_QCP = 9, // QCP file format
    OUTPUT_FORMAT_THREE_GPP2 = 10, /*3GPP2*/
#endif

    OUTPUT_FORMAT_LIST_END // must be last - used to validate format type
};

@@ -77,6 +82,10 @@ enum audio_encoder {
    AUDIO_ENCODER_AAC = 3,
    AUDIO_ENCODER_AAC_PLUS = 4,
    AUDIO_ENCODER_EAAC_PLUS = 5,
#ifdef QCOM_HARDWARE
    AUDIO_ENCODER_EVRC = 6,
    AUDIO_ENCODER_QCELP = 7,
#endif

    AUDIO_ENCODER_LIST_END // must be the last - used to validate the audio encoder type
};
+126 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2011 Code Aurora Forum. All rights reserved
 *
 * 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.
 */

#ifndef EXTENDED_WRITER_H_

#define EXTENDED_WRITER_H_

#include <stdio.h>

#include <media/stagefright/MediaWriter.h>
#include <utils/threads.h>

namespace android {

struct MediaSource;
struct MetaData;

struct ExtendedWriter : public MediaWriter {
    ExtendedWriter(const char *filename);
    ExtendedWriter(int fd);

    status_t initCheck() const;

    virtual status_t addSource(const sp<MediaSource> &source);
    virtual bool reachedEOS();
    virtual status_t start(MetaData *params = NULL);
    virtual status_t stop();
    virtual status_t pause();

protected:
    virtual ~ExtendedWriter();

private:
    FILE *mFile;
    status_t mInitCheck;
    sp<MediaSource> mSource;
    bool mStarted;
    volatile bool mPaused;
    volatile bool mResumed;
    volatile bool mDone;
    volatile bool mReachedEOS;
    pthread_t mThread;
    int64_t mEstimatedSizeBytes;
    int64_t mEstimatedDurationUs;

    int32_t mFormat;

    //QCP/EVRC header
    struct QCPEVRCHeader
    {
        /* RIFF Section */
        char riff[4];
        unsigned int s_riff;
        char qlcm[4];

        /* Format chunk */
        char fmt[4];
        unsigned int s_fmt;
        char mjr;
        char mnr;
        unsigned int data1;

        /* UNIQUE ID of the codec */
        unsigned short data2;
        unsigned short data3;
        char data4[8];
        unsigned short ver;

        /* Codec Info */
        char name[80];
        unsigned short abps;

        /* average bits per sec of the codec */
        unsigned short bytes_per_pkt;
        unsigned short samp_per_block;
        unsigned short samp_per_sec;
        unsigned short bits_per_samp;
        unsigned char vr_num_of_rates;

        /* Rate Header fmt info */
        unsigned char rvd1[3];
        unsigned short vr_bytes_per_pkt[8];
        unsigned int rvd2[5];

        /* Vrat chunk */
        unsigned char vrat[4];
        unsigned int s_vrat;
        unsigned int v_rate;
        unsigned int size_in_pkts;

        /* Data chunk */
        unsigned char data[4];
        unsigned int s_data;
    } __attribute__ ((packed));

    struct QCPEVRCHeader mHeader;
    off_t mOffset; //note off_t

    static void *ThreadWrapper(void *);
    status_t threadFunc();
    bool exceedsFileSizeLimit();
    bool exceedsFileDurationLimit();

    ExtendedWriter(const ExtendedWriter &);
    ExtendedWriter &operator=(const ExtendedWriter &);

    status_t writeQCPHeader( );
    status_t writeEVRCHeader( );
};

}  // namespace android

#endif  // AMR_WRITER_H_
+11 −2
Original line number Diff line number Diff line
@@ -227,6 +227,11 @@ public class MediaRecorder

        /** @hide H.264/AAC data encapsulated in MPEG2/TS */
        public static final int OUTPUT_FORMAT_MPEG2TS = 8;

        /** QCP file format */
        public static final int QCP = 9;
        /** 3GPP2 media file format*/
        public static final int THREE_GPP2 = 10;
    };

    /**
@@ -245,10 +250,14 @@ public class MediaRecorder
        public static final int AMR_WB = 2;
        /** AAC audio codec */
        public static final int AAC = 3;
        /** @hide enhanced AAC audio codec */
        /** enhanced AAC audio codec */
        public static final int AAC_PLUS = 4;
        /** @hide enhanced AAC plus audio codec */
        /** enhanced AAC plus audio codec */
        public static final int EAAC_PLUS = 5;
        /** EVRC audio codec */
        public static final int EVRC = 6;
        /** QCELP audio codec */
        public static final int QCELP =7;
    }

    /**
Loading