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

Provide access to decrypted AudioPackets, regardless of sequence number #418

Closed
mentlerd opened this issue Jul 28, 2017 · 17 comments
Closed
Assignees
Labels
level: experienced requires some java/jda experience status: completed has been completed but is not yet released type: feature

Comments

@mentlerd
Copy link

For applications that wish to do per-user voice recording an API like this would be really useful.

The responsibility of having to reassemble the audio stream from out-of-order packets should be placed on the consumers of the interface.

@SparklingComet
Copy link

It would be really useful, but recording people without them knowing in a (group)voice chat is illegal in many countries. It should be restricted to the currently logged in user's voice, if possible. (Not sure whether it is)

@Almighty-Alpaca
Copy link
Collaborator

People can and will always abuse features. Restricting recording to yourself (which is implementation wise something entirely different from recording others btw) just because someone might use on other people without their knowledge is really bad imo.

@SparklingComet
Copy link

SparklingComet commented Jul 28, 2017

Restricting recording to yourself (which is implementation wise something entirely different from recording others btw)

I thought so

Restricting recording to yourself just because someone might use on other people without their knowledge is really bad imo.

True, but we are allowing them to do so by adding this. If I am speaking with someone and I want to record only myself, I can use a mic/recording software. A bot will allow abusing and nothing else.

@MinnDevelopment
Copy link
Member

JDA already supports receiving the audio of users when they speak. I don't understand how this discussion is relevant to the thread.

@SparklingComet
Copy link

JDA already supports receiving the audio of users when they speak. I don't understand how this discussion is relevant to the thread.

It's relevant to the suggestion - whether or not it makes sense.

@MinnDevelopment
Copy link
Member

The suggestion has nothing to do with the fact that you can already implement such a functionality with the current state of JDA. It is requested to give access to unhandled frames to users.
You are talking about generally having voice receive support which is already a thing thus discussing whether it should be restricted or not is nonsense.

@SparklingComet
Copy link

The suggestion has nothing to do with the fact that you can already implement such a functionality with the current state of JDA. It is requested to give access to unhandled frames to users.
You are talking about generally having voice receive support which is already a thing thus discussing whether it should be restricted or not is nonsense.

If it's already a thing, the whole issue can be closed. It's not my reply, but the issue itself that's redundant.

@MinnDevelopment
Copy link
Member

No you don't even understand what is requested, stop arguing about something that is completely irrelevant to this thread please.

@DV8FromTheWorld
Copy link
Member

@mentlerd I don't see the use case.

Additionally, it really isn't the client's responsibility to decode and ensure packet ordering. That is the entire point of a library. It abstracts that system so that the client doesn't have to care about it. Also, to properly decode audio packets, we have to keep a semblance of order, otherwise OPUS's decoding algorithms get mad and can produce jarring audio artifacts

If you want UserSpecific audio recording (e.g, not the combined audio of all users), JDA already provides that.

@mentlerd
Copy link
Author

mentlerd commented Aug 7, 2017

My use case would be a "rolling window" voice recorder bot, that would allow to capture the last X minutes of conversation, with separate channels for each user.

Since this application is not realtime at all, I could just save the packets in the order I receive them onto the disk, then later reassemble each user's complete stream (accounting for packet order, and discord not sending audio packets for continuous silence), decode OPUS and encode the audio to a different format.

This approach requires other metadata to be saved to the disk, but as you have mentioned before, this application is out of the scope of the library.

I am only asking for an API to access raw AudioPackets, and possibly disable OPUS decoding to save on performance.

@Sanduhr32
Copy link
Contributor

Sanduhr32 commented Aug 7, 2017

Discord sends the AudioPackets in the OPUS format so JDA wont or cant change that (i dunno i'm not staff) , and you can access the packets via AudioReceiveHandler using the methods handleUserAudio or handleCombinedAudio. Here is an example

//Be sure you set the AudioReceiveHandler in the (Guild) AudioManager
public void handleCombinedAudio(CombinedAudio combinedAudio) {
    combinedAudio.getAudioData(1.0)); //The 1.0 is the volume which should be a double
    //The Method docs can be found here: http://home.dv8tion.net:8080/job/JDA/lastSuccessfulBuild/javadoc/net/dv8tion/jda/core/audio/AudioReceiveHandler.html#handleCombinedAudio-net.dv8tion.jda.core.audio.CombinedAudio-
    //I recommend to use a volume between 0.0 and 2.0 because it isnt changing the length of the bytes too much and isnt too loud or too quiet
    //You can use handleUserAudio too
    //If you want to create a recordigs bot and only for a few you can use switch/case and their user id's
    //If you want to save the packets i recommend a FileOutputStream to a pcm file
}

I hope that helps you.
Regards Sanduhr

PS: I recommend Audacity for converting the pcm into the format of your choice

@mentlerd
Copy link
Author

mentlerd commented Aug 7, 2017

I appreciate your attempt to help, but I am very well aware of the current interface of the audio system.
What I am requesting currently cannot be done without the modification of the library core files.

This is not a support/help ticket, and I have done my homework on the subject.

@DV8FromTheWorld
Copy link
Member

I appreciate the PR and I will review it after audio-resume, however, based on your use case, I don't see why this can't be implemented with current functionality.

Could you possibly elaborate as to why you cant capture the PCM output via UserAudio and save that to the disk?

@DV8FromTheWorld
Copy link
Member

DV8FromTheWorld commented Aug 18, 2017

@MinnDevelopment has further elaborated on your use-case in a way that I missed.

You basically need what the AudioSendHandler has, a flag to determine isOpus, but instead of encoding, prevent decoding.

I will review your PR, but most likely AudioReceiveHandler will have a method in which you can decide whether to use opus decoding or not.

@DV8FromTheWorld
Copy link
Member

I do have plans for this, namely a boolean hook in AudioReceiveHandler to control decoding, similar to the isOpus hook in AudioSendHandler

@mpotthoff
Copy link

I'm actually in need of the same feature. It seems like @MinnDevelopment has already started working on it in feature/opus-interceptor half a year ago. For now, I'm using a rebased version of it and it seems to be working fine so far. Are there any plans to finish it?

@MinnDevelopment
Copy link
Member

There are currently no plans to work on voice receive at all due to #904

@MinnDevelopment MinnDevelopment mentioned this issue May 6, 2019
6 tasks
@MinnDevelopment MinnDevelopment added status: in progress already in the process of being implemented and removed up for grabs labels May 6, 2019
@MinnDevelopment MinnDevelopment removed this from the JDA Longtime Goals milestone May 6, 2019
@MinnDevelopment MinnDevelopment added status: completed has been completed but is not yet released and removed status: in progress already in the process of being implemented labels Jun 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
level: experienced requires some java/jda experience status: completed has been completed but is not yet released type: feature
Projects
None yet
Development

No branches or pull requests

7 participants