Skip to content

Commit

Permalink
chore: optimize code by formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
LichKing-2234 committed Jun 28, 2021
1 parent 9eabe45 commit 9a1baae
Show file tree
Hide file tree
Showing 17 changed files with 1,253 additions and 833 deletions.
28 changes: 4 additions & 24 deletions example/lib/examples/advanced/create_stream_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class _State extends State<CreateStreamData> {
late final RtcEngine _engine;
bool isJoined = false;
int? remoteUid;
bool isLowAudio = true;

@override
void initState() {
Expand All @@ -44,7 +43,7 @@ class _State extends State<CreateStreamData> {

// make this room live broadcasting room
await _engine.setChannelProfile(ChannelProfile.LiveBroadcasting);
await this._updateClientRole(ClientRole.Broadcaster);
await _engine.setClientRole(ClientRole.Broadcaster);

// Set audio route to speaker
await _engine.setDefaultAudioRoutetoSpeakerphone(true);
Expand Down Expand Up @@ -113,32 +112,13 @@ class _State extends State<CreateStreamData> {
}));
}

_updateClientRole(ClientRole role) async {
var option;
if (role == ClientRole.Broadcaster) {
await _engine.setVideoEncoderConfiguration(VideoEncoderConfiguration(
dimensions: VideoDimensions(640, 360),
frameRate: VideoFrameRate.Fps30,
orientationMode: VideoOutputOrientationMode.Adaptative));
// enable camera/mic, this will bring up permission dialog for first time
await _engine.enableLocalAudio(true);
await _engine.enableLocalVideo(true);
} else {
// You have to provide client role options if set to audience
option = ClientRoleOptions(isLowAudio
? AudienceLatencyLevelType.LowLatency
: AudienceLatencyLevelType.UltraLowLatency);
}
await _engine.setClientRole(role, option);
}

_onPressSend() async {
if (_controller.text.length == 0) {
return;
}

var streamId = await _engine.createDataStreamWithConfig(
DataStreamConfig(syncWithAudio: false, ordered: false));
var streamId = await _engine
.createDataStreamWithConfig(DataStreamConfig(false, false));
if (streamId != null) {
_engine.sendStreamMessage(streamId, _controller.text);
}
Expand All @@ -158,7 +138,7 @@ class _State extends State<CreateStreamData> {
children: [
Expanded(
flex: 1,
child: RaisedButton(
child: ElevatedButton(
onPressed: _initEngine,
child: Text('Join channel'),
),
Expand Down
16 changes: 9 additions & 7 deletions example/lib/examples/advanced/live_streaming.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,18 @@ class _State extends State<LiveStreaming> {
var option;
if (role == ClientRole.Broadcaster) {
await _engine.setVideoEncoderConfiguration(VideoEncoderConfiguration(
dimensions: VideoDimensions(640, 360),
dimensions: VideoDimensions(width: 640, height: 360),
frameRate: VideoFrameRate.Fps30,
orientationMode: VideoOutputOrientationMode.Adaptative));
// enable camera/mic, this will bring up permission dialog for first time
await _engine.enableLocalAudio(true);
await _engine.enableLocalVideo(true);
} else {
// You have to provide client role options if set to audience
option = ClientRoleOptions(isLowAudio
? AudienceLatencyLevelType.LowLatency
: AudienceLatencyLevelType.UltraLowLatency);
option = ClientRoleOptions(
audienceLatencyLevel: isLowAudio
? AudienceLatencyLevelType.LowLatency
: AudienceLatencyLevelType.UltraLowLatency);
}
await _engine.setClientRole(role, option);
}
Expand All @@ -157,9 +158,10 @@ class _State extends State<LiveStreaming> {
isLowAudio = !isLowAudio;
_engine.setClientRole(
ClientRole.Audience,
ClientRoleOptions(isLowAudio
? AudienceLatencyLevelType.LowLatency
: AudienceLatencyLevelType.UltraLowLatency));
ClientRoleOptions(
audienceLatencyLevel: isLowAudio
? AudienceLatencyLevelType.LowLatency
: AudienceLatencyLevelType.UltraLowLatency));
});
}

Expand Down
26 changes: 3 additions & 23 deletions example/lib/examples/advanced/media_channel_relay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class _State extends State<MediaChannelRelay> {
late final RtcEngine _engine;
bool isJoined = false;
int? remoteUid;
bool isLowAudio = true;
bool isRelaying = false;

@override
Expand All @@ -45,7 +44,7 @@ class _State extends State<MediaChannelRelay> {

// make this room live broadcasting room
await _engine.setChannelProfile(ChannelProfile.LiveBroadcasting);
await this._updateClientRole(ClientRole.Broadcaster);
await _engine.setClientRole(ClientRole.Broadcaster);

// Set audio route to speaker
await _engine.setDefaultAudioRoutetoSpeakerphone(true);
Expand Down Expand Up @@ -111,25 +110,6 @@ class _State extends State<MediaChannelRelay> {
}));
}

_updateClientRole(ClientRole role) async {
var option;
if (role == ClientRole.Broadcaster) {
await _engine.setVideoEncoderConfiguration(VideoEncoderConfiguration(
dimensions: VideoDimensions(640, 360),
frameRate: VideoFrameRate.Fps30,
orientationMode: VideoOutputOrientationMode.Adaptative));
// enable camera/mic, this will bring up permission dialog for first time
await _engine.enableLocalAudio(true);
await _engine.enableLocalVideo(true);
} else {
// You have to provide client role options if set to audience
option = ClientRoleOptions(isLowAudio
? AudienceLatencyLevelType.LowLatency
: AudienceLatencyLevelType.UltraLowLatency);
}
await _engine.setClientRole(role, option);
}

_onPressRelayOrStop() async {
if (isRelaying) {
await _engine.stopChannelMediaRelay();
Expand All @@ -140,8 +120,8 @@ class _State extends State<MediaChannelRelay> {
}

await _engine.startChannelMediaRelay(ChannelMediaRelayConfiguration(
ChannelMediaInfo(0, channelName: config.channelId, token: config.token),
[ChannelMediaInfo(0, channelName: '', token: '')]));
ChannelMediaInfo(config.channelId, 0, token: config.token),
[ChannelMediaInfo('', 0, token: '')]));

_controller.clear();
}
Expand Down
4 changes: 2 additions & 2 deletions example/lib/examples/advanced/multi_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class _State extends State<MultiChannel> {
this._addListener(_channel0);

await _channel0.setClientRole(ClientRole.Broadcaster);
await _channel0.joinChannel(null, null, 0, ChannelMediaOptions(true, true));
await _channel0.joinChannel(null, null, 0, ChannelMediaOptions());
}

_joinChannel1() async {
Expand All @@ -68,7 +68,7 @@ class _State extends State<MultiChannel> {
this._addListener(_channel1);

await _channel1.setClientRole(ClientRole.Broadcaster);
await _channel1.joinChannel(null, null, 0, ChannelMediaOptions(true, true));
await _channel1.joinChannel(null, null, 0, ChannelMediaOptions());
}

_addListener(RtcChannel channel) {
Expand Down
30 changes: 3 additions & 27 deletions example/lib/examples/advanced/voice_change.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class _State extends State<VoiceChange> {
late final RtcEngine _engine;
bool isJoined = false;
List<int> remoteUids = [];
bool isLowAudio = true;
int? uidMySelf;
int? selectedVoiceToolBtn;
AudioEffectPreset currentAudioEffectPreset = AudioEffectPreset.AudioEffectOff;
Expand Down Expand Up @@ -55,12 +54,9 @@ class _State extends State<VoiceChange> {
_engine = await RtcEngine.createWithConfig(RtcEngineConfig(config.appId));
this._addListener();

// enable video module and set up video encoding configs
await _engine.enableVideo();

// make this room live broadcasting room
await _engine.setChannelProfile(ChannelProfile.LiveBroadcasting);
await this._updateClientRole(ClientRole.Broadcaster);
await _engine.setClientRole(ClientRole.Broadcaster);

// Set audio route to speaker
await _engine.setDefaultAudioRoutetoSpeakerphone(true);
Expand Down Expand Up @@ -99,26 +95,7 @@ class _State extends State<VoiceChange> {
}));
}

_updateClientRole(ClientRole role) async {
var option;
if (role == ClientRole.Broadcaster) {
await _engine.setVideoEncoderConfiguration(VideoEncoderConfiguration(
dimensions: VideoDimensions(640, 360),
frameRate: VideoFrameRate.Fps30,
orientationMode: VideoOutputOrientationMode.Adaptative));
// enable camera/mic, this will bring up permission dialog for first time
await _engine.enableLocalAudio(true);
await _engine.enableLocalVideo(true);
} else {
// You have to provide client role options if set to audience
option = ClientRoleOptions(isLowAudio
? AudienceLatencyLevelType.LowLatency
: AudienceLatencyLevelType.UltraLowLatency);
}
await _engine.setClientRole(role, option);
}

_onPressBFButtonn(dynamic type, int index) async {
_onPressBFButton(dynamic type, int index) async {
switch (index) {
case 0:
case 1:
Expand Down Expand Up @@ -388,7 +365,7 @@ class _State extends State<VoiceChange> {
setState(() {
selectedVoiceToolBtn = index;
});
_onPressBFButtonn(type, index);
_onPressBFButton(type, index);
});
}

Expand Down Expand Up @@ -462,7 +439,6 @@ class _CusBtnState extends State<_CusBtn> {

@override
void didUpdateWidget(covariant _CusBtn oldWidget) {
// TODO: implement didUpdateWidget
super.didUpdateWidget(oldWidget);
this.setState(() {
isEnable = !widget.isOff;
Expand Down
4 changes: 2 additions & 2 deletions example/lib/examples/basic/join_channel_audio.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ class _State extends State<JoinChannelAudio> {
_engine
.playEffect(
1,
await (RtcEngineExtension.getAssetAbsolutePath(
"assets/Sound_Horizon.mp3") as FutureOr<String>),
await (_engine.getAssetAbsolutePath("assets/Sound_Horizon.mp3")
as FutureOr<String>),
-1,
1,
1,
Expand Down
2 changes: 2 additions & 0 deletions lib/rtc_engine.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
library agora_rtc_engine;

export 'src/classes.dart';
export 'src/enums.dart';
export 'src/events.dart' hide RtcChannelEventHandler;
Expand Down
2 changes: 1 addition & 1 deletion lib/rtc_local_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SurfaceView extends RtcSurfaceView {
);
}

/// (Android only) TextureView.
/// TextureView.
class TextureView extends RtcTextureView {
/// Constructs a [TextureView]
TextureView({
Expand Down
2 changes: 1 addition & 1 deletion lib/rtc_remote_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SurfaceView extends RtcSurfaceView {
);
}

/// (Android only) TextureView.
/// TextureView.
class TextureView extends RtcTextureView {
/// Constructs a [TextureView]
TextureView({
Expand Down
Loading

0 comments on commit 9a1baae

Please sign in to comment.