Skip to content

Add audio recording for Android Platform #1884

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

Merged
merged 9 commits into from
Jul 25, 2025
Merged

Conversation

maloleroy
Copy link
Contributor

Hi, I've been working with @Aul16 on a project that requires audio-only recording using the sip_ua package. He implemented it for the Android platform in Java and after thorough testing, it works as a charm. It produces a MP3 file.

Here is some demo code that is now possible on a SIP/WebRTC audio call:

// On call start
final recorder = MediaRecorder();
await recorder.start(
  path,
  audioChannel: RecorderAudioChannel.INPUT, // or RecorderAudioChannel.OUTPUT
);
// On call stop
await recorder.stop();

Here, "on call start" means in sip_ua something like

call.peerConnection!.onAddStream = (MediaStream stream) async {
  // Add a small delay to ensure the stream is fully established
  await Future.delayed(const Duration(milliseconds: 500));
  await startRecording(); // apparently the stream parameter is not needed
}

and "on call stop" means something like

// in a SipUaHelperListener's callStateChanged
if (state.state == CallStateEnum.FAILED || state.state == CallStateEnum.ENDED) {
  stopRecording();
}

We also tested using multiple MediaRecorder instances at once, one on RecorderAudioChannel.INPUT and one on RecorderAudioChannel.OUTPUT (for the both sides of a phone call), and it apparently doesn't cause any problems.

Note that we didn't make any automated tests and that there is still no implementation for other platforms than Android.

@maloleroy
Copy link
Contributor Author

While this PR doesn't exactly solve these issues, I'm mentioning #1677 and #1501 here

Copy link
Member

@cloudwebrtc cloudwebrtc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@cloudwebrtc cloudwebrtc merged commit fc20336 into flutter-webrtc:main Jul 25, 2025
8 checks passed
@cloudwebrtc cloudwebrtc mentioned this pull request Jul 25, 2025
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

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy