startRecording method

Future<void> startRecording({
  1. String? webhookUrl,
  2. String? awsDirPath,
  3. Map<String, dynamic>? config,
  4. Map<String, dynamic>? transcription,
})

Implementation

Future<void> startRecording(
    {String? webhookUrl,
    String? awsDirPath,
    Map<String, dynamic>? config,
    Map<String, dynamic>? transcription}) async {
  Map<String, dynamic> data = {};
  if (webhookUrl != null) data["webhookUrl"] = webhookUrl;
  if (awsDirPath != null) data["awsDirPath"] = awsDirPath;
  if (config != null) data["config"] = config;
  if (transcription != null) data["transcription"] = transcription;

  Span? startRecordingSpan;

  try {
    if (videoSDKTelemetery != null) {
      startRecordingSpan = videoSDKTelemetery!.trace(
        spanName: 'startRecording() Start',
        attributes: [
          Attribute.fromString(
              'webhookUrl', webhookUrl ?? 'webhookUrl Not Specify'),
          Attribute.fromString(
              'awsDirPath', awsDirPath ?? 'awsDirPath Not Specify'),
          Attribute.fromString('config',
              config != null ? config.toString() : 'config Not Specify'),
          Attribute.fromString(
              'transcription',
              transcription != null
                  ? transcription.toString()
                  : 'transcription not started'),
        ],
      );
    }
  } catch (error) {}

  try {
    await _webSocket!.socket.request('startRecording', data);

    if (startRecordingSpan != null) {
      videoSDKTelemetery!.completeSpan(
          span: startRecordingSpan,
          status: StatusCode.ok,
          message: 'startRecording() End');
    }
  } catch (error) {
    //
    VideoSDKLog.createLog(
        message: "Error in startRecording() \n ${error.toString()}",
        logLevel: "ERROR");
    //
    log("Error while starting recording $error");

    if (startRecordingSpan != null) {
      videoSDKTelemetery!.completeSpan(
          span: startRecordingSpan,
          status: StatusCode.error,
          message: 'startRecording() Failed \n ${error.toString()}');
    }
  }
}