Esempio n. 1
0
 /// <summary>
 /// Named Reference key
 /// </summary>
 /// <param name="reader"></param>
 public MXFRefKey(MXFReader reader, UInt32 size, string name)
     : base(reader.Position)
 {
     this.Name   = name;
     this.Key    = new MXFKey(reader, size);
     this.Length = this.Key.Length;
 }
Esempio n. 2
0
 /// <summary>
 /// Create the KLV key
 /// </summary>
 /// <param name="reader"></param>
 public MXFKLV(MXFReader reader, MXFKey key)
     : base(reader)
 {
     this.Key        = CreateAndValidateKey(reader);
     this.Length     = DecodeBerLength(reader);
     this.DataOffset = reader.Position;
 }
Esempio n. 3
0
        /// <summary>
        /// Validate if the current position is a valid SMPTE key
        /// </summary>
        private MXFKey CreateAndValidateKey(MXFReader reader)
        {
            byte iso = reader.ReadB();
            byte len = reader.ReadB();
            byte smp = 0, te = 0;
            bool valid = false;

            if (iso == 0x06)              // Do not check length when not iso
            {
                smp   = reader.ReadB();
                te    = reader.ReadB();
                valid = (smp == 0x2B && te == 0x34);                 // SMPTE define
            }
            if (!valid)
            {
                //throw new ApplicationException(string.Format("Invalid SMPTE Key found at offset {0}! Incorrect MXF file!", reader.Position - 4));
                MXFKey key = new MXFKey(iso, len, smp, te, reader);
                LogError("Invalid SMPTE Key found at offset {0}! Key: {1}", reader.Position - 4, key.Name);
                return(key);
            }
            else
            {
                return(new MXFKey(iso, len, smp, te, reader));
            }
        }
Esempio n. 4
0
 public MXFAUID(MXFReader reader, string name)
     : base(reader.Position)
 {
     this.Name   = name;
     this.Key    = reader.ReadULKey();
     this.Length = this.Key.Length;
 }
 /// <summary>
 /// Overridden method to process local tags
 /// </summary>
 /// <param name="localTag"></param>
 protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
 {
     switch (localTag.Tag)
     {
     case 0x3E01: this.DataEssenceCoding = reader.ReadULKey();       return(true);
     }
     return(base.ParseLocalTag(reader, localTag));
 }
Esempio n. 6
0
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case var _ when localTag.Key == audioBitRate_Key: this.MPEGAudioBitRate = reader.ReadUInt32(); return(true);

            case var _ when localTag.Key == channelAssignment_Key: this.MPEGAudioChannelAssignment = reader.ReadULKey(); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x0102: this.GenerationUID = reader.ReadKey(); return(true);

            case 0x0101: this.ObjectClass = reader.ReadKey(); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
Esempio n. 8
0
 protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
 {
     switch (localTag.Tag)
     {
     case 0x0011: ReferencedType = reader.ReadULKey(); return(true);
         // TODO maybe this is more appropriate?
         //case 0x0011: this.AddChild(reader.ReadReference<MXFTypeDefinition>("ReferencedType")); return true;
     }
     return(base.ParseLocalTag(reader, localTag));
 }
Esempio n. 9
0
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x0013: this.AddChild(reader.ReadAUIDSet("TargetSet", "Target")); return(true);

            case 0x0012: WeakReferencedType = reader.ReadULKey(); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="reader"></param>
        private void Initialize(MXFReader reader)
        {
            // Make sure we read at the data position
            reader.Seek(this.DataOffset);

            // Read all local tags
            long klvEnd = this.DataOffset + this.Length;

            while (reader.Position + 4 < klvEnd)
            {
                MXFLocalTag tag  = new MXFLocalTag(reader);
                long        next = tag.DataOffset + tag.Size;

                if (tag.Tag == 0x3C0A)
                {
                    // Generic instance UID
                    this.InstanceUID = reader.ReadKey();
                }
                else
                {
                    if (tag.Tag > 0x7FFF)
                    {
                        // Find the tag in the primerpack's keys
                        if (this.Partition != null && this.Partition.PrimerKeys != null)
                        {
                            if (this.Partition.PrimerKeys.ContainsKey(tag.Tag))
                            {
                                MXFEntryPrimer entry = this.Partition.PrimerKeys[tag.Tag];
                                tag.Name = entry.AliasUID.Key.Name;
                            }
                        }
                    }

                    // Allow derived classes to handle the data
                    if (!ParseLocalTag(reader, tag))
                    {
                        // Not processed, use default
                        tag.Parse(reader);

                        // Add to the collection
                        AddChild(tag);
                    }
                }

                reader.Seek(next);
            }

            // Allow derived classes to do some final work
            PostInitialize();
        }
Esempio n. 11
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x3006: this.LinkedTrackId = reader.ReadD(); return(true);

            case 0x3001: this.SampleRate = reader.ReadRational(); return(true);

            case 0x3002: this.ContainerDuration = reader.ReadL(); return(true);

            case 0x3004: this.EssenceContainer = reader.ReadKey(); return(true);

            case 0x3005: this.Codec = reader.ReadKey(); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
Esempio n. 12
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x3C0A: this.InstanceID = reader.ReadUUIDKey(); return(true);

            case 0x0102: this.LinkedGenerationID = reader.ReadULKey(); return(true);

            case 0x0101: this.ObjectClass = reader.ReadULKey(); return(true);

            // TODO replace generic MXFObject with class ApplicationPluginObject once implemented
            case var _ when localTag.Key == appPluginObjects_Key:
                this.AddChild(reader.ReadReferenceSet <MXFObject>("Application Plugin Objects", "Application Plugin Object"));
                return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
Esempio n. 13
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x3D03: this.AudioSamplingRate = reader.ReadRational(); return(true);

            case 0x3D02: this.Locked = reader.ReadBool(); return(true);

            case 0x3D04: this.AudioRefLevel = reader.ReadsB(); return(true);

            case 0x3D05: this.ElectroSpatialFormulation = reader.ReadB(); return(true);

            case 0x3D07: this.ChannelCount = reader.ReadD(); return(true);

            case 0x3D01: this.QuantizationBits = reader.ReadD(); return(true);

            case 0x3D0C: this.DialNorm = reader.ReadsB(); return(true);

            case 0x3D06: this.SoundEssenceCoding = reader.ReadKey(); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
Esempio n. 14
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            if (localTag.Key != null)
            {
                switch (localTag.Key)
                {
                case var _ when localTag.Key == cryptoContextId_Key: this.CryptographicContextID = reader.ReadULKey(); return(true);

                case var _ when localTag.Key == cipherAlgorithm_Key: this.CipherAlgorithm = reader.ReadULKey(); return(true);

                case var _ when localTag.Key == cryptoKeyID_Key: this.CryptographicKeyID = reader.ReadULKey(); return(true);

                case var _ when localTag.Key == mICAlgorithm_Key: this.MICAlgorithm = reader.ReadULKey(); return(true);

                case var _ when localTag.Key == sourceContainerFormat_Key: this.SourceContainerFormat = reader.ReadULKey(); return(true);

                case var _ when localTag.Key == mICCarriage_Key: this.MICCarriage = reader.ReadULKey(); return(true);
                }
            }

            return(base.ParseLocalTag(reader, localTag));
        }
Esempio n. 15
0
        /// <summary>
        /// Validate if the current position is a valid SMPTE key
        /// </summary>
        private MXFKey CreateAndValidateKey(MXFReader reader)
        {
            long originalPos = reader.Position;

            byte[] prefix = reader.ReadArray(reader.ReadByte, 4);
            bool   valid  = prefix.SequenceEqual(validULPrefix);

            // TODO does this really make sense checking key length if not valid whenever not equal to 16 bytes?
            // read the other bytes of the UL (length is defined in second byte minus two already read bytes)
            byte[] other    = reader.ReadArray(reader.ReadByte, prefix[1] - 2);
            byte[] keyBytes = prefix.Concat(other).ToArray();
            MXFKey key      = new MXFKey(keyBytes);

            // TODO the responsibility for checking the key should be moved to file MXFKey???
            // TODO check that none of the bytes excceds value 7F = 127 according to SMPTE298M
            if (!valid)
            {
                //throw new ApplicationException(string.Format("Invalid SMPTE Key found at offset {0}! Incorrect MXF file!", reader.Position - 4));
                LogError("Invalid SMPTE Key found at offset {0}! Key: {1}", reader.Position - 4, key.Name);
                throw new Exception(string.Format("Invalid SMPTE UL found at @{0}! Key: {1}", originalPos, key.ToString()));
            }
            return(key);
        }
Esempio n. 16
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x3C09: this.ThisGenerationUID = reader.ReadULKey(); return(true);

            case 0x3C01: this.CompanyName = reader.ReadUTF16String(localTag.Size); return(true);

            case 0x3C02: this.ProductName = reader.ReadUTF16String(localTag.Size); return(true);

            case 0x3C03: this.ProductVersion = reader.ReadProductVersion(); return(true);

            case 0x3C04: this.ProductVersionString = reader.ReadUTF16String(localTag.Size); return(true);

            case 0x3C05: this.ProductUID = reader.ReadULKey(); return(true);

            case 0x3C06: this.ModificationDate = reader.ReadTimestamp(); return(true);

            case 0x3C07: this.ToolkitVersion = reader.ReadProductVersion(); return(true);

            case 0x3C08: this.Platform = reader.ReadUTF16String(localTag.Size); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
Esempio n. 17
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x3B02: this.LastModificationDate = reader.ReadTimestamp(); return(true);

            case 0x3B05: this.Version = reader.ReadW(); return(true);

            case 0x3B07: this.ObjectModelVersion = reader.ReadD(); return(true);

            case 0x3B03: this.ContentStorageUID = new MXFRefKey(reader, 16, "ContentStorageUID"); return(true);

            case 0x3B08: this.PrimaryPackageUID = new MXFRefKey(reader, 16, "PrimaryPackageUID"); return(true);

            case 0x3B09: this.OperationalPattern = new MXFKey(reader, 16); return(true);

            case 0x3B06: ReadKeyList(reader, "Identifications", "Identification"); return(true);

            case 0x3B0A: ReadKeyList(reader, "Essencecontainers", "Essencecontainer"); return(true);

            case 0x3B0B: ReadKeyList(reader, "Descriptive Metadata Schemes", "DM scheme"); return(true);
            }
            return(base.ParseLocalTag(reader, localTag));
        }
Esempio n. 18
0
 /// <summary>
 /// Create a new reference key by reading from the current file location
 /// </summary>
 /// <param name="firstPart"></param>
 /// <param name="reader"></param>
 public MXFRefKey(MXFReader reader)
     : base(reader.Position)
 {
     this.Key    = new MXFKey(reader, 16);
     this.Length = 16;
 }
Esempio n. 19
0
        /// <summary>
        /// Overridden method to process local tags
        /// </summary>
        /// <param name="localTag"></param>
        protected override bool ParseLocalTag(MXFReader reader, MXFLocalTag localTag)
        {
            switch (localTag.Tag)
            {
            case 0x3215: this.SignalStandard = reader.ReadB(); return(true);

            case 0x320C: this.FrameLayout = reader.ReadB(); return(true);

            case 0x3203: this.StoredWidth = reader.ReadD(); return(true);

            case 0x3202: this.StoredHeight = reader.ReadD(); return(true);

            case 0x3216: this.StoredF2Offset = (Int32)reader.ReadD(); return(true);

            case 0x3205: this.SampledWidth = reader.ReadD(); return(true);

            case 0x3204: this.SampledHeight = reader.ReadD(); return(true);

            case 0x3206: this.SampledXOffset = (Int32)reader.ReadD(); return(true);

            case 0x3207: this.SampledYOffset = (Int32)reader.ReadD(); return(true);

            case 0x3208: this.DisplayHeight = reader.ReadD(); return(true);

            case 0x3209: this.DisplayWidth = reader.ReadD(); return(true);

            case 0x320A: this.DisplayXOffset = (Int32)reader.ReadD(); return(true);

            case 0x320B: this.DisplayYOffset = (Int32)reader.ReadD(); return(true);

            case 0x3217: this.DisplayF2Offset = (Int32)reader.ReadD(); return(true);

            case 0x320E: this.AspectRatio = reader.ReadRational(); return(true);

            case 0x3218: this.ActiveFormatDescriptor = reader.ReadB(); return(true);

            case 0x320D:
                this.VideoLineMap    = new Int32[4];
                this.VideoLineMap[0] = (Int32)reader.ReadD();
                this.VideoLineMap[1] = (Int32)reader.ReadD();
                this.VideoLineMap[2] = (Int32)reader.ReadD();
                this.VideoLineMap[3] = (Int32)reader.ReadD();
                return(true);

            case 0x320F: this.AlphaTransparency = reader.ReadB(); return(true);

            case 0x3210: this.TransferCharacteristics = reader.ReadKey(); return(true);

            case 0x3211: this.ImageAlignmentOffset = reader.ReadD(); return(true);

            case 0x3213: this.ImageStartOffset = reader.ReadD(); return(true);

            case 0x3214: this.ImageEndOffset = reader.ReadD(); return(true);

            case 0x3212: this.FieldDominance = reader.ReadB(); return(true);

            case 0x3201: this.PictureEssenceCoding = reader.ReadKey(); return(true);

            case 0x321A: this.CodingEquations = reader.ReadKey(); return(true);

            case 0x3219: this.ColorPrimaries = reader.ReadKey(); return(true);
            }

            //PropertyDescriptor prop = TypeDescriptor.GetProperties(typeof(MXFGenericPictureEssenceDescriptor))["StoredWidth"];
            //DescriptionAttribute attr = prop.Attributes[typeof(DescriptionAttribute)] as DescriptionAttribute;
            //FieldInfo fi = attr.GetType().GetField("description", BindingFlags.NonPublic | BindingFlags.Instance);
            //if (fi != null)
            //	fi.SetValue(attr, "DIT IS GELUKT!!!");

            return(base.ParseLocalTag(reader, localTag));
        }
Esempio n. 20
0
        public static bool AreAllPartitionsOP1a(this MXFFile file)
        {
            MXFKey op1a = new MXFKey(0x06, 0x0E, 0x2B, 0x34, 0x04, 0x01, 0x01, 0x01, 0x0D, 0x01, 0x02, 0x01, 0x01, 0x01, 0x09, 0x00);

            return(file.Partitions.Select(p => p.OP).Any(s => s == op1a));
        }