Skip to content

Commit

Permalink
add doc to StreamBase methods
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Oct 9, 2024
1 parent 83f06d8 commit bd166e2
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions library/src/main/java/com/pedro/library/base/StreamBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ abstract class StreamBase(
else requestKeyframe()
}

/**
* Force VideoEncoder to produce a keyframe. Ignored if not recording or streaming.
* This could be ignored depend of the Codec implementation in each device.
*/
fun requestKeyframe() {
if (videoEncoder.isRunning) {
videoEncoder.requestKeyframe()
Expand Down Expand Up @@ -377,6 +381,10 @@ abstract class StreamBase(
*/
fun getGlInterface(): GlStreamInterface = glInterface

/**
* Replace the current BaseRecordController.
* This method allow record in other format or even create your custom implementation and record in a new format.
*/
fun setRecordController(recordController: BaseRecordController) {
if (!isRecording) this.recordController = recordController
}
Expand Down Expand Up @@ -418,6 +426,10 @@ abstract class StreamBase(
if (!isRecording) recordController.resetFormats()
}

/**
* Stop stream, record and preview and then release all resources.
* You must call it after finish all the work.
*/
fun release() {
if (isStreaming) stopStream()
if (isRecording) stopRecord()
Expand All @@ -427,6 +439,11 @@ abstract class StreamBase(
audioSource.release()
}

/**
* Reset VideoEncoder. Only recommended if a VideoEncoder class error is received in the EncoderErrorCallback
*
* @return true if success, false if failed
*/
fun resetVideoEncoder(): Boolean {
glInterface.removeMediaCodecSurface()
val result = videoEncoder.reset()
Expand All @@ -435,6 +452,11 @@ abstract class StreamBase(
return true
}

/**
* Reset AudioEncoder. Only recommended if an AudioEncoder class error is received in the EncoderErrorCallback
*
* @return true if success, false if failed
*/
fun resetAudioEncoder(): Boolean = audioEncoder.reset()

private fun prepareEncoders(): Boolean {
Expand Down Expand Up @@ -477,6 +499,10 @@ abstract class StreamBase(

abstract fun getStreamClient(): StreamBaseClient

/**
* Change VideoCodec used.
* This could fail depend of the Codec supported in each Protocol. For example AV1 is not supported in SRT
*/
fun setVideoCodec(codec: VideoCodec) {
setVideoCodecImp(codec)
recordController.setVideoCodec(codec)
Expand All @@ -488,6 +514,10 @@ abstract class StreamBase(
videoEncoder.type = type
}

/**
* Change AudioCodec used.
* This could fail depend of the Codec supported in each Protocol. For example G711 is not supported in SRT
*/
fun setAudioCodec(codec: AudioCodec) {
setAudioCodecImp(codec)
recordController.setAudioCodec(codec)
Expand Down

0 comments on commit bd166e2

Please sign in to comment.