Ejemplo n.º 1
0
 /// <summary>
 ///	Tries to find the local tag in the primer pack and if so,
 ///	adds the referring key to the tag.
 /// </summary>
 /// <param name="tag"></param>
 private void AddRefKeyFromPrimerPack(MXFLocalTag tag)
 {
     if (this.Partition != null && this.Partition.PrimerKeys != null)
     {
         if (this.Partition.PrimerKeys.ContainsKey(tag.Tag))
         {
             MXFEntryPrimer entry = this.Partition.PrimerKeys[tag.Tag];
             tag.Key = entry.AliasUID.Key;
         }
     }
 }
        /// <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();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Set all properties to readonly (recursive through to the base classes)
        /// </summary>
        public void UpdateTypeDescriptions(Type type, Dictionary <UInt16, MXFEntryPrimer> allPrimerKeys)
        {
            if (type != null && allPrimerKeys != null)
            {
                if (type.BaseType != null)
                {
                    UpdateTypeDescriptions(type.BaseType, allPrimerKeys);
                }

                foreach (PropertyDescriptor prop in TypeDescriptor.GetProperties(type))
                {
                    DescriptionAttribute attr = prop.Attributes[typeof(DescriptionAttribute)] as DescriptionAttribute;
                    if (attr != null)
                    {
                        if (!string.IsNullOrEmpty(attr.Description) && attr.Description.Length == 4)
                        {
                            string newDescription = "";

                            // Get the local tag
                            try
                            {
                                UInt16 localTag = (UInt16)Convert.ToInt32(attr.Description, 16);

                                // Find the local tag in the primer pack
                                if (allPrimerKeys.ContainsKey(localTag))
                                {
                                    MXFEntryPrimer prime = allPrimerKeys[localTag];
                                    newDescription = prime.AliasUID.Key.Name;
                                }

                                FieldInfo fi = attr.GetType().GetField("description", BindingFlags.NonPublic | BindingFlags.Instance);
                                if (fi != null)
                                {
                                    fi.SetValue(attr, newDescription);
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Read partition tag list
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="categoryName"></param>
        /// <returns></returns>
        protected UInt32 ReadTagList(MXFReader reader, string categoryName)
        {
            UInt32 nofItems   = reader.ReadD();
            UInt32 objectSize = reader.ReadD();             // useless size of objects, always 16 according to specs

            MXFObject keylist = new MXFNamedObject(categoryName, reader.Position);

            if (nofItems > 0 && nofItems < UInt32.MaxValue)
            {
                m_PrimerKeys = new Dictionary <UInt16, MXFEntryPrimer>();
                for (int n = 0; n < nofItems; n++)
                {
                    MXFEntryPrimer entry = new MXFEntryPrimer(reader);
                    m_PrimerKeys.Add(entry.LocalTag, entry);     // Add to our own internal list
                    keylist.AddChild(entry);                     // And add the entry as one of our children
                }
            }
            this.AddChild(keylist);
            return(nofItems);
        }