Class RtmpMuxer

java.lang.Object
io.antmedia.muxer.Muxer
io.antmedia.muxer.RtmpMuxer

public class RtmpMuxer extends Muxer
  • Field Details

    • url

      private String url
    • trailerWritten

      private volatile boolean trailerWritten
    • statusListener

      private IEndpointStatusListener statusListener
    • allocatedExtraDataPointer

      private org.bytedeco.javacpp.BytePointer allocatedExtraDataPointer
    • status

      private String status
    • keyFrameReceived

      boolean keyFrameReceived
    • preparedIO

      private AtomicBoolean preparedIO
  • Constructor Details

    • RtmpMuxer

      public RtmpMuxer(String url, io.vertx.core.Vertx vertx)
  • Method Details

    • parseRtmpURL

      void parseRtmpURL(String url)
    • getOutputURL

      public String getOutputURL()
      Overrides:
      getOutputURL in class Muxer
    • 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
      Overrides:
      addStream in class Muxer
      Returns:
    • setStatusListener

      public void setStatusListener(IEndpointStatusListener listener)
    • getOutputFormatContext

      public org.bytedeco.ffmpeg.avformat.AVFormatContext getOutputFormatContext()
      Specified by:
      getOutputFormatContext in class Muxer
    • setStatus

      public void setStatus(String status)
    • getStatus

      public String 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
      Overrides:
      prepareIO in class Muxer
      Returns:
    • 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 class Muxer
    • 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 comments writeHeader
      Overrides:
      writeTrailer in class Muxer
    • clearResource

      public void clearResource()
      Overrides:
      clearResource in class Muxer
    • 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 class Muxer
      Parameters:
      width - , video width
      height - , video height
      codecId - , codec id of the stream
      streamIndex - , stream index
      isAVC - , 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 class Muxer
      Parameters:
      pkt - Content of the data in AVPacket class
      inputTimebase - input time base is required to calculate the correct dts and pts values for the container
      outputTimebase - 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 class Muxer
    • isCodecSupported

      public boolean isCodecSupported(int codecId)
      Specified by:
      isCodecSupported in class Muxer