22 lines
732 B
Dart
22 lines
732 B
Dart
import 'dart:async';
|
|
import 'dart:typed_data';
|
|
|
|
import '../proto/messages.pb.dart';
|
|
|
|
/// Abstract decoder interface. Feeds raw frames in, emits envelopes out.
|
|
///
|
|
/// On native, the implementation runs in an isolate and batches envelopes.
|
|
/// On Web, the implementation decodes synchronously in [feed].
|
|
abstract class Decoder {
|
|
/// Stream of decoded envelopes (or batches thereof, flattened to per-envelope).
|
|
Stream<Envelope> get envelopes;
|
|
|
|
/// Spin up any background machinery. No-op on the inline (Web) decoder.
|
|
Future<void> start();
|
|
|
|
/// Push a raw frame for decoding. Returns immediately.
|
|
void feed(Uint8List frame);
|
|
|
|
/// Tear down. Stops the isolate (on native) and closes the stream.
|
|
Future<void> dispose();
|
|
} |