Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/flutter_webrtc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 0.1.2

* Update flutter_webrtc to 0.9.28.
* Fix the data channel does not work in flutter_webrtc_demo.
* Support frame cryptor.

## 0.1.1

* Update flutter_webrtc to 0.9.23.
Expand Down
9 changes: 5 additions & 4 deletions packages/flutter_webrtc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,19 @@ For other Tizen devices :

```yaml
dependencies:
flutter_webrtc: ^0.9.23
flutter_webrtc_tizen: ^0.1.1
flutter_webrtc: ^0.9.28
flutter_webrtc_tizen: ^0.1.2
```

## Functionality

| Feature | Tizen |
| :----------------: | :----------------: |
| Audio/Video | :heavy_check_mark: |
| Data Channel | [WIP] |
| Data Channel | :heavy_check_mark: |
| Screen Capture | [WIP] |
| Unified-Plan | :heavy_check_mark: |
| Simulcast | [WIP] |
| Simulcast | :heavy_check_mark: |
| MediaRecorder | [WIP] |
|SFrame/FrameCryptor | :heavy_check_mark: |
| Insertable Streams | [WIP] |
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class _CallSampleState extends State<CallSample> {

void _accept() {
if (_session != null) {
_signaling?.accept(_session!.sid);
_signaling?.accept(_session!.sid, 'video');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class _DataChannelSampleState extends State<DataChannelSample> {
Session? _session;
Timer? _timer;
var _text = '';
bool _waitAccept = false;

@override
void initState() {
Expand All @@ -40,6 +41,55 @@ class _DataChannelSampleState extends State<DataChannelSample> {
_timer?.cancel();
}

Future<bool?> _showAcceptDialog() {
return showDialog<bool?>(
context: context,
builder: (context) {
return AlertDialog(
title: Text('title'),
content: Text('accept?'),
actions: <Widget>[
MaterialButton(
child: Text(
'Reject',
style: TextStyle(color: Colors.red),
),
onPressed: () => Navigator.of(context).pop(false),
),
MaterialButton(
child: Text(
'Accept',
style: TextStyle(color: Colors.green),
),
onPressed: () => Navigator.of(context).pop(true),
),
],
);
},
);
}

Future<bool?> _showInvateDialog() {
return showDialog<bool?>(
context: context,
builder: (context) {
return AlertDialog(
title: Text('title'),
content: Text('waiting'),
actions: <Widget>[
TextButton(
child: Text('cancel'),
onPressed: () {
Navigator.of(context).pop(false);
_hangUp();
},
),
],
);
},
);
}

void _connect(BuildContext context) async {
_signaling ??= Signaling(widget.host, context);
await _signaling!.connect();
Expand All @@ -66,33 +116,53 @@ class _DataChannelSampleState extends State<DataChannelSample> {
}
};

_signaling?.onCallStateChange = (Session session, CallState state) {
_signaling?.onCallStateChange = (Session session, CallState state) async {
switch (state) {
case CallState.CallStateNew:
{
setState(() {
_session = session;
_inCalling = true;
});
_timer =
Timer.periodic(Duration(seconds: 1), _handleDataChannelTest);
break;
}
setState(() {
_session = session;
});
_timer = Timer.periodic(Duration(seconds: 1), _handleDataChannelTest);
break;
case CallState.CallStateBye:
{
setState(() {
_inCalling = false;
});
_timer?.cancel();
_dataChannel = null;
_inCalling = false;
_session = null;
_text = '';
break;
if (_waitAccept) {
_waitAccept = false;
Navigator.of(context).pop(false);
}
setState(() {
_inCalling = false;
});
_timer?.cancel();
_dataChannel = null;
_inCalling = false;
_session = null;
_text = '';
break;
case CallState.CallStateInvite:
_waitAccept = true;
await _showInvateDialog();
break;
case CallState.CallStateConnected:
if (_waitAccept) {
_waitAccept = false;
Navigator.of(context).pop(false);
}
setState(() {
_inCalling = true;
});
break;
case CallState.CallStateRinging:
var accept = await _showAcceptDialog();
if (accept!) {
_accept();
setState(() {
_inCalling = true;
});
} else {
_reject();
}

break;
}
};

Expand All @@ -104,6 +174,18 @@ class _DataChannelSampleState extends State<DataChannelSample> {
};
}

void _accept() {
if (_session != null) {
_signaling?.accept(_session!.sid, 'data');
}
}

void _reject() {
if (_session != null) {
_signaling?.reject(_session!.sid);
}
}

Future<void> _handleDataChannelTest(Timer timer) async {
var text = 'Say hello ${timer.tick} times, from [$_selfId]';
await _dataChannel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,12 @@ class Signaling {
}
}

void accept(String sessionId) {
void accept(String sessionId, String media) {
var session = _sessions[sessionId];
if (session == null) {
return;
}
_createAnswer(session, 'video');
_createAnswer(session, media);
}

void reject(String sessionId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_background/flutter_background.dart';
import 'package:flutter_webrtc/flutter_webrtc.dart';

import 'src/device_enumeration_sample.dart';
import 'src/get_display_media_sample.dart';
import 'src/get_user_media_sample.dart'
if (dart.library.html) 'src/get_user_media_sample_web.dart';
Expand All @@ -15,11 +16,11 @@ import 'src/loopback_sample_unified_tracks.dart';
import 'src/route_item.dart';

void main() {
WidgetsFlutterBinding.ensureInitialized();
if (WebRTC.platformIsDesktop) {
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
} else if (WebRTC.platformIsAndroid) {
WidgetsFlutterBinding.ensureInitialized();
startForegroundService();
//startForegroundService();
}
runApp(MyApp());
}
Expand Down Expand Up @@ -90,6 +91,15 @@ class _MyAppState extends State<MyApp> {
MaterialPageRoute(
builder: (BuildContext context) => GetUserMediaSample()));
}),
RouteItem(
title: 'Device Enumeration',
push: (BuildContext context) {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) =>
DeviceEnumerationSample()));
}),
RouteItem(
title: 'GetDisplayMedia',
push: (BuildContext context) {
Expand Down
Loading