utd_media_client 2.12.0
utd_media_client: ^2.12.0 copied to clipboard
UTD Media Client — real-time audio and video for Flutter (iOS, Android, Web).
Changelog #
2.12.0 #
The Android build now uses the UTD audio library (io.utdstream:rtc, native library libutdstream_rtc.so) instead of the stock
io.github.webrtc-sdk:android AAR, and the AI noise suppression and the software echo canceller no longer need a fork of
flutter_webrtc. (2.11.0 was prepared but never published: everything in it is in this release.) Until now 2.10.0 declared the stock
library, so the audio improvements built into ours (AI noise suppression, the music mode, the audio-chain patches) were never in an app's
build, and UtdmClient.initialize handed softwareVoiceProcessing and fieldTrials (the UTD-AiNs flag) to the engine only through
our fork of the plugin: the official flutter_webrtc from pub.dev ignores both. They now go to the audio library itself, before the native
engine is built, through UtdmAudioProcessing.configureEngine. Additive: no existing signature changed, and the options map initialize
sends to the plugin is unchanged, so a fork keeps working.
-
New (Android):
UtdmMusicPlayer, the music player of the audio library. The host plays a song into the room (MP3, AAC, M4A, WAV; a file path, acontent://URI or anhttp(s)://URL). The song goes into the reference of the echo canceller, so it does not come back as an echo;setPublishEnabled(true)also mixes it into the audio that everybody hears (off by default, with a limiter in front of the mix so it cannot clip); the local and the published volumes are independent (setLocalVolume,setPublishVolume, 0 to 1). While a song plays, the AI noise suppression of the microphone moves to its music mode by itself. API:UtdmMusicPlayer.instance(one per process: the audio engine is built once),load(uri),play,pause,resume,stop,seekTo(ms),setLoopCount(n)(0 once, -1 for ever),getPositionMs,getDurationMs,getState, the streamevents(UtdmMusicStateChanged,UtdmMusicPositionevery 250 ms while playing,UtdmMusicCompleted) and thestatusnotifier a screen can draw from. States: idle, loading, ready, playing, paused, stopped, error; errors: none, unsupported format, open failed, decoder failed, engine not built.loadanswers at once and the result comes through the events. Additive: nothing changed for an app that does not use it. Not available on other platforms (UtdmMusicPlayer.isAvailableis false andloadthrowsUtdmMusicUnavailableException). The server can switch it off with the field trialUTD-MusicPlayer/Disabled/(loadthen ends in the error state, engine not built). A muted host still sends the song (the mute is not told to the server while a song is sent). While a song is sent to the room (setPublishEnabled(true)and a song playing or paused),LocalTrack.mute()on the microphone disables the native track as before (the audio library then zeroes the microphone and mixes only the song) andmutedstays true here, but the server is NOT told a track mute: a muted track stops the audio of the track, and the song with it. The new eventTrackMuteHoldChangedEvent(held)andLocalTrack.muteHeldFromServersay so, so an app can tell the room who is muted (utd_stream_sdk0.5.4 and the kits do, with the data topicutd.mic_state). When the song stops, is paused for good, ends or the sending is switched off while the user is still muted, the track mute is sent then; when a song starts while the user is already muted for the server, the track is opened for the server again and the native track stays disabled; the unmute is told to the server only if the mute was. A mute that comes FROM the server or an admin (SignalRemoteMuteTrackEvent) is a full mute: the server is told, nothing is held, and the song that was sent stops. The native track is disabled before the muted state is announced and enabled before the unmuted one, and a restart of a muted microphone (a device change) opens its new capture disabled. The reconcile after a participant update and the publish request after a restart do not tell the server the held mute. TheMicCaptureGuarddoes NOT release a muted capture in the background while a song is sent (the song runs on the pulse of the capture, and the microphone itself stays silenced in the audio library): the system microphone indicator stays on while the song is sent, and the guard works as before when the song stops. In the background the song needs a foreground service of type microphone (UtdmForegroundService, which the UTD kits start on a seat): the song is sent on the pulse of the capture, and without that service Android silences the capture of an app in the background, so the room stops hearing the song (measured on a Samsung A17 with the service on: the song kept reaching the room in the background while the host was muted, and when it ended the microphone was released and the indicator went off). Copyright is the app developer's: UTD Stream does not check or license the songs; the developer is responsible for the licenses of what users play into a room. Needs the audio library build that carries the player. Known limit: while a song plays from the loudspeaker and is NOT published, the room hears a faint echo of it from the host's open microphone (measured on a Samsung A17: about −45 dBFS at the listeners, against about −17 dBFS for the same song when it is published); the echo canceller removes music less than speech. -
Fix (privacy):
Track.disable()now disables the native track even when the track has not been started yet. It did nothing before the track was started, and a track is started by its publish, so a track that an app disabled and then published (to publish it muted) was published ENABLED and sent the microphone until the mute that followed. Nowdisable()then publish sends silence from the first frame, and starting does not enable the track.enable()is unchanged. Test:test/track/disable_before_start_test.dart. -
Behavior change: mute keeps the microphone open (the ZEGO-style mute), the only mute of the microphone, for every app that upgrades. It is NOT opt-in: an app whose pubspec has a caret (
^2.10.1, or a kit orutd_stream_sdkthat depends on it) gets this on its nextpub upgrade. A mute disables the track: it stays published and the far end receives silence, while the capture and the echo canceller keep running, so an unmute is instant and does not bring an echo burst with it. In the audio library (build20261123T150003Z, patch 0013UTD-MuteKeepsMic, on by default) a mute no longer stops and restarts the Android recording (that fast stop/start could crash the recording thread,AudioRecordJavaThread). What the user sees: the system microphone indicator (the green dot) stays on for as long as the user is muted in the foreground. That is by design; say so in your privacy policy and in the Play Store Data safety form. The microphone is closed for real in two cases: the track is muted AND the app goes to the background (a guard insideRoom:LocalTrack.releaseCapture()lets the sender go of the track and stops it, so the native library closes the recording; when the app is backLocalTrack.reacquireCapture()puts a new track back, disabled, still muted), and when the track is unpublished or the room is left. A paused or inactive state that is only a permission dialog or the app switcher (inactive) is not the background. This is Android: on iOSreleaseCapturestops the track only and the OS indicator is not measured. New public API:LocalTrack.releaseCapture(),LocalTrack.reacquireCapture(),LocalTrack.captureReleased.mute,unmute,releaseCapture,reacquireCaptureandrestartTrackof one track now run one at a time (an unmute during a release, or during a reacquire, used to leave a dead capture or open two). Fix:AudioCaptureOptions.copyWithdroppedstopAudioCaptureOnMute,voiceIsolationandprocessor; it keeps them now (an app that calledcopyWith(...)while relying on the old default must check). There is no option for the app to go back to the old mute (AudioCaptureOptions.stopAudioCaptureOnMuteis removed, see Removed below). Only UTD Stream can, from the server, with the field trialUTD-MuteKeepsMic/Disabled/inUtdmClient.initialize(fieldTrials: ...)(read once, when the engine is built: it needs a new process). With it on, the audio library stops and restarts the recording on a mute as before, and Dart does the same: a mute of a microphone track lets go of the sender (replaceTrack(null)) and stops the capture, an unmute opens a new capture and puts it back, and the background guard does nothing. The switch is set only byUtdmClient.initialize(fieldTrials: ...): callingUtdmAudioProcessing.configureEngine(fieldTrials: ...)directly passes the trial to the audio library but does NOT set the Dart side, so always go throughinitialize. -
Removed:
AudioCaptureOptions.stopAudioCaptureOnMute(the field, the constructor parameter and thecopyWithparameter). The mute of a microphone is always the keep-open mute and the app has no choice of it. Upgrade step: deletestopAudioCaptureOnMute:from your code (anyAudioCaptureOptions(...)orcopyWith(...)that passes it; the code does not compile until you do). Only UTD Stream can bring the old mute back, from the server, with the field trialUTD-MuteKeepsMic/Disabled/. -
Echo cancellation and noise suppression are ours on every Android phone. On the media audio profile (
mediaAudioProfile: true, what the UTD room kits use), the phone's own echo canceller and noise suppressor are switched off and the audio library's echo canceller (AEC3) and noise suppression run instead, the same on every device, whatever the phone advertises.UtdmClient.initialize(preferPlatformVoiceProcessing: true)(the per-model opt-out the kits used, e.g. forM2004J7AC) is now ignored on Android; the parameter stays so existing callers compile. iOS keeps Apple's voice-processing unit. -
Fix: the echo when the audio moves to another device (a Bluetooth headset taken off, the loudspeaker, the earpiece). The echo canceller kept the old device's echo path until it found the new one by itself: on a Samsung A17, taking a Bluetooth headset off let the far end hear the room's own echo for about 6 s (up to −27 dBFS). The audio library (patch 0019
UTD-RouteRealign, on by default) now hears the change from the system (the playout device and the communication device) and the echo canceller starts again on the new path at once: the delay is estimated again and it is careful until it holds, while the noise suppression and the rest keep their state and the microphone is not reopened. A device that changes back and forth re-aligns once, after it settles (300 ms), never twice within 2 s, and a session where nobody touches the audio never re-aligns (10 minutes measured: none). Cost, on a switch TO the earpiece only: the microphone moves with it to its in-ear path, much louder, so the room hears nothing from the microphone for about 4 s after that switch (it comes back over 250 ms); a song that is being sent keeps playing. Any other switch (loudspeaker, Bluetooth, wired) loses nothing of what the user says. Measured on a Samsung A17 with the far end talking, the echo after the switch: to the earpiece 0.25 to 0.75 s at −16 to −40 dBFS in 6 runs of 6 (without the fix 1 to 2.75 s at −6.5 to −9 dBFS); to the loudspeaker none in 5 of 6 and 0.5 s in one (without it 0.5 to 1.25 s). The server turns it off with the field trialUTD-RouteRealign/Disabled/(read once, when the engine is built). The Bluetooth headset itself is not measured yet (the switch measured is the loudspeaker / earpiece one from the app). -
AI noise suppression on by default (Android).
UtdmClient.initializenow always asks the audio library for its AI noise suppression with the settings measured against ZEGO (UTD-AiNs/Enabled,model:rnnoise,floor:30/), unless the field trials already carry aUTD-AiNskey: the server turns it off withUTD-AiNs/Disabled/(kill switch, read once when the engine is built) or sends other settings of its own. Nothing to do in the app. -
AI residual-echo suppressor on by default on 64-bit ARM Android (
UTD-AiRes): the short echo of the first microphone opening is mostly gone. Until now an unmute in the first seconds after taking a seat could let up to a second of echo through while the echo canceller was still learning the device; what is left is, in some runs, a quarter of a second at the very instant the microphone opens.UtdmClient.initializenow also asks the audio library for its AI residual-echo suppressor (UTD-AiRes/Enabled,t:300,s:500,gate:1/) when the AI noise suppression is on and the app runs as 64-bit ARM (the ABI of the app's process, not what the phone supports; never on 32-bit ARM). Measured on a Samsung A17 (Android 17) with this release's defaults (AI noise suppression floor 30), the far end talking and the user silent, the first 14.5 s after the microphone opens, 10 runs each way: echo above −45 dBFS at the listeners in 1 of 10 runs with it (a single 0.25 s burst at −36 dBFS at the very instant the microphone opened) against 8 of 10 without it (UTD-AiRes/Disabled/: up to 1.5 s, up to −28 dBFS); a first check of 4 runs on the same build had one such 0.25 s burst too (−32 dBFS, at the instant the microphone opened). The user's own voice is not removed (the double-talk loss is about 4.4 dB, the same as with the noise suppression alone). Cost per 10 ms of audio: about 130 µs at the core's maximum clock, 391 µs raw at the clock it really ran at (about 32 % of the maximum). A CPU guard in the audio library turns it off for the rest of the process on a phone too slow for it (two 5 s windows in a row over 400 µs per 10 ms at the core's maximum clock, or over 1.5 ms whatever the clock); the echo canceller then goes on with its own estimate in place, with no echo burst. In the music/singing mode (UtdmAudioProcessing.setMusicMode(true), and whileUtdmMusicPlayerplays a song) it is bypassed like the AI noise suppression and comes back when the mode ends (host-tested; on a Samsung A17 its state was seen switching to bypassed while a song played, the sound itself is not measured on a phone yet). Off: the server sendsUTD-AiRes/Disabled/(kill switch, read once when the engine is built), andUTD-AiNs/Disabled/turns both off. Measured on one phone model so far; an unmute right after the app was in the background while muted (the capture starts anew there; before, up to a second of echo) is not measured with it yet. -
New:
UtdmAudioProcessing.configureEngine({softwareVoiceProcessing, fieldTrials})answers, per setting, whether the audio library took it ({}on another platform or an older library), andUtdmAudioProcessing.engineConfig()returns what the library holds now. They need the audio library build that hassetUtdSoftwareVoiceProcessing/setUtdFieldTrials(patch 0010); this release pinsio.utdstream:rtcbuild20261123T150003Z(AAR sha256af693047fcd58c6134a4f94e36e8f58fa7acd3365d6a043f99af6907ca3cbf67), which has them. With the stock library or an older build the calls answer "not available" and nothing else happens. -
Same classes, different native library. The Java API is the stock one (
org.webrtc.*) plus fourteen static methods onExternalAudioProcessingFactory(setUtdMusicMode,getUtdAiNsState,getUtdAiNsCpuUs,getUtdAiNsModel,getUtdAiResCpuUs,getUtdAiNsCpuRawUs,getUtdAiNsClockPercent,setUtdSoftwareVoiceProcessing,getUtdSoftwareVoiceProcessing,setUtdFieldTrials,getUtdFieldTrials,getUtdAiResCpuRawUs,getUtdAiResClockPercent,getUtdAiResState); a comparison of the two libraries found no other change in the Java API or in the exported native symbols, so code that compiled against the stock library compiles and links against ours. The native library is loaded asutdstream_rtcinstead ofjingle_peerconnection_so. Its size is about 10 % larger per ABI. The library is built from the same WebRTC revision as the stock one (M144,ec20be4f), by us, with our patches (licences: see theNOTICEinside the AAR). -
How an app gets it: nothing to do. The plugin adds the repository (
https://maven.udt-stream.com/, asked for the groupio.utdstreamonly) to the app's build and replaces the stockio.github.webrtc-sdk:androiddependency, whichflutter_webrtcbrings, with ours, so the APK holds ONE copy oforg.webrtc. A Flutter app cannot useRepositoriesMode.FAIL_ON_PROJECT_REPOS(Flutter's own Gradle plugin adds a project repository, so the build fails before it reaches us); withRepositoriesMode.PREFER_SETTINGS, which ignores project repositories, add these two lines to thedependencyResolutionManagement { repositories { ... } }block of yoursettings.gradle(flutter_webrtcneeds the first, we need the second):maven { url = uri("https://jitpack.io") }andexclusiveContent { forRepository { maven { url = uri("https://maven.udt-stream.com/") } }; filter { includeGroup("io.utdstream") } }. The first build downloads the AAR (all four ABIs, about 53 MB; the APK keeps only the ABIs it targets); builds without network access need the artifact in your own mirror. If your app has a dependency override on the webrtc-utd fork of flutter_webrtc, you can keep it or remove it: both build and use the UTD Stream library with 2.12.0; the fork is no longer required. -
What an app sees. A different native library name inside the APK (
libutdstream_rtc.so). An app that referenced the stock library file by name (jingle_peerconnection_so), or that keeps ProGuard rules for it, must follow; the Java classes are unchanged, so the usual-keep class org.webrtc.**rules still apply. -
Checked on clean apps (Flutter's current Gradle, AGP 9.0.1) and on a handset (Samsung A17), for the build and
aiNsState()only (the mute behavior has its own measurements, in the release notes of the audio library build): the build passes without a duplicateorg.webrtcclass, the APK holdslibutdstream_rtc.soand nolibjingle_peerconnection_so, andUtdmAudioProcessing.aiNsState()answers a number. Not yet checked: an app that closes its repositories. -
How to check that you have it:
UtdmAudioProcessing.aiNsState()answers an integer instead of null on Android.
2.10.2 #
Fix: a room whose full restart could not re-publish a local track stayed "reconnecting" for ever. After the engine rebuilds the connection it re-publishes the local tracks and only then emits RoomReconnectedEvent. A re-publish that threw (the microphone track was already gone: addTransceiver(): track is null) ended the handler before the event, so the room never said it was back although both peer connections were connected; an app that waits for the event (utd_stream_sdk does) stayed on "reconnecting" until it was closed (measured on a handset, more than 100 s). The failure is now logged (warning) and RoomReconnectedEvent is emitted either way. New, additive: RoomReconnectedEvent.republishFailed (a list of TrackSource, empty by default and after a resume) names the local tracks that could NOT be published again after a full restart ([TrackSource.unknown] when the re-publish itself threw); a track that fails no longer stops the ones after it (LocalParticipant.lastRepublishFailures). A track listed there is not published: publish it again (setMicrophoneEnabled(true)) or show it as off. utd_stream_sdk 0.5.3 does that for the microphone by itself. Nothing else changed on the success path. Test: test/core/restart_republish_test.dart.
2.10.1 #
Fix: an app created with the current Flutter (Android Gradle Plugin 9) did not build with this plugin. The plugin compiled against
Android 34 while connectivity_plus, device_info_plus, flutter_webrtc and androidx.core 1.18 require 36, so the app failed at
:utd_media_client:checkReleaseAarMetadata. The plugin now compiles against 36. Nothing else changed: no Dart API, no manifest, no
minSdk. If you pinned compileSdk for the app, nothing to do; if your build failed with that message, upgrade to 2.10.1.
2.10.0 #
No public API was removed or changed: an app on ^2.9.9 that upgrades keeps compiling. It is NOT a drop-in upgrade for the
Android manifest, though: this version's plugin manifest is merged into EVERY app that depends on it, whether or not the app
ever calls UtdmForegroundService.start. See "Android manifest merge" below, and read it before you upgrade an app that
targets Android 14 (API 34).
-
Android manifest merge (read before upgrading). The plugin's
AndroidManifest.xmlnow adds to every app that uses this package the permissionsFOREGROUND_SERVICE,FOREGROUND_SERVICE_MICROPHONE,FOREGROUND_SERVICE_MEDIA_PLAYBACK,POST_NOTIFICATIONSandWAKE_LOCK, and a<service>of typemicrophone|mediaPlayback(io.utd.media.plugin.UtdmForegroundService, not exported). Nothing runs until Dart callsstart, but the declarations are in the app regardless. An app that targets API 34 and declares a foreground service must complete the foreground-service declaration in the Play Console (Microphone and Media playback types), even if it never starts this service; without it the upload can be rejected. If you do not want any of it (your app has its own service, or does not use a foreground service), remove it in your app'sandroid/app/src/main/AndroidManifest.xml:<service android:name="io.utd.media.plugin.UtdmForegroundService" tools:node="remove" />and a<uses-permission android:name="..." tools:node="remove" />line for each of the five permissions above (addxmlns:tools="http://schemas.android.com/tools"to<manifest>). Apps on the UTD kits (utd_audio_room_kit3.15.0 andutd_stream_sdk0.4.0) start the service for you by default; see their changelogs. -
New:
UtdmForegroundService(Android).start([UtdmForegroundServiceConfig])/stop()/isRunningfor a foreground service of typemicrophone|mediaPlaybackwith an ongoing, low-importance notification whose title, text, small icon, channel and id are the app's. Android 9+ silences the microphone of a backgrounded app without one, and Android 14+ requires the type andFOREGROUND_SERVICE_MICROPHONE; the plugin's manifest declares the permissions and the service (see "Android manifest merge" above for the Play Console declaration and how to remove them). Nothing runs until Dart callsstart; on other platforms the calls do nothing and answer false.UtdmForegroundServiceConfig(microphone: false)starts the same service asmediaPlaybackonly, for a user who listens to a room and is not on the microphone (the app needs noRECORD_AUDIOfor it). Callingstartagain on the running service withmicrophone: trueswitches it tomicrophone|mediaPlaybackand back, inside the same service: Android 12+ does not allow a foreground service to be STARTED from the background, but a running one can change its type. While it runs the service holds a partial wake lock and a Wi-Fi lock (WAKE_LOCK): the wake lock keeps the CPU awake with the screen off; the low-latency Wi-Fi lock is applied by Android only while the screen is on, so it may do nothing in the background; both are released with the service, and the wake lock has a timeout as a safety net (11 hours by default, orUtdmForegroundServiceConfig.wakeLockTimeout; callingstartagain restarts it). An app that removedWAKE_LOCKfrom its manifest runs without them. A refused microphone type no longer ends a running listener service: when Android refuses the switch tomicrophone|mediaPlayback(the app is in the background, orRECORD_AUDIOis missing) the service stays asmediaPlaybackandUtdmForegroundService.microphoneRefusedfires (true: still running; false: it stopped), so the app takes the user off the microphone while they keep hearing the room. Astop()that arrives before the system delivered thestartis served right afterstartForeground(stopping first crashed the app withForegroundServiceDidNotStartInTimeException); if the system never delivers that start, the stop is carried out after 10 seconds. -
Fix (Android, media audio profile): the room no longer falls to the earpiece when a speaker leaves a seat. On the media profile (
UtdmClient.initialize(mediaAudioProfile: true)) the audio configuration is re-applied each time the number of audio tracks changes (a speaker takes or leaves a seat, you included). It used the stockmediapreset, which hasforceHandleAudioRoutingoff, so each change switched the library's device handling off and the output fell back to the earpiece: a listener heard the room low from the ear piece after somebody stepped down, and a charger plugged in moved the sound to the loudspeaker for a moment and back. The profile now uses the same preset withforceHandleAudioRoutingon, and after each change the output is put back on the loudspeaker (a connected Bluetooth or wired headset first) unless the app chose otherwise withHardware.setSpeakerphoneOn(false). The communication profile (calls, and a publisher withoutmediaProfileWhilePublishing) is unchanged. Tested on a handset: the loudspeaker route. The Bluetooth / wired-headset preference is reviewed in the code (it is the library's ownsetSpeakerphoneOnButPreferBluetooth) but was not tested with a real headset. Apps on^2.9.9withmediaAudioProfile: trueget the fix by upgrading this package alone. -
New:
UtdmAudioProcessing(Android), the controls of the AI noise suppression of the UTD audio library.setMusicMode(bool)tells the noise suppression that a singing or music seat is speaking, so it leaves the voice alone (the speech-oriented model would clip a song; without the call a singer is processed as speech);aiNsState()andaiNsCpuUs()give the state of the suppression and the microphone-path time it takes per 10 ms, for a quality report. They call three static methods oforg.webrtc.ExternalAudioProcessingFactorythat exist only in a build of the audio library that carries the noise-suppression stage (found by name when called): on any other build, and on every other platform, each call answers false / null and changes nothing, so nothing breaks with the audio library you already use. The field trial that turns the suppression on isUtdmClient.initialize(fieldTrials:)withUTD-AiNs/Enabled,model:rnnoise,floor:N/(the SDK and the kits set it from the engine's per-device audio profile). New with this library:UtdmAudioProcessing.aiNsModel()(which model runs) andaiResCpuUs()(what the layer after the echo canceller costs), both null on a library without them. And, for telling a slow phone clock from a slow model:aiNsCpuRawUs()(the processor time of the suppression thread per 10 ms at the clock the cores really ran at;aiNsCpuUs()is that time scaled to the maximum clock) andaiNsClockPercent()(the mean clock of those cores as a percentage of their maximum); both are null when the library has none or cannot readcpufreq(it answers -1). -
The ICE state and the network type, for telemetry.
Room.eventsnow carriesRoomIceStateChangedEvent(state,previous,isPublisher,restarts: lower-casenew,checking,connected,completed,disconnected,failed,closed;restartscounts the ICE restarts a resume started), andUtdmNetwork(await UtdmNetwork.ensureStarted(), thenUtdmNetwork.type=wifi,cellular,ethernet,otherornone, andUtdmNetwork.changedWithin()) reads the connectivity events the engine already used. Additive: nothing existing changes, no new permission, no polling. -
Fix: an unanswered publisher offer no longer hangs every publish behind it. While the publisher waits for the answer to its offer (
have-local-offer), later negotiations only wait behind it; an answer that never comes (sent on a signal socket that was dying during a resume: measured once in eight network-cut runs on a handset) left the microphone dead until the user left. An offer now has 6 seconds; if it is still unanswered the engine starts ONE full reconnect (as livekit-client JS does). A reconnect that is already running owns the recovery on its own schedule: the watchdog never stands behind a watchdog, and re-arms only on a new offer.UtdmClient.negotiationTimeoutscounts the unanswered offers of the process, and each one is logged at warning level. Behavior change only for sessions that would have hung. -
Fix:
setLoggingLevelthrewUnsupported operationunless the app had enabled hierarchical logging; it enables it itself now. -
New:
UtdmClient.initialize(fieldTrials:). WebRTC field trials for the engine (Key/Value/Key2/Value2/), sent in the same options map assoftwareVoiceProcessingandandroidAudioConfigurationand applied once, when the native engine is built. Only keys that start withUTD-leave Dart (UtdmClient.sanitizeFieldTrialsdrops the rest and any key without a value); null or empty sends nothing, so an app that does not pass it sends exactly the map it sent before. Needs the plugin build that readsoptions['fieldTrials']; an older one ignores the key. -
New: stable error codes.
UtdmErrorCodelists the codes the UTD Stream engine sends in thecodefield of a refusal ({"message": "...", "code": "...", "retryable": false}), spelled as the engine sends them (includingrate_limitedandmedia_update_failed).UtdmException.codecarries one (String?), andConnectExceptiongets it when a refused connect is explained by the answer of the media server's/rtc/validatecheck. That answer comes from the media server (or the proxy in front of it), not from the engine, and in the usual case it is plain text such asaccess denied, so against a real media serverConnectException.codeisnull(measured: a 401 with a plain-text body). Do not rely on this package to surface UTD Stream engine error codes; take them from the engine's own REST answers (the kits' error catalog does that). It is filled only if that answer happens to be JSON and contains a stringcode; any other body (plain text, HTML, empty, malformed, a non-stringcode) leaves itnulland changes nothing else. Branch oncode, never onmessage: the text is free and can be reworded. A code this version does not know is passed through as-is.UtdmErrorCode.fromBody(String?)parses a body and never throws. No constructor changed incompatibly: the new parameter is optional and named. -
New, opt-in:
UtdmClient.initialize(mediaProfileWhilePublishing: true)keeps a speaker on the media profile (Android). Until now, withmediaAudioProfile: true, anyone holding a local microphone track was moved to the communication profile (MODE_IN_COMMUNICATION, voice-call stream) and everyone else stayed onMODE_NORMAL. With the new flag the speaker stays onMODE_NORMAL+ the music stream too, so a room is never a phone call. Defaultfalse: an app that does not pass it behaves exactly as on 2.9.x (pinned by tests). It needsmediaAudioProfile: true(orbypassVoiceProcessing) and changes no native option. Trade-off to know before turning it on: the echo canceller then has to cope with the music-path output delay by itself; the 2026-09-20 measurement that led to the communication profile for speakers was about exactly that. Check ERL/ERLE per handset after enabling. Also pinned by a test: the default mute (stopAudioCaptureOnMute: true) stops and disposes the native track and stream, it does not only silence an open microphone (whether the platform then releases the recorder is the engine's behavior, verify on a device). -
restartConnectiondoes not send LEAVE (unchanged on purpose). The signal connection is closed with no LEAVE, exactly as in 2.9.9. A LEAVE would reach every existing app and the engine reads it as the participant leaving for good, which can end a live or free a seat before the same identity rejoins. A test now pins this. -
Internal rename (no public API change): the generated protocol files under
lib/src/protoare nowutd_rtc,utd_modelsandutd_metricsinstead oflivekit_*. They are not exported. The protobuf package name in the generated code (thePackageNameconstants and the.package.Typenames) is nowutdstream, so the string "livekit" is no longer in a built app; the wire format is unchanged (the package name is not part of the binary messages the engine sends and reads; onlyAnytype URLs and reflection use it, and this package uses neither). The base64-encoded file descriptors inutd_rtc.pbjson.dartstill carry the old package name inside their bytes (the.pbjsontype-name maps were renamed, the descriptors were not regenerated); nothing reads them at runtime. -
isCloudUrlalways answersfalse. Region discovery only ever applied to hosts ending in.livekit.cloudor.livekit.run(the upstream hosted cloud, not UTD Stream). Every UTD Stream host, and every other host, is unchanged. Only an app that points this package at a.livekit.cloud/.livekit.runhost loses region discovery. -
Fix: a refused connect whose answer is not valid UTF-8 now still raises
ConnectException. Reading the answer's text threw aFormatExceptionthat replaced theConnectException(also in 2.9.9). The text is now decoded leniently in that case; a normal answer is read exactly as before.
Upgrading from 2.9.9: bump to ^2.10.0; nothing else is needed.
Not part of this package: the engine's /ws signaling closes (4001/4003/4006/4008) are read by utd_stream_sdk
and utd_signaling, not by this package, which talks to the media server only.
2.9.9 #
-
DataReceivedEvent.senderIdentity(new, optional): the identity the packet itself names, even when the room has no participant for it.DataReceivedEvent.participantis looked up by the packet's identity, so it isnullwhenever the room has no entry for the sender at that moment (his first packets before he was registered, a packet that arrives just after he left, a participant list being rebuilt), and thatnulllooked exactly like data sent from the Server API. A receiver that has to decide something about the sender (who to mute, whose chat to drop) could not tell "a participant I cannot resolve" from "the server", and a payload can name anyone.senderIdentityis the identity the server stamped on the packet; it isnullonly for data sent from the Server API, which carries none.Nothing else changes:
participantis resolved exactly as before, the constructor parameter is optional (existing code that builds aDataReceivedEventcompiles unchanged), and no event, field or default moves.
2.9.8 #
- The beauty filter survives a recovery re-publish. 2.9.7 added a fallback
that re-publishes the source when un-mute fails, but it built the new track
bare — so the processor
restartTrackcarefully preserves on the normal path was dropped on exactly the un-mute that had already gone wrong. The camera came back plain and nothing said why. The processor is now carried across, and a processor that refuses to re-attach is logged rather than allowed to sink the recovery: a camera back without its filter still beats a camera that never comes back.
2.9.7 #
Un-muting a track could fail and leave it muted for the rest of the session, silently.
-
With
stopOnMute(the default) un-mute runsrestartTrack(), which throws outright whensender == null— after a reconnect takes the sender with it, for instance — and can also throw fromgetUserMediawhen the OS has not finished releasing the capture device. InsideLocalTrack.unmutethat throw skipped bothenable()andupdateMuted(false): the track stayed stopped, the server was never told, and the UI showed a live microphone publishing nothing.Measured on a production host: after a
DUPLICATE_IDENTITYreconnect, the mic was un-muted and the participant then sat in their own live stream for 365 seconds having published zero seconds of audio — inaudible to their entire room, not only to a PK opponent. The camera showed the same shape in the same session (6 seconds published out of 365).setSourceEnablednow catches a failed un-mute, drops the dead publication and re-publishes the source from a fresh track, which does not depend on the old sender. The failure is logged at SEVERE instead of vanishing.
CHANGELOG #
2.9.6 #
-
A resume that does not hold is no longer treated as a recovery.
A subscriber peer connection can fail while the
resumethat answers it succeeds at the signalling layer. The engine then cleared the pending reconnect, which zeroesreconnectAttempts— anddefaultRetryDelaysInMs[0]is 0 ms. So the next failure retried instantly, from a zeroed counter, and the backoff could never grow to reach the full-reconnect escalation.Measured on a live room (2026-09-22, Samsung SM-A175F): 263 successful resumes in four minutes, one every 0.88 s, every one carrying
RR_SUBSCRIBER_FAILED, until the user closed the room by hand. Audio dropped on every cycle. The session recovered the moment a new connection replaced it — which is now automatic: three resumes that fail again inside ten seconds force a full reconnect. -
The video renderer has one writer for its track instead of five.
_attach()awaits in the middle, andsrcObjectwas written from the attach itself, the stream-updated listener,didUpdateWidget, the iOS platform-view callback anddisposeRenderer. Overlapping attaches resumed out of order, so the loser of the race wrote last. From the same session: the track was attached and then cleared again 16 ms later, leaving the camera black for the remote side until the whole room was rebuilt. Every write now carries the attach generation it was issued under and stale writers are dropped. -
Focus and exposure taps no longer throw into the app's error handler.
On Android these reach
CameraUtils.setFocusPoint, which dereferences the device orientation enum — null before the orientation manager attaches, so it throwsNullPointerException: 'int java.lang.Enum.ordinal()'. Unawaited, that surfaced as an unhandled async error, four times in one second on a single preview tap. Focus is a convenience; a handset that refuses it is now logged, not raised.
2.9.5 #
-
preferPlatformVoiceProcessing— hand echo cancellation to the device on handsets where ours measurably does not run.Measured on a Xiaomi M2004J7AC (Android 12), with our webrtc fork active and the media profile confirmed applied on every sample: ERL frozen at -29.1 dB and ERLE frozen at 0.18 across 24 consecutive reports — one distinct value, which is an instantiated canceller that never processed anything. On the same build, in the same room, a Samsung SM-A175F reported nine distinct ERLE values and removed up to 12 dB.
Nothing is left to configure on such a device: hardware cancellation is off, the call capture path is kept, software cancellation is requested and confirmed delivered. It does not run. So that handset gets the platform's canceller — which is what cleaned its audio in the field — and the caller decides per model.
Media ROUTING is unchanged either way: a listener is still never put in the telephony profile.
2.9.4 #
-
Asks for the one audio configuration that works on every handset, through an option our fork of the webrtc plugin adds: webrtc-utd.
Upstream exposes a single switch that reaches the Android audio device module, and it bundles five decisions: hardware AEC off, hardware NS off, stereo in, stereo out, and a raw MIC capture source instead of VOICE_COMMUNICATION. We need the first two and none of the last three — the capture source is what breaks software cancellation, because AEC3 aligns the microphone against what was played inside a bounded delay window and VOICE_COMMUNICATION is the low-latency path Android tunes for exactly that.
Measured on 2026-09-21 across one live room, three handsets, one build: a Samsung SM-A175F cancelling 8-12 dB, a Redmi Note 9 at 0.18-1.3 dB — nothing — and a third reporting no stats at all. The two failing devices also never went quiet on the wire while their user was silent, sending 15-58 kbps of room noise continuously, because the noise suppressor lives in the same module and was not running either.
Handing the job to the platform is not the safe answer: hardware cancellation is broken on a long tail of devices that advertise it (Signal ships a device blacklist for this), and ZEGO's own documentation says the system canceller is weaker on some Android handsets — which is why their default mode uses their own.
A build without the fork ignores the unknown option and falls back to the platform canceller, so this is safe to send unconditionally. To pick it up:
dependency_overrides: flutter_webrtc: git: url: https://github.com/UTD-Stream-Engine/webrtc-utd.git
2.9.3 #
-
The platform's own echo canceller does the work again — on the path where it actually runs.
2.9.1 broke a deadlock from the software side: the Android module announces a built-in canceller on Android 10+, libwebrtc's AEC3 stands down for it, and the built-in one never engaged because the media profile is
MODE_NORMAL. SendingbypassVoiceProcessingstopped the module claiming it, so AEC3 could run.It ran on some handsets. Measured across one live room on 2026-09-21, three phones on the same build: a Samsung SM-A175F cancelling 8-12 dB, a Redmi M2004J7AC frozen at 0.77 dB — AEC3 present and never converging — and a third reporting no audio-source stats at all. Software cancellation has to align the microphone against what was played inside a bounded delay window, and that window is a property of the device's audio path. Some devices fit it. Some never will, and no amount of tuning on our side changes that.
So the deadlock is broken from the other side instead. Since 2.9.2 a publisher runs in
MODE_IN_COMMUNICATION— the built-in canceller's home — so the module keeps its hardware AEC and its hardware noise suppressor, and the platform cancels on the path every phone vendor tests for its own call app. Where a device reports no built-in canceller, the module does not enable one and AEC3 runs as before: every device ends up with exactly one canceller, and the device's own declaration picks which.The cost, stated plainly: where the hardware canceller takes over, the software one stands down and stops reporting, so
echoReturnLossarrives null on those devices. Null now means "the platform is handling it". The device model that ships with every quality report is what identifies a handset that claims a canceller and cancels nothing.
2.9.2 #
-
The Android audio profile now follows the MICROPHONE, not the session. 2.9.1 let the software echo canceller run again, and on one handset it did: ERL ~20 dB, ERLE 6-9 dB, cancelling. On a second handset in the same live battle, on the same build, it sat at ERL -28 dB and ERLE 0.18 dB for the whole session — running, seeing the microphone far louder than the reference it was given, subtracting nothing. When that user muted, the other side was clean: the loop closed at the microphone of the device whose canceller never converged.
The reason is the media profile itself.
MODE_NORMALplays out over the music path — buffered, high latency, and latency that varies by device. The canceller aligns the microphone against what it played inside a bounded delay window; past that window it cannot subtract anything. One device fits, another does not, and nothing in the app can tell which.So a publisher now gets
MODE_IN_COMMUNICATION— Android's low-latency voice route, with a delay the canceller can align to — and a listener keeps the media profile, which is what the profile was for: no telephony state, no earpiece routing, other apps keep the microphone. The switch happens as the local audio track appears and reverses when the last one goes, so a listener who takes the microphone mid-session gets it too. That path used to run on iOS only: an Android session kept whatever profile it was given at connect for its entire life.The loudspeaker is re-asserted on every switch — the communication profile routes to the earpiece by default, and a broadcaster must not be moved there.
2.9.1 #
-
The media audio profile left Android 10+ with NO echo canceller at all.
mediaAudioProfilekept the software APM on at the track, as 2.9.0 intended — but the native audio module is built withsetUseHardwareAcousticEchoCanceler(SDK_INT >= Q), so on Android 10+ it announced a built-in AEC and libwebrtc's AEC3 stood down in its favour, while the built-in one never engaged under the profile'sMODE_NORMAL+ music stream. Each canceller stepped aside for the other.Measured on a live PK broadcast on 2026-09-20: 112 quality samples, the media profile applied on every one, the microphone live (
audioLevelup to 0.85), andechoReturnLoss/echoReturnLossEnhancementreported on zero of them. Both sides heard themselves come back.The module builder exposes no "hardware AEC off, software APM on" switch, so on Android only the media profile now passes the plugin's
bypassVoiceProcessingoption to the ENGINE — the module stops claiming a built-in AEC — whileNative.bypassVoiceProcessingstays false so capture constraints keep requesting echoCancellation / noiseSuppression / autoGainControl. AEC3 then runs. The rest of that option's bundle comes with it: raw MIC capture source, stereo input/output, no hardware NS.iOS is untouched: there the same option would bypass the voice-processing unit, which IS the canceller and does engage under the
playAndRecord+videoChatrecipe.Verification is the telemetry, not a listening test: ERL/ERLE arriving at all means a canceller is running.
2.9.0 #
-
Asking for media-style ROUTING was also switching every echo canceller off.
mediaAudioProfile: trueexists for one thing: keep the app out of the OS telephony profile so a LISTENER is never "in a call" — other apps keep the microphone (a WhatsApp voice note works with the room open), playout routes like music instead of to the earpiece, and the volume buttons move media volume. It was implemented by also passingbypassVoiceProcessingto the native engine, which on Android bundles five audio-device-module build settings (hardware AEC off, hardware NS off, stereo input, stereo output, andMediaRecorder.AudioSource.MICin place ofVOICE_COMMUNICATION), on iOS bypasses the voice-processing IO unit, and — throughAudioCaptureOptionsbeing overridden inoptions.dart— also forces WebRTC's own software APM (AEC/NS/AGC) off. A user on the mic and on the loudspeaker was therefore publishing a raw, unprocessed microphone, and the room heard itself come back.Routing and processing are two different decisions and are now spelled separately.
mediaAudioProfiledeclares only the Android media audio attributes;bypassVoiceProcessingkeeps its exact previous meaning for callers who ask for it explicitly. Nothing about the listener behaviour the profile exists for changes. -
Known limit, Android only. A device that advertises a built-in AEC makes libwebrtc's APM stand down in its favour, and a built-in AEC may not engage under
MODE_NORMAL. Keeping the software APM while suppressing only the hardware advertisement needs an ADM switch flutter_webrtc does not expose, and the Android audio MODE cannot be changed once a room is live:setAndroidAudioConfigurationwrites cached fields, andAudioManager.setModeruns only inside AudioSwitch's one-timeactivate(), which is not reachable again until every peer connection is disposed. On iOS there is no such limit — the voice-processing unit is back and cancelling.
2.8.5 #
- Uplink audio quality was invisible: every speaker looked perfect.
packetsLost,jitterandroundTripTimeare not fields ofoutbound-rtp— they are what the REMOTE end reports about what it received, and live in the linkedremote-inbound-rtpentry. The audio sender read all three offoutbound-rtp, where they are always null, and the caller turned that null into a zero. Measured on production: 802,417 quality reports with round-trip time null in ALL of them and loss reported as 0.0000 throughout — a speaker losing a fifth of their packets was indistinguishable from a flawless one. Now resolved throughremoteId, the same way the video sender already did. With no linked report yet the values stay NULL, so "not known" stays distinguishable from "no loss".
2.8.4 #
- A replaced subscriber data channel no longer keeps delivering. When the server opened a data channel for a label it had already opened (a subscriber renegotiation), the field was overwritten but the previous channel stayed OPEN with its message handler attached — so from then on every message on that label was handled once per still-attached channel, silently duplicating the room's own state updates and anything an app sends, for the rest of the session. The replaced channel is now detached and closed.
- Fixed an unbounded listener leak on the same path. The subscriber
channel's state-change handler registered ANOTHER listener on the publisher
channel every time it fired, so both the listener count and the emitted
SubscriberDataChannelStateUpdatedEvents grew without bound. It now subscribes once, reports the subscriber channel's own state (it previously reported the publisher's), and the subscription is cancelled when the channel is replaced or the connection is torn down.
2.8.3 #
- Loud failure when the audio profile can no longer be applied. The native
engine is built once per process and flutter_webrtc builds it implicitly
(call profile, no options) on the first native call of any kind — device
enumeration, a video renderer, a speakerphone toggle, another kit. A
UtdmClient.initialize(mediaAudioProfile: true)that arrives after that was silently a no-op: the room then ran in the call profile for the rest of the process, with no runtime way back.initializenow detects it and logs a SEVERE, unmistakable message instead;UtdmClient.engineHasMediaAudioProfileexposes the applied profile so a kit can assert it. Rule for integrators: the kit that owns the audio profile must be the first thing in the app to touch the media engine.
2.8.2 #
- Android: a listener's first join no longer plays through the earpiece.
Under the media profile (
mediaAudioProfile/bypassVoiceProcessing) the audio device module was still built with WebRTC's defaultUSAGE_VOICE_COMMUNICATIONplayout attributes. Android routes that usage with the phone strategy, so underMODE_NORMAL— with nothing having forced the speaker — playout went to the earpiece on a large share of devices until something activated device routing (which only happens once a local audio track exists). Leaving and re-entering "fixed" it, which is exactly how it was reported.initializenow passes media attributes (USAGE_MEDIA/CONTENT_TYPE_SPEECH) so playout routes like music — speaker, A2DP, wired — by platform policy from the first frame. No API change; the call-profile initialize is untouched.
2.8.1 #
- Fix compile error on older Dart front-ends:
publishOptionsaccesses inside the videonegotiate()closure relied on flow-analysis promotion that older SDKs reject after anawait("could not be promoted due to an 'await' or 'yield'"). Read the options once into a non-nullable local instead.
2.8.0 #
- Add
mediaAudioProfiletoUtdmClient.initialize: keeps the OS audio session in the media profile (AndroidMODE_NORMAL+musicstream on connect, no Apple voice-processing IO unit — same native layer asbypassVoiceProcessing) while the software audio processing (echoCancellation / noiseSuppression / autoGainControl) keeps followingAudioCaptureOptionsinstead of being forced off. Fixes degraded speaker audio (no AEC/NS/AGC at all) in media-mode rooms.bypassVoiceProcessingsemantics are unchanged: media profile AND raw, unprocessed microphone. - Fix
AudioCaptureOptions.toMediaConstraintsMap(): thevoiceIsolationconstraint was populated fromnoiseSuppressioninstead of thevoiceIsolationfield.
2.7.1 #
- Fix iOS/macOS build failure:
ios/Classesandmacos/ClassesSwift sources were published as symlink path stubs (plain-text files containing../../shared_swift/...) instead of real code, breakingpod installbuilds with "Expressions are not allowed at the top level". Sources are now real files.
2.7.0 #
- Realtime audio, video and data channels for Flutter across iOS, Android, Web, macOS, Windows and Linux.
- Adaptive stream and dynacast for efficient bandwidth usage.
- Screen sharing on all supported platforms.
- End-to-end encryption for audio/video.
- Declarative, event-driven room and participant APIs.