[matroska] r879 - in trunk/mkNETtools: . CLI MuxEngine PluginManager Plugins/WavPlugin

[email protected]
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: jcsston
Date: 2004-10-13 21:24:39 +0400 (Wed, 13 Oct 2004)
New Revision: 879

Added:
   trunk/mkNETtools/MuxEngine/
   trunk/mkNETtools/MuxEngine/AssemblyInfo.cs
   trunk/mkNETtools/MuxEngine/InputSource.cs
   trunk/mkNETtools/MuxEngine/MuxEngine.cs
   trunk/mkNETtools/MuxEngine/MuxEngine.csproj
   trunk/mkNETtools/MuxEngine/MuxEngine.csproj.user
   trunk/mkNETtools/MuxEngine/MuxThread.cs
Modified:
   trunk/mkNETtools/CLI/Test.cs
   trunk/mkNETtools/PluginManager/PluginManager.cs
   trunk/mkNETtools/Plugins/WavPlugin/WavOutput.cs
   trunk/mkNETtools/mkNETtools.sln
Log:
Core Muxing Engine started.
Added Input and Output Plugin detection in PluginManager.

Modified: trunk/mkNETtools/CLI/Test.cs
===================================================================
--- trunk/mkNETtools/CLI/Test.cs	2004-10-13 16:13:35 UTC (rev 878)
+++ trunk/mkNETtools/CLI/Test.cs	2004-10-13 17:24:39 UTC (rev 879)
@@ -28,20 +28,15 @@
       ArgumentProcessor CommandLine = new ArgumentProcessor(Args);
 
       // Look for specific arguments values and display them if they exist (return null if they don't)
-      if(CommandLine["param1"]!=null) Console.WriteLine("Param1 value: "+CommandLine["param1"]);
-      else Console.WriteLine("Param1 not defined !");
+      if (CommandLine["i"] != null) 
+        Console.WriteLine("i value: " + CommandLine["i"]);
+      else 
+        Console.WriteLine("i not defined !");
 			
-      if(CommandLine["height"]!=null) Console.WriteLine("Height value: "+CommandLine["height"]);
-      else Console.WriteLine("Height not defined !");
-			
-      if(CommandLine["width"]!=null) Console.WriteLine("Width value: "+CommandLine["width"]);
-      else Console.WriteLine("Width not defined !");
-			
-      if(CommandLine["size"]!=null) Console.WriteLine("Size value: "+CommandLine["size"]);
-      else Console.WriteLine("Size not defined !");
-			
-      if(CommandLine["debug"]!=null) Console.WriteLine("Debug value: "+CommandLine["debug"]);
-      else Console.WriteLine("Debug not defined !");
+      if (CommandLine["o"] != null) 
+        Console.WriteLine("o value: " + CommandLine["o"]);
+      else 
+        Console.WriteLine("o not defined !");
 
       PluginManager.PluginManager manager = new PluginManager.PluginManager();
       foreach (string name in manager.PluginNames) 

Added: trunk/mkNETtools/MuxEngine/AssemblyInfo.cs
===================================================================
--- trunk/mkNETtools/MuxEngine/AssemblyInfo.cs	2004-10-13 16:13:35 UTC (rev 878)
+++ trunk/mkNETtools/MuxEngine/AssemblyInfo.cs	2004-10-13 17:24:39 UTC (rev 879)
@@ -0,0 +1,58 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+//
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+//
+[assembly: AssemblyTitle("")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("")]
+[assembly: AssemblyCopyright("")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]		
+
+//
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Revision and Build Numbers 
+// by using the '*' as shown below:
+
+[assembly: AssemblyVersion("1.0.*")]
+
+//
+// In order to sign your assembly you must specify a key to use. Refer to the 
+// Microsoft .NET Framework documentation for more information on assembly signing.
+//
+// Use the attributes below to control which key is used for signing. 
+//
+// Notes: 
+//   (*) If no key is specified, the assembly is not signed.
+//   (*) KeyName refers to a key that has been installed in the Crypto Service
+//       Provider (CSP) on your machine. KeyFile refers to a file which contains
+//       a key.
+//   (*) If the KeyFile and the KeyName values are both specified, the 
+//       following processing occurs:
+//       (1) If the KeyName can be found in the CSP, that key is used.
+//       (2) If the KeyName does not exist and the KeyFile does exist, the key 
+//           in the KeyFile is installed into the CSP and used.
+//   (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
+//       When specifying the KeyFile, the location of the KeyFile should be
+//       relative to the project output directory which is
+//       %Project Directory%\obj\<configuration>. For example, if your KeyFile is
+//       located in the project directory, you would specify the AssemblyKeyFile 
+//       attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
+//   (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
+//       documentation for more information on this.
+//
+[assembly: AssemblyDelaySign(false)]
+[assembly: AssemblyKeyFile("")]
+[assembly: AssemblyKeyName("")]

Added: trunk/mkNETtools/MuxEngine/InputSource.cs
===================================================================
--- trunk/mkNETtools/MuxEngine/InputSource.cs	2004-10-13 16:13:35 UTC (rev 878)
+++ trunk/mkNETtools/MuxEngine/InputSource.cs	2004-10-13 17:24:39 UTC (rev 879)
@@ -0,0 +1,19 @@
+using System;
+using mkNETtools.PluginManager;
+using mkNETtools.PluginHelper;
+
+namespace mkNETtools.MuxEngine
+{
+	/// <summary>
+	/// Summary description for InputSource.
+	/// </summary>
+	public class InputSource
+	{
+    protected IBaseInputPlugin m_Plugin = null;
+
+		public InputSource(IBaseInputPlugin plugin)
+		{
+      m_Plugin = plugin;
+		}
+	}
+}

Added: trunk/mkNETtools/MuxEngine/MuxEngine.cs
===================================================================
--- trunk/mkNETtools/MuxEngine/MuxEngine.cs	2004-10-13 16:13:35 UTC (rev 878)
+++ trunk/mkNETtools/MuxEngine/MuxEngine.cs	2004-10-13 17:24:39 UTC (rev 879)
@@ -0,0 +1,50 @@
+using System;
+using System.Collections;
+
+namespace mkNETtools.MuxEngine
+{
+	/// <summary>
+	/// Summary description for MuxEngine.
+	/// </summary>
+	public class MuxEngine
+	{
+    protected ArrayList m_Input = new ArrayList();
+    protected string m_OutputFilename = "";
+    protected MuxThread m_Thread = new MuxThread();
+
+		public MuxEngine()
+		{
+			//
+			// TODO: Add constructor logic here
+			//
+		}
+
+    void AddInput(InputSource input) 
+    {
+      m_Input.Add(input);
+    }
+
+    public string OutputFilename
+    {
+      get
+      {
+        return m_OutputFilename;
+      }
+      set
+      {
+        m_OutputFilename = value;
+      }
+    }
+
+    void Start()
+    {
+      m_Thread.Load(m_Input, m_OutputFilename);
+      m_Thread.Start();
+    }
+
+    void Stop()
+    {
+      m_Thread.Stop();
+    }
+	}
+}

Added: trunk/mkNETtools/MuxEngine/MuxEngine.csproj
===================================================================
--- trunk/mkNETtools/MuxEngine/MuxEngine.csproj	2004-10-13 16:13:35 UTC (rev 878)
+++ trunk/mkNETtools/MuxEngine/MuxEngine.csproj	2004-10-13 17:24:39 UTC (rev 879)
@@ -0,0 +1,110 @@
+<VisualStudioProject>
+    <CSHARP
+        ProjectType = "Local"
+        ProductVersion = "7.10.3077"
+        SchemaVersion = "2.0"
+        ProjectGuid = "{A98EF19E-393D-4EDB-A83F-8D242E770363}"
+    >
+        <Build>
+            <Settings
+                ApplicationIcon = ""
+                AssemblyKeyContainerName = ""
+                AssemblyName = "mkNETtools.MuxEngine"
+                AssemblyOriginatorKeyFile = ""
+                DefaultClientScript = "JScript"
+                DefaultHTMLPageLayout = "Grid"
+                DefaultTargetSchema = "IE50"
+                DelaySign = "false"
+                OutputType = "Library"
+                PreBuildEvent = ""
+                PostBuildEvent = ""
+                RootNamespace = "mkNETtools.MuxEngine"
+                RunPostBuildEvent = "OnBuildSuccess"
+                StartupObject = ""
+            >
+                <Config
+                    Name = "Debug"
+                    AllowUnsafeBlocks = "false"
+                    BaseAddress = "285212672"
+                    CheckForOverflowUnderflow = "false"
+                    ConfigurationOverrideFile = ""
+                    DefineConstants = "DEBUG;TRACE"
+                    DocumentationFile = ""
+                    DebugSymbols = "true"
+                    FileAlignment = "4096"
+                    IncrementalBuild = "false"
+                    NoStdLib = "false"
+                    NoWarn = ""
+                    Optimize = "false"
+                    OutputPath = "..\Debug\"
+                    RegisterForComInterop = "false"
+                    RemoveIntegerChecks = "false"
+                    TreatWarningsAsErrors = "false"
+                    WarningLevel = "4"
+                />
+                <Config
+                    Name = "Release"
+                    AllowUnsafeBlocks = "false"
+                    BaseAddress = "285212672"
+                    CheckForOverflowUnderflow = "false"
+                    ConfigurationOverrideFile = ""
+                    DefineConstants = "TRACE"
+                    DocumentationFile = "mkNETtools.MuxEngine.xml"
+                    DebugSymbols = "false"
+                    FileAlignment = "4096"
+                    IncrementalBuild = "false"
+                    NoStdLib = "false"
+                    NoWarn = ""
+                    Optimize = "true"
+                    OutputPath = "..\Release\"
+                    RegisterForComInterop = "false"
+                    RemoveIntegerChecks = "false"
+                    TreatWarningsAsErrors = "false"
+                    WarningLevel = "4"
+                />
+            </Settings>
+            <References>
+                <Reference
+                    Name = "System"
+                    AssemblyName = "System"
+                    HintPath = "C:\WINXP\Microsoft.NET\Framework\v1.1.4322\System.dll"
+                />
+                <Reference
+                    Name = "PluginManager"
+                    Project = "{7CBBC988-B4BD-4610-AA07-BE171A60D723}"
+                    Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
+                />
+                <Reference
+                    Name = "PluginHelper"
+                    Project = "{BEE56F2B-43B9-407E-9579-BBE863D23AD7}"
+                    Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
+                />
+            </References>
+        </Build>
+        <Files>
+            <Include>
+                <File
+                    RelPath = "AssemblyInfo.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "InputSource.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "MuxEngine.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
+                    RelPath = "MuxThread.cs"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+            </Include>
+        </Files>
+    </CSHARP>
+</VisualStudioProject>
+

Added: trunk/mkNETtools/MuxEngine/MuxEngine.csproj.user
===================================================================
--- trunk/mkNETtools/MuxEngine/MuxEngine.csproj.user	2004-10-13 16:13:35 UTC (rev 878)
+++ trunk/mkNETtools/MuxEngine/MuxEngine.csproj.user	2004-10-13 17:24:39 UTC (rev 879)
@@ -0,0 +1,48 @@
+<VisualStudioProject>
+    <CSHARP LastOpenVersion = "7.10.3077" >
+        <Build>
+            <Settings ReferencePath = "" >
+                <Config
+                    Name = "Debug"
+                    EnableASPDebugging = "false"
+                    EnableASPXDebugging = "false"
+                    EnableUnmanagedDebugging = "false"
+                    EnableSQLServerDebugging = "false"
+                    RemoteDebugEnabled = "false"
+                    RemoteDebugMachine = ""
+                    StartAction = "Project"
+                    StartArguments = ""
+                    StartPage = ""
+                    StartProgram = ""
+                    StartURL = ""
+                    StartWorkingDirectory = ""
+                    StartWithIE = "true"
+                />
+                <Config
+                    Name = "Release"
+                    EnableASPDebugging = "false"
+                    EnableASPXDebugging = "false"
+                    EnableUnmanagedDebugging = "false"
+                    EnableSQLServerDebugging = "false"
+                    RemoteDebugEnabled = "false"
+                    RemoteDebugMachine = ""
+                    StartAction = "Project"
+                    StartArguments = ""
+                    StartPage = ""
+                    StartProgram = ""
+                    StartURL = ""
+                    StartWorkingDirectory = ""
+                    StartWithIE = "true"
+                />
+            </Settings>
+        </Build>
+        <OtherProjectSettings
+            CopyProjectDestinationFolder = ""
+            CopyProjectUncPath = ""
+            CopyProjectOption = "0"
+            ProjectView = "ProjectFiles"
+            ProjectTrust = "0"
+        />
+    </CSHARP>
+</VisualStudioProject>
+

Added: trunk/mkNETtools/MuxEngine/MuxThread.cs
===================================================================
--- trunk/mkNETtools/MuxEngine/MuxThread.cs	2004-10-13 16:13:35 UTC (rev 878)
+++ trunk/mkNETtools/MuxEngine/MuxThread.cs	2004-10-13 17:24:39 UTC (rev 879)
@@ -0,0 +1,50 @@
+using System;
+using System.Collections;
+using System.Threading;
+
+namespace mkNETtools.MuxEngine
+{
+	/// <summary>
+	/// Summary description for MuxThread.
+	/// </summary>
+	public class MuxThread
+	{
+    protected Thread m_Thread = null;
+    protected bool m_bExit = false;
+    protected ArrayList m_Input;
+    protected string m_OutputFilename;
+
+		public MuxThread()
+		{
+			m_Thread = new Thread(new ThreadStart(this.ThreadProc));
+      m_Thread.Name = "Muxing Thread";
+		}
+
+    public void Load(ArrayList input, string outputFilename)
+    {
+      m_Input = input;
+      m_OutputFilename = outputFilename;
+    }
+
+    public void Start()
+    {
+      m_Thread.Start();
+    }
+
+    public void Stop()
+    {
+      m_bExit = true;
+      if (m_Thread.Join(1000 * 30) == false)
+        throw new ThreadInterruptedException("Muxing Thread failed to exit after 30 seconds");
+    }
+
+    protected void ThreadProc()
+    {
+      while (!m_bExit) 
+      {
+
+        Thread.Sleep(10);
+      }
+    }
+	}
+}

Modified: trunk/mkNETtools/PluginManager/PluginManager.cs
===================================================================
--- trunk/mkNETtools/PluginManager/PluginManager.cs	2004-10-13 16:13:35 UTC (rev 878)
+++ trunk/mkNETtools/PluginManager/PluginManager.cs	2004-10-13 17:24:39 UTC (rev 879)
@@ -75,7 +75,7 @@
       get 
       {
         string[] output = new string[plugins.Count];
-        for (int i =0 ; i< plugins.Count; i++)
+        for (int i = 0; i < plugins.Count; i++)
         {
           IBasePlugin plugin = (IBasePlugin)plugins[i];
           output[i] = plugin.GetPluginName() + " : " + plugin.GetType().FullName;
@@ -84,6 +84,50 @@
       }
     }
 
+    public IBasePlugin [] Plugins
+    {
+      get 
+      {
+        return (IBasePlugin [])plugins.ToArray(typeof(IBasePlugin));
+      }
+    }
+
+    public IBaseInputPlugin [] InputPlugins
+    {
+      get 
+      {
+        ArrayList inputPlugins = new ArrayList();
+
+        foreach (IBasePlugin plugin in plugins)
+        {
+          if (plugin == typeof(IBaseInputPlugin)) 
+          {
+            inputPlugins.Add(plugin);
+          }
+        }
+
+        return (IBaseInputPlugin [])inputPlugins.ToArray(typeof(IBaseInputPlugin));
+      }
+    }
+
+    public IBaseOutputPlugin [] OutputPlugins
+    {
+      get 
+      {
+        ArrayList outputPlugins = new ArrayList();
+
+        foreach (IBasePlugin plugin in plugins)
+        {
+          if (plugin == typeof(IBaseOutputPlugin)) 
+          {
+            outputPlugins.Add(plugin);
+          }
+        }
+
+        return (IBaseOutputPlugin [])outputPlugins.ToArray(typeof(IBaseOutputPlugin));
+      }
+    }
+
     public void UnloadPlugin(string typename)
     {
       for (int i = 0; i < plugins.Count; i++)

Modified: trunk/mkNETtools/Plugins/WavPlugin/WavOutput.cs
===================================================================
--- trunk/mkNETtools/Plugins/WavPlugin/WavOutput.cs	2004-10-13 16:13:35 UTC (rev 878)
+++ trunk/mkNETtools/Plugins/WavPlugin/WavOutput.cs	2004-10-13 17:24:39 UTC (rev 879)
@@ -12,6 +12,7 @@
 	public class WavOutput : IBaseOutputPlugin
 	{
     protected WavWriter m_Writer = null;
+    protected string m_Filename = "";
     protected WaveFormatEx m_Wfx = new WaveFormatEx();
 
 		public WavOutput()
@@ -32,7 +33,7 @@
       {
         IAudioTrackInfo track = (IAudioTrackInfo)tracks[0];
         
-        m_Wfx.wFormatTag = 0;
+        m_Wfx = new WaveFormatEx();
         m_Wfx.nChannels = (short)track.Channels;
         m_Wfx.wBitsPerSample = (short)track.Bitdepth;
         // Should I use the sampling rate or ouptut sampling rate?
@@ -42,14 +43,21 @@
 
         if (track.CodecID == CodecIDs.AUDIO_ACM) 
         {
+          MemoryStream memStream = new MemoryStream(track.CodecPrivate, 0, track.CodecPrivate.Length, false);
+          BinaryReader binReader = new BinaryReader(memStream);
+          m_Wfx.Read(binReader, track.CodecPrivate.Length);
+        }
+        else if (track.CodecID == CodecIDs.AUDIO_MPEG_LAYER3) 
+        {
+          m_Wfx.wFormatTag = (short)WaveFormatEx.WAVE_FORMAT_MPEG_LAYER3;
           int wfxSize = m_Wfx.GetSize();
           m_Wfx.cbSize = (short)(track.CodecPrivate.Length - wfxSize);
           m_Wfx.cbData = new byte[m_Wfx.cbSize];
           Array.Copy(track.CodecPrivate, wfxSize, m_Wfx.cbData, 0, m_Wfx.cbSize);
         }
-        else if (track.CodecID == CodecIDs.AUDIO_MPEG_LAYER3) 
+        else if (track.CodecID == CodecIDs.AUDIO_MPEG_LAYER2 || track.CodecID == CodecIDs.AUDIO_MPEG_LAYER1) 
         {
-
+          m_Wfx.wFormatTag = (short)WaveFormatEx.WAVE_FORMAT_MPEG_LAYER12;
         }
         else
         {
@@ -60,11 +68,15 @@
       {
         throw new ArgumentException("Wav only supports an audio track.", ex);
       }
-      
+      // Now we can open the file
+      m_Writer.Open(m_Filename, m_Wfx);
     }
 
     public void WriteFrame(ref Frame frame)
     {
+      // Right now we just ignore timecodes and write the sample data out directly
+      // Prehaps later we could add some padding code if some samples are dropped
+      // If samples are overlapping that's just too bad.
       m_Writer.WriteSampleData(ref frame.Data, 0, frame.Data.Length);
     }
 
@@ -84,13 +96,12 @@
     public void Close()
     {
       m_Writer = null;
-      m_Wfx = new WaveFormatEx();
     }
 
     public void Open(string filename)
     {
-      m_Writer = new WavWriter();
-      m_Writer.Open(filename, m_Wfx);
+      m_Writer = new WavWriter();     
+      m_Filename = filename;
     }
 
     public bool IsSupported(string filename)

Modified: trunk/mkNETtools/mkNETtools.sln
===================================================================
--- trunk/mkNETtools/mkNETtools.sln	2004-10-13 16:13:35 UTC (rev 878)
+++ trunk/mkNETtools/mkNETtools.sln	2004-10-13 17:24:39 UTC (rev 879)
@@ -23,6 +23,10 @@
 	ProjectSection(ProjectDependencies) = postProject
 	EndProjectSection
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MuxEngine", "MuxEngine\MuxEngine.csproj", "{A98EF19E-393D-4EDB-A83F-8D242E770363}"
+	ProjectSection(ProjectDependencies) = postProject
+	EndProjectSection
+EndProject
 Global
 	GlobalSection(SolutionConfiguration) = preSolution
 		Debug = Debug
@@ -53,6 +57,10 @@
 		{B1ED75BD-38C8-423A-AAB1-01D8CD2AE297}.Debug.Build.0 = Debug|.NET
 		{B1ED75BD-38C8-423A-AAB1-01D8CD2AE297}.Release.ActiveCfg = Release|.NET
 		{B1ED75BD-38C8-423A-AAB1-01D8CD2AE297}.Release.Build.0 = Release|.NET
+		{A98EF19E-393D-4EDB-A83F-8D242E770363}.Debug.ActiveCfg = Debug|.NET
+		{A98EF19E-393D-4EDB-A83F-8D242E770363}.Debug.Build.0 = Debug|.NET
+		{A98EF19E-393D-4EDB-A83F-8D242E770363}.Release.ActiveCfg = Release|.NET
+		{A98EF19E-393D-4EDB-A83F-8D242E770363}.Release.Build.0 = Release|.NET
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 	EndGlobalSection
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.