Ejemplo n.º 1
0
        /// <summary>
        ///    Reads the contents of the current instance.
        /// </summary>
        /// <param name="propertiesStyle">
        ///    A <see cref="ReadStyle" /> value specifying at what level
        ///    of accuracy to read the media properties, or <see
        ///    cref="ReadStyle.None" /> to ignore the properties.
        /// </param>
        private void Read(ReadStyle propertiesStyle)
        {
            Mode = AccessMode.Read;
            try
            {
                HeaderObject header = new HeaderObject(this, 0);

                if (header.HasContentDescriptors)
                {
                    TagTypesOnDisk |= TagTypes.Asf;
                }

                asf_tag = new Asf.Tag(header);

                InvariantStartPosition = (long)header.OriginalSize;
                InvariantEndPosition   = Length;

                if (propertiesStyle != ReadStyle.None)
                {
                    properties = header.Properties;
                }
            }
            finally
            {
                Mode = AccessMode.Closed;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///    Saves the changes made in the current instance to the
        ///    file it represents.
        /// </summary>
        public override void Save()
        {
            Mode = AccessMode.Write;
            try
            {
                HeaderObject header = new HeaderObject(this, 0);

                if (asf_tag == null)
                {
                    header.RemoveContentDescriptors();
                    TagTypesOnDisk &= ~TagTypes.Asf;
                }
                else
                {
                    TagTypesOnDisk |= TagTypes.Asf;
                    header.AddUniqueObject(
                        asf_tag.ContentDescriptionObject);
                    header.AddUniqueObject(
                        asf_tag.ExtendedContentDescriptionObject);
                    header.Extension.AddUniqueObject(
                        asf_tag.MetadataLibraryObject);
                }

                ByteVector output = header.Render();
                long       diff   = output.Count - (long)header.OriginalSize;
                Insert(output, 0, (long)header.OriginalSize);

                InvariantStartPosition += diff;
                InvariantEndPosition   += diff;
            }
            finally
            {
                Mode = AccessMode.Closed;
            }
        }