Skip to content

Commit

Permalink
refactor!: Split Archive/Broadcast layout method
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Sep 10, 2024
1 parent 39befbd commit d5e9a75
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 31 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [1.0.0] - 2024-09-12
GA release!

### Changed
- Split `layout` method in `Archive.Builder` and `Broadcast.Builder` into 3 separate presets
- Publish Javadoc JAR in Dokka HTML format

## [1.0.0-beta2] - 2024-09-06

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Maven Release](https://maven-badges.herokuapp.com/maven-central/com.vonage/server-sdk-kotlin/badge.svg)](https://central.sonatype.com/artifact/com.vonage/server-sdk-kotlin)
[![Build Status](https://github.com/Vonage/vonage-kotlin-sdk/actions/workflows/build.yml/badge.svg)](https://github.com/Vonage/vonage-kotlin-sdk/actions/workflows/build.yml)
[![codecov](https://codecov.io/gh/Vonage/vonage-kotlin-sdk/graph/badge.svg?token=YNBJUD8OUT)](https://codecov.io/gh/Vonage/vonage-kotlin-sdk)
![SLOC](https://img.shields.io/badge/Total%20lines-10k-brightgreen)
![SLOC](https://sloc.xyz/github/Vonage/vonage-kotlin-sdk)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE.txt)

Expand Down
71 changes: 45 additions & 26 deletions src/main/kotlin/com/vonage/client/kt/Video.kt
Original file line number Diff line number Diff line change
Expand Up @@ -625,44 +625,63 @@ fun Broadcast.Builder.addRtmpStream(properties: Rtmp.Builder.() -> Unit): Broadc
fun Broadcast.Builder.hls(properties: Hls.Builder.() -> Unit = {}): Broadcast.Builder =
hls(Hls.builder().apply(properties).build())


/**
* Sets the layout for a composed archive. If this option is specified,
* [Archive.Builder.outputMode] must be set to [OutputMode.COMPOSED].
* Sets the layout for a composed archive.
*
* @param initialLayout The layout type to use for the archive as an enum.
*
* @param initialLayout The layout type to use for the archive as an enum. If set to
* [ScreenLayoutType.CUSTOM], then you must also set the `stylesheet` property.
* @return The updated archive builder.
*/
fun Archive.Builder.standardLayout(initialLayout: ScreenLayoutType): Archive.Builder =
layout(streamCompositionLayout(initialLayout, null, null))

/**
* Sets the layout for a composed archive to [ScreenLayoutType.BEST_FIT].
*
* @param screenshareType (OPTIONAL) The layout type to use when there is a screen-sharing stream in the
* session. Note if you set this property, then `initialLayout` must be set to [ScreenLayoutType.BEST_FIT]
* and you must leave the `stylesheet` property unset (null).
* @param screenshareType The layout type to use when there is a screen-sharing stream in the session.
*
* @return The updated archive builder.
*/
fun Archive.Builder.screenshareLayout(screenshareType: ScreenLayoutType): Archive.Builder =
layout(streamCompositionLayout(ScreenLayoutType.BEST_FIT, screenshareType, null))

/**
* Sets the layout for a composed archive to [ScreenLayoutType.CUSTOM].
*
* @param stylesheet (OPTIONAL) The CSS stylesheet to use for the archive. If you set this property,
* then `initialLayout` must be set to [ScreenLayoutType.CUSTOM].
* @param stylesheet The CSS stylesheet to use for the archive.
*
* @return The updated archive builder.
*/
fun Archive.Builder.layout(initialLayout: ScreenLayoutType,
screenshareType: ScreenLayoutType? = null,
stylesheet: String? = null): Archive.Builder =
layout(streamCompositionLayout(initialLayout, screenshareType, stylesheet))
fun Archive.Builder.customLayout(stylesheet: String): Archive.Builder =
layout(streamCompositionLayout(ScreenLayoutType.CUSTOM, null, stylesheet))

/**
* Specify this to assign the initial layout type for the broadcast. If you do not specify an initial layout type,
* the broadcast stream uses [ScreenLayoutType.BEST_FIT] as the default layout type.
* Specify this to assign the initial layout type for the broadcast.
*
* @param initialLayout The layout type to use for the broadcast as an enum. If set to
* [ScreenLayoutType.CUSTOM], then you must also set the `stylesheet` property.
* @param initialLayout The layout type to use for the broadcast as an enum.
*
* @param screenshareType (OPTIONAL) The layout type to use when there is a screen-sharing stream in the
* session. Note if you set this property, then `initialLayout` must be set to [ScreenLayoutType.BEST_FIT]
* and you must leave the `stylesheet` property unset (null).
* @return The updated broadcast builder.
*/
fun Broadcast.Builder.standardLayout(initialLayout: ScreenLayoutType): Broadcast.Builder =
layout(streamCompositionLayout(initialLayout, null, null))

/**
* Sets the layout for the broadcast to [ScreenLayoutType.BEST_FIT].
*
* @param screenshareType The layout type to use when there is a screen-sharing stream in the session.
*
* @return The updated broadcast builder.
*/
fun Broadcast.Builder.screenshareLayout(screenshareType: ScreenLayoutType): Broadcast.Builder =
layout(streamCompositionLayout(ScreenLayoutType.BEST_FIT, screenshareType, null))

/**
* Sets the layout for the broadcast to [ScreenLayoutType.CUSTOM].
*
* @param stylesheet (OPTIONAL) The CSS stylesheet to use for the broadcast. If you set this property,
* then `initialLayout` must be set to [ScreenLayoutType.CUSTOM].
* @param stylesheet The CSS stylesheet to use for the broadcast.
*
* @return The updated broadcast builder.
*/
fun Broadcast.Builder.layout(initialLayout: ScreenLayoutType = ScreenLayoutType.BEST_FIT,
screenshareType: ScreenLayoutType? = null,
stylesheet: String? = null): Broadcast.Builder =
layout(streamCompositionLayout(initialLayout, screenshareType, stylesheet))
fun Broadcast.Builder.customLayout(stylesheet: String): Broadcast.Builder =
layout(streamCompositionLayout(ScreenLayoutType.CUSTOM, null, stylesheet))
9 changes: 5 additions & 4 deletions src/test/kotlin/com/vonage/client/kt/VideoTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -878,8 +878,9 @@ class VideoTest : AbstractTest() {
multiArchiveTag(multiArchiveTag)
hasVideo(archiveHasVideo); hasAudio(archiveHasAudio)
streamMode(archiveStreamMode); outputMode(archiveOutputMode)
layout(ScreenLayoutType.HORIZONTAL) // This is to get 100% coverage; override below
layout(ScreenLayoutType.CUSTOM, stylesheet = stylesheet)
standardLayout(ScreenLayoutType.HORIZONTAL)
screenshareLayout(ScreenLayoutType.BEST_FIT)
customLayout(stylesheet)
})
}

Expand Down Expand Up @@ -912,8 +913,8 @@ class VideoTest : AbstractTest() {
multiBroadcastTag(multiBroadcastTag)
maxDuration(maxDuration); maxBitrate(maxBitrate)
resolution(broadcastResolution); streamMode(broadcastStreamMode)
layout(); layout(ScreenLayoutType.VERTICAL) // This is to get 100% coverage; override below
layout(ScreenLayoutType.BEST_FIT, ScreenLayoutType.PIP)
standardLayout(ScreenLayoutType.VERTICAL); customLayout(stylesheet)
screenshareLayout(ScreenLayoutType.PIP)
hls {
dvr(dvr); lowLatency(lowLatency)
}
Expand Down

0 comments on commit d5e9a75

Please sign in to comment.