Files
MatchLiveTv/mobile/lib/platform/streaming_channel.dart
Emiliano Frascaro bba6df52c0 Initial commit: monorepo Match Live TV.
Rails API, app Flutter, infrastruttura Docker/MediaMTX, sito marketing e documentazione di deploy.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-26 17:45:37 +02:00

54 lines
1.4 KiB
Dart

import 'package:flutter/services.dart';
/// Bridge verso engine nativo Android (CameraX + RootEncoder).
class StreamingChannel {
StreamingChannel._();
static const MethodChannel _channel =
MethodChannel('com.matchlivetv.match_live_tv/streaming');
static const EventChannel _metricsChannel =
EventChannel('com.matchlivetv.match_live_tv/streaming_events');
static Future<void> startPreview() async {
await _channel.invokeMethod('startPreview');
}
static Future<bool> bindPreview() async {
final ok = await _channel.invokeMethod<bool>('bindPreview');
return ok ?? false;
}
static Future<void> stopPreview() async {
await _channel.invokeMethod('stopPreview');
}
static Future<void> startStream({
required String rtmpUrl,
int targetBitrate = 2500000,
int targetFps = 30,
}) async {
await _channel.invokeMethod('startStream', {
'rtmpUrl': rtmpUrl,
'videoBitrate': targetBitrate,
'fps': targetFps,
});
}
static Future<void> stopStream() async {
await _channel.invokeMethod('stopStream');
}
static Future<void> pauseStream() async {
await _channel.invokeMethod('pauseStream');
}
static Future<Map<String, dynamic>?> getMetrics() async {
final result =
await _channel.invokeMethod<Map<dynamic, dynamic>>('getMetrics');
return result?.map((key, value) => MapEntry(key.toString(), value));
}
static EventChannel get metricsStream => _metricsChannel;
}