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

Commit 62ad9071 authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Add support for fragmented mp4 to MPEG4Extractor

This makes FragmentedMP4Extractor obsolete. It will be removed in a
separate change.

Change-Id: Ida74c07ccf84983e20a1320ee24ffc7a5c083859
parent 0d026335
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -54,6 +54,8 @@ public:

    // Convenience methods:
    bool getUInt16(off64_t offset, uint16_t *x);
    bool getUInt32(off64_t offset, uint32_t *x);
    bool getUInt64(off64_t offset, uint64_t *x);

    // May return ERROR_UNSUPPORTED.
    virtual status_t getSize(off64_t *size);
+26 −0
Original line number Diff line number Diff line
@@ -59,6 +59,32 @@ bool DataSource::getUInt16(off64_t offset, uint16_t *x) {
    return true;
}

bool DataSource::getUInt32(off64_t offset, uint32_t *x) {
    *x = 0;

    uint32_t tmp;
    if (readAt(offset, &tmp, 4) != 4) {
        return false;
    }

    *x = ntohl(tmp);

    return true;
}

bool DataSource::getUInt64(off64_t offset, uint64_t *x) {
    *x = 0;

    uint64_t tmp;
    if (readAt(offset, &tmp, 8) != 8) {
        return false;
    }

    *x = ntoh64(tmp);

    return true;
}

status_t DataSource::getSize(off64_t *size) {
    *size = 0;

+853 −29

File changed.

Preview size limit exceeded, changes collapsed.

+18 −0
Original line number Diff line number Diff line
@@ -18,7 +18,12 @@

#define MPEG4_EXTRACTOR_H_

#include <arpa/inet.h>

#include <media/stagefright/DataSource.h>
#include <media/stagefright/MediaExtractor.h>
#include <media/stagefright/Utils.h>
#include <utils/List.h>
#include <utils/Vector.h>
#include <utils/String8.h>

@@ -29,6 +34,11 @@ class DataSource;
class SampleTable;
class String8;

struct SidxEntry {
    size_t mSize;
    uint32_t mDurationUs;
};

class MPEG4Extractor : public MediaExtractor {
public:
    // Extractor assumes ownership of "source".
@@ -39,6 +49,7 @@ public:
    virtual sp<MetaData> getTrackMetaData(size_t index, uint32_t flags);

    virtual sp<MetaData> getMetaData();
    virtual uint32_t flags() const;

    // for DRM
    virtual char* getDrmTrackInfo(size_t trackID, int *len);
@@ -47,6 +58,7 @@ protected:
    virtual ~MPEG4Extractor();

private:

    struct Track {
        Track *next;
        sp<MetaData> meta;
@@ -56,6 +68,10 @@ private:
        bool skipTrack;
    };

    Vector<SidxEntry> mSidxEntries;
    uint64_t mSidxDuration;
    off64_t mMoofOffset;

    sp<DataSource> mDataSource;
    status_t mInitCheck;
    bool mHasVideo;
@@ -93,6 +109,8 @@ private:

    status_t parseTrackHeader(off64_t data_offset, off64_t data_size);

    status_t parseSegmentIndex(off64_t data_offset, size_t data_size);

    Track *findTrackByMimePrefix(const char *mimePrefix);

    MPEG4Extractor(const MPEG4Extractor &);