Skip to content

Commit c41787d

Browse files
committed
Merge branch 'channel-layouts' into 'master'
Improved audio handling See merge request videocore/encore!144
2 parents fd97fae + 4689201 commit c41787d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+974
-292
lines changed

Dockerfile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ LABEL org.opencontainers.image.url="https://github.com/svt/encore"
55
LABEL org.opencontainers.image.source="https://github.com/svt/encore"
66

77
COPY build/libs/encore*.jar /app/encore.jar
8-
COPY bin/start.sh /app/start.sh
98

109
WORKDIR /app
1110

12-
ENV JAVA_OPTS "-XX:MaxRAMPercentage=10"
13-
14-
CMD ["/app/start.sh"]
11+
CMD ["java", "-jar", "encore.jar"]

bin/start.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

build.gradle.kts

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
33
plugins {
44
idea
55
jacoco
6-
id("org.springframework.boot") version "2.6.6"
7-
id("se.ascp.gradle.gradle-versions-filter") version "0.1.10"
8-
kotlin("jvm") version "1.6.20"
9-
kotlin("plugin.spring") version "1.6.20"
6+
id("org.springframework.boot") version "2.7.6"
7+
id("se.ascp.gradle.gradle-versions-filter") version "0.1.16"
8+
kotlin("jvm") version "1.7.21"
9+
kotlin("plugin.spring") version "1.7.21"
1010
id("com.github.fhermansson.assertj-generator") version "1.1.4"
11-
id("org.jmailen.kotlinter") version "3.9.0"
12-
id("io.spring.dependency-management") version "1.0.11.RELEASE"
13-
id("pl.allegro.tech.build.axion-release") version "1.13.3"
11+
id("org.jmailen.kotlinter") version "3.12.0"
12+
id("io.spring.dependency-management") version "1.1.0"
13+
id("pl.allegro.tech.build.axion-release") version "1.14.2"
1414

1515
//openapi generation
1616
id("com.github.johnrengelman.processes") version "0.5.0"
@@ -33,7 +33,15 @@ assertjGenerator {
3333
}
3434

3535
kotlinter {
36-
disabledRules = arrayOf("import-ordering")
36+
disabledRules = arrayOf(
37+
"import-ordering",
38+
"trailing-comma-on-declaration-site",
39+
"trailing-comma-on-call-site"
40+
)
41+
}
42+
43+
tasks.lintKotlinTest {
44+
source = (source - fileTree("src/test/generated-java")).asFileTree
3745
}
3846

3947
tasks.test {
@@ -69,14 +77,14 @@ configurations {
6977

7078
dependencyManagement {
7179
imports {
72-
mavenBom("org.springframework.cloud:spring-cloud-dependencies:2021.0.1")
80+
mavenBom("org.springframework.cloud:spring-cloud-dependencies:2021.0.5")
7381
}
7482
}
7583

76-
val redissonVersion = "3.18.0"
84+
val redissonVersion = "3.18.1"
7785

7886
dependencies {
79-
implementation("se.svt.oss:media-analyzer:1.0.3")
87+
implementation("se.svt.oss:media-analyzer:2.0.1")
8088
implementation(kotlin("reflect"))
8189

8290
implementation("org.springframework.boot:spring-boot-starter-web")
@@ -89,32 +97,32 @@ dependencies {
8997
implementation("org.springframework.boot:spring-boot-starter-security")
9098

9199
implementation("org.redisson:redisson-spring-boot-starter:$redissonVersion")
92-
implementation("org.redisson:redisson-spring-data-26:$redissonVersion") // match boot version
93-
implementation("io.github.microutils:kotlin-logging:2.1.21")
100+
implementation("org.redisson:redisson-spring-data-27:$redissonVersion") // match boot version
101+
implementation("io.github.microutils:kotlin-logging:3.0.2")
94102
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
95-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0")
96-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.0")
97-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.6.0")
103+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
104+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.6.4")
105+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.6.4")
98106

99107
implementation("org.springframework.cloud:spring-cloud-starter-openfeign")
100108
implementation("io.github.openfeign:feign-okhttp")
101109
implementation("org.springframework.retry:spring-retry")
102110
implementation("org.springframework.boot:spring-boot-starter-aop")
103111

104112
//openapi generation
105-
implementation("org.springdoc:springdoc-openapi-ui:1.5.10")
106-
implementation("org.springdoc:springdoc-openapi-kotlin:1.5.10")
107-
implementation("org.springdoc:springdoc-openapi-data-rest:1.5.10")
108-
implementation("org.springdoc:springdoc-openapi-hateoas:1.5.10")
113+
implementation("org.springdoc:springdoc-openapi-ui:1.6.12")
114+
implementation("org.springdoc:springdoc-openapi-kotlin:1.6.12")
115+
implementation("org.springdoc:springdoc-openapi-data-rest:1.6.12")
116+
implementation("org.springdoc:springdoc-openapi-hateoas:1.6.12")
109117

110118
testImplementation("se.svt.oss:junit5-redis-extension:3.0.0")
111119
testImplementation("se.svt.oss:random-port-initializer:1.0.5")
112-
testImplementation("org.awaitility:awaitility:4.1.1")
120+
testImplementation("org.awaitility:awaitility")
113121
testImplementation("org.springframework.boot:spring-boot-starter-test")
114122
testImplementation("org.springframework.security:spring-security-test")
115-
testImplementation("org.assertj:assertj-core:3.20.2") // Can be bumped with future kotlin 1.7 release, https://github.com/assertj/assertj-core/issues/2357
116-
testImplementation("io.mockk:mockk:1.12.3")
117-
testImplementation("com.squareup.okhttp3:mockwebserver:3.14.9")//shall match with okhttp version used
123+
testImplementation("org.assertj:assertj-core")
124+
testImplementation("io.mockk:mockk:1.13.2")
125+
testImplementation("com.github.tomakehurst:wiremock-jre8:2.35.0")
118126
testImplementation("com.ninja-squad:springmockk:3.1.1")
119127
testImplementation("org.junit.jupiter:junit-jupiter-api")
120128
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")

gradle/wrapper/gradle-wrapper.jar

935 Bytes
Binary file not shown.

gradlew

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ set -- \
205205
org.gradle.wrapper.GradleWrapperMain \
206206
"$@"
207207

208+
# Stop when "xargs" is not available.
209+
if ! command -v xargs >/dev/null 2>&1
210+
then
211+
die "xargs is not available"
212+
fi
213+
208214
# Use "xargs" to parse quoted args.
209215
#
210216
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

src/main/kotlin/se/svt/oss/encore/RedisConfiguration.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ import org.springframework.context.annotation.Configuration
1212
import org.springframework.data.redis.core.RedisKeyValueAdapter
1313
import org.springframework.data.redis.core.convert.RedisCustomConversions
1414
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories
15+
import se.svt.oss.encore.repository.ByteArrayToChannelLayoutConverter
1516
import se.svt.oss.encore.repository.ByteArrayToOffsetDateTimeConverter
1617
import se.svt.oss.encore.repository.ByteArrayToURIConverter
1718
import se.svt.oss.encore.repository.ByteArrayToUUIDConverter
19+
import se.svt.oss.encore.repository.ChannelLayoutToByteArrayConverter
1820
import se.svt.oss.encore.repository.OffsetDateTimeToByteArrayConverter
1921
import se.svt.oss.encore.repository.URIToByteArrayConverter
2022
import se.svt.oss.encore.repository.UUIDToByteArrayConverter
@@ -31,7 +33,9 @@ class RedisConfiguration {
3133
UUIDToByteArrayConverter(),
3234
ByteArrayToUUIDConverter(),
3335
URIToByteArrayConverter(),
34-
ByteArrayToURIConverter()
36+
ByteArrayToURIConverter(),
37+
ChannelLayoutToByteArrayConverter(),
38+
ByteArrayToChannelLayoutConverter()
3539
)
3640
)
3741

src/main/kotlin/se/svt/oss/encore/config/AudioMixPreset.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
// SPDX-License-Identifier: EUPL-1.2
44
package se.svt.oss.encore.config
55

6+
import se.svt.oss.encore.model.profile.ChannelLayout
7+
68
data class AudioMixPreset(
79
val fallbackToAuto: Boolean = true,
8-
val defaultPan: Map<Int, String> = emptyMap(),
9-
val panMapping: Map<Int, Map<Int, String>> = emptyMap()
10+
val defaultPan: Map<ChannelLayout, String> = emptyMap(),
11+
val panMapping: Map<ChannelLayout, Map<ChannelLayout, String>> = emptyMap(),
1012
)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package se.svt.oss.encore.config
2+
3+
import se.svt.oss.encore.model.profile.ChannelLayout
4+
5+
data class EncodingProperties(
6+
val audioMixPresets: Map<String, AudioMixPreset> = mapOf("default" to AudioMixPreset()),
7+
val defaultChannelLayouts: Map<Int, ChannelLayout> = emptyMap(),
8+
val flipWidthHeightIfPortrait: Boolean = true
9+
)

src/main/kotlin/se/svt/oss/encore/config/EncoreProperties.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ import java.time.Duration
1212
@ConstructorBinding
1313
data class EncoreProperties(
1414
val localTemporaryEncode: Boolean = false,
15-
val audioMixPresets: Map<String, AudioMixPreset> = mapOf("default" to AudioMixPreset()),
1615
val concurrency: Int = 2,
1716
val pollInitialDelay: Duration = Duration.ofSeconds(10),
1817
val pollDelay: Duration = Duration.ofSeconds(5),
1918
val redisKeyPrefix: String = "encore",
2019
val security: Security = Security(),
21-
val openApi: OpenApi = OpenApi()
20+
val openApi: OpenApi = OpenApi(),
21+
val encoding: EncodingProperties = EncodingProperties()
2222
) {
2323
data class Security(
2424
val enabled: Boolean = false,

src/main/kotlin/se/svt/oss/encore/model/EncoreJob.kt

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,87 +28,109 @@ import javax.validation.constraints.Positive
2828
data class EncoreJob(
2929

3030
@Schema(
31-
description = "The Encore Internal EncoreJob Identity", example = "fb2baa17-8972-451b-bb1e-1bc773283476",
32-
accessMode = Schema.AccessMode.READ_ONLY, hidden = false, defaultValue = "A random UUID"
31+
description = "The Encore Internal EncoreJob Identity",
32+
example = "fb2baa17-8972-451b-bb1e-1bc773283476",
33+
accessMode = Schema.AccessMode.READ_ONLY,
34+
hidden = false,
35+
defaultValue = "A random UUID"
3336
)
34-
@Id val id: UUID = UUID.randomUUID(),
37+
@Id
38+
val id: UUID = UUID.randomUUID(),
3539

3640
@Schema(
37-
description = "External id - for external backreference", example = "any-string",
41+
description = "External id - for external backreference",
42+
example = "any-string",
3843
nullable = true
3944
)
4045
val externalId: String? = null,
4146

4247
@Schema(
4348
description = "The name of the encoding profile to use",
44-
example = "x264-animated", required = true
49+
example = "x264-animated",
50+
required = true
4551
)
4652
@NotBlank
4753
val profile: String,
4854

4955
@Schema(
5056
description = "A directory path to where the output should be written",
51-
example = "/an/output/path/dir", required = true
57+
example = "/an/output/path/dir",
58+
required = true
5259
)
5360
@NotBlank
5461
val outputFolder: String,
5562

5663
@Schema(
5764
description = "Base filename of output files",
58-
example = "any_file", required = true
65+
example = "any_file",
66+
required = true
5967
)
6068
@NotBlank
6169
val baseName: String,
6270

6371
@Schema(
6472
description = "The Creation date for the EncoreJob",
65-
example = "2021-04-22T03:00:48.759168+02:00", accessMode = Schema.AccessMode.READ_ONLY,
73+
example = "2021-04-22T03:00:48.759168+02:00",
74+
accessMode = Schema.AccessMode.READ_ONLY,
6675
defaultValue = "now()"
6776
)
6877
@Indexed
6978
val createdDate: OffsetDateTime = OffsetDateTime.now(),
7079

7180
@Schema(
7281
description = "An url to which the progress status callback should be directed",
73-
example = "http://projectx/encorecallback", nullable = true
82+
example = "http://projectx/encorecallback",
83+
nullable = true
7484
)
7585
val progressCallbackUri: URI? = null,
7686

7787
@Schema(
7888
description = "The queue priority of the EncoreJob",
79-
defaultValue = "0", minimum = "0", maximum = "100"
89+
defaultValue = "0",
90+
minimum = "0",
91+
maximum = "100"
8092
)
8193
@Min(0)
8294
@Max(100)
8395
val priority: Int = 0,
8496

8597
@Schema(
8698
description = "The exception message, if the EncoreJob failed",
87-
example = "input/output error", accessMode = Schema.AccessMode.READ_ONLY, nullable = true
99+
example = "input/output error",
100+
accessMode = Schema.AccessMode.READ_ONLY,
101+
nullable = true
88102
)
89103
var message: String? = null,
90104

91105
@Schema(
92106
description = "The EncoreJob progress",
93-
example = "57", accessMode = Schema.AccessMode.READ_ONLY, defaultValue = "0"
107+
example = "57",
108+
accessMode = Schema.AccessMode.READ_ONLY,
109+
defaultValue = "0"
94110
)
95111
var progress: Int = 0,
96112

97113
@Schema(
98114
description = "The Encoding speed of the job (compared to it's play speed/input duration)",
99-
example = "0.334", accessMode = Schema.AccessMode.READ_ONLY, nullable = true
115+
example = "0.334",
116+
accessMode = Schema.AccessMode.READ_ONLY,
117+
nullable = true
100118
)
101119
var speed: Double? = null,
102120

103121
@Schema(
104122
description = "The time for when the EncoreJob was picked from the queue)",
105-
example = "2021-04-19T07:20:43.819141+02:00", accessMode = Schema.AccessMode.READ_ONLY, nullable = true
123+
example = "2021-04-19T07:20:43.819141+02:00",
124+
accessMode = Schema.AccessMode.READ_ONLY,
125+
nullable = true
106126
)
107127
var startedDate: OffsetDateTime? = null,
108128

109129
@Schema(
110130
description = "The time for when the EncoreJob was completed (fail or success)",
111-
example = "2021-04-19T07:20:43.819141+02:00", accessMode = Schema.AccessMode.READ_ONLY, nullable = true
131+
example = "2021-04-19T07:20:43.819141+02:00",
132+
accessMode = Schema.AccessMode.READ_ONLY,
133+
nullable = true
112134
)
113135
var completedDate: OffsetDateTime? = null,
114136

@@ -119,7 +141,8 @@ data class EncoreJob(
119141
val debugOverlay: Boolean = false,
120142

121143
@Schema(
122-
description = "Key/Values to append to the MDC log context", defaultValue = "{}"
144+
description = "Key/Values to append to the MDC log context",
145+
defaultValue = "{}"
123146
)
124147
val logContext: Map<String, String> = emptyMap(),
125148

@@ -131,7 +154,8 @@ data class EncoreJob(
131154

132155
@Schema(
133156
description = "Time in seconds for when the thumbnail should be picked. Overrides profile configuration for thumbnails",
134-
example = "1800.5", nullable = true
157+
example = "1800.5",
158+
nullable = true
135159
)
136160
@Positive
137161
val thumbnailTime: Double? = null,
@@ -150,7 +174,6 @@ data class EncoreJob(
150174
description = "The Job Status",
151175
accessMode = Schema.AccessMode.READ_ONLY
152176
)
153-
154177
@Indexed
155178
var status = Status.NEW
156179
set(value) {

0 commit comments

Comments
 (0)