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

Commit 54573c59 authored by Robert Shih's avatar Robert Shih Committed by Android (Google) Code Review
Browse files

Merge "MediaExtractor: getSampleSize API"

parents 1d2fbc08 d908f38e
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -23414,6 +23414,7 @@ package android.media {
    method public java.util.Map<java.util.UUID, byte[]> getPsshInfo();
    method public boolean getSampleCryptoInfo(android.media.MediaCodec.CryptoInfo);
    method public int getSampleFlags();
    method public long getSampleSize();
    method public long getSampleTime();
    method public int getSampleTrackIndex();
    method public final int getTrackCount();
+6 −0
Original line number Diff line number Diff line
@@ -626,6 +626,12 @@ final public class MediaExtractor {
     */
    public native long getSampleTime();

    /**
     * @return size of the current sample in bytes or -1 if no more
     * samples are available.
     */
    public native long getSampleSize();

    // Keep these in sync with their equivalents in NuMediaExtractor.h
    /**
     * The sample is a sync sample (or in {@link MediaCodec}'s terminology
+29 −0
Original line number Diff line number Diff line
@@ -244,6 +244,10 @@ status_t JMediaExtractor::getSampleTime(int64_t *sampleTimeUs) {
    return mImpl->getSampleTime(sampleTimeUs);
}

status_t JMediaExtractor::getSampleSize(size_t *sampleSize) {
    return mImpl->getSampleSize(sampleSize);
}

status_t JMediaExtractor::getSampleFlags(uint32_t *sampleFlags) {
    *sampleFlags = 0;

@@ -505,6 +509,28 @@ static jlong android_media_MediaExtractor_getSampleTime(
    return (jlong) sampleTimeUs;
}

static jlong android_media_MediaExtractor_getSampleSize(
        JNIEnv *env, jobject thiz) {
    sp<JMediaExtractor> extractor = getMediaExtractor(env, thiz);

    if (extractor == NULL) {
        jniThrowException(env, "java/lang/IllegalStateException", NULL);
        return -1ll;
    }

    size_t sampleSize;
    status_t err = extractor->getSampleSize(&sampleSize);

    if (err == ERROR_END_OF_STREAM) {
        return -1ll;
    } else if (err != OK) {
        jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
        return -1ll;
    }

    return (jlong) sampleSize;
}

static jint android_media_MediaExtractor_getSampleFlags(
        JNIEnv *env, jobject thiz) {
    sp<JMediaExtractor> extractor = getMediaExtractor(env, thiz);
@@ -884,6 +910,9 @@ static const JNINativeMethod gMethods[] = {
    { "getSampleTime", "()J",
        (void *)android_media_MediaExtractor_getSampleTime },

    { "getSampleSize", "()J",
        (void *)android_media_MediaExtractor_getSampleSize },

    { "getSampleFlags", "()I",
        (void *)android_media_MediaExtractor_getSampleFlags },

+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ struct JMediaExtractor : public RefBase {
    status_t readSampleData(jobject byteBuf, size_t offset, size_t *sampleSize);
    status_t getSampleTrackIndex(size_t *trackIndex);
    status_t getSampleTime(int64_t *sampleTimeUs);
    status_t getSampleSize(size_t *sampleSize);
    status_t getSampleFlags(uint32_t *sampleFlags);
    status_t getSampleMeta(sp<MetaData> *sampleMeta);
    status_t getMetrics(Parcel *reply) const;