Skip to content

Commit d5e9a75

Browse files
committed
refactor!: Split Archive/Broadcast layout method
1 parent 39befbd commit d5e9a75

File tree

4 files changed

+55
-31
lines changed

4 files changed

+55
-31
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77
## [1.0.0] - 2024-09-12
88
GA release!
99

10+
### Changed
11+
- Split `layout` method in `Archive.Builder` and `Broadcast.Builder` into 3 separate presets
12+
- Publish Javadoc JAR in Dokka HTML format
13+
1014
## [1.0.0-beta2] - 2024-09-06
1115

1216
### Added

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![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)
44
[![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)
55
[![codecov](https://codecov.io/gh/Vonage/vonage-kotlin-sdk/graph/badge.svg?token=YNBJUD8OUT)](https://codecov.io/gh/Vonage/vonage-kotlin-sdk)
6-
![SLOC](https://img.shields.io/badge/Total%20lines-10k-brightgreen)
6+
![SLOC](https://sloc.xyz/github/Vonage/vonage-kotlin-sdk)
77
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
88
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE.txt)
99

src/main/kotlin/com/vonage/client/kt/Video.kt

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -625,44 +625,63 @@ fun Broadcast.Builder.addRtmpStream(properties: Rtmp.Builder.() -> Unit): Broadc
625625
fun Broadcast.Builder.hls(properties: Hls.Builder.() -> Unit = {}): Broadcast.Builder =
626626
hls(Hls.builder().apply(properties).build())
627627

628+
628629
/**
629-
* Sets the layout for a composed archive. If this option is specified,
630-
* [Archive.Builder.outputMode] must be set to [OutputMode.COMPOSED].
630+
* Sets the layout for a composed archive.
631+
*
632+
* @param initialLayout The layout type to use for the archive as an enum.
631633
*
632-
* @param initialLayout The layout type to use for the archive as an enum. If set to
633-
* [ScreenLayoutType.CUSTOM], then you must also set the `stylesheet` property.
634+
* @return The updated archive builder.
635+
*/
636+
fun Archive.Builder.standardLayout(initialLayout: ScreenLayoutType): Archive.Builder =
637+
layout(streamCompositionLayout(initialLayout, null, null))
638+
639+
/**
640+
* Sets the layout for a composed archive to [ScreenLayoutType.BEST_FIT].
634641
*
635-
* @param screenshareType (OPTIONAL) The layout type to use when there is a screen-sharing stream in the
636-
* session. Note if you set this property, then `initialLayout` must be set to [ScreenLayoutType.BEST_FIT]
637-
* and you must leave the `stylesheet` property unset (null).
642+
* @param screenshareType The layout type to use when there is a screen-sharing stream in the session.
643+
*
644+
* @return The updated archive builder.
645+
*/
646+
fun Archive.Builder.screenshareLayout(screenshareType: ScreenLayoutType): Archive.Builder =
647+
layout(streamCompositionLayout(ScreenLayoutType.BEST_FIT, screenshareType, null))
648+
649+
/**
650+
* Sets the layout for a composed archive to [ScreenLayoutType.CUSTOM].
638651
*
639-
* @param stylesheet (OPTIONAL) The CSS stylesheet to use for the archive. If you set this property,
640-
* then `initialLayout` must be set to [ScreenLayoutType.CUSTOM].
652+
* @param stylesheet The CSS stylesheet to use for the archive.
641653
*
642654
* @return The updated archive builder.
643655
*/
644-
fun Archive.Builder.layout(initialLayout: ScreenLayoutType,
645-
screenshareType: ScreenLayoutType? = null,
646-
stylesheet: String? = null): Archive.Builder =
647-
layout(streamCompositionLayout(initialLayout, screenshareType, stylesheet))
656+
fun Archive.Builder.customLayout(stylesheet: String): Archive.Builder =
657+
layout(streamCompositionLayout(ScreenLayoutType.CUSTOM, null, stylesheet))
648658

649659
/**
650-
* Specify this to assign the initial layout type for the broadcast. If you do not specify an initial layout type,
651-
* the broadcast stream uses [ScreenLayoutType.BEST_FIT] as the default layout type.
660+
* Specify this to assign the initial layout type for the broadcast.
652661
*
653-
* @param initialLayout The layout type to use for the broadcast as an enum. If set to
654-
* [ScreenLayoutType.CUSTOM], then you must also set the `stylesheet` property.
662+
* @param initialLayout The layout type to use for the broadcast as an enum.
655663
*
656-
* @param screenshareType (OPTIONAL) The layout type to use when there is a screen-sharing stream in the
657-
* session. Note if you set this property, then `initialLayout` must be set to [ScreenLayoutType.BEST_FIT]
658-
* and you must leave the `stylesheet` property unset (null).
664+
* @return The updated broadcast builder.
665+
*/
666+
fun Broadcast.Builder.standardLayout(initialLayout: ScreenLayoutType): Broadcast.Builder =
667+
layout(streamCompositionLayout(initialLayout, null, null))
668+
669+
/**
670+
* Sets the layout for the broadcast to [ScreenLayoutType.BEST_FIT].
671+
*
672+
* @param screenshareType The layout type to use when there is a screen-sharing stream in the session.
673+
*
674+
* @return The updated broadcast builder.
675+
*/
676+
fun Broadcast.Builder.screenshareLayout(screenshareType: ScreenLayoutType): Broadcast.Builder =
677+
layout(streamCompositionLayout(ScreenLayoutType.BEST_FIT, screenshareType, null))
678+
679+
/**
680+
* Sets the layout for the broadcast to [ScreenLayoutType.CUSTOM].
659681
*
660-
* @param stylesheet (OPTIONAL) The CSS stylesheet to use for the broadcast. If you set this property,
661-
* then `initialLayout` must be set to [ScreenLayoutType.CUSTOM].
682+
* @param stylesheet The CSS stylesheet to use for the broadcast.
662683
*
663684
* @return The updated broadcast builder.
664685
*/
665-
fun Broadcast.Builder.layout(initialLayout: ScreenLayoutType = ScreenLayoutType.BEST_FIT,
666-
screenshareType: ScreenLayoutType? = null,
667-
stylesheet: String? = null): Broadcast.Builder =
668-
layout(streamCompositionLayout(initialLayout, screenshareType, stylesheet))
686+
fun Broadcast.Builder.customLayout(stylesheet: String): Broadcast.Builder =
687+
layout(streamCompositionLayout(ScreenLayoutType.CUSTOM, null, stylesheet))

src/test/kotlin/com/vonage/client/kt/VideoTest.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -878,8 +878,9 @@ class VideoTest : AbstractTest() {
878878
multiArchiveTag(multiArchiveTag)
879879
hasVideo(archiveHasVideo); hasAudio(archiveHasAudio)
880880
streamMode(archiveStreamMode); outputMode(archiveOutputMode)
881-
layout(ScreenLayoutType.HORIZONTAL) // This is to get 100% coverage; override below
882-
layout(ScreenLayoutType.CUSTOM, stylesheet = stylesheet)
881+
standardLayout(ScreenLayoutType.HORIZONTAL)
882+
screenshareLayout(ScreenLayoutType.BEST_FIT)
883+
customLayout(stylesheet)
883884
})
884885
}
885886

@@ -912,8 +913,8 @@ class VideoTest : AbstractTest() {
912913
multiBroadcastTag(multiBroadcastTag)
913914
maxDuration(maxDuration); maxBitrate(maxBitrate)
914915
resolution(broadcastResolution); streamMode(broadcastStreamMode)
915-
layout(); layout(ScreenLayoutType.VERTICAL) // This is to get 100% coverage; override below
916-
layout(ScreenLayoutType.BEST_FIT, ScreenLayoutType.PIP)
916+
standardLayout(ScreenLayoutType.VERTICAL); customLayout(stylesheet)
917+
screenshareLayout(ScreenLayoutType.PIP)
917918
hls {
918919
dvr(dvr); lowLatency(lowLatency)
919920
}

0 commit comments

Comments
 (0)