Add comments

pull/360/head
Mattia Iavarone 6 years ago
parent d08c56c821
commit 98c4c684e2
  1. 3
      cameraview/src/main/gles/com/otaliastudios/cameraview/AudioMediaEncoder.java
  2. 35
      cameraview/src/main/gles/com/otaliastudios/cameraview/MediaEncoder.java
  3. 7
      cameraview/src/main/gles/com/otaliastudios/cameraview/VideoMediaEncoder.java

@ -41,9 +41,8 @@ class AudioMediaEncoder extends MediaEncoder {
} }
@EncoderThread
@Override @Override
void release() { void release() {
super.release();
} }
} }

@ -21,23 +21,56 @@ abstract class MediaEncoder {
private MediaEncoderEngine.Controller mController; private MediaEncoderEngine.Controller mController;
private int mTrackIndex; private int mTrackIndex;
/**
* Called to prepare this encoder before starting.
* Any initialization should be done here as it does not interfere with the original
* thread (that, generally, is the rendering thread).
*
* At this point subclasses MUST create the {@link #mMediaCodec} object.
*
* @param controller the muxer controller
*/
@EncoderThread @EncoderThread
void prepare(MediaEncoderEngine.Controller controller) { void prepare(MediaEncoderEngine.Controller controller) {
mController = controller; mController = controller;
mBufferInfo = new MediaCodec.BufferInfo(); mBufferInfo = new MediaCodec.BufferInfo();
} }
/**
* Start recording. This might be a lightweight operation
* in case the encoder needs to wait for a certain event
* like a "frame available".
*/
@EncoderThread @EncoderThread
abstract void start(); abstract void start();
/**
* The caller notifying of a certain event occurring.
* Should analyze the string and see if the event is important.
* @param event what happened
* @param data object
*/
@EncoderThread @EncoderThread
abstract void notify(String event, Object data); abstract void notify(String event, Object data);
/**
* Stop recording.
* This MUST happen SYNCHRONOUSLY!
*/
@EncoderThread @EncoderThread
abstract void stop(); abstract void stop();
/**
* Release resources here.
*/
@EncoderThread @EncoderThread
abstract void release(); void release() {
if (mMediaCodec != null) {
mMediaCodec.stop();
mMediaCodec.release();
mMediaCodec = null;
}
}
/** /**
* Extracts all pending data from the encoder and forwards it to the muxer. * Extracts all pending data from the encoder and forwards it to the muxer.

@ -16,6 +16,7 @@ import java.nio.ByteBuffer;
/** /**
* This alone does nothing. * This alone does nothing.
* Subclasses must make sure they write each frame onto the given Surface {@link #mSurface}. * Subclasses must make sure they write each frame onto the given Surface {@link #mSurface}.
*
* @param <C> the config object. * @param <C> the config object.
*/ */
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2) @RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN_MR2)
@ -90,10 +91,6 @@ abstract class VideoMediaEncoder<C extends VideoMediaEncoder.Config> extends Med
@EncoderThread @EncoderThread
@Override @Override
void release() { void release() {
if (mMediaCodec != null) { super.release();
mMediaCodec.stop();
mMediaCodec.release();
mMediaCodec = null;
}
} }
} }

Loading…
Cancel
Save