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

Commit 10551fcd authored by Wei Jia's avatar Wei Jia
Browse files

IDataSource: add getFlags() to expose DataSource::flags().

This will let MPEG4Extractor cache stbl data. Therefore it can avoid data
flushing in data source (NuCachedSource2) due to reading stbl and access
unit data alternatively when the stream is larger than max cache size.

Bug: 26533748
Change-Id: Ia534755ab9130e4dcee94d53ca3c933d1b9eb566
parent 987f9532
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -41,6 +41,9 @@ public:
    // This should be called before deleting |this|. The other methods may
    // return errors if they're called after calling close().
    virtual void close() = 0;
    // Get the flags of the source.
    // Refer to DataSource:Flags for the definition of the flags.
    virtual uint32_t getFlags() = 0;

private:
    DISALLOW_EVIL_CONSTRUCTORS(IDataSource);
+13 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ enum {
    READ_AT,
    GET_SIZE,
    CLOSE,
    GET_FLAGS,
};

struct BpDataSource : public BpInterface<IDataSource> {
@@ -68,6 +69,13 @@ struct BpDataSource : public BpInterface<IDataSource> {
        data.writeInterfaceToken(IDataSource::getInterfaceDescriptor());
        remote()->transact(CLOSE, data, &reply);
    }

    virtual uint32_t getFlags() {
        Parcel data, reply;
        data.writeInterfaceToken(IDataSource::getInterfaceDescriptor());
        remote()->transact(GET_FLAGS, data, &reply);
        return reply.readUint32();
    }
};

IMPLEMENT_META_INTERFACE(DataSource, "android.media.IDataSource");
@@ -100,6 +108,11 @@ status_t BnDataSource::onTransact(
            close();
            return NO_ERROR;
        } break;
        case GET_FLAGS: {
            CHECK_INTERFACE(IDataSource, data, reply);
            reply->writeUint32(getFlags());
            return NO_ERROR;
        } break;
        default:
            return BBinder::onTransact(code, data, reply, flags);
    }
+4 −0
Original line number Diff line number Diff line
@@ -95,6 +95,10 @@ status_t CallbackDataSource::getSize(off64_t *size) {
    return OK;
}

uint32_t CallbackDataSource::flags() {
    return mIDataSource->getFlags();
}

TinyCacheSource::TinyCacheSource(const sp<DataSource>& source)
    : mSource(source), mCachedOffset(0), mCachedSize(0) {
}
+4 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ public:
    virtual ssize_t readAt(off64_t offset, size_t size);
    virtual status_t getSize(off64_t* size);
    virtual void close();
    virtual uint32_t getFlags();

private:
    sp<IMemory> mMemory;
@@ -122,6 +123,9 @@ status_t RemoteDataSource::getSize(off64_t* size) {
void RemoteDataSource::close() {
    mSource = NULL;
}
uint32_t RemoteDataSource::getFlags() {
    return mSource->flags();
}

// static
sp<IMediaExtractor> MediaExtractor::Create(
+1 −0
Original line number Diff line number Diff line
@@ -36,6 +36,7 @@ public:
    virtual status_t initCheck() const;
    virtual ssize_t readAt(off64_t offset, void *data, size_t size);
    virtual status_t getSize(off64_t *size);
    virtual uint32_t flags();

private:
    sp<IDataSource> mIDataSource;