Example #1
0
        /// <summary>
        /// Takes an RPC state from the drive and a CMI from a disc and checks if the regions are compatible.
        /// </summary>
        /// <param name="rpc">The <c>RegionalPlaybackControlState</c> from drive.</param>
        /// <param name="cmi">The <c>LeadInCopyright</c> from disc.</param>
        /// <returns><c>true</c> if the regions are compatible, else <c>false</c></returns>
        public static bool CheckRegion(CSS_CPRM.RegionalPlaybackControlState rpc, CSS_CPRM.LeadInCopyright cmi)
        {
            // if disc region is all or none, we cannot do anything but try to read it as is
            if (cmi.RegionInformation == 0xFF ||
                cmi.RegionInformation == 0x00)
            {
                return(true);
            }

            return(((rpc.RegionMask & 0x01) == (cmi.RegionInformation & 0x01) && (rpc.RegionMask & 0x01) != 0x01) ||
                   ((rpc.RegionMask & 0x02) == (cmi.RegionInformation & 0x02) && (rpc.RegionMask & 0x02) != 0x02) ||
                   ((rpc.RegionMask & 0x04) == (cmi.RegionInformation & 0x04) && (rpc.RegionMask & 0x04) != 0x04) ||
                   ((rpc.RegionMask & 0x08) == (cmi.RegionInformation & 0x08) && (rpc.RegionMask & 0x08) != 0x08) ||
                   ((rpc.RegionMask & 0x10) == (cmi.RegionInformation & 0x10) && (rpc.RegionMask & 0x10) != 0x10) ||
                   ((rpc.RegionMask & 0x20) == (cmi.RegionInformation & 0x20) && (rpc.RegionMask & 0x20) != 0x20) ||
                   ((rpc.RegionMask & 0x40) == (cmi.RegionInformation & 0x40) && (rpc.RegionMask & 0x40) != 0x40) ||
                   ((rpc.RegionMask & 0x80) == (cmi.RegionInformation & 0x80) && (rpc.RegionMask & 0x80) != 0x80));
        }
Example #2
0
        internal static void AddMediaTagToSidecar(string outputPath,
                                                  KeyValuePair <MediaTagType, byte[]> tag,
                                                  ref CICMMetadataType sidecar)
        {
            switch (tag.Key)
            {
            case MediaTagType.DVD_PFI:
                sidecar.OpticalDisc[0].PFI = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };
                break;

            case MediaTagType.DVD_DMI:
                sidecar.OpticalDisc[0].DMI = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };
                break;

            case MediaTagType.DVD_CMI:
            case MediaTagType.HDDVD_CPI:
                sidecar.OpticalDisc[0].CMI = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };

                CSS_CPRM.LeadInCopyright cpy = CSS_CPRM.DecodeLeadInCopyright(tag.Value).Value;
                if (cpy.CopyrightType != CopyrightType.NoProtection)
                {
                    sidecar.OpticalDisc[0].CopyProtection = cpy.CopyrightType.ToString();
                }

                break;

            case MediaTagType.DVD_BCA:
            case MediaTagType.BD_BCA:
                sidecar.OpticalDisc[0].BCA = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };
                break;

            case MediaTagType.BD_DDS:
            case MediaTagType.DVDRAM_DDS:
                sidecar.OpticalDisc[0].DDS = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };
                break;

            case MediaTagType.DVDRAM_SpareArea:
            case MediaTagType.BD_SpareArea:
                sidecar.OpticalDisc[0].SAI = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };
                break;

            case MediaTagType.DVDR_PreRecordedInfo:
                sidecar.OpticalDisc[0].PRI = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };
                break;

            case MediaTagType.DVD_MediaIdentifier:
                sidecar.OpticalDisc[0].MediaID = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };
                break;

            case MediaTagType.DVDR_PFI:
                sidecar.OpticalDisc[0].PFIR = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };
                break;

            case MediaTagType.DVD_ADIP:
                sidecar.OpticalDisc[0].ADIP = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };
                break;

            case MediaTagType.DCB:
                sidecar.OpticalDisc[0].DCB = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };
                break;

            case MediaTagType.BD_DI:
                sidecar.OpticalDisc[0].DI = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };
                break;

            case MediaTagType.Xbox_SecuritySector:
                if (sidecar.OpticalDisc[0].Xbox == null)
                {
                    sidecar.OpticalDisc[0].Xbox = new XboxType();
                }

                sidecar.OpticalDisc[0].Xbox.SecuritySectors = new[]
                {
                    new XboxSecuritySectorsType
                    {
                        RequestNumber   = 0,
                        RequestVersion  = 1,
                        SecuritySectors = new DumpType
                        {
                            Image     = outputPath,
                            Size      = tag.Value.Length,
                            Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                        }
                    }
                };

                break;

            case MediaTagType.Xbox_PFI:
                if (sidecar.OpticalDisc[0].Xbox == null)
                {
                    sidecar.OpticalDisc[0].Xbox = new XboxType();
                }

                sidecar.OpticalDisc[0].Xbox.PFI = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };
                break;

            case MediaTagType.Xbox_DMI:
                if (sidecar.OpticalDisc[0].Xbox == null)
                {
                    sidecar.OpticalDisc[0].Xbox = new XboxType();
                }

                sidecar.OpticalDisc[0].Xbox.DMI = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };
                break;

            case MediaTagType.CD_FullTOC:
                sidecar.OpticalDisc[0].TOC = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };
                break;

            case MediaTagType.CD_ATIP:
                sidecar.OpticalDisc[0].ATIP = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };
                break;

            case MediaTagType.CD_PMA:
                sidecar.OpticalDisc[0].PMA = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };
                break;

            case MediaTagType.CD_TEXT:
                sidecar.OpticalDisc[0].LeadInCdText = new DumpType
                {
                    Image     = outputPath,
                    Size      = tag.Value.Length,
                    Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                };
                break;

            case MediaTagType.CD_LeadIn:
                sidecar.OpticalDisc[0].LeadIn = new[]
                {
                    new BorderType
                    {
                        Image     = outputPath,
                        Size      = tag.Value.Length,
                        Checksums = Checksum.GetChecksums(tag.Value).ToArray()
                    }
                };
                break;
            }
        }