Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No ability to capture remote audio samples? #74

Open
wseemann opened this issue Oct 13, 2023 · 6 comments
Open

No ability to capture remote audio samples? #74

wseemann opened this issue Oct 13, 2023 · 6 comments

Comments

@wseemann
Copy link

Hello, thank you for this awesome library! I'm trying to implement recording of a remote WebRTC stream. I'm able to capture raw video frames using the addSink method on VideoTrack and write them to a file. There doesn't appear a similar method on AudioTrack. Does this library provide the ability to process remote audio sample? Thanks in advance.

@skydoves
Copy link
Member

Hey @wseemann, audio doesn't work by adding a track on the Sink, which renders Video streams.

You can refer to handing audio tracks from Stream's Video SDK.

@wseemann
Copy link
Author

Hello @skydoves, thank you for the reply. I looked over the sample you provided but this doesn't seem to address the issue outlined in my original question. The code snippet provided combines multiple media tracks into one. What I'm looking to do is capture the audio samples being sent by the server so I can save them to a file. As I noted, it is possible using addSink on the video track, but there doesn't appear to be a method to retrieve audio track samples. Is there something I'm misunderstanding in this snippet which allows me to do that?

@shenbengit
Copy link

@wseemann This library may be what you need,WebRTCExtension
use:

val audioDeviceModule = JavaAudioDeviceModule.builder(this)
     .setAudioTrackStateCallback(object : JavaAudioDeviceModule.AudioTrackStateCallback {
        override fun onWebRtcAudioTrackStart() {
            //kotlin
            audioDeviceModule.setAudioTrackSamplesReadyCallback {
                val audioFormat = it.audioFormat
                val channelCount = it.channelCount
                val sampleRate = it.sampleRate
                //pcm
                val data = it.data
            }
        }

        override fun onWebRtcAudioTrackStop() {
        }

}) 
.setSamplesReadyCallback {

}.createAudioDeviceModule()

@zibozeng
Copy link

@skydoves I'm also looking for the solution for detecting whether the remote user is talking. For what you posted above, I checked. I saw the comments for these two callbacks, says they are for detecting audio input, does it mean the local audio input or remote? since what i want to know is how to detect the remote users. What's more is this callback doesn't include any information about which audio track the data was coming through, so how do I detect which remote user is talking if there are multiple connections communicating around?

@tessmerandre
Copy link

@zibozeng have you found any solution for this? If so, do you mind sharing, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants