RtspStream

@RequiresApi(value = 21)
class RtspStream(context: Context, connectChecker: ConnectChecker, videoSource: VideoSource, audioSource: AudioSource) : StreamBase

Created by pedro on 14/3/22.

If you use VideoManager.Source.SCREEN/AudioManager.Source.INTERNAL. Call changeVideoSourceScreen/changeAudioSourceInternal is necessary to start it.

Constructors

Link copied to clipboard
constructor(context: Context, connectChecker: ConnectChecker)
constructor(context: Context, connectChecker: ConnectChecker, videoSource: VideoSource, audioSource: AudioSource)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Change audio source. Must be called after prepareAudio.

Link copied to clipboard

Change video source to Camera1 or Camera2. Must be called after prepareVideo.

Link copied to clipboard
fun forceCodecType(codecTypeVideo: CodecUtil.CodecType, codecTypeAudio: CodecUtil.CodecType)
Link copied to clipboard
fun forceFpsLimit(enabled: Boolean)

Force stream to work with fps selected in prepareVideo method. Must be called before prepareVideo. This is not recommend because could produce fps problems.

Link copied to clipboard

Get glInterface used to render video. This is useful to send filters to stream. Must be called after prepareVideo.

Link copied to clipboard
open override fun getStreamClient(): RtspStreamClient
Link copied to clipboard

return surface texture that can be used to render and encode custom data. Return null if video not prepared. start and stop rendering must be managed by the user.

Link copied to clipboard

Pause record. Ignored if you are not recording.

Link copied to clipboard
fun prepareAudio(sampleRate: Int, isStereo: Boolean, bitrate: Int, echoCanceler: Boolean = false, noiseSuppressor: Boolean = false): Boolean

Necessary only one time before start stream or record. If you want change values stop stream and record is necessary.

Link copied to clipboard
fun prepareVideo(width: Int, height: Int, bitrate: Int, fps: Int = 30, iFrameInterval: Int = 2, rotation: Int = 0, profile: Int = -1, level: Int = -1): Boolean

Necessary only one time before start preview, stream or record. If you want change values stop preview, stream and record is necessary.

Link copied to clipboard
fun release()

Stop stream, record and preview and then release all resources. You must call it after finish all the work.

Link copied to clipboard

Force VideoEncoder to produce a keyframe. Ignored if not recording or streaming. This could be ignored depend of the Codec implementation in each device.

Link copied to clipboard

Reset AudioEncoder. Only recommended if an AudioEncoder class error is received in the EncoderErrorCallback

Link copied to clipboard

Reset VideoEncoder. Only recommended if a VideoEncoder class error is received in the EncoderErrorCallback

Link copied to clipboard

Resume record. Ignored if you are not recording and in pause mode.

Link copied to clipboard

Change AudioCodec used. This could fail depend of the Codec supported in each Protocol. For example G711 is not supported in SRT

Link copied to clipboard
fun setEncoderErrorCallback(encoderErrorCallback: EncoderErrorCallback?)

Set a callback to know errors related with Video/Audio encoders

Link copied to clipboard
Link copied to clipboard
fun setOrientation(orientation: Int)

Change stream orientation depend of activity orientation. This method affect to preview and stream. Must be called after prepareVideo.

Link copied to clipboard

Replace the current BaseRecordController. This method allow record in other format or even create your custom implementation and record in a new format.

Link copied to clipboard
fun setTimestampMode(timestampModeVideo: TimestampMode, timestampModeAudio: TimestampMode)

Set the mode to calculate timestamp. By default CLOCK. Must be called before startRecord/startStream or it will be ignored.

Link copied to clipboard

Set video bitrate in bits per second while streaming.

Link copied to clipboard

Change VideoCodec used. This could fail depend of the Codec supported in each Protocol. For example AV1 is not supported in SRT

Link copied to clipboard
fun startPreview(surfaceView: SurfaceView, autoHandle: Boolean = false)

Start preview in the selected SurfaceView. Must be called after prepareVideo.

fun startPreview(textureView: TextureView, autoHandle: Boolean = false)

Start preview in the selected TextureView. Must be called after prepareVideo.

fun startPreview(surfaceTexture: SurfaceTexture, width: Int, height: Int)

Start preview in the selected SurfaceTexture. Must be called after prepareVideo.

fun startPreview(surface: Surface, width: Int, height: Int)

Start preview in the selected Surface. Must be called after prepareVideo.

Link copied to clipboard

Start record.

Link copied to clipboard
fun startStream(endPoint: String)

Start stream.

Link copied to clipboard

Stop preview. Must be called after prepareVideo.

Link copied to clipboard
Link copied to clipboard

Stop stream.