Author: jcsston
Date: 2004-10-02 09:40:36 +0400 (Sat, 02 Oct 2004)
New Revision: 852
Added:
trunk/JEBML/CommandLineSample.vjsproj
Modified:
trunk/JEBML/JEBML.sln
trunk/JEBML/src/org/ebml/EBMLReader.java
trunk/JEBML/src/org/ebml/matroska/MatroskaBlock.java
trunk/JEBML/src/org/ebml/matroska/MatroskaDocType.java
trunk/JEBML/src/org/ebml/sample/CommandLineSample.java
Log:
Added chapter elements ID's
Created J# project for command-line sample
Added: trunk/JEBML/CommandLineSample.vjsproj
===================================================================
--- trunk/JEBML/CommandLineSample.vjsproj 2004-10-01 20:51:21 UTC (rev 851)
+++ trunk/JEBML/CommandLineSample.vjsproj 2004-10-02 05:40:36 UTC (rev 852)
@@ -0,0 +1,71 @@
+<VisualStudioProject>
+ <VISUALJSHARP
+ ProjectType = "Local"
+ ProductVersion = "7.10.3077"
+ SchemaVersion = "2.0"
+ ProjectGuid = "{D60EB8EA-93B5-4DF7-B793-B54B1BFC4753}"
+ >
+ <Build>
+ <Settings
+ AssemblyKeyContainerName = ""
+ AssemblyName = "CommandLineSample"
+ AssemblyOriginatorKeyFile = ""
+ DefaultClientScript = "JScript"
+ DefaultHTMLPageLayout = "Grid"
+ DefaultTargetSchema = "IE50"
+ OutputType = "Exe"
+ PreBuildEvent = ""
+ PostBuildEvent = ""
+ RootNamespace = "CommandLineSample"
+ RunPostBuildEvent = "OnBuildSuccess"
+ StartupObject = ""
+ >
+ <Config
+ Name = "Debug"
+ BaseAddress = "285212672"
+ ConfigurationOverrideFile = ""
+ DefineConstants = ""
+ DebugSymbols = "true"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = "bin\Debug\"
+ RegisterForComInterop = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "1"
+ AdditionalOptions = ""
+ />
+ <Config
+ Name = "Release"
+ BaseAddress = "285212672"
+ ConfigurationOverrideFile = ""
+ DefineConstants = ""
+ DebugSymbols = "false"
+ NoWarn = ""
+ Optimize = "false"
+ OutputPath = "bin\Release\"
+ RegisterForComInterop = "false"
+ TreatWarningsAsErrors = "false"
+ WarningLevel = "1"
+ AdditionalOptions = ""
+ />
+ </Settings>
+ <References>
+ <Reference
+ Name = "JEBML"
+ Project = "{2FE45AE7-D916-497F-9035-B6EDA1C9E34C}"
+ Package = "{E6FDF86B-F3D1-11D4-8576-0002A516ECE8}"
+ />
+ </References>
+ </Build>
+ <Files>
+ <Include>
+ <File
+ RelPath = "src\org\ebml\sample\CommandLineSample.java"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ </Include>
+ </Files>
+ </VISUALJSHARP>
+</VisualStudioProject>
+
Modified: trunk/JEBML/JEBML.sln
===================================================================
--- trunk/JEBML/JEBML.sln 2004-10-01 20:51:21 UTC (rev 851)
+++ trunk/JEBML/JEBML.sln 2004-10-02 05:40:36 UTC (rev 852)
@@ -3,6 +3,10 @@
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
+Project("{E6FDF86B-F3D1-11D4-8576-0002A516ECE8}") = "CommandLineSample", "CommandLineSample.vjsproj", "{D60EB8EA-93B5-4DF7-B793-B54B1BFC4753}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
@@ -13,6 +17,10 @@
{2FE45AE7-D916-497F-9035-B6EDA1C9E34C}.Debug.Build.0 = Debug|.NET
{2FE45AE7-D916-497F-9035-B6EDA1C9E34C}.Release.ActiveCfg = Release|.NET
{2FE45AE7-D916-497F-9035-B6EDA1C9E34C}.Release.Build.0 = Release|.NET
+ {D60EB8EA-93B5-4DF7-B793-B54B1BFC4753}.Debug.ActiveCfg = Debug|.NET
+ {D60EB8EA-93B5-4DF7-B793-B54B1BFC4753}.Debug.Build.0 = Debug|.NET
+ {D60EB8EA-93B5-4DF7-B793-B54B1BFC4753}.Release.ActiveCfg = Release|.NET
+ {D60EB8EA-93B5-4DF7-B793-B54B1BFC4753}.Release.Build.0 = Release|.NET
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
Modified: trunk/JEBML/src/org/ebml/EBMLReader.java
===================================================================
--- trunk/JEBML/src/org/ebml/EBMLReader.java 2004-10-01 20:51:21 UTC (rev 851)
+++ trunk/JEBML/src/org/ebml/EBMLReader.java 2004-10-02 05:40:36 UTC (rev 852)
@@ -1,7 +1,5 @@
package org.ebml;
-import java.lang.*;
-
/**
* EBMLReader.java
*
@@ -15,10 +13,15 @@
* <hr>
* <p>The following are the basic steps of how reading in JEBML works.</p>
* <ul>
- * <li>1. The EbmlReader class reads the element header (id+size) and looks it up in the supplied DocType class.
- * <li>2. The correct element type (Binary, UInteger, String, etc) is created using the DocType data, BinaryElement is default element type for unknown elements.
- * <li>3. The MatroskaDocType has the ids of all the elements staticly declared.
- * <br>So to easily find out what an element is, you can use some code like the following code
+ * <li>1. The EbmlReader class reads the element header (id+size) and
+ * looks it up in the supplied DocType class.
+ * <li>2. The correct element type (Binary, UInteger, String, etc) is
+ * created using the DocType data, BinaryElement is default
+ * element type for unknown elements.
+ * <li>3. The MatroskaDocType has the ids of all the elements staticly
+ * declared.
+ * <br>So to easily find out what an element is, you can use some code
+ * like the following code
* <p>
* <code>
* Element level1; <br>
@@ -28,14 +31,18 @@
* } <br>
* </code>
* </p>
- * <li>4. to get the actual data for an Element you call the readData method, if you just want to skip it use skipData().
- * <li>5. MasterElements are special, they the readNextChild() method which returns the next child element, returning null when all the children have been read (it keeps track of the current inputstream position).
+ * <li>4. To get the actual data for an Element you call the readData
+ * method, if you just want to skip it use skipData().
+ * <li>5. MasterElements are special, they have the readNextChild()
+ * method which returns the next child element, returning null
+ * when all the children have been read (it keeps track of the
+ * current inputstream position).
* <li>The usage method for JEBML is very close to libebml/libmatroska.
* </ul>
* <hr>
*
- * Reads EBML elements from a <code>DataSource</code> and looks them up in the
- * provided <code>DocType</code>.
+ * Reads EBML elements from a <code>DataSource</code> and looks them up
+ * in the provided <code>DocType</code>.
*
* @author (c) 2002 John Cannon
* @author (c) 2004 Jory Stone
Modified: trunk/JEBML/src/org/ebml/matroska/MatroskaBlock.java
===================================================================
--- trunk/JEBML/src/org/ebml/matroska/MatroskaBlock.java 2004-10-01 20:51:21 UTC (rev 851)
+++ trunk/JEBML/src/org/ebml/matroska/MatroskaBlock.java 2004-10-02 05:40:36 UTC (rev 852)
@@ -95,7 +95,7 @@
int [] LaceSizes = new int[LaceCount+1];
LaceSizes[LaceCount] = (int)this.getSize();
- long ByteStartPos = source.getFilePointer();
+ //long ByteStartPos = source.getFilePointer();
for (int l = 0; l < LaceCount; l++) {
short LaceSizeByte = 255;
@@ -107,7 +107,7 @@
// Update the size of the last block
LaceSizes[LaceCount] -= LaceSizes[l];
}
- long ByteEndPos = source.getFilePointer();
+ //long ByteEndPos = source.getFilePointer();
LaceSizes[LaceCount] -= HeaderSize;
Modified: trunk/JEBML/src/org/ebml/matroska/MatroskaDocType.java
===================================================================
--- trunk/JEBML/src/org/ebml/matroska/MatroskaDocType.java 2004-10-01 20:51:21 UTC (rev 851)
+++ trunk/JEBML/src/org/ebml/matroska/MatroskaDocType.java 2004-10-02 05:40:36 UTC (rev 852)
@@ -87,6 +87,26 @@
static public byte[] ClusterBlockDuration_Id = {(byte)0x9B};
static public byte[] ClusterReferenceBlock_Id = {(byte)0xFB};
+ static public byte[] Chapters_Id = {0x10, (byte)0x43, (byte)0xA7, (byte)0x70};
+ static public byte [] ChapterEditionEntry_Id = {(byte)0x45, (byte)0xB9};
+ static public byte [] ChapterEditionUID_Id = {(byte)0x45, (byte)0xBC};
+ static public byte [] ChapterEditionFlagHidden_Id = {(byte)0x45, (byte)0xBD};
+ static public byte [] ChapterEditionFlagDefault_Id = {(byte)0x45, (byte)0xDB};
+ static public byte [] ChapterEditionManaged_Id = {(byte)0x45, (byte)0xDD};
+ static public byte [] ChapterAtom_Id = {(byte)0xB6};
+ static public byte [] ChapterAtomChapterUID_Id = {(byte)0x73, (byte)0xC4};
+ static public byte [] ChapterAtomChapterTimeStart_Id = {(byte)0x91};
+ static public byte [] ChapterAtomChapterTimeEnd_Id = {(byte)0x92};
+ static public byte [] ChapterAtomChapterFlagHidden_Id = {(byte)0x98};
+ static public byte [] ChapterAtomChapterFlagEnabled_Id = {(byte)0x45, (byte)0x98};
+ static public byte [] ChapterAtomChapterPhysicalEquiv_Id = {(byte)0x63, (byte)0xC3};
+ static public byte [] ChapterAtomChapterTrack_Id = {(byte)0x8F};
+ static public byte [] ChapterAtomChapterTrackNumber_Id = {(byte)0x89};
+ static public byte [] ChapterAtomChapterDisplay_Id = {(byte)0x80};
+ static public byte [] ChapterAtomChapString_Id = {(byte)0x85};
+ static public byte [] ChapterAtomChapLanguage_Id = {(byte)0x43, (byte)0x7C};
+ static public byte [] ChapterAtomChapCountry_Id = {(byte)0x43, (byte)0x7E};
+
// Track Types
static public byte track_video = 0x01; ///< Rectangle-shaped non-transparent pictures aka video
static public byte track_audio = 0x02; ///< Anything you can hear
@@ -122,7 +142,9 @@
static public MatroskaDocType obj = new MatroskaDocType();
public MatroskaDocType() {
+ //long start = java.lang.System.currentTimeMillis();
init();
+ //System.out.println("MatroskaDocType Loaded in " + java.lang.System.currentTimeMillis() - start + " milliseconds");
}
protected void init() {
@@ -623,7 +645,149 @@
// Add Cluster Element
level0.children.add(level1);
+ level1 = new ElementType("Chapters",
+ (short)1,
+ Chapters_Id,
+ ElementType.MASTER_ELEMENT,
+ new ArrayList());
+ level2 = new ElementType("ChapterEditionEntry",
+ (short)2,
+ ChapterEditionEntry_Id,
+ ElementType.MASTER_ELEMENT,
+ new ArrayList());
+
+ level3 = new ElementType("ChapterEditionUID",
+ (short)3,
+ ChapterEditionUID_Id,
+ ElementType.UINTEGER_ELEMENT,
+ (ArrayList)null);
+ level2.children.add(level3);
+
+ level3 = new ElementType("ChapterEditionFlagHidden",
+ (short)3,
+ ChapterEditionFlagHidden_Id,
+ ElementType.UINTEGER_ELEMENT,
+ (ArrayList)null);
+ level2.children.add(level3);
+
+ level3 = new ElementType("ChapterEditionFlagDefault",
+ (short)3,
+ ChapterEditionFlagDefault_Id,
+ ElementType.UINTEGER_ELEMENT,
+ (ArrayList)null);
+ level2.children.add(level3);
+
+ level3 = new ElementType("ChapterEditionManaged",
+ (short)3,
+ ChapterEditionManaged_Id,
+ ElementType.UINTEGER_ELEMENT,
+ (ArrayList)null);
+ level2.children.add(level3);
+
+ level3 = new ElementType("ChapterAtom",
+ (short)3,
+ ChapterAtom_Id,
+ ElementType.MASTER_ELEMENT,
+ new ArrayList());
+
+ level4 = new ElementType("ChapterAtomChapterUID",
+ (short)4,
+ ChapterAtomChapterUID_Id,
+ ElementType.UINTEGER_ELEMENT,
+ (ArrayList)null);
+ level3.children.add(level4);
+
+ level4 = new ElementType("ChapterAtomChapterTimeStart",
+ (short)4,
+ ChapterAtomChapterTimeStart_Id,
+ ElementType.UINTEGER_ELEMENT,
+ (ArrayList)null);
+ level3.children.add(level4);
+
+ level4 = new ElementType("ChapterAtomChapterTimeEnd",
+ (short)4,
+ ChapterAtomChapterTimeEnd_Id,
+ ElementType.UINTEGER_ELEMENT,
+ (ArrayList)null);
+ level3.children.add(level4);
+
+ level4 = new ElementType("ChapterAtomChapterFlagHidden",
+ (short)4,
+ ChapterAtomChapterFlagHidden_Id,
+ ElementType.UINTEGER_ELEMENT,
+ (ArrayList)null);
+ level3.children.add(level4);
+
+ level4 = new ElementType("ChapterAtomChapterFlagEnabled",
+ (short)4,
+ ChapterAtomChapterFlagEnabled_Id,
+ ElementType.UINTEGER_ELEMENT,
+ (ArrayList)null);
+ level3.children.add(level4);
+
+ level4 = new ElementType("ChapterAtomChapterPhysicalEquiv",
+ (short)4,
+ ChapterAtomChapterPhysicalEquiv_Id,
+ ElementType.UINTEGER_ELEMENT,
+ (ArrayList)null);
+ level3.children.add(level4);
+
+ level4 = new ElementType("ChapterAtomChapterTrack",
+ (short)4,
+ ChapterAtomChapterTrack_Id,
+ ElementType.MASTER_ELEMENT,
+ new ArrayList());
+
+ level5 = new ElementType("ChapterAtomChapterTrackNumber",
+ (short)5,
+ ChapterAtomChapterTrackNumber_Id,
+ ElementType.UINTEGER_ELEMENT,
+ (ArrayList)null);
+ level4.children.add(level5);
+
+ // Add ChapterAtomChapterTrack Element
+ level3.children.add(level4);
+
+ level4 = new ElementType("ChapterAtomChapterDisplay",
+ (short)4,
+ ChapterAtomChapterDisplay_Id,
+ ElementType.MASTER_ELEMENT,
+ new ArrayList());
+
+ level5 = new ElementType("ChapterAtomChapString",
+ (short)5,
+ ChapterAtomChapString_Id,
+ ElementType.STRING_ELEMENT,
+ (ArrayList)null);
+ level4.children.add(level5);
+
+ level5 = new ElementType("ChapterAtomChapLanguage",
+ (short)5,
+ ChapterAtomChapLanguage_Id,
+ ElementType.ASCII_STRING_ELEMENT,
+ (ArrayList)null);
+ level4.children.add(level5);
+
+ level5 = new ElementType("ChapterAtomChapCountry",
+ (short)5,
+ ChapterAtomChapCountry_Id,
+ ElementType.ASCII_STRING_ELEMENT,
+ (ArrayList)null);
+ level4.children.add(level5);
+
+ // Add ChapterAtomChapterDisplay Element
+ level3.children.add(level4);
+
+ // Add ChapterAtom Element
+ level2.children.add(level3);
+
+ // Add ChapterEditionEntry Element
+ level1.children.add(level2);
+
+ // Add Chapters Element
+ level0.children.add(level1);
+
// Add Segment Element
baseLevel.children.add(level0);
Modified: trunk/JEBML/src/org/ebml/sample/CommandLineSample.java
===================================================================
--- trunk/JEBML/src/org/ebml/sample/CommandLineSample.java 2004-10-01 20:51:21 UTC (rev 851)
+++ trunk/JEBML/src/org/ebml/sample/CommandLineSample.java 2004-10-02 05:40:36 UTC (rev 852)
@@ -1,6 +1,7 @@
package org.ebml.sample;
import org.ebml.matroska.*;
+import org.ebml.*;
import java.io.*;
/**
@@ -18,19 +19,33 @@
if (args.length < 2) {
System.out.println("Please provide a matroska filename on the command-line");
+ return;
}
try {
System.out.println("Scanning file: " + args[1]);
- FileInputStream iFS = new FileInputStream(args[1]);
+ FileDataSource iFS = new FileDataSource(args[1]);
MatroskaFile mF = new MatroskaFile(iFS);
+ mF.setScanFirstCluster(true);
mF.readFile();
System.out.println(mF.getReport());
+
+ if (mF.getTrack(1).CodecID.compareTo("A_MPEG/L3") == 0)
+ {
+ System.out.println("Extracting mp3 track");
+ FileOutputStream oFS = new FileOutputStream(args[1] + ".mp3");
+ MatroskaFile.MatroskaFrame frame = mF.getNextFrame();
+ while (frame != null)
+ {
+ oFS.write(frame.Data);
+ frame = mF.getNextFrame();
+ }
+ }
System.out.println("Scan complete");
- } catch (java.io.FileNotFoundException ex) {
+ } catch (java.io.IOException ex) {
ex.printStackTrace();
}
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.