-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from redevRx/agora_call
Agora call
- Loading branch information
Showing
27 changed files
with
1,479 additions
and
355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#Flutter Wrapper | ||
-keep class io.flutter.app.** { *; } | ||
-keep class io.flutter.plugin.** { *; } | ||
-keep class io.flutter.util.** { *; } | ||
-keep class io.flutter.view.** { *; } | ||
-keep class io.flutter.** { *; } | ||
-keep class io.flutter.plugins.** { *; } | ||
-keep class io.agora.**{*;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import 'dart:convert'; | ||
|
||
import 'package:http/http.dart' as http; | ||
|
||
void main() async { | ||
await http | ||
.get( | ||
"http://172.19.128.1:8080/resocial/api/v1/generate/token?channelName=redev&uid=0&role=publisher&expireTime=3600") | ||
.then((token) { | ||
Map t = jsonDecode(token.body); | ||
print('${t['token']}'); | ||
}).catchError((e) => print(e)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:flutter_bloc/flutter_bloc.dart'; | ||
import 'package:socialapp/call/bloc/call_event.dart'; | ||
import 'package:socialapp/call/bloc/call_state.dart'; | ||
import 'package:socialapp/call/repository/call_agora_repository.dart'; | ||
|
||
class CallBloc extends Bloc<CallEvent, CallState> { | ||
CallBloc(CallState initialState) : super(CallInitialState()); | ||
|
||
//call repository | ||
CallAgoraRepository _callAgoraRepository; | ||
|
||
//observer call info | ||
StreamSubscription _callStreamSubscription; | ||
|
||
@override | ||
Stream<CallState> mapEventToState(CallEvent event) async* { | ||
if (event is OnCallStreamStating) { | ||
yield* onLoadCallStream(event); | ||
} | ||
if (event is OnCallStreamStated) { | ||
yield OnCallStreamSuccess(callModel: event.callModel); | ||
} | ||
if (event is OnStartDialEvent) { | ||
_callAgoraRepository.dial( | ||
channelName: event.channelName, | ||
context: event.context, | ||
receiverId: event.receiverId, | ||
senderId: event.senderId, | ||
type: event.type); | ||
} | ||
} | ||
|
||
/** | ||
*start laod dial info | ||
if has data give to go pickUp Screen | ||
then go to home page screen | ||
*/ | ||
@override | ||
Stream<CallState> onLoadCallStream(OnCallStreamStating event) async* { | ||
try { | ||
_callStreamSubscription?.cancel(); | ||
_callStreamSubscription = | ||
_callAgoraRepository.CallStream(uid: event.uid).listen((call) { | ||
if (call != null) { | ||
print("dial info not null"); | ||
add(OnCallStreamStated(callModel: call)); | ||
} else { | ||
print("dial info null"); | ||
} | ||
}); | ||
} catch (e) { | ||
print("dial info null error :$e"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'package:flutter/cupertino.dart'; | ||
import 'package:socialapp/call/model/call_model.dart'; | ||
|
||
abstract class CallEvent {} | ||
|
||
/** | ||
event call stream if call when there is dial to | ||
current | ||
*/ | ||
class OnCallStreamStating extends CallEvent { | ||
final String uid; | ||
|
||
OnCallStreamStating({this.uid}); | ||
} | ||
|
||
/** | ||
this method will call when load data call info success | ||
will work from OnCallStreamStating | ||
*/ | ||
class OnCallStreamStated extends CallEvent { | ||
final CallModel callModel; | ||
|
||
OnCallStreamStated({this.callModel}); | ||
} | ||
|
||
/** | ||
this method will call when start dial to you | ||
freind | ||
*/ | ||
class OnStartDialEvent extends CallEvent { | ||
final BuildContext context; | ||
final String senderId; | ||
final String receiverId; | ||
final String channelName; | ||
final bool type; | ||
|
||
OnStartDialEvent( | ||
{this.context, | ||
this.senderId, | ||
this.receiverId, | ||
this.channelName, | ||
this.type}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:equatable/equatable.dart'; | ||
import 'package:socialapp/call/model/call_model.dart'; | ||
|
||
abstract class CallState extends Equatable {} | ||
|
||
//initial state | ||
//return null value | ||
class CallInitialState extends CallState { | ||
@override | ||
// TODO: implement props | ||
List<Object> get props => []; | ||
} | ||
|
||
/** | ||
this event will return result call stream | ||
*/ | ||
class OnCallStreamSuccess extends CallState { | ||
CallModel callModel; | ||
|
||
OnCallStreamSuccess({this.callModel}); | ||
@override | ||
// TODO: implement props | ||
List<Object> get props => [this.callModel]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
const String APP_ID = "48ae18e6f9834a76b6c9dabc9f390037"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import 'dart:collection'; | ||
|
||
class CallModel { | ||
String callId; | ||
String callName; | ||
String callPic; | ||
String receiverName; | ||
String receiverId; | ||
String receiverPic; | ||
String channelName; | ||
String token; | ||
bool typeCall; | ||
//fasle is voic call true is video call | ||
bool hasDialled; | ||
|
||
CallModel( | ||
{this.callId, | ||
this.callName, | ||
this.callPic, | ||
this.receiverName, | ||
this.receiverId, | ||
this.receiverPic, | ||
this.channelName, | ||
this.token, | ||
this.typeCall, | ||
this.hasDialled}); | ||
|
||
//to map | ||
Map<String, dynamic> toMap(CallModel call) { | ||
Map<String, dynamic> callMap = HashMap(); | ||
callMap["caller_id"] = call.callId; | ||
callMap["caller_name"] = call.callName; | ||
callMap["caller_pic"] = call.callPic; | ||
callMap["receiver_id"] = call.receiverId; | ||
callMap["receiver_name"] = call.receiverName; | ||
callMap["receiver_pic"] = call.receiverPic; | ||
callMap["channel_id"] = call.channelName; | ||
callMap["token"] = call.token; | ||
callMap["type_call"] = call.typeCall; | ||
callMap["has_dialled"] = call.hasDialled; | ||
return callMap; | ||
} | ||
|
||
// String get hasDialled => this.hasDialled; | ||
|
||
CallModel.formMap(Map<String, dynamic> callMap) { | ||
this.callId = callMap["caller_id"]; | ||
this.callName = callMap["caller_name"]; | ||
this.callPic = callMap["caller_pic"]; | ||
this.receiverId = callMap["receiver_id"]; | ||
this.receiverName = callMap["receiver_name"]; | ||
this.receiverPic = callMap["receiver_pic"]; | ||
this.channelName = callMap["channel_id"]; | ||
this.token = callMap["token"]; | ||
this.typeCall = callMap["type_call"]; | ||
this.hasDialled = callMap["has_dialled"]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:permission_handler/permission_handler.dart'; | ||
|
||
class Permissions { | ||
static Future<bool> checkVideoAndMicroPhonegrant() async { | ||
Map<Permission, PermissionStatus> status = | ||
await [Permission.camera, Permission.microphone].request(); | ||
|
||
//case user grant permission | ||
if (status[Permission.camera].isGranted && | ||
status[Permission.microphone].isGranted) { | ||
return true; | ||
} | ||
|
||
if (status[Permission.camera].isUndetermined || | ||
status[Permission.microphone].isUndetermined) { | ||
return false; | ||
} | ||
} | ||
} |
Oops, something went wrong.