Skip to content

Commit 5440312

Browse files
committed
feat(*): replace rtmp and flv by krtmp
1 parent 53fc65c commit 5440312

File tree

66 files changed

+1397
-2210
lines changed

Some content is hidden

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

66 files changed

+1397
-2210
lines changed

core/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ dependencies {
3434
testImplementation(libs.kotlinx.coroutines.test)
3535
testImplementation(libs.robolectric)
3636

37+
androidTestImplementation(project(":streampack-flv"))
38+
3739
androidTestImplementation(libs.androidx.test.core.ktx)
3840
androidTestImplementation(libs.androidx.test.rules)
3941
androidTestImplementation(libs.androidx.junit)

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
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
74
import kotlinx.coroutines.test.runTest
85
import org.junit.Test
96
import org.junit.runner.RunWith
@@ -34,8 +31,7 @@ class EndpointStateTest(private val endpoint: IEndpointInternal) {
3431

3532
return arrayListOf(
3633
DynamicEndpoint(context),
37-
MediaMuxerEndpoint(context),
38-
CompositeEndpoint(FlvMuxer(isForFile = false), FileSink())
34+
MediaMuxerEndpoint(context)
3935
)
4036
}
4137
}

core/src/androidTest/java/io/github/thibaultbee/streampack/core/streamer/single/file/CameraSingleStreamerFileTest.kt

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -120,31 +120,11 @@ class cameraSingleStreamerFileTest(
120120
)
121121
fun getMediaDescriptor(): Iterable<Array<Any?>> {
122122
return arrayListOf(
123-
arrayOf(
124-
UriMediaDescriptor(FileUtils.createCacheFile("video.ts").toUri()),
125-
true,
126-
null
127-
),
128-
arrayOf(
129-
UriMediaDescriptor(FileUtils.createCacheFile("video.mp4").toUri()),
130-
true,
131-
null
132-
),
133123
arrayOf(
134124
UriMediaDescriptor(FileUtils.createCacheFile("video.flv").toUri()),
135125
false,
136126
null
137-
),
138-
arrayOf(
139-
UriMediaDescriptor(FileUtils.createCacheFile("video.webm").toUri()),
140-
true,
141-
null
142-
),
143-
arrayOf(
144-
UriMediaDescriptor(FileUtils.createCacheFile("video.mp4").toUri()),
145-
true,
146-
CompositeEndpointFactory(Mp4Muxer(), FileSink())
147-
),
127+
)
148128
)
149129
}
150130
}

core/src/main/java/io/github/thibaultbee/streampack/core/elements/data/Frame.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ data class Frame(
120120
} else {
121121
null
122122
}
123-
} catch (t: Throwable) {
123+
} catch (_: Throwable) {
124124
null
125125
}
126126

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
@@ -177,7 +177,7 @@ open class AudioCodecConfig(
177177
48000
178178
)
179179

180-
internal fun isAacMimeType(mimeType: String) = mimeType.startsWith(MIMETYPE_AAC_PREFIX)
180+
fun isAacMimeType(mimeType: String) = mimeType.startsWith(MIMETYPE_AAC_PREFIX)
181181

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ internal constructor(
166166

167167
try {
168168
mediaCodec.reset()
169-
} catch (e: IllegalStateException) {
169+
} catch (_: IllegalStateException) {
170170
Logger.d(tag, "Failed to reset")
171171
} finally {
172172
configureSync()
@@ -253,7 +253,7 @@ internal constructor(
253253
private fun releaseSync() {
254254
try {
255255
mediaCodec.stop()
256-
} catch (e: IllegalStateException) {
256+
} catch (_: IllegalStateException) {
257257
Logger.d(tag, "Failed to stop")
258258
}
259259
if (state == State.RELEASED || state == State.PENDING_RELEASE) {

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.Frame
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
@@ -155,22 +154,14 @@ open class DynamicEndpoint(
155154

156155
private fun getFlvFileEndpoint(): IEndpointInternal {
157156
if (flvFileEndpoint == null) {
158-
flvFileEndpoint = CompositeEndpoint(
159-
FlvMuxer(
160-
isForFile = true
161-
), FileSink()
162-
)
157+
flvFileEndpoint = Endpoints.createFlvFileEndpoint()
163158
}
164159
return flvFileEndpoint!!
165160
}
166161

167162
private fun getFlvContentEndpoint(): IEndpointInternal {
168163
if (flvContentEndpoint == null) {
169-
flvContentEndpoint = CompositeEndpoint(
170-
FlvMuxer(
171-
isForFile = true
172-
), ContentSink(context)
173-
)
164+
flvContentEndpoint = Endpoints.createFlvContentEndpoint(context)
174165
}
175166
return flvContentEndpoint!!
176167
}
@@ -203,7 +194,7 @@ open class DynamicEndpoint(
203194

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

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

Lines changed: 0 additions & 30 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
@@ -38,35 +37,6 @@ object CompositeEndpoints {
3837
return CompositeEndpoint(muxer, sink)
3938
}
4039

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

0 commit comments

Comments
 (0)