java.lang.Object | |
↳ | org.opencdnunion.media.streamer.encoder.Encoder<I, O> |
![]() |
![]() |
Base class of encoder modules.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
interface | Encoder.EncoderInfoListener | ||||||||||
interface | Encoder.EncoderListener |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | ENCODER_ERROR_UNKNOWN | ||||||||||
int | ENCODER_ERROR_UNSUPPORTED | ||||||||||
int | ENCODER_STATE_ENCODING | ||||||||||
int | ENCODER_STATE_FLUSHED | ||||||||||
int | ENCODER_STATE_FLUSHING | ||||||||||
int | ENCODER_STATE_IDLE | ||||||||||
int | ENCODER_STATE_INITIALIZING | ||||||||||
int | ENCODER_STATE_STOPPING | ||||||||||
int | INFO_STARTED | ||||||||||
int | INFO_STOPPED |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
protected Object | mEncodeConfig | ||||||||||
protected Handler | mEncodeHandler | ||||||||||
protected HandlerThread | mEncodeThread | ||||||||||
protected boolean | mForceKeyFrame | ||||||||||
protected AtomicInteger | mFrameDropped | ||||||||||
protected AtomicInteger | mFrameEncoded | ||||||||||
protected boolean | mMute | ||||||||||
protected ConditionVariable | mSig | ||||||||||
public SinkPin<I> | mSinkPin | ||||||||||
public SrcPin<O> | mSrcPin | ||||||||||
protected AtomicInteger | mState | ||||||||||
protected boolean | mTransWorkMode | ||||||||||
protected int | mType |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Encoder() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
void |
adjustBitrate(int bitrate)
Adjust bitrate while encoding.
| ||||||||||
void |
configure(Object encodeConfig)
Configure encoder with given format.
| ||||||||||
void |
flush()
flush current encoder data.
| ||||||||||
void | forceKeyFrame() | ||||||||||
boolean |
getAutoWork()
Get if encoder start/stop by input frames.
| ||||||||||
Object | getEncodeConfig() | ||||||||||
Encoder.EncoderInfoListener |
getEncoderInfoListener()
Get encoder info listener.
| ||||||||||
Encoder.EncoderListener |
getEncoderListener()
Get encoder listener.
| ||||||||||
abstract int |
getEncoderType()
Implement by child class, to define what type of encoder this instance is.
| ||||||||||
AVPacketBase | getExtra() | ||||||||||
int |
getFrameDropped()
Get frame dropped number.
| ||||||||||
int |
getFrameEncoded()
Get frame encoded number.
| ||||||||||
SinkPin<I> | getSinkPin() | ||||||||||
SrcPin<O> | getSrcPin() | ||||||||||
int |
getState()
Get current state.
| ||||||||||
boolean |
getUseSyncMode()
Get if encoding frames in sync mode.
| ||||||||||
boolean |
isEncoding()
Is it in
ENCODER_STATE_ENCODING state now. | ||||||||||
void | release() | ||||||||||
void |
setAutoWork(boolean autoWork)
Set if encoder start/stop by input frames.
| ||||||||||
void | setEnableTransWorkMode(boolean enable) | ||||||||||
void |
setEncoderInfoListener(Encoder.EncoderInfoListener infoListener)
Set encoder info listener
| ||||||||||
void |
setEncoderListener(Encoder.EncoderListener listener)
Set encoder listener.
| ||||||||||
void |
setMute(boolean mute)
Set if encode mute audio data.
| ||||||||||
void |
setUseSyncMode(boolean useSyncMode)
Set if encoding frames in sync mode.
| ||||||||||
void |
start()
Start encoding.
| ||||||||||
void |
startRepeatLastFrame()
Repeating to send last video frame.
| ||||||||||
void |
stop()
Stop encoding.
| ||||||||||
void |
stopRepeatLastFrame()
Stop repeating last video frame.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract void | doAdjustBitrate(int bitrate) | ||||||||||
void | doFlush() | ||||||||||
void | doFormatChanged(Object format) | ||||||||||
abstract int | doFrameAvailable(I frame) | ||||||||||
void | doFrameDropped(I frame) | ||||||||||
abstract int | doStart(Object encodeConfig) | ||||||||||
abstract void | doStop() | ||||||||||
void |
onEncodedFormatChanged(Object encodedFormat)
should be called by child class after output format changed.
| ||||||||||
void |
onEncodedFrame(O encodedFrame)
should be called by child class after a video frame encoded.
| ||||||||||
boolean |
onFrameAvailable(I frame)
Give child class a chance to handle onFrameAvailable
| ||||||||||
void | sendError(int err) | ||||||||||
void | sendInfo(int type, int extra) | ||||||||||
boolean |
updateEncodeFormat(Object src, Object dst)
Update encode format with input frame format.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Adjust bitrate while encoding.
Should be call on ENCODER_STATE_ENCODING
.
bitrate | bitrate to adjust to, in bps |
---|
Configure encoder with given format.
Should be set before start encoding.
encodeConfig | encode format to set |
---|
flush current encoder data.
Should be call on ENCODER_STATE_ENCODING
,
and this call should always followed by stop()
.
Get if encoder start/stop by input frames.
Get encoder info listener.
Get encoder listener.
Implement by child class, to define what type of encoder this instance is.
Get frame dropped number.
Should be call on ENCODER_STATE_ENCODING
Get frame encoded number.
Should be call on ENCODER_STATE_ENCODING
.
Get current state.
Get if encoding frames in sync mode.
Is it in ENCODER_STATE_ENCODING
state now.
Set if encoder start/stop by input frames.
For example, onFormatChanged would start encoding if encoder not started,
and frame with FLAG_END_OF_STREAM
would stop encoding.
autoWork | true to enable, false to disable |
---|
Set encoder info listener
infoListener | listener to set |
---|
Set encoder listener.
listener | listener to set |
---|
Set if encode mute audio data.
mute | true to encode mute data, false otherwise |
---|
Set if encoding frames in sync mode.
useSyncMode | true in sync mode, false in async mode. |
---|
Repeating to send last video frame.
Stop repeating last video frame.
should be called by child class after output format changed.
encodedFormat | output format |
---|
should be called by child class after a video frame encoded.
encodedFrame | encoded frame |
---|
Give child class a chance to handle onFrameAvailable
frame | frame |
---|
Update encode format with input frame format.
src | input frame format |
---|---|
dst | encode format to be updated |