Skip to content

Commit 4b74f73

Browse files
committed
feat(*): replace rtmp and flv by krtmp
1 parent 5a81aa8 commit 4b74f73

File tree

64 files changed

+1474
-2192
lines changed

Some content is hidden

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

64 files changed

+1474
-2192
lines changed

core/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ dependencies {
3535
testImplementation(libs.robolectric)
3636

3737
androidTestImplementation(project(":streampack-srt"))
38+
androidTestImplementation(project(":streampack-flv"))
3839
androidTestImplementation(project(":streampack-rtmp"))
3940

4041
androidTestImplementation(libs.androidx.test.core.ktx)

core/src/androidTest/java/io/github/thibaultbee/streampack/core/elements/endpoints/EndpointStateTest.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package io.github.thibaultbee.streampack.core.elements.endpoints
22

33
import androidx.test.platform.app.InstrumentationRegistry
4-
import io.github.thibaultbee.streampack.core.elements.endpoints.composites.CompositeEndpoint
5-
import io.github.thibaultbee.streampack.core.elements.endpoints.composites.muxers.flv.FlvMuxer
6-
import io.github.thibaultbee.streampack.core.elements.endpoints.composites.sinks.FileSink
4+
import io.github.thibaultbee.streampack.ext.flv.elements.endpoints.FlvFileEndpoint
75
import kotlinx.coroutines.Dispatchers
86
import kotlinx.coroutines.test.runTest
97
import org.junit.Test
@@ -37,7 +35,7 @@ class EndpointStateTest(private val endpoint: IEndpointInternal) {
3735
return arrayListOf(
3836
DynamicEndpoint(context, Dispatchers.Default, ioDispatcher),
3937
MediaMuxerEndpoint(context, ioDispatcher),
40-
CompositeEndpoint(FlvMuxer(isForFile = false), FileSink(ioDispatcher))
38+
FlvFileEndpoint(ioDispatcher)
4139
)
4240
}
4341
}

core/src/androidTest/java/io/github/thibaultbee/streampack/core/elements/endpoints/composites/sinks/SinkStateTest.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package io.github.thibaultbee.streampack.core.elements.endpoints.composites.sinks
22

33
import androidx.test.platform.app.InstrumentationRegistry
4-
import io.github.thibaultbee.streampack.ext.rtmp.elements.endpoints.composites.sinks.RtmpSink
54
import io.github.thibaultbee.streampack.ext.srt.elements.endpoints.composites.sinks.SrtSink
65
import kotlinx.coroutines.Dispatchers
76
import kotlinx.coroutines.test.runTest
@@ -33,8 +32,7 @@ class SinkStateTest(private val endpoint: ISinkInternal) {
3332
ContentSink(context, ioDispatcher),
3433
ChunkedFileOutputStreamSink(1000, ioDispatcher),
3534
FakeSink(),
36-
SrtSink(ioDispatcher),
37-
RtmpSink(ioDispatcher)
35+
SrtSink(ioDispatcher)
3836
)
3937
}
4038
}

core/src/main/java/io/github/thibaultbee/streampack/core/elements/encoders/AudioCodecConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ class AudioCodecConfig(
189189
48000
190190
)
191191

192-
internal fun isAacMimeType(mimeType: String) = mimeType.startsWith(MIMETYPE_AAC_PREFIX)
192+
fun isAacMimeType(mimeType: String) = mimeType.startsWith(MIMETYPE_AAC_PREFIX)
193193

194194
private fun getAacProfileFromMimeType(mimeType: String) = when (mimeType) {
195195
MediaFormat.MIMETYPE_AUDIO_AAC -> MediaCodecInfo.CodecProfileLevel.AACObjectLC

core/src/main/java/io/github/thibaultbee/streampack/core/elements/endpoints/DynamicEndpoint.kt

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import io.github.thibaultbee.streampack.core.elements.data.FrameWithCloseable
2222
import io.github.thibaultbee.streampack.core.elements.encoders.CodecConfig
2323
import io.github.thibaultbee.streampack.core.elements.endpoints.composites.CompositeEndpoint
2424
import io.github.thibaultbee.streampack.core.elements.endpoints.composites.CompositeEndpoints
25-
import io.github.thibaultbee.streampack.core.elements.endpoints.composites.muxers.flv.FlvMuxer
2625
import io.github.thibaultbee.streampack.core.elements.endpoints.composites.muxers.ts.TsMuxer
2726
import io.github.thibaultbee.streampack.core.elements.endpoints.composites.muxers.ts.data.TSServiceInfo
2827
import io.github.thibaultbee.streampack.core.elements.endpoints.composites.sinks.ContentSink
@@ -205,22 +204,14 @@ open class DynamicEndpoint(
205204

206205
private fun getFlvFileEndpoint(): IEndpointInternal {
207206
if (flvFileEndpoint == null) {
208-
flvFileEndpoint = CompositeEndpoint(
209-
FlvMuxer(
210-
isForFile = true
211-
), FileSink(ioDispatcher)
212-
)
207+
flvFileEndpoint = Endpoints.createFlvFileEndpoint(ioDispatcher)
213208
}
214209
return flvFileEndpoint!!
215210
}
216211

217212
private fun getFlvContentEndpoint(): IEndpointInternal {
218213
if (flvContentEndpoint == null) {
219-
flvContentEndpoint = CompositeEndpoint(
220-
FlvMuxer(
221-
isForFile = true
222-
), ContentSink(context, ioDispatcher)
223-
)
214+
flvContentEndpoint = Endpoints.createFlvContentEndpoint(context, ioDispatcher)
224215
}
225216
return flvContentEndpoint!!
226217
}
@@ -253,7 +244,7 @@ open class DynamicEndpoint(
253244

254245
private fun getRtmpEndpoint(): IEndpointInternal {
255246
if (rtmpEndpoint == null) {
256-
rtmpEndpoint = CompositeEndpoints.createRtmpEndpoint(ioDispatcher)
247+
rtmpEndpoint = Endpoints.createRtmpEndpoint(ioDispatcher)
257248
}
258249
return rtmpEndpoint!!
259250
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package io.github.thibaultbee.streampack.core.elements.endpoints
2+
3+
import android.content.Context
4+
import kotlinx.coroutines.CoroutineDispatcher
5+
6+
object Endpoints {
7+
/**
8+
* Creates an endpoint for RTMP (with a FLV muxer)
9+
*/
10+
internal fun createRtmpEndpoint(
11+
defaultDispatcher: CoroutineDispatcher,
12+
ioDispatcher: CoroutineDispatcher
13+
): IEndpointInternal {
14+
return try {
15+
val clazz =
16+
Class.forName("io.github.thibaultbee.streampack.ext.rtmp.elements.endpoints.RtmpEndpoint")
17+
clazz.getConstructor(CoroutineDispatcher::class.java, CoroutineDispatcher::class.java)
18+
.newInstance(defaultDispatcher, ioDispatcher) as IEndpointInternal
19+
} catch (e: ClassNotFoundException) {
20+
// Expected if the app was built without the RTMP extension.
21+
throw ClassNotFoundException(
22+
"Attempting to stream RTMP stream without depending on the RTMP extension",
23+
e
24+
)
25+
} catch (t: Throwable) {
26+
// The RTMP extension is present, but instantiation failed.
27+
throw RuntimeException("Error instantiating RTMP extension", t)
28+
}
29+
}
30+
31+
/**
32+
* Creates an endpoint for FLV File
33+
*/
34+
internal fun createFlvFileEndpoint(coroutineDispatcher: CoroutineDispatcher): IEndpointInternal {
35+
return try {
36+
val clazz =
37+
Class.forName("io.github.thibaultbee.streampack.ext.flv.elements.endpoints.FlvFileEndpoint")
38+
clazz.getConstructor(CoroutineDispatcher::class.java)
39+
.newInstance(coroutineDispatcher) as IEndpointInternal
40+
} catch (e: ClassNotFoundException) {
41+
// Expected if the app was built without the FLV extension.
42+
throw ClassNotFoundException(
43+
"Attempting to stream FLV stream without depending on the FLV extension",
44+
e
45+
)
46+
} catch (t: Throwable) {
47+
// The FLV extension is present, but instantiation failed.
48+
throw RuntimeException("Error instantiating FLV file extension", t)
49+
}
50+
}
51+
52+
53+
/**
54+
* Creates an endpoint for FLV File
55+
*/
56+
internal fun createFlvContentEndpoint(
57+
context: Context,
58+
coroutineDispatcher: CoroutineDispatcher
59+
): IEndpointInternal {
60+
return try {
61+
val clazz =
62+
Class.forName("io.github.thibaultbee.streampack.ext.flv.elements.endpoints.FlvContentEndpoint")
63+
clazz.getConstructor(Context::class.java, CoroutineDispatcher::class.java)
64+
.newInstance(context, coroutineDispatcher) as IEndpointInternal
65+
} catch (e: ClassNotFoundException) {
66+
// Expected if the app was built without the FLV extension.
67+
throw ClassNotFoundException(
68+
"Attempting to stream FLV stream without depending on the FLV extension",
69+
e
70+
)
71+
} catch (t: Throwable) {
72+
// The FLV extension is present, but instantiation failed.
73+
throw RuntimeException("Error instantiating FLV content extension", t)
74+
}
75+
}
76+
}

core/src/main/java/io/github/thibaultbee/streampack/core/elements/endpoints/composites/CompositeEndpoints.kt

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ package io.github.thibaultbee.streampack.core.elements.endpoints.composites
1717

1818
import io.github.thibaultbee.streampack.core.elements.endpoints.IEndpointInternal
1919
import io.github.thibaultbee.streampack.core.elements.endpoints.composites.muxers.IMuxerInternal
20-
import io.github.thibaultbee.streampack.core.elements.endpoints.composites.muxers.flv.FlvMuxer
2120
import io.github.thibaultbee.streampack.core.elements.endpoints.composites.muxers.ts.TsMuxer
2221
import io.github.thibaultbee.streampack.core.elements.endpoints.composites.muxers.ts.data.TSServiceInfo
2322
import io.github.thibaultbee.streampack.core.elements.endpoints.composites.sinks.ISinkInternal
@@ -42,36 +41,6 @@ object CompositeEndpoints {
4241
return CompositeEndpoint(muxer, sink)
4342
}
4443

45-
/**
46-
* Creates an endpoint for RTMP (with a FLV muxer)
47-
*/
48-
internal fun createRtmpEndpoint(coroutineDispatcher: CoroutineDispatcher): IEndpointInternal {
49-
val sink = createRtmpSink(coroutineDispatcher)
50-
return CompositeEndpoint(
51-
FlvMuxer(
52-
isForFile = false
53-
), sink
54-
)
55-
}
56-
57-
private fun createRtmpSink(coroutineDispatcher: CoroutineDispatcher): ISinkInternal {
58-
return try {
59-
val clazz =
60-
Class.forName("io.github.thibaultbee.streampack.ext.rtmp.elements.endpoints.composites.sinks.RtmpSink")
61-
clazz.getConstructor(CoroutineDispatcher::class.java)
62-
.newInstance(coroutineDispatcher) as ISinkInternal
63-
} catch (e: ClassNotFoundException) {
64-
// Expected if the app was built without the RTMP extension.
65-
throw ClassNotFoundException(
66-
"Attempting to stream RTMP stream without depending on the RTMP extension",
67-
e
68-
)
69-
} catch (t: Throwable) {
70-
// The RTMP extension is present, but instantiation failed.
71-
throw RuntimeException("Error instantiating RTMP extension", t)
72-
}
73-
}
74-
7544
private fun createSrtSink(coroutineDispatcher: CoroutineDispatcher): ISinkInternal {
7645
return try {
7746
val clazz =

core/src/main/java/io/github/thibaultbee/streampack/core/elements/endpoints/composites/muxers/flv/FlvMuxer.kt

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

0 commit comments

Comments
 (0)