Author: jcsston
Date: 2004-10-14 11:55:44 +0400 (Thu, 14 Oct 2004)
New Revision: 882
Added:
trunk/mkNETtools/Plugins/MpaPlugin/
trunk/mkNETtools/Plugins/MpaPlugin/AssemblyInfo.cs
trunk/mkNETtools/Plugins/MpaPlugin/MpaOutput.cs
trunk/mkNETtools/Plugins/MpaPlugin/MpaPlugin.csproj
trunk/mkNETtools/Plugins/MpaPlugin/MpaPlugin.csproj.user
Modified:
trunk/mkNETtools/CLI/CLI.csproj.user
trunk/mkNETtools/CLI/Test.cs
trunk/mkNETtools/MuxEngine/MuxEngine.cs
trunk/mkNETtools/MuxEngine/MuxThread.cs
trunk/mkNETtools/PluginManager/PluginManager.cs
trunk/mkNETtools/Plugins/MatroskaInput/MatroskaInput.cs
trunk/mkNETtools/Plugins/WavPlugin/WavOutput.cs
trunk/mkNETtools/mkNETtools.sln
Log:
Working for mka->mp3 demuxing.
Modified: trunk/mkNETtools/CLI/CLI.csproj.user
===================================================================
--- trunk/mkNETtools/CLI/CLI.csproj.user 2004-10-14 07:48:39 UTC (rev 881)
+++ trunk/mkNETtools/CLI/CLI.csproj.user 2004-10-14 07:55:44 UTC (rev 882)
@@ -11,7 +11,7 @@
RemoteDebugEnabled = "false"
RemoteDebugMachine = ""
StartAction = "Project"
- StartArguments = ""
+ StartArguments = '-i:"D:\My Music\Eliza Wren - Living on the Outiside.mka" -o:"D:\My Music\Eliza Wren - Living on the Outiside_.mp3"'
StartPage = ""
StartProgram = ""
StartURL = ""
Modified: trunk/mkNETtools/CLI/Test.cs
===================================================================
--- trunk/mkNETtools/CLI/Test.cs 2004-10-14 07:48:39 UTC (rev 881)
+++ trunk/mkNETtools/CLI/Test.cs 2004-10-14 07:55:44 UTC (rev 882)
@@ -61,6 +61,9 @@
Thread.Sleep(100);
}
+ Console.Out.WriteLine("Muxing is complete.");
+ Console.Out.WriteLine("Frames Muxed: " + engine.FramesMuxed);
+ Console.Out.WriteLine("Time Elapsed: " + engine.TimeElapsed);
// Wait for key
Console.Out.WriteLine("Press any key...");
Modified: trunk/mkNETtools/MuxEngine/MuxEngine.cs
===================================================================
--- trunk/mkNETtools/MuxEngine/MuxEngine.cs 2004-10-14 07:48:39 UTC (rev 881)
+++ trunk/mkNETtools/MuxEngine/MuxEngine.cs 2004-10-14 07:55:44 UTC (rev 882)
@@ -44,6 +44,22 @@
}
}
+ public long FramesMuxed
+ {
+ get
+ {
+ return m_Thread.FramesMuxed;
+ }
+ }
+
+ public double TimeElapsed
+ {
+ get
+ {
+ return m_Thread.TimeElapsed;
+ }
+ }
+
public bool Complete
{
get
Modified: trunk/mkNETtools/MuxEngine/MuxThread.cs
===================================================================
--- trunk/mkNETtools/MuxEngine/MuxThread.cs 2004-10-14 07:48:39 UTC (rev 881)
+++ trunk/mkNETtools/MuxEngine/MuxThread.cs 2004-10-14 07:55:44 UTC (rev 882)
@@ -15,6 +15,9 @@
protected ArrayList m_Input = null;
protected OutputTarget m_Output = null;
protected bool m_Complete = false;
+ protected long m_FramesMuxed = 0;
+ protected double m_StartTime = 0.0;
+ protected double m_EndTime = 0.0;
public MuxThread()
{
@@ -28,6 +31,29 @@
m_Output = output;
}
+ public long FramesMuxed
+ {
+ get
+ {
+ return m_FramesMuxed;
+ }
+ }
+
+ public double TimeElapsed
+ {
+ get
+ {
+ if (m_EndTime != 0.0)
+ {
+ return m_EndTime - m_StartTime;
+ }
+ else
+ {
+ return 0.0 - m_StartTime;
+ }
+ }
+ }
+
public bool Complete
{
get
@@ -38,6 +64,25 @@
public void Start()
{
+ // Reset counters
+ m_FramesMuxed = 0;
+ m_StartTime = 0.0;
+ m_EndTime = 0.0;
+
+ // Setup the output plugin
+ ArrayList outputTracks = new ArrayList();
+ foreach (InputSource input in m_Input)
+ {
+ foreach (InputTrackInfo track in input.Tracks)
+ {
+ if (track.Enabled)
+ {
+ outputTracks.Add(track.Track);
+ }
+ }
+ }
+ m_Output.Plugin.Tracks = (ITrackInfo [])outputTracks.ToArray(typeof(ITrackInfo));
+
m_Thread.Start();
}
@@ -94,6 +139,7 @@
m_Output.Plugin.WriteFrame(ref frame);
lastTimecode = frame.Timecode;
bEOF = false;
+ m_FramesMuxed++;
}
}
}
@@ -104,7 +150,7 @@
Console.Out.WriteLine(percent + "%");
lastPercent = percent;
}
- Thread.Sleep(10);
+ //Thread.Sleep(10);
if (bEOF)
break;
}
@@ -113,6 +159,7 @@
}
catch (Exception ex)
{
+ Console.Error.WriteLine(ex);
throw;
}
finally
Modified: trunk/mkNETtools/PluginManager/PluginManager.cs
===================================================================
--- trunk/mkNETtools/PluginManager/PluginManager.cs 2004-10-14 07:48:39 UTC (rev 881)
+++ trunk/mkNETtools/PluginManager/PluginManager.cs 2004-10-14 07:55:44 UTC (rev 882)
@@ -25,7 +25,7 @@
try
{
- files = Directory.GetFiles("." + Path.DirectorySeparatorChar + "Plugins", "*.dll");
+ files = Directory.GetFiles("." + Path.DirectorySeparatorChar + "Plugins", "mkNETtools.Plugins.*.dll");
foreach (string file in files)
{
LoadPlugin(file);
@@ -37,7 +37,7 @@
ex = null;
}
// Look in the current folder
- files = Directory.GetFiles("." + Path.DirectorySeparatorChar, "*.dll");
+ files = Directory.GetFiles("." + Path.DirectorySeparatorChar, "mkNETtools.Plugins.*.dll");
foreach (string file in files)
{
LoadPlugin(file);
Modified: trunk/mkNETtools/Plugins/MatroskaInput/MatroskaInput.cs
===================================================================
--- trunk/mkNETtools/Plugins/MatroskaInput/MatroskaInput.cs 2004-10-14 07:48:39 UTC (rev 881)
+++ trunk/mkNETtools/Plugins/MatroskaInput/MatroskaInput.cs 2004-10-14 07:55:44 UTC (rev 882)
@@ -32,18 +32,20 @@
Frame frame = new Frame();
frame.Track = Track;
- frame.Timecode = (mFrame.Timecode * 1000.0);
- frame.Duration = (mFrame.Duration * 1000.0);
+ frame.Timecode = (mFrame.Timecode / 1000.0);
+ frame.Duration = (mFrame.Duration / 1000.0);
int referenceCount = 1;
if (mFrame.References != null)
referenceCount += mFrame.References.Length;
frame.References = new double[referenceCount];
- frame.References[0] = (mFrame.Reference * 1000.0);
+ frame.References[0] = (mFrame.Reference / 1000.0);
for (int i = 1; i < referenceCount; i++)
- frame.References[i] = (mFrame.References[i] * 1000.0);
+ frame.References[i] = (mFrame.References[i] / 1000.0);
+ frame.Data = ArrayCopy.SByteToByte(mFrame.Data);
+
return frame;
}
@@ -84,15 +86,20 @@
}
ITrackInfo track = tracks[i];
track.Number = mTrack.TrackNo;
- track.Name = mTrack.Name;
- track.Language = mTrack.Language;
+
+ // Copy the track meta-data
+ if (mTrack.Name != null)
+ track.Name = mTrack.Name;
+ if (mTrack.Language != null)
+ track.Language = mTrack.Language;
+
track.CodecID = mTrack.CodecID;
if (mTrack.CodecPrivate != null)
{
track.CodecPrivate = ArrayCopy.SByteToByte(mTrack.CodecPrivate);
}
// Currently all Matroska tracks share the file duration
- track.Duration = m_File.getDuration();
+ track.Duration = (m_File.getDuration() / 1000.0);
}
return tracks;
}
@@ -120,6 +127,7 @@
{
m_DataSource = new FileDataSource(filename, "r");
m_File = new MatroskaFile(m_DataSource);
+ m_File.readFile();
}
public bool IsSupported(string filename)
Added: trunk/mkNETtools/Plugins/MpaPlugin/AssemblyInfo.cs
===================================================================
--- trunk/mkNETtools/Plugins/MpaPlugin/AssemblyInfo.cs 2004-10-14 07:48:39 UTC (rev 881)
+++ trunk/mkNETtools/Plugins/MpaPlugin/AssemblyInfo.cs 2004-10-14 07:55:44 UTC (rev 882)
@@ -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/Plugins/MpaPlugin/MpaOutput.cs
===================================================================
--- trunk/mkNETtools/Plugins/MpaPlugin/MpaOutput.cs 2004-10-14 07:48:39 UTC (rev 881)
+++ trunk/mkNETtools/Plugins/MpaPlugin/MpaOutput.cs 2004-10-14 07:55:44 UTC (rev 882)
@@ -0,0 +1,123 @@
+using System;
+using System.IO;
+
+using mkNETtools.PluginHelper;
+
+namespace mkNETtools.Plugins.MpaPlugin
+{
+ /// <summary>
+ /// Summary description for MpaOutput.
+ /// </summary>
+ [PluginAttribute]
+ public class MpaOutput : IBaseOutputPlugin
+ {
+ protected FileStream m_Output = null;
+
+ public MpaOutput()
+ {
+ //
+ // TODO: Add constructor logic here
+ //
+ }
+
+ #region IBaseOutputPlugin Members
+
+ public ITrackInfo [] Tracks
+ {
+ set
+ {
+ ITrackInfo [] tracks = value;
+ if (tracks.Length != 1)
+ throw new ArgumentException("Mpa only supports one track!");
+
+ try
+ {
+ IAudioTrackInfo track = (IAudioTrackInfo)tracks[0];
+
+ if (track.CodecID == CodecIDs.AUDIO_MPEG_LAYER3)
+ {
+
+ }
+ else if (track.CodecID == CodecIDs.AUDIO_MPEG_LAYER2 || track.CodecID == CodecIDs.AUDIO_MPEG_LAYER1)
+ {
+
+ }
+ else
+ {
+ throw new ArgumentException("CodecID: " + track.CodecID + " is not supported for mpa output.");
+ }
+ }
+ catch (InvalidCastException ex)
+ {
+ throw new ArgumentException("Mpa only supports an audio track.", ex);
+ }
+ }
+ }
+
+ 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_Output.Write(frame.Data, 0, frame.Data.Length);
+ }
+
+ #endregion
+
+ #region IBaseFilePlugin Members
+
+ public string DefaultExt
+ {
+ get
+ {
+ return "mpa|mp3|mp2|mp1";
+ }
+ }
+
+ public void Close()
+ {
+ m_Output.Close();
+ m_Output = null;
+ }
+
+ public void Open(string filename)
+ {
+ m_Output = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.Read);
+ // Tuncate the file
+ m_Output.SetLength(0);
+ }
+
+ public bool IsSupported(string filename)
+ {
+ string ext = Path.GetExtension(filename).ToLower();
+
+ if (ext.CompareTo(".mp3") == 0)
+ return true;
+
+ if (ext.CompareTo(".mp2") == 0)
+ return true;
+
+ if (ext.CompareTo(".mp1") == 0)
+ return true;
+
+ if (ext.CompareTo(".mpa") == 0)
+ return true;
+
+ return false;
+ }
+
+ #endregion
+
+ #region IBasePlugin Members
+
+ public string PluginName
+ {
+ get
+ {
+ return "Mpa Output Plugin v1.0";
+ }
+ }
+
+ #endregion
+ }
+}
Added: trunk/mkNETtools/Plugins/MpaPlugin/MpaPlugin.csproj
===================================================================
--- trunk/mkNETtools/Plugins/MpaPlugin/MpaPlugin.csproj 2004-10-14 07:48:39 UTC (rev 881)
+++ trunk/mkNETtools/Plugins/MpaPlugin/MpaPlugin.csproj 2004-10-14 07:55:44 UTC (rev 882)
@@ -0,0 +1,100 @@
+<VisualStudioProject>
+ <CSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{D0234D18-5829-4981-90D8-3A132DC9A2FE}"
+ >
+ <Build>
+ <Settings
+ ApplicationIcon = ""
+ AssemblyKeyContainerName = ""
+ AssemblyName = "mkNETtools.Plugins.MpaPlugin"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ DelaySign = "false"
+ OutputType = "Library"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "mkNETtools.Plugins.MpaPlugin"
+ 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 = ""
+ DebugSymbols = "false"
+ FileAlignment = "4096"
+ IncrementalBuild = "false"
+ NoStdLib = "false"
+ NoWarn = ""
+ Optimize = "true"
+ OutputPath = "bin\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 = "PluginHelper"
+ Project = "{BEE56F2B-43B9-407E-9579-BBE863D23AD7}"
+ Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
+ />
+ <Reference
+ Name = "MPALib"
+ AssemblyName = "MPALib"
+ HintPath = "MPALib.dll"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "AssemblyInfo.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
+ RelPath = "MpaOutput.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </CSHARP>
+</VisualStudioProject>
+
Added: trunk/mkNETtools/Plugins/MpaPlugin/MpaPlugin.csproj.user
===================================================================
--- trunk/mkNETtools/Plugins/MpaPlugin/MpaPlugin.csproj.user 2004-10-14 07:48:39 UTC (rev 881)
+++ trunk/mkNETtools/Plugins/MpaPlugin/MpaPlugin.csproj.user 2004-10-14 07:55:44 UTC (rev 882)
@@ -0,0 +1,48 @@
+<VisualStudioProject>
+ <CSHARP LastOpenVersion = "7.10.3077" >
+ <Build>
+ <Settings ReferencePath = "D:\Visual Studio Projects\matroska\mkNETtools\Plugins\MpaPlugin\" >
+ <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>
+
Modified: trunk/mkNETtools/Plugins/WavPlugin/WavOutput.cs
===================================================================
--- trunk/mkNETtools/Plugins/WavPlugin/WavOutput.cs 2004-10-14 07:48:39 UTC (rev 881)
+++ trunk/mkNETtools/Plugins/WavPlugin/WavOutput.cs 2004-10-14 07:55:44 UTC (rev 882)
@@ -53,10 +53,13 @@
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);
+ if (track.CodecPrivate.Length > 0)
+ {
+ 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_LAYER2 || track.CodecID == CodecIDs.AUDIO_MPEG_LAYER1)
{
@@ -72,7 +75,7 @@
throw new ArgumentException("Wav only supports an audio track.", ex);
}
// Now we can open the file
- m_Writer.Open(m_Filename, m_Wfx);
+ m_Writer.Open(m_Filename, m_Wfx);
}
}
@@ -103,7 +106,8 @@
public void Open(string filename)
{
- m_Writer = new WavWriter();
+ m_Writer = new WavWriter();
+ m_Writer.WriteFactChunk = false;
m_Filename = filename;
}
Modified: trunk/mkNETtools/mkNETtools.sln
===================================================================
--- trunk/mkNETtools/mkNETtools.sln 2004-10-14 07:48:39 UTC (rev 881)
+++ trunk/mkNETtools/mkNETtools.sln 2004-10-14 07:55:44 UTC (rev 882)
@@ -27,6 +27,10 @@
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MpaPlugin", "Plugins\MpaPlugin\MpaPlugin.csproj", "{D0234D18-5829-4981-90D8-3A132DC9A2FE}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
@@ -61,6 +65,10 @@
{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
+ {D0234D18-5829-4981-90D8-3A132DC9A2FE}.Debug.ActiveCfg = Debug|.NET
+ {D0234D18-5829-4981-90D8-3A132DC9A2FE}.Debug.Build.0 = Debug|.NET
+ {D0234D18-5829-4981-90D8-3A132DC9A2FE}.Release.ActiveCfg = Release|.NET
+ {D0234D18-5829-4981-90D8-3A132DC9A2FE}.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.