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

Opus Interceptor #1001

Merged
merged 17 commits into from
Jun 10, 2019
Merged

Opus Interceptor #1001

merged 17 commits into from
Jun 10, 2019

Conversation

MinnDevelopment
Copy link
Member

@MinnDevelopment MinnDevelopment commented May 6, 2019

Pull Request Etiquette

Changes

  • Internal code
  • Library interface (affecting end-user code)
  • Documentation
  • Other: _____

Closes Issue: #418

Description

Provide a new receive handling for raw opus packets to lazy decode incoming packages.

Example

class Recorder : AudioSendHandler, AudioReceiveHandler {
    var playback = false
    private val queue = LinkedBlockingQueue<OpusPacket>()

    override fun isOpus() = true // we can just passthrough

    override fun canProvide() = playback && queue.isNotEmpty()

    override fun provide20MsAudio(): ByteBuffer {
        val opus = queue.poll().getOpusAudio() // no decoding needed
        return ByteBuffer.wrap(opus)
    }

    override fun canReceiveEncoded() = !playback

    override fun handleEncodedAudio(packet: OpusPacket) {
        queue += packet
    }

// ignored
    override fun canReceiveCombined() = false
    override fun canReceiveUser() = false

    override fun handleCombinedAudio(combinedAudio: CombinedAudio) {}
    override fun handleUserAudio(userAudio: UserAudio) {}
}

# Conflicts:
#	build.gradle
#	src/main/java/net/dv8tion/jda/api/audio/factory/DefaultSendSystem.java
#	src/main/java/net/dv8tion/jda/internal/audio/AudioConnection.java
#	src/main/java/net/dv8tion/jda/internal/audio/AudioPacket.java
#	src/main/java/net/dv8tion/jda/internal/audio/Decoder.java
#	src/main/java/net/dv8tion/jda/internal/requests/WebSocketClient.java
#	src/main/java/net/dv8tion/jda/internal/utils/IOUtil.java
#	src/main/java/net/dv8tion/jda/webhook/WebhookMessage.java
#	src/main/java/net/dv8tion/jda/webhook/WebhookMessageBuilder.java
@MinnDevelopment MinnDevelopment added status: documentation needed lacks documentation, either partially or completely priority: low size: medium labels May 6, 2019
# Conflicts:
#	src/main/java/net/dv8tion/jda/internal/requests/WebSocketClient.java
@MinnDevelopment
Copy link
Member Author

Just as a reminder to myself: I haven't updated the AudioEchoExample to use opus because it needs combined audio which isn't supported when only listening for opus.

@MinnDevelopment MinnDevelopment removed the status: documentation needed lacks documentation, either partially or completely label Jun 7, 2019
@MinnDevelopment MinnDevelopment added this to the v4 beta milestone Jun 7, 2019
@MinnDevelopment MinnDevelopment merged commit eb19aff into v4 Jun 10, 2019
@MinnDevelopment MinnDevelopment deleted the feature/opus-interceptor branch June 10, 2019 22:47
MinnDevelopment added a commit that referenced this pull request Jun 11, 2019
* Add opus receiving capabilities
* Make methods in AudioReceiveHandler defaults
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants