示例#1
0
        /// <summary>
        /// Load the attribute collection from a recording file (dvr-ms or wtv).
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns>An error message or null if the load succeeds.</returns>
        public static string Load(string fileName)
        {
            if (!File.Exists(fileName))
                return ("The recording file ' " + fileName + "' does not exist");

            StreamBufferRecordingAttributes recordingAttributes = new StreamBufferRecordingAttributes();

            int reply = ((IFileSourceFilter)recordingAttributes).Load(fileName, null);
            if (reply != 0)
                return ("The attributes cannot be loaded");

            int reserved = 0;
            short attributeCount;
            reply = ((IStreamBufferRecordingAttribute)recordingAttributes).GetAttributeCount(reserved, out attributeCount);

            attributes = new Collection<RecordingAttribute>();

            for (short index = 0; index < attributeCount; index++)
            {
                StreamBufferAttrDataType attributeType;
                StringBuilder name = null;
                byte[] attributeValue = null;
                short nameLength = 0;
                short valueLength = 0;

                reply = ((IStreamBufferRecordingAttribute)recordingAttributes).GetAttributeByIndex(index,
                    ref reserved,
                    name,
                    ref nameLength,
                    out attributeType,
                    attributeValue,
                    ref valueLength);

                name = new StringBuilder(nameLength);
                attributeValue = new byte[valueLength];

                reply = ((IStreamBufferRecordingAttribute)recordingAttributes).GetAttributeByIndex(index,
                    ref reserved,
                    name,
                    ref nameLength,
                    out attributeType,
                    attributeValue,
                    ref valueLength);

                if (name != null && name.Length != 0)
                {
                    RecordingAttribute attribute = getAttribute(name, attributeType, attributeValue);
                    if (attribute != null)
                        attributes.Add(attribute);
                }
            }

            return (null);
        }
示例#2
0
        /// <summary>
        /// Load the attribute collection from a recording file (dvr-ms or wtv).
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns>An error message or null if the load succeeds.</returns>
        public static string Load(string fileName)
        {
            if (!File.Exists(fileName))
            {
                return("The recording file ' " + fileName + "' does not exist");
            }

            StreamBufferRecordingAttributes recordingAttributes = new StreamBufferRecordingAttributes();

            int reply = ((IFileSourceFilter)recordingAttributes).Load(fileName, null);

            if (reply != 0)
            {
                return("The attributes cannot be loaded");
            }

            int   reserved = 0;
            short attributeCount;

            reply = ((IStreamBufferRecordingAttribute)recordingAttributes).GetAttributeCount(reserved, out attributeCount);

            attributes = new Collection <RecordingAttribute>();

            for (short index = 0; index < attributeCount; index++)
            {
                StreamBufferAttrDataType attributeType;
                StringBuilder            name = null;
                byte[] attributeValue         = null;
                short  nameLength             = 0;
                short  valueLength            = 0;

                reply = ((IStreamBufferRecordingAttribute)recordingAttributes).GetAttributeByIndex(index,
                                                                                                   ref reserved,
                                                                                                   name,
                                                                                                   ref nameLength,
                                                                                                   out attributeType,
                                                                                                   attributeValue,
                                                                                                   ref valueLength);

                name           = new StringBuilder(nameLength);
                attributeValue = new byte[valueLength];

                reply = ((IStreamBufferRecordingAttribute)recordingAttributes).GetAttributeByIndex(index,
                                                                                                   ref reserved,
                                                                                                   name,
                                                                                                   ref nameLength,
                                                                                                   out attributeType,
                                                                                                   attributeValue,
                                                                                                   ref valueLength);

                if (name != null && name.Length != 0)
                {
                    RecordingAttribute attribute = getAttribute(name, attributeType, attributeValue);
                    if (attribute != null)
                    {
                        attributes.Add(attribute);
                    }
                }
            }

            return(null);
        }