Exemple #1
0
        public void SetProperty(WM_ATTR attr)
        {
            object obj;
            uint   size;

            Logger.WriteLogMessage("Set property[" + attr.Name + "].");

            switch (attr.DataType)
            {
            case WMT_ATTR_DATATYPE.WMT_TYPE_STRING:
                byte[] arr = Encoding.Unicode.GetBytes((string)attr.Value + (char)0);
                obj  = arr;
                size = (ushort)arr.Length;
                break;

            case WMT_ATTR_DATATYPE.WMT_TYPE_BOOL:
                obj  = (uint)((bool)attr ? 1 : 0);
                size = 4;
                break;

            case WMT_ATTR_DATATYPE.WMT_TYPE_BINARY:
                obj  = (byte[])attr.Value;
                size = (ushort)((byte[])obj).Length;
                break;

            case WMT_ATTR_DATATYPE.WMT_TYPE_DWORD:
                obj  = (uint)attr;
                size = 4;
                break;

            case WMT_ATTR_DATATYPE.WMT_TYPE_QWORD:
                obj  = (ulong)attr;
                size = 8;
                break;

            case WMT_ATTR_DATATYPE.WMT_TYPE_WORD:
                obj  = (ushort)attr;
                size = 2;
                break;

            case WMT_ATTR_DATATYPE.WMT_TYPE_GUID:
                obj  = (Guid)attr;
                size = (ushort)Marshal.SizeOf(typeof(Guid));
                break;

            default:
                throw new ArgumentException("Invalid data type.", "attr");
            }

            GCHandle h = GCHandle.Alloc(obj, GCHandleType.Pinned);

            try
            {
                _propertyVault.SetProperty(attr.Name, attr.DataType, h.AddrOfPinnedObject(), size);
            }
            finally
            {
                h.Free();
            }
        }
Exemple #2
0
        public void Open(string filePath, TimeSpan startTime, TimeSpan duration)
        {
            if (Utility.IsEmptyString(filePath))
            {
                throw new ArgumentNullException("inputFilePath", "Invalid string parameter.");
            }

            _reader.Open(filePath);

            Logger.WriteLogMessage("Opened file [" + filePath + "] for reading.");

            WMHeaderInfo readerHeaderInfo = new WMHeaderInfo((IWMHeaderInfo)_reader);

            WM_ATTR  attr           = readerHeaderInfo.GetAttribute(Constants.g_wszWMDuration);
            TimeSpan readerDuration = new TimeSpan((long)(ulong)attr.Value);

            Logger.WriteLogMessage("Found input duration [" + readerDuration + "].");

            if (startTime != TimeSpan.Zero)
            {
                //
                // startTime, duration are in 100-nsec ticks
                //
                _reader.SetRange((ulong)startTime.Ticks, duration.Ticks); // seek

                Logger.WriteLogMessage("Set range on reader, startTime [" + startTime + "], duration [" + duration + "].");
            }

            _reader.GetOutputCount(out _readerOutputCount);

            Logger.WriteLogMessage("Found " + _readerOutputCount + " reader outputs.");

            IWMProfile readerProfile = (IWMProfile)_reader;

            readerProfile.GetStreamCount(out _readerStreamCount);
        }
Exemple #3
0
		public void SetAttribute(WM_ATTR attr)
		{
			SetAttribute(0, attr);
		}
Exemple #4
0
		public void SetAttribute(int streamNumber, WM_ATTR attr)
		{
			object obj;
			ushort size;

			switch (attr.DataType)
			{
				case WMT_ATTR_DATATYPE.WMT_TYPE_STRING:
					byte[] arr = Encoding.Unicode.GetBytes((string)attr.Value + (char)0);
					obj = arr;
					size = (ushort)arr.Length;
					break;
				case WMT_ATTR_DATATYPE.WMT_TYPE_BOOL:
					obj = (uint)((bool)attr ? 1 : 0);
					size = 4;
					break;
				case WMT_ATTR_DATATYPE.WMT_TYPE_BINARY:
					obj = (byte[])attr.Value;
					size = (ushort)((byte[])obj).Length;
					break;
				case WMT_ATTR_DATATYPE.WMT_TYPE_DWORD:
					obj = (uint)attr;
					size = 4;
					break;
				case WMT_ATTR_DATATYPE.WMT_TYPE_QWORD:
					obj = (ulong)attr;
					size = 8;
					break;
				case WMT_ATTR_DATATYPE.WMT_TYPE_WORD:
					obj = (ushort)attr;
					size = 2;
					break;
				case WMT_ATTR_DATATYPE.WMT_TYPE_GUID:
					obj = (Guid)attr;
					size = (ushort)Marshal.SizeOf(typeof(Guid));
					break;
				default:
					throw new ArgumentException("Invalid data type", "attr");
			}
			
			GCHandle h = GCHandle.Alloc(obj, GCHandleType.Pinned);

			try
			{
				_headerInfo.SetAttribute((ushort)streamNumber, attr.Name, attr.DataType, h.AddrOfPinnedObject(), size);
			}
			finally
			{
				h.Free();
			}
		}
Exemple #5
0
 public void SetAttribute(WM_ATTR attr)
 {
     SetAttribute(0, attr);
 }