Skip to content

Commit

Permalink
migrate only audio
Browse files Browse the repository at this point in the history
  • Loading branch information
pedroSG94 committed Mar 29, 2024
1 parent 39bd2f1 commit 3a9ba23
Show file tree
Hide file tree
Showing 6 changed files with 174 additions and 228 deletions.
76 changes: 0 additions & 76 deletions library/src/main/java/com/pedro/library/rtmp/RtmpOnlyAudio.java

This file was deleted.

58 changes: 58 additions & 0 deletions 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)
}
}
76 changes: 0 additions & 76 deletions library/src/main/java/com/pedro/library/rtsp/RtspOnlyAudio.java

This file was deleted.

58 changes: 58 additions & 0 deletions 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)
}
}
76 changes: 0 additions & 76 deletions library/src/main/java/com/pedro/library/srt/SrtOnlyAudio.java

This file was deleted.

0 comments on commit 3a9ba23

Please sign in to comment.