From d5e9a755cba28c4197595e195b6ae03cdc831775 Mon Sep 17 00:00:00 2001 From: Sina Madani Date: Tue, 10 Sep 2024 12:08:44 +0100 Subject: [PATCH] refactor!: Split Archive/Broadcast layout method --- CHANGELOG.md | 4 ++ README.md | 2 +- src/main/kotlin/com/vonage/client/kt/Video.kt | 71 ++++++++++++------- .../kotlin/com/vonage/client/kt/VideoTest.kt | 9 +-- 4 files changed, 55 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed38d7c..064bcd2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 5e220d5..7544867 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/src/main/kotlin/com/vonage/client/kt/Video.kt b/src/main/kotlin/com/vonage/client/kt/Video.kt index d6b5c88..da24a48 100644 --- a/src/main/kotlin/com/vonage/client/kt/Video.kt +++ b/src/main/kotlin/com/vonage/client/kt/Video.kt @@ -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)) diff --git a/src/test/kotlin/com/vonage/client/kt/VideoTest.kt b/src/test/kotlin/com/vonage/client/kt/VideoTest.kt index 1c4ad37..8f709d5 100644 --- a/src/test/kotlin/com/vonage/client/kt/VideoTest.kt +++ b/src/test/kotlin/com/vonage/client/kt/VideoTest.kt @@ -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) }) } @@ -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) }