protected AsfFileConfiguration GetConfiguration(string fileName) { AsfFileConfiguration config = new AsfFileConfiguration(); bool isFirstObject = true; _headerObjects = new List <AsfObject>(); using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { while (true) { AsfObject someObject = new AsfObject(stream); if (isFirstObject && someObject.Guid != AsfGuid.ASF_Header_Object) // invalid file { return(null); } isFirstObject = false; if (someObject.Size == 0) { break; } _headerObjects.Add(AsfObject.CreateAsfObject(someObject.Guid, stream, config)); if (someObject.Guid == AsfGuid.ASF_Data_Object) { //parse asf objects after data packets, if any long filePosition = config.AsfHeaderSize + config.AsfPacketCount * config.AsfPacketSize; stream.Position = filePosition; } } } return(config); }
public void TearDown() { _mockRepository = null; _parentAsfObject = null; _detector = null; _asfObject = null; _childAsfObject = null; }
public void CreateAsfObject() { AsfFile asfFile = new AsfFile(testVideoFileName); AsfFileConfiguration config = new AsfFileConfiguration(); AsfFileHeader asfFileHeader; using (FileStream fs = new FileStream(testVideoFileName, FileMode.Open, FileAccess.Read)) { asfFileHeader = (AsfFileHeader)AsfObject.CreateAsfObject(AsfGuid.ASF_Header_Object, fs, config); } Assert.IsNotNull(asfFileHeader); Assert.AreEqual <uint>(5292, asfFileHeader.HeaderSize); }
public AsfHeaderItem(string name, Guid type, Stream stream) { Name = name; _stream = stream; Properties = new Dictionary <string, object>(); Subsections = new Dictionary <string, Dictionary <string, object> >(); AsfObject someObject = new AsfObject(stream, name); Properties.Add("File Position", someObject.Position); Properties.Add("Object ID", someObject.Guid.ToString().ToUpper()); Properties.Add("Object Size", someObject.Size); _childNodes = new List <AsfHeaderItem>(); }
public void SetUp() { // The string "DynamicProxyGenAssembly2" is used in AsfDetector class to grant Rhino Mocks // access to its internals. Debug.Assert(RhinoMocks.NormalName == "DynamicProxyGenAssembly2"); _mockRepository = new MockRepository(); // Mocks and stubs _detector = MockRepository.GenerateStub <IDetector>(); //_resultNode = MockRepository.GenerateStub<IResultNode>(); _childAsfObject = MockRepository.GenerateStub <AsfObject>(Enumerable.Repeat(_detector, 1)); _parentAsfObject = _mockRepository.PartialMock <AsfObject>(Enumerable.Repeat(_detector, 1)); _asfObject = _mockRepository.PartialMock <AsfObject>(Enumerable.Repeat(_detector, 1)); }
public LanguageListObject(AsfObject previousObject) : base(previousObject, AsfObjectName.LanguageListObject) { }
public IndexParametersObject(AsfObject previousObject) : base(previousObject, AsfObjectName.IndexParametersObject) { }
public TimecodeIndexParametersObject(AsfObject previousObject) : base(previousObject, AsfObjectName.TimecodeIndexParametersObject) { }
public AdvancedContentEncryptionObject(AsfObject previousObject) : base(previousObject, AsfObjectName.AdvancedContentEncryptionObject) { }
public StreamBitratePropertiesObject(AsfObject previousObject) : base(previousObject, AsfObjectName.StreamBitratePropertiesObject) { }
public DigitalSignatureObject(AsfObject previousObject) : base(previousObject, AsfObjectName.DigitalSignatureObject) { }
public StreamPrioritizationObject(AsfObject previousObject) : base(previousObject, AsfObjectName.StreamPrioritizationObject) { }
public ErrorCorrectionObject(AsfObject previousObject) : base(previousObject, AsfObjectName.ErrorCorrectionObject) { }
public IndexParametersPlaceholderObject(AsfObject previousObject) : base(previousObject, AsfObjectName.PaddingObject) { }
public HeaderObject(AsfObject previousObject) : base(previousObject, AsfObjectName.HeaderObject) { }
public PaddingObject(AsfObject previousObject) : base(previousObject, AsfObjectName.PaddingObject) { }
public ContentEncryptionObject(AsfObject previousObject) : base(previousObject, AsfObjectName.ContentEncryptionObject) { }
public static List<AsfHeaderItem> GetHeaderObjects(string fileName) { List<AsfHeaderItem> asfHeaderItems = new List<AsfHeaderItem>(); bool isFirstObject = true; AsfHeaderItem asfHeaderItem = null; AsfHeaderItem asfHeaderExtensionsItem = null; AsfHeaderItem.Configuration.Reset(); try { using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { while (true) { AsfObject someObject = new AsfObject(fs); long objSize = (long)someObject.Size; if (objSize == 0) break; Guid objGuid = someObject.Guid; if (isFirstObject && objGuid != AsfGuid.ASF_Header_Object) // invalid file return null; if (objGuid == AsfGuid.ASF_Header_Object) { asfHeaderItem = new AsfFileHeaderItem(fs); asfHeaderItems.Add(asfHeaderItem); isFirstObject = false; } else if (objGuid == AsfGuid.ASF_Stream_Bitrate_Properties_Object) { AsfHeaderItem item = new AsfStreamBitratePropertiesItem(fs); asfHeaderItem.Add(item); } else if (objGuid == AsfGuid.ASF_File_Properties_Object) { AsfFilePropertiesItem item = new AsfFilePropertiesItem(fs); asfHeaderItem.Add(item); } else if (objGuid == AsfGuid.ASF_Header_Extension_Object) { asfHeaderExtensionsItem = new AsfHeaderExtensionItem(fs); asfHeaderItem.Add(asfHeaderExtensionsItem); } else if (objGuid == AsfGuid.ASF_Language_List_Object) { AsfLanguageListObjectItem item = new AsfLanguageListObjectItem(fs); asfHeaderExtensionsItem.Add(item); } else if (objGuid == AsfGuid.ASF_Stream_Properties_Object) { AsfStreamPropertiesObjectItem item = new AsfStreamPropertiesObjectItem(fs); asfHeaderItem.Add(item); } else if (objGuid == AsfGuid.ASF_Extended_Stream_Properties_Object) { AsfExtendedStreamPropertiesItem item = new AsfExtendedStreamPropertiesItem(fs); asfHeaderExtensionsItem.Add(item); } else if (objGuid == AsfGuid.ASF_Compatibility_Object) { AsfCompatibilityObjectItem item = new AsfCompatibilityObjectItem(fs); asfHeaderExtensionsItem.Add(item); } else if (objGuid == AsfGuid.ASF_Metadata_Object) { AsfMetadataObjectItem item = new AsfMetadataObjectItem(fs); asfHeaderExtensionsItem.Add(item); } else if (objGuid == AsfGuid.ASF_Padding_Object) { AsfPaddingObjectItem item = new AsfPaddingObjectItem(fs); asfHeaderExtensionsItem.Add(item); } else if (objGuid == AsfGuid.ASF_Index_Parameters_Placeholder_Object) { AsfIndexParametersPlaceholderItem item = new AsfIndexParametersPlaceholderItem(fs); asfHeaderExtensionsItem.Add(item); } else if (objGuid == AsfGuid.ASF_Extended_Content_Description_Object) { AsfExtendedContentDescriptionItem item = new AsfExtendedContentDescriptionItem(fs); asfHeaderItem.Add(item); } else if (objGuid == AsfGuid.ASF_Codec_List_Object) { AsfCodecListObjectItem item = new AsfCodecListObjectItem(fs); asfHeaderItem.Add(item); } else if (objGuid == AsfGuid.ASF_Data_Object) { AsfDataObjectItem item = new AsfDataObjectItem(fs); asfHeaderItems.Add(item); } else if (objGuid == AsfGuid.ASF_Simple_Index_Object) { AsfSimpleIndexObjectItem item = new AsfSimpleIndexObjectItem(fs); asfHeaderItems.Add(item); } else if (objGuid == AsfGuid.ASF_Bitrate_Mutual_Exclusion_Object) { AsfBitrateMutualExclusionObjectItem item = new AsfBitrateMutualExclusionObjectItem(fs); asfHeaderItem.Add(item); } else if (objGuid == AsfGuid.ASF_Content_Description_Object) { AsfContentDescriptionObjectItem item = new AsfContentDescriptionObjectItem(fs); asfHeaderItem.Add(item); } else if (objGuid == AsfGuid.ASF_Stream_Prioritization_Object) { AsfStreamPrioritizationObjectItem item = new AsfStreamPrioritizationObjectItem(fs); asfHeaderItem.Add(item); } else if (objGuid == AsfGuid.ASF_Timecode_Index_Parameters_Object) { AsfTimecodeIndexParametersObjectItem item = new AsfTimecodeIndexParametersObjectItem(fs); asfHeaderExtensionsItem.Add(item); } else if (objGuid == AsfGuid.ASF_Index_Parameters_Object) { AsfIndexParametersObjectItem item = new AsfIndexParametersObjectItem(fs); asfHeaderExtensionsItem.Add(item); } else if (objGuid == AsfGuid.ASF_Index_Object) { AsfIndexObjectItem item = new AsfIndexObjectItem(fs); asfHeaderItems.Add(item); } else if (objGuid == AsfGuid.ASF_Script_Command_Object) { AsfScriptCommandObjectItem item = new AsfScriptCommandObjectItem(fs); asfHeaderItem.Add(item); } else //Unknown object { fs.Seek(fs.Position + objSize, SeekOrigin.Begin); } } return asfHeaderItems; } } catch (IOException) { return null; } }
public CompatibilityObject(AsfObject previousObject) : base(previousObject, AsfObjectName.CompatibilityObject) { }
public MediaObjectIndexParametersObject(AsfObject previousObject) : base(previousObject, AsfObjectName.MediaObjectIndexParametersObject) { }
public static List <AsfHeaderItem> GetHeaderObjects(string fileName) { List <AsfHeaderItem> asfHeaderItems = new List <AsfHeaderItem>(); bool isFirstObject = true; AsfHeaderItem asfHeaderItem = null; AsfHeaderItem asfHeaderExtensionsItem = null; AsfHeaderItem.Configuration.Reset(); try { using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { while (true) { AsfObject someObject = new AsfObject(fs); long objSize = (long)someObject.Size; if (objSize == 0) { break; } Guid objGuid = someObject.Guid; if (isFirstObject && objGuid != AsfGuid.ASF_Header_Object) // invalid file { return(null); } if (objGuid == AsfGuid.ASF_Header_Object) { asfHeaderItem = new AsfFileHeaderItem(fs); asfHeaderItems.Add(asfHeaderItem); isFirstObject = false; } else if (objGuid == AsfGuid.ASF_Stream_Bitrate_Properties_Object) { AsfHeaderItem item = new AsfStreamBitratePropertiesItem(fs); asfHeaderItem.Add(item); } else if (objGuid == AsfGuid.ASF_File_Properties_Object) { AsfFilePropertiesItem item = new AsfFilePropertiesItem(fs); asfHeaderItem.Add(item); } else if (objGuid == AsfGuid.ASF_Header_Extension_Object) { asfHeaderExtensionsItem = new AsfHeaderExtensionItem(fs); asfHeaderItem.Add(asfHeaderExtensionsItem); } else if (objGuid == AsfGuid.ASF_Language_List_Object) { AsfLanguageListObjectItem item = new AsfLanguageListObjectItem(fs); asfHeaderExtensionsItem.Add(item); } else if (objGuid == AsfGuid.ASF_Stream_Properties_Object) { AsfStreamPropertiesObjectItem item = new AsfStreamPropertiesObjectItem(fs); asfHeaderItem.Add(item); } else if (objGuid == AsfGuid.ASF_Extended_Stream_Properties_Object) { AsfExtendedStreamPropertiesItem item = new AsfExtendedStreamPropertiesItem(fs); asfHeaderExtensionsItem.Add(item); } else if (objGuid == AsfGuid.ASF_Compatibility_Object) { AsfCompatibilityObjectItem item = new AsfCompatibilityObjectItem(fs); asfHeaderExtensionsItem.Add(item); } else if (objGuid == AsfGuid.ASF_Metadata_Object) { AsfMetadataObjectItem item = new AsfMetadataObjectItem(fs); asfHeaderExtensionsItem.Add(item); } else if (objGuid == AsfGuid.ASF_Padding_Object) { AsfPaddingObjectItem item = new AsfPaddingObjectItem(fs); asfHeaderExtensionsItem.Add(item); } else if (objGuid == AsfGuid.ASF_Index_Parameters_Placeholder_Object) { AsfIndexParametersPlaceholderItem item = new AsfIndexParametersPlaceholderItem(fs); asfHeaderExtensionsItem.Add(item); } else if (objGuid == AsfGuid.ASF_Extended_Content_Description_Object) { AsfExtendedContentDescriptionItem item = new AsfExtendedContentDescriptionItem(fs); asfHeaderItem.Add(item); } else if (objGuid == AsfGuid.ASF_Codec_List_Object) { AsfCodecListObjectItem item = new AsfCodecListObjectItem(fs); asfHeaderItem.Add(item); } else if (objGuid == AsfGuid.ASF_Data_Object) { AsfDataObjectItem item = new AsfDataObjectItem(fs); asfHeaderItems.Add(item); } else if (objGuid == AsfGuid.ASF_Simple_Index_Object) { AsfSimpleIndexObjectItem item = new AsfSimpleIndexObjectItem(fs); asfHeaderItems.Add(item); } else if (objGuid == AsfGuid.ASF_Bitrate_Mutual_Exclusion_Object) { AsfBitrateMutualExclusionObjectItem item = new AsfBitrateMutualExclusionObjectItem(fs); asfHeaderItem.Add(item); } else if (objGuid == AsfGuid.ASF_Content_Description_Object) { AsfContentDescriptionObjectItem item = new AsfContentDescriptionObjectItem(fs); asfHeaderItem.Add(item); } else if (objGuid == AsfGuid.ASF_Stream_Prioritization_Object) { AsfStreamPrioritizationObjectItem item = new AsfStreamPrioritizationObjectItem(fs); asfHeaderItem.Add(item); } else if (objGuid == AsfGuid.ASF_Timecode_Index_Parameters_Object) { AsfTimecodeIndexParametersObjectItem item = new AsfTimecodeIndexParametersObjectItem(fs); asfHeaderExtensionsItem.Add(item); } else if (objGuid == AsfGuid.ASF_Index_Parameters_Object) { AsfIndexParametersObjectItem item = new AsfIndexParametersObjectItem(fs); asfHeaderExtensionsItem.Add(item); } else if (objGuid == AsfGuid.ASF_Index_Object) { AsfIndexObjectItem item = new AsfIndexObjectItem(fs); asfHeaderItems.Add(item); } else if (objGuid == AsfGuid.ASF_Script_Command_Object) { AsfScriptCommandObjectItem item = new AsfScriptCommandObjectItem(fs); asfHeaderItem.Add(item); } else //Unknown object { fs.Seek(fs.Position + objSize, SeekOrigin.Begin); } } return(asfHeaderItems); } } catch (IOException) { return(null); } }
public FilePropertiesObject(AsfObject previousObject) : base(previousObject, AsfObjectName.FilePropertiesObject) { }
public ContentDescriptionObject(AsfObject previousObject) : base(previousObject, AsfObjectName.ContentDescriptionObject) { }