public abstract class MediaEncoder
extends java.lang.Object
implements java.lang.Runnable
| Modifier and Type | Class and Description |
|---|---|
static interface |
MediaEncoder.MediaEncoderListener |
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
mIsCapturing
Flag that indicate this encoder is capturing now.
|
protected boolean |
mIsEOS
Flag that indicate encoder received EOS(End Of Stream)
|
protected MediaEncoder.MediaEncoderListener |
mListener |
protected android.media.MediaCodec |
mMediaCodec
MediaCodec instance for encoding
|
protected boolean |
mMuxerStarted
Flag the indicate the muxer is running
|
protected boolean |
mRequestStop
Flag to request stop capturing
|
protected static int |
MSG_FRAME_AVAILABLE |
protected static int |
MSG_STOP_RECORDING |
protected java.lang.Object |
mSync |
protected int |
mTrackIndex
Track Number
|
protected java.lang.ref.WeakReference<MediaMuxerWrapper> |
mWeakMuxer
Weak refarence of MediaMuxerWarapper instance
|
protected static int |
TIMEOUT_USEC |
| Constructor and Description |
|---|
MediaEncoder(MediaMuxerWrapper muxer,
MediaEncoder.MediaEncoderListener listener) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
drain()
drain encoded data and write them to muxer
|
protected void |
encode(byte[] buffer,
int length,
long presentationTimeUs)
Method to set byte array to the MediaCodec encoder
|
protected void |
encode(java.nio.ByteBuffer buffer,
int length,
long presentationTimeUs)
Method to set ByteBuffer to the MediaCodec encoder
|
boolean |
frameAvailableSoon()
the method to indicate frame data is soon available or already available
|
java.lang.String |
getOutputPath() |
protected long |
getPTSUs()
get next encoding presentationTimeUs
|
protected void |
release()
Release all releated objects
|
void |
run()
encoding loop on private thread
|
protected void |
signalEndOfInputStream() |
protected static final int TIMEOUT_USEC
protected static final int MSG_FRAME_AVAILABLE
protected static final int MSG_STOP_RECORDING
protected final java.lang.Object mSync
protected volatile boolean mIsCapturing
protected volatile boolean mRequestStop
protected boolean mIsEOS
protected boolean mMuxerStarted
protected int mTrackIndex
protected android.media.MediaCodec mMediaCodec
protected final java.lang.ref.WeakReference<MediaMuxerWrapper> mWeakMuxer
protected final MediaEncoder.MediaEncoderListener mListener
public MediaEncoder(MediaMuxerWrapper muxer, MediaEncoder.MediaEncoderListener listener)
public java.lang.String getOutputPath()
public boolean frameAvailableSoon()
public void run()
run in interface java.lang.Runnableprotected void release()
protected void signalEndOfInputStream()
protected void encode(byte[] buffer,
int length,
long presentationTimeUs)
buffer - length - length of byte array, zero means EOS.presentationTimeUs - protected void encode(java.nio.ByteBuffer buffer,
int length,
long presentationTimeUs)
buffer - null means EOSpresentationTimeUs - protected void drain()
protected long getPTSUs()