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>
This commit is contained in:
53
mobile/lib/platform/streaming_channel.dart
Normal file
53
mobile/lib/platform/streaming_channel.dart
Normal file
@@ -0,0 +1,53 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user