public interface

EncoderCallback

 androidx.camera.video.internal.encoder.EncoderCallback

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 encoder callback event.

Summary

Fields
public static final EncoderCallbackEMPTY

An empty implementation.

Methods
public voidonEncodedData(EncodedData encodedData)

The method called when a new encoded data comes.

public voidonEncodeError(EncodeException e)

The method called when error occurs while encoding.

public voidonEncodePaused()

The method called when encoder is currently started and Encoder.pause() is invoked.

public voidonEncodeStart()

The method called before the first encoded data.

public voidonEncodeStop()

The method called after the last encoded data.

public voidonOutputConfigUpdate(OutputConfig outputConfig)

The method called when encoder gets a new output config.

Fields

public static final EncoderCallback EMPTY

An empty implementation.

Methods

public void onEncodeStart()

The method called before the first encoded data.

public void onEncodeStop()

The method called after the last encoded data.

public void onEncodePaused()

The method called when encoder is currently started and Encoder.pause() is invoked.

The callback is only triggered when the encoder is completely paused. Successive calls to Encoder.pause() and Encoder.start() may not trigger the callback. EncoderCallback.onEncodedData(EncodedData) will not be triggered after this callback.

public void onEncodeError(EncodeException e)

The method called when error occurs while encoding.

After that, EncoderCallback.onEncodedData(EncodedData) and EncoderCallback.onEncodeStop() will not be triggered.

Parameters:

e: the encode error

public void onEncodedData(EncodedData encodedData)

The method called when a new encoded data comes.

Parameters:

encodedData: the encoded data

public void onOutputConfigUpdate(OutputConfig outputConfig)

The method called when encoder gets a new output config.

Parameters:

outputConfig: the output config

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 androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;

/**
 * The encoder callback event.
 */
@RequiresApi(21) // TODO(b/200306659): Remove and replace with annotation on package-info.java
public interface EncoderCallback {

    /** The method called before the first encoded data. */
    void onEncodeStart();

    /** The method called after the last encoded data. */
    void onEncodeStop();

    /**
     * The method called when encoder is currently started and {@link Encoder#pause()} is invoked.
     *
     * <p>The callback is only triggered when the encoder is completely paused. Successive calls
     * to {@link Encoder#pause()} and {@link Encoder#start()} may not trigger the callback.
     * {@link #onEncodedData} will not be triggered after this callback.
     */
    default void onEncodePaused() {
    }

    /**
     * The method called when error occurs while encoding.
     *
     * <p>After that, {@link #onEncodedData} and {@link #onEncodeStop} will not be triggered.
     *
     * @param e the encode error
     */
    void onEncodeError(@NonNull EncodeException e);

    /**
     * The method called when a new encoded data comes.
     *
     * @param encodedData the encoded data
     */
    void onEncodedData(@NonNull EncodedData encodedData);

    /**
     * The method called when encoder gets a new output config.
     *
     * @param outputConfig the output config
     */
    void onOutputConfigUpdate(@NonNull OutputConfig outputConfig);

    /** An empty implementation. */
    EncoderCallback EMPTY = new EncoderCallback() {
        /** {@inheritDoc} */
        @Override
        public void onEncodeStart() {
        }

        /** {@inheritDoc} */
        @Override
        public void onEncodeStop() {
        }

        /** {@inheritDoc} */
        @Override
        public void onEncodeError(@NonNull EncodeException e) {
        }

        /** {@inheritDoc} */
        @Override
        public void onEncodedData(@NonNull EncodedData encodedData) {
        }

        /** {@inheritDoc} */
        @Override
        public void onOutputConfigUpdate(@NonNull OutputConfig outputConfig) {
        }
    };
}