Package io.antmedia.muxer
Class EndpointMuxer
java.lang.Object
io.antmedia.muxer.Muxer
io.antmedia.muxer.EndpointMuxer
-
Nested Class Summary
Nested classes/interfaces inherited from class io.antmedia.muxer.Muxer
Muxer.VideoBuffer -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.bytedeco.javacpp.BytePointerprivate AtomicBoolean(package private) booleanprivate AtomicBooleanprivate Stringprivate IEndpointStatusListenerprivate booleanprivate StringFields inherited from class io.antmedia.muxer.Muxer
audioPkt, avRationalTimeBase, BITSTREAM_FILTER_H264_MP4TOANNEXB, BITSTREAM_FILTER_HEVC_MP4TOANNEXB, bsfAudioFilterContextList, bsfFilterContextList, bsfVideoNames, DATE_TIME_PATTERN, extension, file, firstAudioDts, firstKeyFrameReceived, firstVideoDts, format, headerWritten, initialResourceNameOverride, initialResourceNameWithoutExtension, inputOutputStreamIndexMap, inputTimeBaseMap, isInitialized, isRunning, logger, loggerStatic, optionDictionary, options, outputFormatContext, registeredStreamIndexList, rotation, scope, SEGMENT_INDEX_LENGTH, streamId, subFolder, TEMP_EXTENSION, time2log, tmpPacket, vertx, videoExtradata, videoHeight, videoPkt, videoWidth -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddStream(org.bytedeco.ffmpeg.avcodec.AVCodec codec, org.bytedeco.ffmpeg.avcodec.AVCodecContext codecContext, int streamIndex) Add a new stream with this codec, codecContext and stream Index parameters.booleanaddVideoStream(int width, int height, org.bytedeco.ffmpeg.avutil.AVRational timebase, int codecId, int streamIndex, boolean isAVC, org.bytedeco.ffmpeg.avcodec.AVCodecParameters codecpar) Add video stream to the muxer with direct parameters.voidavWriteFrame(org.bytedeco.ffmpeg.avcodec.AVPacket pkt, org.bytedeco.ffmpeg.avformat.AVFormatContext context) voidprivate booleanorg.bytedeco.ffmpeg.avformat.AVFormatContextbooleanisCodecSupported(int codecId) (package private) voidparseEndpointURL(String url) booleanThis function may be called by multiple encoders.voidvoidsetStatusListener(IEndpointStatusListener listener) voidwriteFrameInternal(org.bytedeco.ffmpeg.avcodec.AVPacket pkt, org.bytedeco.ffmpeg.avutil.AVRational inputTimebase, org.bytedeco.ffmpeg.avutil.AVRational outputTimebase, org.bytedeco.ffmpeg.avformat.AVFormatContext context, int codecType) booleanIf the broadcast is stopped while the muxer is writing the header it cannot complete writing the header Then writeTrailer causes crash because of memory problem.voidwritePacket(org.bytedeco.ffmpeg.avcodec.AVPacket pkt, org.bytedeco.ffmpeg.avutil.AVRational inputTimebase, org.bytedeco.ffmpeg.avutil.AVRational outputTimebase, int codecType) All other writePacket functions call this function to make the jobvoidThis function may be called by multiple encoders.voidwriteVideoBuffer(ByteBuffer encodedVideoFrame, long dts, int frameRotation, int streamIndex, boolean isKeyFrame, long firstFrameTimeStamp, long pts) Methods inherited from class io.antmedia.muxer.Muxer
addAudioStream, addExtradataIfRequired, addStream, allocateAVPacket, avNewStream, checkToDropPacket, contextChanged, contextChanged, contextWillChange, contextWillChange, getAppAdaptor, getAppSettings, getAudioNotWrittenCount, getAverageBitrate, getBitStreamFilter, getBsfAudioNames, getBsfFilterContextList, getCurrentVoDTimeStamp, getDurationInMs, getDurationInMs, getErrorDefinition, getExtendedName, getFile, getFileName, getFormat, getInputTimeBaseMap, getIsRunning, getLastPts, getOptionDictionary, getPacketBufferWithExtradata, getPreviewFile, getRecordFile, getRegisteredStreamIndexList, getResolution, getResourceFile, getSubFolder, getTmpPacket, getUserRecordFile, getVideoCodecId, getVideoExtradata, getVideoHeight, getVideoNotWrittenCount, getVideoWidth, init, init, initAudioBitstreamFilter, initVideoBitstreamFilter, isAddDateTimeToSourceName, logPacketIssue, openIO, replaceDoubleSlashesWithSingleSlash, setAddDateTimeToSourceName, setAudioBitreamFilter, setBitstreamFilter, setCurrentVoDTimeStamp, setFormat, setInitialResourceNameOverride, setIsRunning, setOption, setStreamId, setSubfolder, writeAudioBuffer, writeAudioFrame, writeDataFrame, writeMetaData, writePacket, writePacket, writeVideoBuffer, writeVideoFrame
-
Field Details
-
url
-
trailerWritten
private volatile boolean trailerWritten -
statusListener
-
allocatedExtraDataPointer
private org.bytedeco.javacpp.BytePointer allocatedExtraDataPointer -
status
-
keyFrameReceived
boolean keyFrameReceived -
preparedIO
-
cancelOpenIO
-
muxerType
-
-
Constructor Details
-
EndpointMuxer
-
-
Method Details
-
getMuxerType
-
parseEndpointURL
-
getOutputURL
- Overrides:
getOutputURLin classMuxer
-
addStream
public boolean addStream(org.bytedeco.ffmpeg.avcodec.AVCodec codec, org.bytedeco.ffmpeg.avcodec.AVCodecContext codecContext, int streamIndex) Add a new stream with this codec, codecContext and stream Index parameters. After adding streams, need to call prepareIO() This method is called by encoder. After encoder is opened, it adds codec context to the muxer -
setStatusListener
-
getOutputFormatContext
public org.bytedeco.ffmpeg.avformat.AVFormatContext getOutputFormatContext()- Specified by:
getOutputFormatContextin classMuxer
-
setStatus
-
getStatus
-
prepareIO
public boolean prepareIO()This function may be called by multiple encoders. Make sure that it is called once. See the sample implementations how it is being protected Implement this function with synchronized keyword as the subclass -
writeHeader
public boolean writeHeader()If the broadcast is stopped while the muxer is writing the header it cannot complete writing the header Then writeTrailer causes crash because of memory problem. We need to control if header is written before trying to write Trailer and synchronize them.- Overrides:
writeHeaderin classMuxer
-
writeTrailer
public void writeTrailer()This function may be called by multiple encoders. Make sure that it is called once. See the sample implementations how it is being protected Implement this function with synchronized keyword as the subclass Look at the commentswriteHeader- Overrides:
writeTrailerin classMuxer
-
clearResource
public void clearResource()- Overrides:
clearResourcein classMuxer
-
exitIfCancelled
private boolean exitIfCancelled() -
addVideoStream
public boolean addVideoStream(int width, int height, org.bytedeco.ffmpeg.avutil.AVRational timebase, int codecId, int streamIndex, boolean isAVC, org.bytedeco.ffmpeg.avcodec.AVCodecParameters codecpar) Add video stream to the muxer with direct parameters. This method is called when there is a WebRTC ingest and there is no adaptive streaming- Overrides:
addVideoStreamin classMuxer- Parameters:
width- , video widthheight- , video heightcodecId- , codec id of the streamstreamIndex- , stream indexisAVC- , true if packets are in AVC format, false if in annexb format- Returns:
- true if successful, false if failed
-
writePacket
public void writePacket(org.bytedeco.ffmpeg.avcodec.AVPacket pkt, org.bytedeco.ffmpeg.avutil.AVRational inputTimebase, org.bytedeco.ffmpeg.avutil.AVRational outputTimebase, int codecType) Description copied from class:MuxerAll other writePacket functions call this function to make the job- Overrides:
writePacketin classMuxer- Parameters:
pkt- Content of the data in AVPacket classinputTimebase- input time base is required to calculate the correct dts and pts values for the containeroutputTimebase- output time base is required to calculate the correct dts and pts values for the container
-
writeFrameInternal
public void writeFrameInternal(org.bytedeco.ffmpeg.avcodec.AVPacket pkt, org.bytedeco.ffmpeg.avutil.AVRational inputTimebase, org.bytedeco.ffmpeg.avutil.AVRational outputTimebase, org.bytedeco.ffmpeg.avformat.AVFormatContext context, int codecType) -
avWriteFrame
public void avWriteFrame(org.bytedeco.ffmpeg.avcodec.AVPacket pkt, org.bytedeco.ffmpeg.avformat.AVFormatContext context) -
writeVideoBuffer
public void writeVideoBuffer(ByteBuffer encodedVideoFrame, long dts, int frameRotation, int streamIndex, boolean isKeyFrame, long firstFrameTimeStamp, long pts) - Overrides:
writeVideoBufferin classMuxer
-
isCodecSupported
public boolean isCodecSupported(int codecId) - Specified by:
isCodecSupportedin classMuxer
-