Update MSSMoovProcessor.cs

This commit is contained in:
√(noham)² 2025-02-01 19:13:42 +01:00
parent cd4dfb5e75
commit 948f7aa75a

View File

@ -36,8 +36,8 @@ public partial class MSSMoovProcessor
private bool IsProtection; private bool IsProtection;
private string ProtectionSystemId; private string ProtectionSystemId;
private string ProtectionData; private string ProtectionData;
private string? ProtecitonKID; private string? ProtectionKID;
private string? ProtecitonKID_PR; private string? ProtectionKID_PR;
private byte[] UnityMatrix private byte[] UnityMatrix
{ {
get get
@ -166,13 +166,13 @@ public partial class MSSMoovProcessor
var text = Encoding.ASCII.GetString(bytes); var text = Encoding.ASCII.GetString(bytes);
var kidBytes = Convert.FromBase64String(KIDRegex().Match(text).Groups[1].Value); var kidBytes = Convert.FromBase64String(KIDRegex().Match(text).Groups[1].Value);
// save kid for playready // save kid for playready
this.ProtecitonKID_PR = HexUtil.BytesToHex(kidBytes); this.ProtectionKID_PR = HexUtil.BytesToHex(kidBytes);
// fix byte order // fix byte order
var reverse1 = new[] { kidBytes[3], kidBytes[2], kidBytes[1], kidBytes[0] }; var reverse1 = new[] { kidBytes[3], kidBytes[2], kidBytes[1], kidBytes[0] };
var reverse2 = new[] { kidBytes[5], kidBytes[4], kidBytes[7], kidBytes[6] }; var reverse2 = new[] { kidBytes[5], kidBytes[4], kidBytes[7], kidBytes[6] };
Array.Copy(reverse1, 0, kidBytes, 0, reverse1.Length); Array.Copy(reverse1, 0, kidBytes, 0, reverse1.Length);
Array.Copy(reverse2, 0, kidBytes, 4, reverse1.Length); Array.Copy(reverse2, 0, kidBytes, 4, reverse1.Length);
this.ProtecitonKID = HexUtil.BytesToHex(kidBytes); this.ProtectionKID = HexUtil.BytesToHex(kidBytes);
} }
// widevine // widevine
else if (ProtectionSystemId.ToUpper() == "EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED") else if (ProtectionSystemId.ToUpper() == "EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED")
@ -225,7 +225,7 @@ public partial class MSSMoovProcessor
tencPayload.AddRange([0, 0]); tencPayload.AddRange([0, 0]);
tencPayload.Add(0x1); // default_IsProtected tencPayload.Add(0x1); // default_IsProtected
tencPayload.Add(0x8); // default_Per_Sample_IV_size tencPayload.Add(0x8); // default_Per_Sample_IV_size
tencPayload.AddRange(HexUtil.HexToBytes(ProtecitonKID)); // default_KID tencPayload.AddRange(HexUtil.HexToBytes(ProtectionKID)); // default_KID
// tencPayload.Add(0x8);// default_constant_IV_size // tencPayload.Add(0x8);// default_constant_IV_size
// tencPayload.AddRange(new byte[8]);// default_constant_IV // tencPayload.AddRange(new byte[8]);// default_constant_IV
var tencBox = FullBox("tenc", 0, 0, tencPayload.ToArray()); var tencBox = FullBox("tenc", 0, 0, tencPayload.ToArray());
@ -753,10 +753,10 @@ public partial class MSSMoovProcessor
using var _stream = new MemoryStream(); using var _stream = new MemoryStream();
using var _writer = new BinaryWriter2(_stream); using var _writer = new BinaryWriter2(_stream);
var sysIdData = HexUtil.HexToBytes("edef8ba9-79d6-4ace-a3c8-27dcd51d21ed".Replace("-", "")); var sysIdData = HexUtil.HexToBytes("edef8ba9-79d6-4ace-a3c8-27dcd51d21ed".Replace("-", ""));
// var kid = HexUtil.HexToBytes(ProtecitonKID); // var kid = HexUtil.HexToBytes(ProtectionKID);
_writer.Write(sysIdData); // SystemID 16 bytes _writer.Write(sysIdData); // SystemID 16 bytes
var psshData = HexUtil.HexToBytes($"08011210{ProtecitonKID}1A046E647265220400000000"); var psshData = HexUtil.HexToBytes($"08011210{ProtectionKID}1A046E647265220400000000");
_writer.WriteUInt(psshData.Length); // Size of Data 4 bytes _writer.WriteUInt(psshData.Length); // Size of Data 4 bytes
_writer.Write(psshData); // Data _writer.Write(psshData); // Data
var psshBox = FullBox("pssh", 0, 0, _stream.ToArray()); var psshBox = FullBox("pssh", 0, 0, _stream.ToArray());