Class AppSrc.Builder<B extends AppSrc.Builder<B>>

Type Parameters:
B - the type of the Builder that is returned
All Implemented Interfaces:
BuilderInterface
Enclosing class:
AppSrc

public static class AppSrc.Builder<B extends AppSrc.Builder<B>> extends BaseSrc.Builder<B>
Inner class implementing a builder pattern to construct a GObject with properties.
  • Constructor Details

    • Builder

      protected Builder()
      Default constructor for a Builder object.
  • Method Details

    • build

      public AppSrc build()
      Finish building the AppSrc object. This will call GObject.withProperties(Type, String[], Value[]) to create a new GObject instance, which is then cast to AppSrc.
      Overrides:
      build in class BaseSrc.Builder<B extends AppSrc.Builder<B>>
      Returns:
      a new instance of AppSrc with the properties that were set in the Builder object.
    • setBlock

      public B setBlock(boolean block)
      When max-bytes are queued and after the enough-data signal has been emitted, block any further push-buffer calls until the amount of queued bytes drops below the max-bytes limit.
      Parameters:
      block - the value for the block property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setCaps

      public B setCaps(Caps caps)
      The GstCaps that will negotiated downstream and will be put on outgoing buffers.
      Parameters:
      caps - the value for the caps property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setDuration

      public B setDuration(long duration)
      The total duration in nanoseconds of the data stream. If the total duration is known, it is recommended to configure it with this property.
      Parameters:
      duration - the value for the duration property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.10
    • setEmitSignals

      public B setEmitSignals(boolean emitSignals)
      Make appsrc emit the "need-data", "enough-data" and "seek-data" signals. This option is by default enabled for backwards compatibility reasons but can disabled when needed because signal emission is expensive.
      Parameters:
      emitSignals - the value for the emit-signals property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setFormat

      public B setFormat(Format format)
      The format to use for segment events. When the source is producing timestamped buffers this property should be set to GST_FORMAT_TIME.
      Parameters:
      format - the value for the format property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setHandleSegmentChange

      public B setHandleSegmentChange(boolean handleSegmentChange)

      When enabled, appsrc will check GstSegment in GstSample which was pushed via gst_app_src_push_sample() or "push-sample" signal action. If a GstSegment is changed, corresponding segment event will be followed by next data flow.

      FIXME: currently only GST_FORMAT_TIME format is supported and therefore GstAppSrc::format should be time. However, possibly GstAppSrc can support other formats.

      Parameters:
      handleSegmentChange - the value for the handle-segment-change property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.18
    • setIsLive

      public B setIsLive(boolean isLive)
      Instruct the source to behave like a live source. This includes that it will only push out buffers in the PLAYING state.
      Parameters:
      isLive - the value for the is-live property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setLeakyType

      public B setLeakyType(AppLeakyType leakyType)
      When set to any other value than GST_APP_LEAKY_TYPE_NONE then the appsrc will drop any buffers that are pushed into it once its internal queue is full. The selected type defines whether to drop the oldest or new buffers.
      Parameters:
      leakyType - the value for the leaky-type property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.20
    • setMaxBuffers

      public B setMaxBuffers(long maxBuffers)
      The maximum amount of buffers that can be queued internally. After the maximum amount of buffers are queued, appsrc will emit the "enough-data" signal.
      Parameters:
      maxBuffers - the value for the max-buffers property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.20
    • setMaxBytes

      public B setMaxBytes(long maxBytes)
      The maximum amount of bytes that can be queued internally. After the maximum amount of bytes are queued, appsrc will emit the "enough-data" signal.
      Parameters:
      maxBytes - the value for the max-bytes property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setMaxLatency

      public B setMaxLatency(long maxLatency)
    • setMaxTime

      public B setMaxTime(long maxTime)
      The maximum amount of time that can be queued internally. After the maximum amount of time are queued, appsrc will emit the "enough-data" signal.
      Parameters:
      maxTime - the value for the max-time property
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.20
    • setMinLatency

      public B setMinLatency(long minLatency)
      The minimum latency of the source. A value of -1 will use the default latency calculations of GstBaseSrc.
      Parameters:
      minLatency - the value for the min-latency property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setMinPercent

      public B setMinPercent(int minPercent)
      Make appsrc emit the "need-data" signal when the amount of bytes in the queue drops below this percentage of max-bytes.
      Parameters:
      minPercent - the value for the min-percent property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setSize

      public B setSize(long size)
      The total size in bytes of the data stream. If the total size is known, it is recommended to configure it with this property.
      Parameters:
      size - the value for the size property
      Returns:
      the Builder instance is returned, to allow method chaining
    • setStreamType

      public B setStreamType(AppStreamType streamType)
      The type of stream that this source is producing. For seekable streams the application should connect to the seek-data signal.
      Parameters:
      streamType - the value for the stream-type property
      Returns:
      the Builder instance is returned, to allow method chaining
    • onEndOfStream

      public B onEndOfStream(AppSrc.EndOfStreamCallback handler)
      Notify appsrc that no more buffer are available.
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onEnoughData

      public B onEnoughData(AppSrc.EnoughDataCallback handler)
      Signal that the source has enough data. It is recommended that the application stops calling push-buffer until the need-data signal is emitted again to avoid excessive buffer queueing.
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onNeedData

      public B onNeedData(AppSrc.NeedDataCallback handler)

      Signal that the source needs more data. In the callback or from another thread you should call push-buffer or end-of-stream.

      length is just a hint and when it is set to -1, any number of bytes can be pushed into appsrc.

      You can call push-buffer multiple times until the enough-data signal is fired.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onPushBuffer

      public B onPushBuffer(AppSrc.PushBufferCallback handler)

      Adds a buffer to the queue of buffers that the appsrc element will push to its source pad.

      This function does not take ownership of the buffer, but it takes a reference so the buffer can be unreffed at any time after calling this function.

      When the block property is TRUE, this function can block until free space becomes available in the queue.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also:
    • onPushBufferList

      public B onPushBufferList(AppSrc.PushBufferListCallback handler)

      Adds a buffer list to the queue of buffers and buffer lists that the appsrc element will push to its source pad.

      This function does not take ownership of the buffer list, but it takes a reference so the buffer list can be unreffed at any time after calling this function.

      When the block property is TRUE, this function can block until free space becomes available in the queue.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.14
      See Also:
    • onPushSample

      public B onPushSample(AppSrc.PushSampleCallback handler)

      Extract a buffer from the provided sample and adds the extracted buffer to the queue of buffers that the appsrc element will push to its source pad. This function set the appsrc caps based on the caps in the sample and reset the caps if they change. Only the caps and the buffer of the provided sample are used and not for example the segment in the sample.

      This function does not take ownership of the sample, but it takes a reference so the sample can be unreffed at any time after calling this function.

      When the block property is TRUE, this function can block until free space becomes available in the queue.

      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      Since:
      1.6
      See Also:
    • onSeekData

      public B onSeekData(AppSrc.SeekDataCallback handler)
      Seek to the given offset. The next push-buffer should produce buffers from the new offset. This callback is only called for seekable stream types.
      Parameters:
      handler - the signal handler
      Returns:
      the Builder instance is returned, to allow method chaining
      See Also: