public interface

EncodedData

implements java.lang.AutoCloseable

 androidx.camera.video.internal.encoder.EncodedData

Subclasses:

EncodedDataImpl, BufferCopiedEncodedData

Gradle dependencies

compile group: 'androidx.camera', name: 'camera-video', version: '1.2.0-alpha01'

  • groupId: androidx.camera
  • artifactId: camera-video
  • version: 1.2.0-alpha01

Artifact androidx.camera:camera-video:1.2.0-alpha01 it located at Google repository (https://maven.google.com/)

Overview

The encoded data which is generated by the Encoder.

Once EncodedData is no longer needed, it has to call EncodedData.close() to return to encoder, otherwise it may cause leakage or failure.

Summary

Methods
public voidclose()

The encoded data should be explicitly closed in order to release the resources.

public MediaCodec.BufferInfogetBufferInfo()

Gets the java.nio.ByteBuffer's additional information.

public java.nio.ByteBuffergetByteBuffer()

Gets the java.nio.ByteBuffer of the encoded data.

public <any>getClosedFuture()

The that is complete when EncodedData.close() is called.

public longgetPresentationTimeUs()

Gets the timestamp of the encoded data in microseconds.

public booleanisKeyFrame()

Returns true if this is a video key frame (I-Frame).

public longsize()

Gets the data size in bytes.

Methods

public java.nio.ByteBuffer getByteBuffer()

Gets the java.nio.ByteBuffer of the encoded data.

After EncodedData.close() is called, the byte buffer will be returned to encoder. Therefore, make sure not to use this byte buffer after EncodedData.close() is called, otherwise it may get uncertain behavior.

public MediaCodec.BufferInfo getBufferInfo()

Gets the java.nio.ByteBuffer's additional information.

See also:

public long getPresentationTimeUs()

Gets the timestamp of the encoded data in microseconds.

public long size()

Gets the data size in bytes.

public boolean isKeyFrame()

Returns true if this is a video key frame (I-Frame).

public void close()

The encoded data should be explicitly closed in order to release the resources.

public <any> getClosedFuture()

The that is complete when EncodedData.close() is called.

Source

/*
 * Copyright 2020 The Android Open Source Project
 *
 * 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.
 */

package androidx.camera.video.internal.encoder;

import android.media.MediaCodec;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;

import com.google.common.util.concurrent.ListenableFuture;

import java.nio.ByteBuffer;

/**
 * The encoded data which is generated by the {@link Encoder}.
 *
 * <p>Once {@link EncodedData} is no longer needed, it has to call {@link #close} to return to
 * encoder, otherwise it may cause leakage or failure.
 *
 * @see EncoderCallback#onEncodedData
 */
@RequiresApi(21) // TODO(b/200306659): Remove and replace with annotation on package-info.java
public interface EncodedData extends AutoCloseable {
    /**
     * Gets the {@link ByteBuffer} of the encoded data.
     *
     * <p>After {@link #close} is called, the byte buffer will be returned to encoder. Therefore,
     * make sure not to use this byte buffer after {@link #close} is called, otherwise it may get
     * uncertain behavior.
     */
    @NonNull
    ByteBuffer getByteBuffer();

    /**
     * Gets the {@link ByteBuffer}'s additional information.
     *
     * @see MediaCodec.BufferInfo
     */
    @NonNull
    MediaCodec.BufferInfo getBufferInfo();

    /** Gets the timestamp of the encoded data in microseconds. */
    long getPresentationTimeUs();

    /** Gets the data size in bytes. */
    long size();

    /**  Returns true if this is a video key frame (I-Frame). */
    boolean isKeyFrame();

    /** The encoded data should be explicitly closed in order to release the resources. */
    @Override
    void close();

    /** The {@link ListenableFuture} that is complete when {@link #close} is called. */
    @NonNull
    ListenableFuture<Void> getClosedFuture();
}