diff --git a/example/lib/config/agora.config.dart b/example/lib/config/agora.config.dart index 945487a81..05251467b 100644 --- a/example/lib/config/agora.config.dart +++ b/example/lib/config/agora.config.dart @@ -4,6 +4,11 @@ const appId = YOUR_APP_ID; /// Please refer to https://docs.agora.io/en/Agora%20Platform/token const token = YOUR_TOEKN; +/// Your channel ID const channelId = YOUR_CHANNEL_ID; + +/// Your int user ID const uid = YOUR_UID; + +/// Your string user ID const stringUid = YOUR_STRING_UID; diff --git a/example/lib/examples/advanced/index.dart b/example/lib/examples/advanced/index.dart index f9dbc5175..6f8a58df0 100644 --- a/example/lib/examples/advanced/index.dart +++ b/example/lib/examples/advanced/index.dart @@ -1,5 +1,6 @@ import 'package:agora_rtc_engine_example/examples/advanced/multi_channel.dart'; +/// Data source for advanced examples final Advanced = [ {'name': 'Advanced'}, {'name': 'MultiChannel', 'widget': MultiChannel()} diff --git a/example/lib/examples/advanced/multi_channel.dart b/example/lib/examples/advanced/multi_channel.dart index c05a43166..4171029d1 100644 --- a/example/lib/examples/advanced/multi_channel.dart +++ b/example/lib/examples/advanced/multi_channel.dart @@ -10,8 +10,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:permission_handler/permission_handler.dart'; -const channelId0 = 'channel0'; -const channelId1 = 'channel1'; +const _channelId0 = 'channel0'; +const _channelId1 = 'channel1'; /// MultiChannel Example class MultiChannel extends StatefulWidget { @@ -54,7 +54,7 @@ class _State extends State { await [Permission.microphone, Permission.camera].request(); } - widget._channel0 = await RtcChannel.create(channelId0); + widget._channel0 = await RtcChannel.create(_channelId0); this._addListener(widget._channel0); await widget._channel0.setClientRole(ClientRole.Broadcaster); @@ -67,7 +67,7 @@ class _State extends State { await [Permission.microphone, Permission.camera].request(); } - widget._channel1 = await RtcChannel.create(channelId1); + widget._channel1 = await RtcChannel.create(_channelId1); this._addListener(widget._channel1); await widget._channel1.setClientRole(ClientRole.Broadcaster); @@ -80,11 +80,11 @@ class _State extends State { channel.setEventHandler( RtcChannelEventHandler(joinChannelSuccess: (channel, uid, elapsed) { log('joinChannelSuccess ${channel} ${uid} ${elapsed}'); - if (channelId == channelId0) { + if (channelId == _channelId0) { setState(() { isJoined0 = true; }); - } else if (channelId == channelId1) { + } else if (channelId == _channelId1) { setState(() { isJoined1 = true; }); @@ -95,12 +95,12 @@ class _State extends State { log('userOffline ${channel.channelId} $uid $reason'); }, leaveChannel: (stats) { log('leaveChannel ${channel.channelId} ${stats.toJson()}'); - if (channelId == channelId0) { + if (channelId == _channelId0) { this.setState(() { isJoined0 = false; remoteUid0.clear(); }); - } else if (channelId == channelId1) { + } else if (channelId == _channelId1) { this.setState(() { isJoined1 = false; remoteUid1.clear(); @@ -109,21 +109,21 @@ class _State extends State { }, remoteVideoStateChanged: (uid, state, reason, elapsed) { log('remoteVideoStateChanged ${uid} ${state} ${reason} ${elapsed}'); if (state == VideoRemoteState.Starting) { - if (channelId == channelId0) { + if (channelId == _channelId0) { this.setState(() { remoteUid0.add(uid); }); - } else if (channelId == channelId1) { + } else if (channelId == _channelId1) { this.setState(() { remoteUid1.add(uid); }); } } else if (state == VideoRemoteState.Stopped) { - if (channelId == channelId0) { + if (channelId == _channelId0) { this.setState(() { remoteUid0.removeWhere((element) => element == uid); }); - } else if (channelId == channelId1) { + } else if (channelId == _channelId1) { this.setState(() { remoteUid1.removeWhere((element) => element == uid); }); @@ -168,7 +168,7 @@ class _State extends State { this._joinChannel0(); } }, - child: Text('${isJoined0 ? 'Leave' : 'Join'} $channelId0'), + child: Text('${isJoined0 ? 'Leave' : 'Join'} $_channelId0'), ), ) ], @@ -185,7 +185,7 @@ class _State extends State { this._joinChannel1(); } }, - child: Text('${isJoined1 ? 'Leave' : 'Join'} $channelId1'), + child: Text('${isJoined1 ? 'Leave' : 'Join'} $_channelId1'), ), ) ], @@ -200,27 +200,27 @@ class _State extends State { children: [ RaisedButton( onPressed: this._publishChannel0, - child: Text('Publish ${channelId0}'), + child: Text('Publish ${_channelId0}'), ), RaisedButton( onPressed: () { setState(() { - renderChannelId = channelId0; + renderChannelId = _channelId0; }); }, - child: Text('Render ${channelId0}'), + child: Text('Render ${_channelId0}'), ), RaisedButton( onPressed: this._publishChannel1, - child: Text('Publish ${channelId1}'), + child: Text('Publish ${_channelId1}'), ), RaisedButton( onPressed: () { setState(() { - renderChannelId = channelId1; + renderChannelId = _channelId1; }); }, - child: Text('Render ${channelId1}'), + child: Text('Render ${_channelId1}'), ), ], ), @@ -231,9 +231,9 @@ class _State extends State { _renderVideo() { List remoteUid = null; - if (renderChannelId == channelId0) { + if (renderChannelId == _channelId0) { remoteUid = remoteUid0; - } else if (renderChannelId == channelId1) { + } else if (renderChannelId == _channelId1) { remoteUid = remoteUid1; } return Expanded( diff --git a/example/lib/examples/basic/index.dart b/example/lib/examples/basic/index.dart index 7e3fbc9d5..3db05577a 100644 --- a/example/lib/examples/basic/index.dart +++ b/example/lib/examples/basic/index.dart @@ -2,6 +2,7 @@ import 'package:agora_rtc_engine_example/examples/basic/join_channel_audio.dart' import 'package:agora_rtc_engine_example/examples/basic/join_channel_video.dart'; import 'package:agora_rtc_engine_example/examples/basic/string_uid.dart'; +/// Data source for basic examples final Basic = [ {'name': 'Basic'}, {'name': 'JoinChannelAudio', 'widget': JoinChannelAudio()}, diff --git a/example/lib/examples/basic/join_channel_video.dart b/example/lib/examples/basic/join_channel_video.dart index dbd0e49a9..068cac6d9 100644 --- a/example/lib/examples/basic/join_channel_video.dart +++ b/example/lib/examples/basic/join_channel_video.dart @@ -157,27 +157,26 @@ class _State extends State { child: Stack( children: [ RtcLocalView.SurfaceView(), - if (remoteUid != null) - Align( - alignment: Alignment.topLeft, - child: SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Row( - children: List.of(remoteUid.map( - (e) => GestureDetector( - onTap: this._switchRender, - child: Container( - width: 120, - height: 120, - child: RtcRemoteView.SurfaceView( - uid: e, - ), + Align( + alignment: Alignment.topLeft, + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Row( + children: List.of(remoteUid.map( + (e) => GestureDetector( + onTap: this._switchRender, + child: Container( + width: 120, + height: 120, + child: RtcRemoteView.SurfaceView( + uid: e, ), ), - )), - ), + ), + )), ), - ) + ), + ) ], ), ); diff --git a/lib/agora_rtc_engine_web.dart b/lib/agora_rtc_engine_web.dart index f2b9604b0..59939e20d 100644 --- a/lib/agora_rtc_engine_web.dart +++ b/lib/agora_rtc_engine_web.dart @@ -1,4 +1,5 @@ import 'dart:async'; + // In order to *not* need this ignore, consider extracting the "web" version // of your plugin as a separate package, instead of inlining it in the same // package as the core of your plugin. @@ -11,7 +12,7 @@ import 'package:flutter_web_plugins/flutter_web_plugins.dart'; /// A web implementation of the AgoraRtcEngine plugin. class AgoraRtcEngineWeb { static void registerWith(Registrar registrar) { - final MethodChannel channel = MethodChannel( + final channel = MethodChannel( 'agora_rtc_engine', const StandardMethodCodec(), registrar.messenger, @@ -28,11 +29,11 @@ class AgoraRtcEngineWeb { switch (call.method) { case 'getPlatformVersion': return getPlatformVersion(); - break; default: throw PlatformException( code: 'Unimplemented', - details: 'agora_rtc_engine for web doesn\'t implement \'${call.method}\'', + details: + 'agora_rtc_engine for web doesn\'t implement \'${call.method}\'', ); } } diff --git a/lib/rtc_channel.dart b/lib/rtc_channel.dart index c89b8681b..256fcb38f 100644 --- a/lib/rtc_channel.dart +++ b/lib/rtc_channel.dart @@ -1,2 +1,2 @@ -export 'src/events.dart' show RtcChannelEventHandler; +export 'src/events.dart' hide RtcEngineEventHandler; export 'src/rtc_channel.dart' show RtcChannel; diff --git a/lib/rtc_engine.dart b/lib/rtc_engine.dart index 8919aefe4..fdf09d846 100644 --- a/lib/rtc_engine.dart +++ b/lib/rtc_engine.dart @@ -1,5 +1,5 @@ export 'src/classes.dart'; export 'src/enums.dart'; -export 'src/events.dart' show RtcEngineEventHandler; +export 'src/events.dart' hide RtcChannelEventHandler; export 'src/rtc_engine.dart' show RtcEngine; export 'src/rtc_engine_extension.dart'; diff --git a/lib/src/events.dart b/lib/src/events.dart index 203945008..050f6edd7 100644 --- a/lib/src/events.dart +++ b/lib/src/events.dart @@ -2,96 +2,153 @@ import 'classes.dart'; import 'enum_converter.dart'; import 'enums.dart'; +// ignore: public_member_api_docs typedef EmptyCallback = void Function(); +// ignore: public_member_api_docs typedef WarningCallback = void Function(WarningCode warn); +// ignore: public_member_api_docs typedef ErrorCallback = void Function(ErrorCode err); +// ignore: public_member_api_docs typedef ApiCallCallback = void Function( ErrorCode error, String api, String result); +// ignore: public_member_api_docs typedef UidWithElapsedAndChannelCallback = void Function( String channel, int uid, int elapsed); +// ignore: public_member_api_docs typedef RtcStatsCallback = void Function(RtcStats stats); +// ignore: public_member_api_docs typedef UserAccountCallback = void Function(int uid, String userAccount); +// ignore: public_member_api_docs typedef UserInfoCallback = void Function(int uid, UserInfo userInfo); +// ignore: public_member_api_docs typedef ClientRoleCallback = void Function( ClientRole oldRole, ClientRole newRole); +// ignore: public_member_api_docs typedef UidWithElapsedCallback = void Function(int uid, int elapsed); +// ignore: public_member_api_docs typedef UserOfflineCallback = void Function(int uid, UserOfflineReason reason); +// ignore: public_member_api_docs typedef ConnectionStateCallback = void Function( ConnectionStateType state, ConnectionChangedReason reason); +// ignore: public_member_api_docs typedef NetworkTypeCallback = void Function(NetworkType type); +// ignore: public_member_api_docs typedef TokenCallback = void Function(String token); +// ignore: public_member_api_docs typedef AudioVolumeCallback = void Function( List speakers, int totalVolume); +// ignore: public_member_api_docs typedef UidCallback = void Function(int uid); +// ignore: public_member_api_docs typedef ElapsedCallback = void Function(int elapsed); +// ignore: public_member_api_docs typedef VideoFrameCallback = void Function(int width, int height, int elapsed); +// ignore: public_member_api_docs typedef UidWithMutedCallback = void Function(int uid, bool muted); +// ignore: public_member_api_docs typedef VideoSizeCallback = void Function( int uid, int width, int height, int rotation); +// ignore: public_member_api_docs typedef RemoteVideoStateCallback = void Function(int uid, VideoRemoteState state, VideoRemoteStateReason reason, int elapsed); +// ignore: public_member_api_docs typedef LocalVideoStateCallback = void Function( LocalVideoStreamState localVideoState, LocalVideoStreamError error); +// ignore: public_member_api_docs typedef RemoteAudioStateCallback = void Function(int uid, AudioRemoteState state, AudioRemoteStateReason reason, int elapsed); +// ignore: public_member_api_docs typedef LocalAudioStateCallback = void Function( AudioLocalState state, AudioLocalError error); +// ignore: public_member_api_docs typedef FallbackCallback = void Function(bool isFallbackOrRecover); +// ignore: public_member_api_docs typedef FallbackWithUidCallback = void Function( int uid, bool isFallbackOrRecover); +// ignore: public_member_api_docs typedef AudioRouteCallback = void Function(AudioOutputRouting routing); +// ignore: public_member_api_docs typedef RectCallback = void Function(Rect rect); +// ignore: public_member_api_docs typedef NetworkQualityCallback = void Function(NetworkQuality quality); +// ignore: public_member_api_docs typedef NetworkQualityWithUidCallback = void Function( int uid, NetworkQuality txQuality, NetworkQuality rxQuality); +// ignore: public_member_api_docs typedef LastmileProbeCallback = void Function(LastmileProbeResult result); +// ignore: public_member_api_docs typedef LocalVideoStatsCallback = void Function(LocalVideoStats stats); +// ignore: public_member_api_docs typedef LocalAudioStatsCallback = void Function(LocalAudioStats stats); +// ignore: public_member_api_docs typedef RemoteVideoStatsCallback = void Function(RemoteVideoStats stats); +// ignore: public_member_api_docs typedef RemoteAudioStatsCallback = void Function(RemoteAudioStats stats); +// ignore: public_member_api_docs typedef AudioMixingStateCallback = void Function( AudioMixingStateCode state, AudioMixingErrorCode errorCode); +// ignore: public_member_api_docs typedef SoundIdCallback = void Function(int soundId); +// ignore: public_member_api_docs typedef RtmpStreamingStateCallback = void Function( String url, RtmpStreamingState state, RtmpStreamingErrorCode errCode); +// ignore: public_member_api_docs typedef StreamInjectedStatusCallback = void Function( String url, int uid, InjectStreamStatus status); +// ignore: public_member_api_docs typedef StreamMessageCallback = void Function( int uid, int streamId, String data); +// ignore: public_member_api_docs typedef StreamMessageErrorCallback = void Function( int uid, int streamId, ErrorCode error, int missed, int cached); +// ignore: public_member_api_docs typedef MediaRelayStateCallback = void Function( ChannelMediaRelayState state, ChannelMediaRelayError code); +// ignore: public_member_api_docs typedef MediaRelayEventCallback = void Function(ChannelMediaRelayEvent code); +// ignore: public_member_api_docs typedef VideoFrameWithUidCallback = void Function( int uid, int width, int height, int elapsed); +// ignore: public_member_api_docs typedef UrlWithErrorCallback = void Function(String url, ErrorCode error); +// ignore: public_member_api_docs typedef UrlCallback = void Function(String url); +// ignore: public_member_api_docs typedef TransportStatsCallback = void Function( int uid, int delay, int lost, int rxKBitRate); +// ignore: public_member_api_docs typedef UidWithEnabledCallback = void Function(int uid, bool enabled); +// ignore: public_member_api_docs typedef EnabledCallback = void Function(bool enabled); +// ignore: public_member_api_docs typedef AudioQualityCallback = void Function( int uid, int quality, int delay, int lost); +// ignore: public_member_api_docs typedef MetadataCallback = void Function( String buffer, int uid, int timeStampMs); +// ignore: public_member_api_docs typedef FacePositionCallback = void Function( int imageWidth, int imageHeight, List faces); +// ignore: public_member_api_docs typedef StreamPublishStateCallback = void Function( String channel, StreamPublishState oldState, StreamPublishState newState, int elapseSinceLastState); +// ignore: public_member_api_docs typedef StreamSubscribeStateCallback = void Function( String channel, int uid, StreamSubscribeState oldState, StreamSubscribeState newState, int elapseSinceLastState); +// ignore: public_member_api_docs typedef RtmpStreamingEventCallback = void Function( String url, RtmpStreamingEvent eventCode); +// ignore: public_member_api_docs typedef UserSuperResolutionEnabledCallback = void Function( int uid, bool enabled, SuperResolutionStateReason reason); +// ignore: public_member_api_docs typedef UploadLogResultCallback = void Function( String requestId, bool success, UploadErrorReason reason); @@ -881,8 +938,6 @@ class RtcEngineEventHandler { /// Occurs when the first audio frame is published. /// - /// - /// /// The SDK triggers this callback under one of the following circumstances: /// - The local client enables the audio module and calls [RtcEngine.joinChannel] successfully. /// - The local client calls [RtcEngine.muteLocalAudioStream] (`true`) and [RtcEngine.muteLocalAudioStream] (`false`) in sequence. @@ -894,8 +949,6 @@ class RtcEngineEventHandler { /// Occurs when the first video frame is published. /// - /// - /// /// The SDK triggers this callback under one of the following circumstances: /// - The local client enables the video module and calls [RtcEngine.joinChannel] successfully. /// - The local client calls [RtcEngine.muteLocalVideoStream] (`true`) and [RtcEngine.muteLocalVideoStream] (`false`) in sequence. @@ -907,8 +960,6 @@ class RtcEngineEventHandler { /// Occurs when the audio publishing state changes. /// - /// - /// /// This callback indicates the publishing state change of the local audio stream. /// /// The `StreamPublishStateCallback` typedef includes the following parameters: @@ -920,8 +971,6 @@ class RtcEngineEventHandler { /// Occurs when the video publishing state changes. /// - /// - /// /// This callback indicates the publishing state change of the local video stream. /// /// The `StreamPublishStateCallback` typedef includes the following parameters: @@ -933,8 +982,6 @@ class RtcEngineEventHandler { /// Occurs when the audio subscribing state changes. /// - /// - /// /// This callback indicates the subscribing state change of a remote audio stream. /// /// The `StreamSubscribeStateCallback` typedef includes the following parameters: @@ -946,8 +993,6 @@ class RtcEngineEventHandler { /// Occurs when the video subscribing state changes. /// - /// - /// /// This callback indicates the subscribing state change of a remote video stream. /// /// The `StreamSubscribeStateCallback` typedef includes the following parameters: @@ -959,8 +1004,6 @@ class RtcEngineEventHandler { /// Reports events during the RTMP or RTMPS streaming. /// - /// - /// /// The `RtmpStreamingEventCallback` typedef includes the following parameters: /// - [String] `url`: The RTMP or RTMPS streaming URL. /// - [RtmpStreamingEvent] `eventCode`: The event code. See [RtmpStreamingEvent]. @@ -1688,8 +1731,6 @@ class RtcChannelEventHandler { /// Occurs when the audio publishing state changes. /// - /// - /// /// This callback indicates the publishing state change of the local audio stream. /// /// The `StreamPublishStateCallback` typedef includes the following parameters: @@ -1701,8 +1742,6 @@ class RtcChannelEventHandler { /// Occurs when the video publishing state changes. /// - /// - /// /// This callback indicates the publishing state change of the local video stream. /// /// The `StreamPublishStateCallback` typedef includes the following parameters: @@ -1714,8 +1753,6 @@ class RtcChannelEventHandler { /// Occurs when the audio subscribing state changes. /// - /// - /// /// This callback indicates the subscribing state change of a remote audio stream. /// /// The `StreamSubscribeStateCallback` typedef includes the following parameters: @@ -1727,8 +1764,6 @@ class RtcChannelEventHandler { /// Occurs when the video subscribing state changes. /// - /// - /// /// This callback indicates the subscribing state change of a remote video stream. /// /// The `StreamSubscribeStateCallback` typedef includes the following parameters: @@ -1740,8 +1775,6 @@ class RtcChannelEventHandler { /// Reports events during the RTMP or RTMPS streaming. /// - /// - /// /// The `RtmpStreamingEventCallback` typedef includes the following parameters: /// - [String] `url`: The RTMP or RTMPS streaming URL. /// - [RtmpStreamingEvent] `eventCode`: The event code. See [RtmpStreamingEvent]. diff --git a/lib/src/rtc_engine.dart b/lib/src/rtc_engine.dart index 4542ed7d8..8678fd4fb 100644 --- a/lib/src/rtc_engine.dart +++ b/lib/src/rtc_engine.dart @@ -68,10 +68,6 @@ class RtcEngine with RtcEngineInterface { /// Creates an [RtcEngine] instance. /// - /// **Deprecated** - /// - /// This method is deprecated since v3.3.1. - /// /// Unless otherwise specified, all the methods provided by the RtcEngine class are executed asynchronously. Agora recommends calling these methods in the same thread. /// /// **Note** @@ -117,8 +113,7 @@ class RtcEngine with RtcEngineInterface { /// - The error code, if this method call fails: /// - [ErrorCode.InvalidAppId] @deprecated - static Future createWithAreaCode( - String appId, AreaCode areaCode) async { + static Future createWithAreaCode(String appId, AreaCode areaCode) { return createWithConfig(RtcEngineConfig(appId, areaCode: areaCode)); } diff --git a/test/agora_rtc_engine_test.dart b/test/agora_rtc_engine_test.dart index 51e4ffebf..a8582a269 100644 --- a/test/agora_rtc_engine_test.dart +++ b/test/agora_rtc_engine_test.dart @@ -4,7 +4,7 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { - const MethodChannel channel = MethodChannel('agora_rtc_engine'); + const channel = MethodChannel('agora_rtc_engine'); TestWidgetsFlutterBinding.ensureInitialized();