RecorderConfiguration.fromJson constructor

RecorderConfiguration.fromJson(
  1. Map<String, dynamic> json
)

Implementation

factory RecorderConfiguration.fromJson(final Map<String, dynamic> json) {
  final Map<String, dynamic> hardwareSpecificationsAsString =
      jsonDecode(json['hardwareSpecifications']) ?? <String, dynamic>{};

  final Map<HardwareSpecification, String> hardwareSpecifications =
      <HardwareSpecification, String>{};
  for (final HardwareSpecification spec in HardwareSpecification.values) {
    if (!hardwareSpecificationsAsString.containsKey(spec.id.toString())) {
      continue;
    }
    hardwareSpecifications[spec] =
        hardwareSpecificationsAsString[spec.id.toString()] ?? '';
  }

  return RecorderConfiguration(
    logsDir: json['logsDir'] ?? '',
    dataSource: DataSource.init(json['dataSource']),
    hardwareSpecifications: hardwareSpecifications,
    recordedTypes: json['recordedTypes'] != null
        ? (json['recordedTypes'] as List<dynamic>)
            .map(
              (final dynamic item) => DataType.values.firstWhere(
                (final DataType e) => e.id == item,
              ),
            )
            .toList()
        : <DataType>[],
    minDurationSeconds: json['minDurationSeconds'] ?? 30,
    videoQuality: ResolutionExtension.fromId(
      json['videoQuality'] ?? Resolution.unknown.id,
    ),
    chunkDurationSeconds: json['chunkDurationSeconds'] ?? 3600,
    continuousRecording: json['bContinuousRecording'] ?? true,
    enableAudio: json['bEnableAudio'] ?? false,
    maxDiskSpaceUsed: json['maxDiskSpaceUsed'] ?? 0,
    keepMinSeconds: json['keepMinSeconds'] ?? 0,
    deleteOlderThanKeepMin: json['deleteOlderThanKeepMin'] ?? false,
    transportMode: json['transportMode'] != null
        ? RecordingTransportMode.values.firstWhere(
            (final RecordingTransportMode e) => e.id == json['transportMode'],
          )
        : RecordingTransportMode.unknown,
  );
}