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

Commit faddd5d7 authored by Andreas Huber's avatar Andreas Huber Committed by Android (Google) Code Review
Browse files

Merge "Support for determining the mime type of media via metadata extraction."

parents 5d3c9c10 1cb02bf6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ enum {
    METADATA_KEY_VIDEO_HEIGHT    = 19,
    METADATA_KEY_VIDEO_WIDTH     = 20,
    METADATA_KEY_WRITER          = 21,
    METADATA_KEY_MIMETYPE        = 22,
    // Add more here...
};

+1 −0
Original line number Diff line number Diff line
@@ -255,5 +255,6 @@ public class MediaMetadataRetriever
    public static final int METADATA_KEY_VIDEO_HEIGHT    = 19;
    public static final int METADATA_KEY_VIDEO_WIDTH     = 20;
    public static final int METADATA_KEY_WRITER          = 21;
    public static final int METADATA_KEY_MIMETYPE        = 22;
    // Add more here...
}
+12 −0
Original line number Diff line number Diff line
@@ -128,6 +128,18 @@ AMRExtractor::AMRExtractor(const sp<DataSource> &source)
AMRExtractor::~AMRExtractor() {
}

sp<MetaData> AMRExtractor::getMetaData() {
    sp<MetaData> meta = new MetaData;

    if (mInitCheck != OK) {
        return meta;
    }

    meta->setCString(kKeyMIMEType, mIsWide ? "audio/amr-wb" : "audio/amr");

    return meta;
}

size_t AMRExtractor::countTracks() {
    return mInitCheck == OK ? 1 : 0;
}
+4 −0
Original line number Diff line number Diff line
@@ -711,6 +711,10 @@ status_t MP3Source::read(
sp<MetaData> MP3Extractor::getMetaData() {
    sp<MetaData> meta = new MetaData;

    if (mFirstFramePos < 0) {
        return meta;
    }

    meta->setCString(kKeyMIMEType, "audio/mpeg");

    ID3 id3(mDataSource);
+21 −1
Original line number Diff line number Diff line
@@ -152,6 +152,7 @@ static const char *FourCC2MIME(uint32_t fourcc) {
MPEG4Extractor::MPEG4Extractor(const sp<DataSource> &source)
    : mDataSource(source),
      mHaveMetadata(false),
      mHasVideo(false),
      mFirstTrack(NULL),
      mLastTrack(NULL) {
}
@@ -167,6 +168,23 @@ MPEG4Extractor::~MPEG4Extractor() {
    mFirstTrack = mLastTrack = NULL;
}

sp<MetaData> MPEG4Extractor::getMetaData() {
    sp<MetaData> meta = new MetaData;

    status_t err;
    if ((err = readMetaData()) != OK) {
        return meta;
    }

    if (mHasVideo) {
        meta->setCString(kKeyMIMEType, "video/mp4");
    } else {
        meta->setCString(kKeyMIMEType, "audio/mp4");
    }

    return meta;
}

size_t MPEG4Extractor::countTracks() {
    status_t err;
    if ((err = readMetaData()) != OK) {
@@ -561,6 +579,8 @@ status_t MPEG4Extractor::parseChunk(off_t *offset, int depth) {
        case FOURCC('s', '2', '6', '3'):
        case FOURCC('a', 'v', 'c', '1'):
        {
            mHasVideo = true;

            if (mHandlerType != FOURCC('v', 'i', 'd', 'e')) {
                return ERROR_MALFORMED;
            }
Loading