diff --git a/lib/src/agora_rtc_engine.dart b/lib/src/agora_rtc_engine.dart index a51160a71..25fd3f57b 100644 --- a/lib/src/agora_rtc_engine.dart +++ b/lib/src/agora_rtc_engine.dart @@ -1739,6 +1739,7 @@ class RtcEngineEventHandler { this.onRtmpStreamingStateChanged, this.onRtmpStreamingEvent, this.onTranscodingUpdated, + this.onAudioRoutingChanged, this.onChannelMediaRelayStateChanged, this.onChannelMediaRelayEvent, this.onLocalPublishFallbackToAudioOnly, @@ -2423,6 +2424,13 @@ class RtcEngineEventHandler { /// When the LiveTranscoding class in the method updates, the SDK triggers the onTranscodingUpdated callback to report the update information. If you call the method to set the LiveTranscoding class for the first time, the SDK does not trigger this callback. final void Function()? onTranscodingUpdated; + /// Occurs when the local audio route changes. + /// + /// This method is for Android, iOS and macOS only. + /// + /// * [routing] The current audio routing. See AudioRoute. + final void Function(int routing)? onAudioRoutingChanged; + /// Occurs when the state of the media stream relay changes. /// /// The SDK returns the state of the current media relay with any error message. diff --git a/lib/src/binding/agora_rtc_engine_event_impl.dart b/lib/src/binding/agora_rtc_engine_event_impl.dart index 21299a328..35670535c 100644 --- a/lib/src/binding/agora_rtc_engine_event_impl.dart +++ b/lib/src/binding/agora_rtc_engine_event_impl.dart @@ -1283,6 +1283,21 @@ class RtcEngineEventHandlerWrapper implements EventLoopEventHandler { rtcEngineEventHandler.onTranscodingUpdated!(); return true; + case 'onAudioRoutingChanged': + if (rtcEngineEventHandler.onAudioRoutingChanged == null) { + return true; + } + final jsonMap = jsonDecode(eventData); + RtcEngineEventHandlerOnAudioRoutingChangedJson paramJson = + RtcEngineEventHandlerOnAudioRoutingChangedJson.fromJson(jsonMap); + paramJson = paramJson.fillBuffers(buffers); + int? routing = paramJson.routing; + if (routing == null) { + return true; + } + rtcEngineEventHandler.onAudioRoutingChanged!(routing); + return true; + case 'onChannelMediaRelayStateChanged': if (rtcEngineEventHandler.onChannelMediaRelayStateChanged == null) { return true; diff --git a/lib/src/binding/event_handler_param_json.dart b/lib/src/binding/event_handler_param_json.dart index f87340467..099cbcc0b 100644 --- a/lib/src/binding/event_handler_param_json.dart +++ b/lib/src/binding/event_handler_param_json.dart @@ -3326,6 +3326,33 @@ extension RtcEngineEventHandlerOnTranscodingUpdatedJsonBufferExt } } +@JsonSerializable(explicitToJson: true) +class RtcEngineEventHandlerOnAudioRoutingChangedJson { + const RtcEngineEventHandlerOnAudioRoutingChangedJson({this.routing}); + + @JsonKey(name: 'routing') + final int? routing; + factory RtcEngineEventHandlerOnAudioRoutingChangedJson.fromJson( + Map json) => + _$RtcEngineEventHandlerOnAudioRoutingChangedJsonFromJson(json); + Map toJson() => + _$RtcEngineEventHandlerOnAudioRoutingChangedJsonToJson(this); +} + +extension RtcEngineEventHandlerOnAudioRoutingChangedJsonBufferExt + on RtcEngineEventHandlerOnAudioRoutingChangedJson { + RtcEngineEventHandlerOnAudioRoutingChangedJson fillBuffers( + List bufferList) { + if (bufferList.isEmpty) return this; + return this; + } + + List collectBufferList() { + final bufferList = []; + return bufferList; + } +} + @JsonSerializable(explicitToJson: true) class RtcEngineEventHandlerOnChannelMediaRelayStateChangedJson { const RtcEngineEventHandlerOnChannelMediaRelayStateChangedJson( diff --git a/lib/src/binding/event_handler_param_json.g.dart b/lib/src/binding/event_handler_param_json.g.dart index e7ab726a0..f1abcf15b 100644 --- a/lib/src/binding/event_handler_param_json.g.dart +++ b/lib/src/binding/event_handler_param_json.g.dart @@ -2353,6 +2353,19 @@ Map _$RtcEngineEventHandlerOnTranscodingUpdatedJsonToJson( RtcEngineEventHandlerOnTranscodingUpdatedJson instance) => {}; +RtcEngineEventHandlerOnAudioRoutingChangedJson + _$RtcEngineEventHandlerOnAudioRoutingChangedJsonFromJson( + Map json) => + RtcEngineEventHandlerOnAudioRoutingChangedJson( + routing: json['routing'] as int?, + ); + +Map _$RtcEngineEventHandlerOnAudioRoutingChangedJsonToJson( + RtcEngineEventHandlerOnAudioRoutingChangedJson instance) => + { + 'routing': instance.routing, + }; + RtcEngineEventHandlerOnChannelMediaRelayStateChangedJson _$RtcEngineEventHandlerOnChannelMediaRelayStateChangedJsonFromJson( Map json) => diff --git a/tool/terra/.yarnrc.yml b/tool/terra/.yarnrc.yml index 71338f830..f03163f41 100644 --- a/tool/terra/.yarnrc.yml +++ b/tool/terra/.yarnrc.yml @@ -1,3 +1,3 @@ nodeLinker: node-modules -yarnPath: .yarn/releases/yarn-4.0.1.cjs +yarnPath: .yarn/releases/yarn-4.0.2.cjs diff --git a/tool/terra/package.json b/tool/terra/package.json index 998f0f31e..e8f0b496a 100644 --- a/tool/terra/package.json +++ b/tool/terra/package.json @@ -19,5 +19,5 @@ "ts-node": "^10.9.1", "typescript": "^5.1.6" }, - "packageManager": "yarn@4.0.1" + "packageManager": "yarn@4.0.2" } diff --git a/tool/terra/terra_config_main.yaml b/tool/terra/terra_config_main.yaml index 82834b3d2..8519fd898 100644 --- a/tool/terra/terra_config_main.yaml +++ b/tool/terra/terra_config_main.yaml @@ -2,6 +2,8 @@ parsers: - name: LegacyCXXParser package: '@agoraio-extensions/terra-legacy-cxx-parser' args: + language: dart + nativeSdkVersion: 4.1.1.21 includeHeaderDirs: - '@agoraio-extensions/terra_shared_configs:headers/rtc_4.1.1.21/include' parseFiles: @@ -17,7 +19,6 @@ parsers: - '@agoraio-extensions/terra_shared_configs:headers/rtc_4.1.1.21/include/IAgoraParameter.h' customHeaders: - '@agoraio-extensions/terra_shared_configs:headers/rtc_4.1.1.21/custom_headers/*.h' - language: dart legacyRenders: - DartSyntaxRender - DartEventHandlerParamJsonRender