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
void release() {
super.release();
}
}

@ -21,23 +21,56 @@ abstract class MediaEncoder {
private MediaEncoderEngine.Controller mController;
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
void prepare(MediaEncoderEngine.Controller controller) {
mController = controller;
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
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
abstract void notify(String event, Object data);
/**
* Stop recording.
* This MUST happen SYNCHRONOUSLY!
*/
@EncoderThread
abstract void stop();
/**
* Release resources here.
*/
@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.

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

Loading…
Cancel
Save