using System; using System.Collections.Concurrent; using System.IO; using System.Linq; using BurnOutSharp.Interfaces; namespace BurnOutSharp.FileType { /// /// AACS media key block /// public class AACSMediaKeyBlock : IScannable { /// public ConcurrentDictionary> Scan(Scanner scanner, string file) { if (!File.Exists(file)) return null; using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read)) { return Scan(scanner, fs, file); } } /// public ConcurrentDictionary> Scan(Scanner scanner, Stream stream, string file) { // If the MKB file itself fails try { // Create the wrapper BinaryObjectScanner.Wrappers.AACSMediaKeyBlock mkb = BinaryObjectScanner.Wrappers.AACSMediaKeyBlock.Create(stream); if (mkb == null) return null; // Setup the output var protections = new ConcurrentDictionary>(); protections[file] = new ConcurrentQueue(); var typeAndVersion = mkb.Records.FirstOrDefault(r => r.RecordType == BinaryObjectScanner.Models.AACS.RecordType.TypeAndVersion); if (typeAndVersion == null) protections[file].Enqueue("AACS (Unknown Version)"); else protections[file].Enqueue($"AACS {(typeAndVersion as BinaryObjectScanner.Models.AACS.TypeAndVersionRecord).VersionNumber}"); return protections; } catch (Exception ex) { if (scanner.IncludeDebug) Console.WriteLine(ex); } return null; } } }