Class JNIEncoder
- java.lang.Object
-
- net.sf.fmj.media.AbstractControls
-
- net.sf.fmj.media.AbstractPlugIn
-
- net.sf.fmj.media.AbstractCodec
-
- org.jitsi.impl.neomedia.codec.video.h264.JNIEncoder
-
- All Implemented Interfaces:
javax.media.Codec,javax.media.Controls,javax.media.PlugIn,RTCPFeedbackMessageListener
public class JNIEncoder extends net.sf.fmj.media.AbstractCodec implements RTCPFeedbackMessageListener
Implements an FMJ H.264 encoder using FFmpeg (and x264).- Author:
- Damian Minkov, Lyubomir Marinov, Sebastien Vincent
-
-
Field Summary
Fields Modifier and Type Field Description static String[]AVAILABLE_PRESETSThe available presets we can use with the encoder.static StringBASELINE_PROFILEThe name of the baseline H.264 (encoding) profile.static booleanDEFAULT_DEFAULT_INTRA_REFRESHThe default value of theDEFAULT_INTRA_REFRESH_PNAMEConfigurationService property.static StringDEFAULT_DEFAULT_PROFILEThe default value of theDEFAULT_PROFILE_PNAMEConfigurationService property.static intDEFAULT_FRAME_RATEThe frame rate to be assumed by JNIEncoder instances in the absence of any other frame rate indication.static StringDEFAULT_INTRA_REFRESH_PNAMEThe name of the boolean ConfigurationService property which specifies whether Periodic Intra Refresh is to be used by default.static intDEFAULT_KEYINTThe default maximum GOP (group of pictures) size i.e.static StringDEFAULT_PRESETThe default value of thePRESET_PNAMEConfigurationService property.static StringDEFAULT_PROFILE_PNAMEThe name of the ConfigurationService property which specifies the H.264 (encoding) profile to be used in the absence of negotiation.static StringHIGH_PROFILEThe name of the high H.264 (encoding) profile.static StringKEYINT_PNAMEThe name of the integer ConfigurationService property which specifies the maximum GOP (group of pictures) size i.e.static StringMAIN_PROFILEThe name of the main H.264 (encoding) profile.static StringPRESET_PNAMEThe name of the ConfigurationService property which specifies the x264 preset to be used by JNIEncoder.static intX264_KEYINT_MAX_INFINITEstatic intX264_KEYINT_MIN_AUTO
-
Constructor Summary
Constructors Constructor Description JNIEncoder()Initializes a new JNIEncoder instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Closes this Codec.StringgetName()Gets the name of this Codec.javax.media.Format[]getSupportedOutputFormats(javax.media.Format in)Returns the list of formats supported at the output.voidopen()Opens this Codec.intprocess(javax.media.Buffer inBuffer, javax.media.Buffer outBuffer)Processes/encodes a buffer.voidrtcpFeedbackMessageReceived(RTCPFeedbackMessageEvent ev)Notifies this RTCPFeedbackListener that an RTCP feedback message has been receivedvoidsetAdditionalCodecSettings(Map<String,String> additionalCodecSettings)Sets additional settings on this Codec.javax.media.FormatsetInputFormat(javax.media.Format format)Sets the Format of the media data to be input to this Codec.voidsetKeyFrameControl(KeyFrameControl keyFrameControl)Sets the KeyFrameControl to be used by this JNIEncoder as a means of control over its key frame-related logic.javax.media.FormatsetOutputFormat(javax.media.Format format)Sets the Format in which this Codec is to output media data.voidsetPacketizationMode(String packetizationMode)Sets the packetization mode to be used for the H.264 RTP payload output by this JNIEncoder and the associated packetizer.-
Methods inherited from class net.sf.fmj.media.AbstractCodec
checkInputBuffer, dump, getInputFormat, getOutputFormat, getSupportedInputFormats, isEOM, propagateEOM
-
Methods inherited from class net.sf.fmj.media.AbstractControls
addControl, getControl, getControls, removeControl
-
-
-
-
Field Detail
-
AVAILABLE_PRESETS
public static final String[] AVAILABLE_PRESETS
The available presets we can use with the encoder.
-
BASELINE_PROFILE
public static final String BASELINE_PROFILE
The name of the baseline H.264 (encoding) profile.- See Also:
- Constant Field Values
-
DEFAULT_DEFAULT_INTRA_REFRESH
public static final boolean DEFAULT_DEFAULT_INTRA_REFRESH
The default value of theDEFAULT_INTRA_REFRESH_PNAMEConfigurationService property.- See Also:
- Constant Field Values
-
MAIN_PROFILE
public static final String MAIN_PROFILE
The name of the main H.264 (encoding) profile.- See Also:
- Constant Field Values
-
DEFAULT_DEFAULT_PROFILE
public static final String DEFAULT_DEFAULT_PROFILE
The default value of theDEFAULT_PROFILE_PNAMEConfigurationService property.- See Also:
- Constant Field Values
-
DEFAULT_FRAME_RATE
public static final int DEFAULT_FRAME_RATE
The frame rate to be assumed by JNIEncoder instances in the absence of any other frame rate indication.- See Also:
- Constant Field Values
-
DEFAULT_INTRA_REFRESH_PNAME
public static final String DEFAULT_INTRA_REFRESH_PNAME
The name of the boolean ConfigurationService property which specifies whether Periodic Intra Refresh is to be used by default. The default value is true. The value may be overridden bysetAdditionalCodecSettings(Map).- See Also:
- Constant Field Values
-
DEFAULT_KEYINT
public static final int DEFAULT_KEYINT
The default maximum GOP (group of pictures) size i.e. the maximum interval between keyframes. The x264 library defaults to 250.- See Also:
- Constant Field Values
-
DEFAULT_PRESET
public static final String DEFAULT_PRESET
The default value of thePRESET_PNAMEConfigurationService property.
-
DEFAULT_PROFILE_PNAME
public static final String DEFAULT_PROFILE_PNAME
The name of the ConfigurationService property which specifies the H.264 (encoding) profile to be used in the absence of negotiation. Though it seems that RFC 3984 "RTP Payload Format for H.264 Video" specifies the baseline profile as the default, we have till the time of this writing defaulted to the main profile and we do not currently want to change from the main to the base profile unless we really have to.- See Also:
- Constant Field Values
-
HIGH_PROFILE
public static final String HIGH_PROFILE
The name of the high H.264 (encoding) profile.- See Also:
- Constant Field Values
-
KEYINT_PNAME
public static final String KEYINT_PNAME
The name of the integer ConfigurationService property which specifies the maximum GOP (group of pictures) size i.e. the maximum interval between keyframes. FFmpeg calls it gop_size, x264 refers to it as keyint or i_keyint_max.- See Also:
- Constant Field Values
-
PRESET_PNAME
public static final String PRESET_PNAME
The name of the ConfigurationService property which specifies the x264 preset to be used by JNIEncoder. A preset is a collection of x264 options that will provide a certain encoding speed to compression ratio. A slower preset will provide better compression i.e. quality per size.- See Also:
- Constant Field Values
-
X264_KEYINT_MAX_INFINITE
public static final int X264_KEYINT_MAX_INFINITE
- See Also:
- Constant Field Values
-
X264_KEYINT_MIN_AUTO
public static final int X264_KEYINT_MIN_AUTO
- See Also:
- Constant Field Values
-
-
Method Detail
-
close
public void close()
Closes this Codec.- Specified by:
closein interfacejavax.media.PlugIn- Overrides:
closein classnet.sf.fmj.media.AbstractPlugIn
-
getName
public String getName()
Gets the name of this Codec.- Specified by:
getNamein interfacejavax.media.PlugIn- Overrides:
getNamein classnet.sf.fmj.media.AbstractPlugIn- Returns:
- codec name
-
getSupportedOutputFormats
public javax.media.Format[] getSupportedOutputFormats(javax.media.Format in)
Returns the list of formats supported at the output.- Specified by:
getSupportedOutputFormatsin interfacejavax.media.Codec- Specified by:
getSupportedOutputFormatsin classnet.sf.fmj.media.AbstractCodec- Parameters:
in- input Format to determine corresponding output Formats- Returns:
- array of formats supported at output
-
open
public void open() throws javax.media.ResourceUnavailableExceptionOpens this Codec.- Specified by:
openin interfacejavax.media.PlugIn- Overrides:
openin classnet.sf.fmj.media.AbstractPlugIn- Throws:
javax.media.ResourceUnavailableException
-
process
public int process(javax.media.Buffer inBuffer, javax.media.Buffer outBuffer)Processes/encodes a buffer.- Specified by:
processin interfacejavax.media.Codec- Specified by:
processin classnet.sf.fmj.media.AbstractCodec- Parameters:
inBuffer- input bufferoutBuffer- output buffer- Returns:
- BUFFER_PROCESSED_OK if buffer has been successfully processed
-
rtcpFeedbackMessageReceived
public void rtcpFeedbackMessageReceived(RTCPFeedbackMessageEvent ev)
Notifies this RTCPFeedbackListener that an RTCP feedback message has been received- Specified by:
rtcpFeedbackMessageReceivedin interfaceRTCPFeedbackMessageListener- Parameters:
ev- an RTCPFeedbackMessageEvent which specifies the details of the notification event such as the feedback message type and the payload type
-
setAdditionalCodecSettings
public void setAdditionalCodecSettings(Map<String,String> additionalCodecSettings)
Sets additional settings on this Codec.- Parameters:
additionalCodecSettings- the additional settings to be set on this Codec
-
setInputFormat
public javax.media.Format setInputFormat(javax.media.Format format)
Sets the Format of the media data to be input to this Codec.- Specified by:
setInputFormatin interfacejavax.media.Codec- Overrides:
setInputFormatin classnet.sf.fmj.media.AbstractCodec- Parameters:
format- the Format of media data to set on this Codec- Returns:
- the Format of media data set on this Codec or null if the specified format is not supported by this Codec
-
setKeyFrameControl
public void setKeyFrameControl(KeyFrameControl keyFrameControl)
Sets the KeyFrameControl to be used by this JNIEncoder as a means of control over its key frame-related logic.- Parameters:
keyFrameControl- the KeyFrameControl to be used by this JNIEncoder as a means of control over its key frame-related logic
-
setOutputFormat
public javax.media.Format setOutputFormat(javax.media.Format format)
Sets the Format in which this Codec is to output media data.- Specified by:
setOutputFormatin interfacejavax.media.Codec- Overrides:
setOutputFormatin classnet.sf.fmj.media.AbstractCodec- Parameters:
format- the Format in which this Codec is to output media data- Returns:
- the Format in which this Codec is currently configured to output media data or null if format was found to be incompatible with this Codec
-
setPacketizationMode
public void setPacketizationMode(String packetizationMode)
Sets the packetization mode to be used for the H.264 RTP payload output by this JNIEncoder and the associated packetizer.- Parameters:
packetizationMode- the packetization mode to be used for the H.264 RTP payload output by this JNIEncoder and the associated packetizer
-
-