getMediaMimeType static method

String? getMediaMimeType(
  1. String codecValue
)

Implementation

static String? getMediaMimeType(String codecValue) {
  String codec = codecValue;

  codec = codec.trim().toLowerCase();
  if (codec.startsWith('avc1') || codec.startsWith('avc3')) {
    return MimeTypes.videoH264;
  }

  if (codec.startsWith('hev1') || codec.startsWith('hvc1')) {
    return MimeTypes.videoH265;
  }

  if (codec.startsWith('dvav') ||
      codec.startsWith('dva1') ||
      codec.startsWith('dvhe') ||
      codec.startsWith('dvh1')) return MimeTypes.videoDolbyVision;

  if (codec.startsWith('av01')) return MimeTypes.videoAv1;

  if (codec.startsWith('vp9') || codec.startsWith('vp09')) {
    return MimeTypes.videoVp9;
  }
  if (codec.startsWith('vp8') || codec.startsWith('vp08')) {
    return MimeTypes.videoVp8;
  }
  if (codec.startsWith('mp4a')) {
    String? mimeType;
    if (codec.startsWith('mp4a.')) {
      final String objectTypeString = codec.substring(5);
      if (objectTypeString.length >= 2) {
        try {
          final String objectTypeHexString =
              objectTypeString.substring(0, 2).toUpperCase();
          final int objectTypeInt = int.parse(objectTypeHexString, radix: 16);
          mimeType = _getMimeTypeFromMp4ObjectType(objectTypeInt);
        } on FormatException {
          //do nothing
          //print(ignored);
        }
      }
    }
    return mimeType ??= MimeTypes.audioAac;
  }
  if (codec.startsWith('ac-3') || codec.startsWith('dac3')) {
    return MimeTypes.audioAc3;
  }

  if (codec.startsWith('ec-3') || codec.startsWith('dec3')) {
    return MimeTypes.audioEAc3;
  }

  if (codec.startsWith('ec+3')) return MimeTypes.audioEAc3Joc;

  if (codec.startsWith('ac-4') || codec.startsWith('dac4')) {
    return MimeTypes.audioAc4;
  }

  if (codec.startsWith('dtsc') || codec.startsWith('dtse')) {
    return MimeTypes.audioDts;
  }

  if (codec.startsWith('dtsh') || codec.startsWith('dtsl')) {
    return MimeTypes.audioDtsHd;
  }
  if (codec.startsWith('opus')) return MimeTypes.audioOpus;
  if (codec.startsWith('vorbis')) return MimeTypes.audioVorbis;
  if (codec.startsWith('flac')) return MimeTypes.audioFlac;
  return getCustomMimeTypeForCodec(codec);
}