videoFramesStream method

  1. @override
Stream<VideoFrame> videoFramesStream()
override

Implementation

@override
Stream<VideoFrame> videoFramesStream() {
  return videoFramesEventChannel.receiveBroadcastStream().map(
    (dynamic event) {
      final map = Map<String, dynamic>.from(event as Map);
      final codecStr = map['codec'] as String? ?? 'raw';
      final codec = codecStr == 'hvc1' ? VideoCodec.hvc1 : VideoCodec.raw;
      final bytes = map['bytes'] as Uint8List;
      final bytesPerRow = (map['bytesPerRow'] as num?)?.toInt();
      return VideoFrame(
        codec: codec,
        bytes: bytes,
        width: (map['width'] as num).toInt(),
        height: (map['height'] as num).toInt(),
        presentationTimestampUs: (map['ptsUs'] as num).toInt(),
        isKeyframe: (map['isKeyframe'] as bool?) ?? true,
        bytesPerRow: bytesPerRow,
      );
    },
  );
}