From 3a9ba23bac63872dcded5ef2c4113cfe6192c419 Mon Sep 17 00:00:00 2001 From: pedro Date: Fri, 29 Mar 2024 20:43:24 +0100 Subject: [PATCH] migrate only audio --- .../com/pedro/library/rtmp/RtmpOnlyAudio.java | 76 ------------------- .../com/pedro/library/rtmp/RtmpOnlyAudio.kt | 58 ++++++++++++++ .../com/pedro/library/rtsp/RtspOnlyAudio.java | 76 ------------------- .../com/pedro/library/rtsp/RtspOnlyAudio.kt | 58 ++++++++++++++ .../com/pedro/library/srt/SrtOnlyAudio.java | 76 ------------------- .../com/pedro/library/srt/SrtOnlyAudio.kt | 58 ++++++++++++++ 6 files changed, 174 insertions(+), 228 deletions(-) delete mode 100644 library/src/main/java/com/pedro/library/rtmp/RtmpOnlyAudio.java create mode 100644 library/src/main/java/com/pedro/library/rtmp/RtmpOnlyAudio.kt delete mode 100644 library/src/main/java/com/pedro/library/rtsp/RtspOnlyAudio.java create mode 100644 library/src/main/java/com/pedro/library/rtsp/RtspOnlyAudio.kt delete mode 100644 library/src/main/java/com/pedro/library/srt/SrtOnlyAudio.java create mode 100644 library/src/main/java/com/pedro/library/srt/SrtOnlyAudio.kt diff --git a/library/src/main/java/com/pedro/library/rtmp/RtmpOnlyAudio.java b/library/src/main/java/com/pedro/library/rtmp/RtmpOnlyAudio.java deleted file mode 100644 index fa8d08bff..000000000 --- a/library/src/main/java/com/pedro/library/rtmp/RtmpOnlyAudio.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2023 pedroSG94. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pedro.library.rtmp; - -import android.media.MediaCodec; - -import com.pedro.common.AudioCodec; -import com.pedro.common.ConnectChecker; -import com.pedro.library.base.OnlyAudioBase; -import com.pedro.library.util.streamclient.RtmpStreamClient; -import com.pedro.rtmp.rtmp.RtmpClient; - -import java.nio.ByteBuffer; - -/** - * More documentation see: - * {@link com.pedro.library.base.OnlyAudioBase} - * - * Created by pedro on 10/07/18. - */ -public class RtmpOnlyAudio extends OnlyAudioBase { - - private final RtmpClient rtmpClient; - private final RtmpStreamClient streamClient; - - public RtmpOnlyAudio(ConnectChecker connectChecker) { - super(); - rtmpClient = new RtmpClient(connectChecker); - streamClient = new RtmpStreamClient(rtmpClient, null); - streamClient.setOnlyAudio(true); - } - - @Override - public RtmpStreamClient getStreamClient() { - return streamClient; - } - - @Override - protected void setAudioCodecImp(AudioCodec codec) { - rtmpClient.setAudioCodec(codec); - } - - @Override - protected void prepareAudioRtp(boolean isStereo, int sampleRate) { - rtmpClient.setAudioInfo(sampleRate, isStereo); - } - - @Override - protected void startStreamRtp(String url) { - rtmpClient.connect(url); - } - - @Override - protected void stopStreamRtp() { - rtmpClient.disconnect(); - } - - @Override - protected void getAacDataRtp(ByteBuffer aacBuffer, MediaCodec.BufferInfo info) { - rtmpClient.sendAudio(aacBuffer, info); - } -} diff --git a/library/src/main/java/com/pedro/library/rtmp/RtmpOnlyAudio.kt b/library/src/main/java/com/pedro/library/rtmp/RtmpOnlyAudio.kt new file mode 100644 index 000000000..2a3afb57f --- /dev/null +++ b/library/src/main/java/com/pedro/library/rtmp/RtmpOnlyAudio.kt @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2023 pedroSG94. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.pedro.library.rtmp + +import android.media.MediaCodec +import com.pedro.common.AudioCodec +import com.pedro.common.ConnectChecker +import com.pedro.library.base.OnlyAudioBase +import com.pedro.library.util.streamclient.RtmpStreamClient +import com.pedro.rtmp.rtmp.RtmpClient +import java.nio.ByteBuffer + +/** + * More documentation see: + * [com.pedro.library.base.OnlyAudioBase] + * + * Created by pedro on 10/07/18. + */ +class RtmpOnlyAudio(connectChecker: ConnectChecker) : OnlyAudioBase() { + + private val rtmpClient = RtmpClient(connectChecker).apply { setOnlyAudio(true) } + private val streamClient = RtmpStreamClient(rtmpClient, null) + + override fun getStreamClient(): RtmpStreamClient = streamClient + + override fun setAudioCodecImp(codec: AudioCodec) { + rtmpClient.setAudioCodec(codec) + } + + override fun prepareAudioRtp(isStereo: Boolean, sampleRate: Int) { + rtmpClient.setAudioInfo(sampleRate, isStereo) + } + + override fun startStreamRtp(url: String) { + rtmpClient.connect(url) + } + + override fun stopStreamRtp() { + rtmpClient.disconnect() + } + + override fun getAacDataRtp(aacBuffer: ByteBuffer, info: MediaCodec.BufferInfo) { + rtmpClient.sendAudio(aacBuffer, info) + } +} diff --git a/library/src/main/java/com/pedro/library/rtsp/RtspOnlyAudio.java b/library/src/main/java/com/pedro/library/rtsp/RtspOnlyAudio.java deleted file mode 100644 index 1005dfd67..000000000 --- a/library/src/main/java/com/pedro/library/rtsp/RtspOnlyAudio.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2023 pedroSG94. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pedro.library.rtsp; - -import android.media.MediaCodec; - -import com.pedro.common.AudioCodec; -import com.pedro.common.ConnectChecker; -import com.pedro.library.base.OnlyAudioBase; -import com.pedro.library.util.streamclient.RtspStreamClient; -import com.pedro.rtsp.rtsp.RtspClient; - -import java.nio.ByteBuffer; - -/** - * More documentation see: - * {@link com.pedro.library.base.OnlyAudioBase} - * - * Created by pedro on 10/07/18. - */ -public class RtspOnlyAudio extends OnlyAudioBase { - - private final RtspClient rtspClient; - private final RtspStreamClient streamClient; - - public RtspOnlyAudio(ConnectChecker connectChecker) { - super(); - rtspClient = new RtspClient(connectChecker); - rtspClient.setOnlyAudio(true); - streamClient = new RtspStreamClient(rtspClient, null); - } - - @Override - public RtspStreamClient getStreamClient() { - return streamClient; - } - - @Override - protected void setAudioCodecImp(AudioCodec codec) { - rtspClient.setAudioCodec(codec); - } - - @Override - protected void prepareAudioRtp(boolean isStereo, int sampleRate) { - rtspClient.setAudioInfo(sampleRate, isStereo); - } - - @Override - protected void startStreamRtp(String url) { - rtspClient.connect(url); - } - - @Override - protected void stopStreamRtp() { - rtspClient.disconnect(); - } - - @Override - protected void getAacDataRtp(ByteBuffer aacBuffer, MediaCodec.BufferInfo info) { - rtspClient.sendAudio(aacBuffer, info); - } -} \ No newline at end of file diff --git a/library/src/main/java/com/pedro/library/rtsp/RtspOnlyAudio.kt b/library/src/main/java/com/pedro/library/rtsp/RtspOnlyAudio.kt new file mode 100644 index 000000000..a6e08d8eb --- /dev/null +++ b/library/src/main/java/com/pedro/library/rtsp/RtspOnlyAudio.kt @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2023 pedroSG94. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.pedro.library.rtsp + +import android.media.MediaCodec +import com.pedro.common.AudioCodec +import com.pedro.common.ConnectChecker +import com.pedro.library.base.OnlyAudioBase +import com.pedro.library.util.streamclient.RtspStreamClient +import com.pedro.rtsp.rtsp.RtspClient +import java.nio.ByteBuffer + +/** + * More documentation see: + * [com.pedro.library.base.OnlyAudioBase] + * + * Created by pedro on 10/07/18. + */ +class RtspOnlyAudio(connectChecker: ConnectChecker) : OnlyAudioBase() { + + private val rtspClient = RtspClient(connectChecker).apply { setOnlyAudio(true) } + private val streamClient = RtspStreamClient(rtspClient, null) + + override fun getStreamClient(): RtspStreamClient = streamClient + + override fun setAudioCodecImp(codec: AudioCodec) { + rtspClient.setAudioCodec(codec) + } + + override fun prepareAudioRtp(isStereo: Boolean, sampleRate: Int) { + rtspClient.setAudioInfo(sampleRate, isStereo) + } + + override fun startStreamRtp(url: String) { + rtspClient.connect(url) + } + + override fun stopStreamRtp() { + rtspClient.disconnect() + } + + override fun getAacDataRtp(aacBuffer: ByteBuffer, info: MediaCodec.BufferInfo) { + rtspClient.sendAudio(aacBuffer, info) + } +} \ No newline at end of file diff --git a/library/src/main/java/com/pedro/library/srt/SrtOnlyAudio.java b/library/src/main/java/com/pedro/library/srt/SrtOnlyAudio.java deleted file mode 100644 index 15afa864a..000000000 --- a/library/src/main/java/com/pedro/library/srt/SrtOnlyAudio.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2023 pedroSG94. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.pedro.library.srt; - -import android.media.MediaCodec; - -import com.pedro.common.AudioCodec; -import com.pedro.common.ConnectChecker; -import com.pedro.library.base.OnlyAudioBase; -import com.pedro.library.util.streamclient.SrtStreamClient; -import com.pedro.srt.srt.SrtClient; - -import java.nio.ByteBuffer; - -/** - * More documentation see: - * {@link OnlyAudioBase} - * - * Created by pedro on 8/9/23. - */ -public class SrtOnlyAudio extends OnlyAudioBase { - - private final SrtClient srtClient; - private final SrtStreamClient streamClient; - - public SrtOnlyAudio(ConnectChecker connectChecker) { - super(); - srtClient = new SrtClient(connectChecker); - streamClient = new SrtStreamClient(srtClient, null); - streamClient.setOnlyAudio(true); - } - - @Override - public SrtStreamClient getStreamClient() { - return streamClient; - } - - @Override - protected void setAudioCodecImp(AudioCodec codec) { - srtClient.setAudioCodec(codec); - } - - @Override - protected void prepareAudioRtp(boolean isStereo, int sampleRate) { - srtClient.setAudioInfo(sampleRate, isStereo); - } - - @Override - protected void startStreamRtp(String url) { - srtClient.connect(url); - } - - @Override - protected void stopStreamRtp() { - srtClient.disconnect(); - } - - @Override - protected void getAacDataRtp(ByteBuffer aacBuffer, MediaCodec.BufferInfo info) { - srtClient.sendAudio(aacBuffer, info); - } -} diff --git a/library/src/main/java/com/pedro/library/srt/SrtOnlyAudio.kt b/library/src/main/java/com/pedro/library/srt/SrtOnlyAudio.kt new file mode 100644 index 000000000..6e5da518e --- /dev/null +++ b/library/src/main/java/com/pedro/library/srt/SrtOnlyAudio.kt @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2023 pedroSG94. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.pedro.library.srt + +import android.media.MediaCodec +import com.pedro.common.AudioCodec +import com.pedro.common.ConnectChecker +import com.pedro.library.base.OnlyAudioBase +import com.pedro.library.util.streamclient.SrtStreamClient +import com.pedro.srt.srt.SrtClient +import java.nio.ByteBuffer + +/** + * More documentation see: + * [OnlyAudioBase] + * + * Created by pedro on 8/9/23. + */ +class SrtOnlyAudio(connectChecker: ConnectChecker) : OnlyAudioBase() { + + private val srtClient = SrtClient(connectChecker).apply { setOnlyAudio(true) } + private val streamClient = SrtStreamClient(srtClient, null) + + override fun getStreamClient(): SrtStreamClient = streamClient + + override fun setAudioCodecImp(codec: AudioCodec) { + srtClient.setAudioCodec(codec) + } + + override fun prepareAudioRtp(isStereo: Boolean, sampleRate: Int) { + srtClient.setAudioInfo(sampleRate, isStereo) + } + + override fun startStreamRtp(url: String) { + srtClient.connect(url) + } + + override fun stopStreamRtp() { + srtClient.disconnect() + } + + override fun getAacDataRtp(aacBuffer: ByteBuffer, info: MediaCodec.BufferInfo) { + srtClient.sendAudio(aacBuffer, info) + } +}