Skip to content

Commit

Permalink
docs(bufferapi): add missing docs and improve formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
123mpozzi committed Oct 18, 2023
1 parent f65ecc7 commit acd6b8e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ private const val MODULE_NAME = "BufferModule"

@ReactModule(name = MODULE_NAME)
class BufferModule(private val context: ReactApplicationContext) : ReactContextBaseJavaModule(context) {
/**
* Collection of [BufferLevel] objects
* @param audio [BufferLevel] for [MediaType.Audio].
* @param video [BufferLevel] for [MediaType.Video].
*/
data class RNBufferLevels(val audio: BufferLevel, val video: BufferLevel)

/**
Expand All @@ -19,9 +24,9 @@ class BufferModule(private val context: ReactApplicationContext) : ReactContextB
override fun getName() = MODULE_NAME

/**
* Gets the buffer level from the Player
* @param nativeId Native Id of the collector instance.
* @param type The type of buffer to return the level for.
* Gets the [buffer level][BufferLevel] from the Player
* @param nativeId Target player id.
* @param type The [type of buffer][JsonConverter.toBufferType] to return the level for.
* @param promise JS promise object.
*/
@ReactMethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ import java.util.UUID
class JsonConverter {
companion object {
/**
* Converts an arbitrary `json` to `PlayerConfig`.
* @param json JS object representing the `PlayerConfig`.
* @return The generated `PlayerConfig` if successful, `null` otherwise.
* Converts an arbitrary `json` to [PlayerConfig].
* @param json JS object representing the [PlayerConfig].
* @return The generated [PlayerConfig] if successful, `null` otherwise.
*/
@JvmStatic
fun toPlayerConfig(json: ReadableMap?): PlayerConfig {
Expand Down Expand Up @@ -121,9 +121,9 @@ class JsonConverter {
}

/**
* Converts any JS object into a `BufferMediaTypeConfig` object.
* @param json JS object representing the `BufferMediaTypeConfig`.
* @return The generated `BufferMediaTypeConfig` if successful, `null` otherwise.
* Converts any JS object into a [BufferMediaTypeConfig] object.
* @param json JS object representing the [BufferMediaTypeConfig].
* @return The generated [BufferMediaTypeConfig] if successful, `null` otherwise.
*/
@JvmStatic
fun toBufferMediaTypeConfig(json: ReadableMap?): BufferMediaTypeConfig? {
Expand All @@ -138,9 +138,9 @@ class JsonConverter {
}

/**
* Converts any JS object into a `BufferConfig` object.
* @param json JS object representing the `BufferConfig`.
* @return The generated `BufferConfig` if successful, `null` otherwise.
* Converts any JS object into a [BufferConfig] object.
* @param json JS object representing the [BufferConfig].
* @return The generated [BufferConfig] if successful, `null` otherwise.
*/
@JvmStatic
fun toBufferConfig(json: ReadableMap?): BufferConfig? {
Expand Down Expand Up @@ -215,9 +215,9 @@ class JsonConverter {
}

/**
* Converts an arbitrary `json` to `SourceOptions`.
* @param json JS object representing the `SourceOptions`.
* @return The generated `SourceOptions`.
* Converts an arbitrary `json` to [SourceOptions].
* @param json JS object representing the [SourceOptions].
* @return The generated [SourceOptions].
*/
@JvmStatic
fun toSourceOptions(json: ReadableMap?): SourceOptions {
Expand Down Expand Up @@ -1190,8 +1190,15 @@ class JsonConverter {
}
}

/**
* Maps an integer value into the corresponding [BufferType] value.
*
* Currently `0` is mapped to [BufferType.ForwardDuration], and `1` to [BufferType.BackwardDuration].
* Other values fall back to [BufferType.ForwardDuration]
* @param value The integer value to seek a [BufferType] for.
*/
@JvmStatic
fun toBufferType(json: Int?): BufferType = when (json) {
fun toBufferType(value: Int?): BufferType = when (value) {
0 -> BufferType.ForwardDuration
1 -> BufferType.BackwardDuration
else -> BufferType.ForwardDuration
Expand Down
4 changes: 2 additions & 2 deletions src/bufferApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ export class BufferApi {
}

/**
* Returns the {@link BufferLevel} for the chosen {@link BufferType|buffer type} and {@link MediaType|media type} of the active Source.
* @param type The type of buffer to return the level for.
* Gets the {@link BufferLevel|buffer level} from the Player
* @param type The {@link BufferType|type of buffer} to return the level for.
* @returns a {@link BufferLevels} that contains {@link BufferLevel} values for audio and video.
*/
getLevel = async (type: BufferType): Promise<BufferLevels> => {
Expand Down

0 comments on commit acd6b8e

Please sign in to comment.