add: debian file, perform various fixes

This commit is contained in:
Charles
2024-01-15 22:44:05 -08:00
parent ccafa34f33
commit 195cd67c90
17 changed files with 432 additions and 204 deletions
@@ -31,5 +31,6 @@
android:value="2" />
</application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
</manifest>
+24 -13
View File
@@ -38,15 +38,16 @@ class CallState extends State<Call> {
logger.i("Init remote renderer");
await _remoteRenderer.initialize();
logger.i("Creating session");
await _createSesson();
await _createSession();
}
_createSesson() async {
_createSession() async {
var callOptions = CallOptions(metadata: {
'Authorization': await widget.sessionService.getAuthToken(widget.home)
});
var cancelCreate = Completer();
var sendIceCandidates = Completer();
var clientSession = await widget.client.createSession(
pb.CreateSessionRequest(
@@ -73,6 +74,8 @@ class CallState extends State<Call> {
};
peerConnection.onIceCandidate = (candidate) async {
await sendIceCandidates.future;
logger.i("Sending ICE candidate");
if (candidate.candidate == null) {
await widget.client.createIceMessage(
CreateIceMessageRequest(
@@ -99,16 +102,15 @@ class CallState extends State<Call> {
};
peerConnection.onIceConnectionState = (state) {
statusLine = "Ice state now $state";
statusLine = "$state";
setState(() {});
logger.i("Ice state now $state");
switch (state) {
case RTCIceConnectionState.RTCIceConnectionStateClosed:
case RTCIceConnectionState.RTCIceConnectionStateDisconnected:
//case RTCIceConnectionState.RTCIceConnectionStateClosed:
//case RTCIceConnectionState.RTCIceConnectionStateDisconnected:
case RTCIceConnectionState.RTCIceConnectionStateFailed:
cancelCreate.complete(CallCancelled());
_connect();
//_connect();
default:
// do nothing
}
@@ -136,7 +138,6 @@ class CallState extends State<Call> {
var offer = await peerConnection.createOffer();
await peerConnection.setLocalDescription(offer);
// Send offer through signaling server
logger.i("Offer is $offer");
await widget.client.createIceMessage(
pb.CreateIceMessageRequest(
sessionIdentifier: clientSession.id,
@@ -149,6 +150,20 @@ class CallState extends State<Call> {
),
options: callOptions);
// Expect back a response
var someResponse = await Future.any([
widget.client.popIceMessage(
pb.PopIceMessageRequest(sessionIdentifier: clientSession.id),
options: callOptions),
cancelCreate.future,
]);
var resp = someResponse as pb.IceMessage;
var session = resp.session;
await peerConnection
.setRemoteDescription(RTCSessionDescription(session.sdp, "answer"));
sendIceCandidates.complete();
// Get candidates from remote
while (true) {
var someResponse = await Future.any([
@@ -168,10 +183,6 @@ class CallState extends State<Call> {
resp.candidate.sdpLineIndex));
} else if (resp.hasNoMoreCandidates()) {
logger.i("No more candidates from remote");
} else if (resp.hasSession()) {
var session = resp.session;
await peerConnection
.setRemoteDescription(RTCSessionDescription(session.sdp, "answer"));
break;
}
}
@@ -183,7 +194,7 @@ class CallState extends State<Call> {
Text(widget.cameraID.id),
Text(statusLine),
SizedBox(
height: 480,
height: 320,
child: _ready
? RTCVideoView(_remoteRenderer)
: const Text("Loading...")),
+27 -18
View File
@@ -1,3 +1,5 @@
import 'dart:collection';
import 'package:flutter/material.dart';
//import 'package:grpc/grpc_web.dart';
import 'package:grpc/grpc.dart';
@@ -36,9 +38,9 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
title: 'Home Sensors',
theme: ThemeData.dark(
// colorScheme: ColorScheme.fromSeed(seedColor: Colors.black87),
useMaterial3: true,
),
home: MyHomePage(
@@ -75,8 +77,8 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State<MyHomePage> {
String topMessage = "Creating session...";
List<Call> camerasToRender = [];
List<Widget> samples = [];
List<Widget> camerasToRender = [];
Map<String, Widget> cameraSamples = {};
@override
void initState() {
@@ -100,8 +102,11 @@ class _MyHomePageState extends State<MyHomePage> {
.listSamples(ListSamplesRequest(), options: callOptions);
for (var sample in resp.samples) {
samples
.add(Text("${sample.type}: ${sample.reading} on ${sample.cameraId}"));
if (sample.type == Sample_Type.TEMPERATURE_C) {
var reading = (sample.reading * 9.0 / 5.0) + 32;
cameraSamples[sample.cameraId.id] =
Text("${reading.toStringAsFixed(2)} f");
}
}
setState(() {});
}
@@ -113,12 +118,22 @@ class _MyHomePageState extends State<MyHomePage> {
var cameras = await widget.client
.listCameras(ListCamerasRequest(), options: callOptions);
cameras.cameras.sort((a, b) => a.identifier.id.compareTo(b.identifier.id));
camerasToRender = [];
for (var camera in cameras.cameras) {
camerasToRender.add(Call(
widget.client,
widget.sessionService,
cameraID: camera.identifier,
home: widget.home,
List<Widget> children = [
Call(
widget.client,
widget.sessionService,
cameraID: camera.identifier,
home: widget.home,
),
];
if (cameraSamples.containsKey(camera.identifier.id)) {
children.add(cameraSamples[camera.identifier.id]!);
}
camerasToRender.add(Column(
children: children,
));
}
setState(() {});
@@ -134,12 +149,7 @@ class _MyHomePageState extends State<MyHomePage> {
// than having to individually change instances of widgets.
return Scaffold(
appBar: AppBar(
// TRY THIS: Try changing the color here to a specific color (to
// Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
// change color while the other colors stay the same.
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: SingleChildScrollView(
@@ -150,7 +160,6 @@ class _MyHomePageState extends State<MyHomePage> {
children: <Widget>[
Text(topMessage),
] +
samples +
camerasToRender,
),
));