Skip to content

Commit

Permalink
Add missing onAudioRoutingChanged
Browse files Browse the repository at this point in the history
  • Loading branch information
littleGnAl committed Nov 16, 2023
1 parent 097c9db commit d76c270
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 3 deletions.
8 changes: 8 additions & 0 deletions lib/src/agora_rtc_engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1739,6 +1739,7 @@ class RtcEngineEventHandler {
this.onRtmpStreamingStateChanged,
this.onRtmpStreamingEvent,
this.onTranscodingUpdated,
this.onAudioRoutingChanged,
this.onChannelMediaRelayStateChanged,
this.onChannelMediaRelayEvent,
this.onLocalPublishFallbackToAudioOnly,
Expand Down Expand Up @@ -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.
Expand Down
15 changes: 15 additions & 0 deletions lib/src/binding/agora_rtc_engine_event_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
27 changes: 27 additions & 0 deletions lib/src/binding/event_handler_param_json.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, dynamic> json) =>
_$RtcEngineEventHandlerOnAudioRoutingChangedJsonFromJson(json);
Map<String, dynamic> toJson() =>
_$RtcEngineEventHandlerOnAudioRoutingChangedJsonToJson(this);
}

extension RtcEngineEventHandlerOnAudioRoutingChangedJsonBufferExt
on RtcEngineEventHandlerOnAudioRoutingChangedJson {
RtcEngineEventHandlerOnAudioRoutingChangedJson fillBuffers(
List<Uint8List> bufferList) {
if (bufferList.isEmpty) return this;
return this;
}

List<Uint8List> collectBufferList() {
final bufferList = <Uint8List>[];
return bufferList;
}
}

@JsonSerializable(explicitToJson: true)
class RtcEngineEventHandlerOnChannelMediaRelayStateChangedJson {
const RtcEngineEventHandlerOnChannelMediaRelayStateChangedJson(
Expand Down
13 changes: 13 additions & 0 deletions lib/src/binding/event_handler_param_json.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tool/terra/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.0.1.cjs
yarnPath: .yarn/releases/yarn-4.0.2.cjs
2 changes: 1 addition & 1 deletion tool/terra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
},
"packageManager": "[email protected].1"
"packageManager": "[email protected].2"
}
3 changes: 2 additions & 1 deletion tool/terra/terra_config_main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit d76c270

Please sign in to comment.