Package io.antmedia.muxer
Class RtmpMuxer
java.lang.Object
io.antmedia.muxer.Muxer
io.antmedia.muxer.RtmpMuxer
-
Nested Class Summary
Nested classes/interfaces inherited from class io.antmedia.muxer.Muxer
Muxer.VideoBuffer
-
Field Summary
Modifier and TypeFieldDescriptionprivate org.bytedeco.javacpp.BytePointer
(package private) boolean
private AtomicBoolean
private String
private IEndpointStatusListener
private boolean
private String
Fields 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, 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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
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.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.void
avWriteFrame
(org.bytedeco.ffmpeg.avcodec.AVPacket pkt, org.bytedeco.ffmpeg.avformat.AVFormatContext context) void
org.bytedeco.ffmpeg.avformat.AVFormatContext
boolean
isCodecSupported
(int codecId) (package private) void
parseRtmpURL
(String url) boolean
This function may be called by multiple encoders.void
void
setStatusListener
(IEndpointStatusListener listener) private 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) boolean
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.void
writePacket
(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 jobvoid
This function may be called by multiple encoders.void
writeVideoBuffer
(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, avNewStream, checkToDropPacket, contextChanged, contextWillChange, getAppAdaptor, getAppSettings, getAudioNotWrittenCount, getAverageBitrate, getBitStreamFilter, getBsfAudioNames, getCurrentVoDTimeStamp, getDurationInMs, getDurationInMs, getErrorDefinition, getExtendedName, getFile, getFileName, getFormat, getInputTimeBaseMap, getIsRunning, getLastPts, getOptionDictionary, getPacketBufferWithExtradata, getPreviewFile, getRecordFile, getRegisteredStreamIndexList, getResolution, getResourceFile, getSubFolder, getTmpPacket, getUserRecordFile, getVideoCodecId, getVideoHeight, getVideoNotWrittenCount, getVideoWidth, init, init, initAudioBitstreamFilter, initVideoBitstreamFilter, isAddDateTimeToSourceName, logPacketIssue, openIO, replaceDoubleSlashesWithSingleSlash, setAddDateTimeToSourceName, setAudioBitreamFilter, setBitstreamFilter, setCurrentVoDTimeStamp, setIsRunning, setOption, 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
-
-
Constructor Details
-
RtmpMuxer
-
-
Method Details
-
parseRtmpURL
-
getOutputURL
- Overrides:
getOutputURL
in 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:
getOutputFormatContext
in 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:
writeHeader
in 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:
writeTrailer
in classMuxer
-
clearResource
public void clearResource()- Overrides:
clearResource
in classMuxer
-
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:
addVideoStream
in 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:Muxer
All other writePacket functions call this function to make the job- Overrides:
writePacket
in 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
private 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:
writeVideoBuffer
in classMuxer
-
isCodecSupported
public boolean isCodecSupported(int codecId) - Specified by:
isCodecSupported
in classMuxer
-