[matroska] r865 - in trunk/JEBML: . src/org/ebml src/org/ebml/io src/org/ebml/matroska src/org/ebml/sample src/org/ebml/util

[email protected]
Newsgroups gmane.comp.multimedia.matroska.cvs
Message-ID <[email protected]>
Author: jcsston
Date: 2004-10-07 12:15:33 +0400 (Thu, 07 Oct 2004)
New Revision: 865

Added:
   trunk/JEBML/src/org/ebml/matroska/MatroskaSegment.java
Modified:
   trunk/JEBML/JEBML.vjsproj
   trunk/JEBML/src/org/ebml/BinaryElement.java
   trunk/JEBML/src/org/ebml/DateElement.java
   trunk/JEBML/src/org/ebml/DocType.java
   trunk/JEBML/src/org/ebml/EBMLReader.java
   trunk/JEBML/src/org/ebml/EBMLWriter.java
   trunk/JEBML/src/org/ebml/Element.java
   trunk/JEBML/src/org/ebml/ElementType.java
   trunk/JEBML/src/org/ebml/FloatElement.java
   trunk/JEBML/src/org/ebml/MasterElement.java
   trunk/JEBML/src/org/ebml/SignedIntegerElement.java
   trunk/JEBML/src/org/ebml/StringElement.java
   trunk/JEBML/src/org/ebml/UnknownElementType.java
   trunk/JEBML/src/org/ebml/UnsignedIntegerElement.java
   trunk/JEBML/src/org/ebml/io/DataSeekable.java
   trunk/JEBML/src/org/ebml/io/DataSource.java
   trunk/JEBML/src/org/ebml/io/DataWriter.java
   trunk/JEBML/src/org/ebml/io/FileDataSource.java
   trunk/JEBML/src/org/ebml/io/FileDataWriter.java
   trunk/JEBML/src/org/ebml/io/InputStreamDataSource.java
   trunk/JEBML/src/org/ebml/matroska/MatroskaBlock.java
   trunk/JEBML/src/org/ebml/matroska/MatroskaDocType.java
   trunk/JEBML/src/org/ebml/matroska/MatroskaFile.java
   trunk/JEBML/src/org/ebml/matroska/MatroskaFileFrame.java
   trunk/JEBML/src/org/ebml/matroska/MatroskaFileSimpleTag.java
   trunk/JEBML/src/org/ebml/matroska/MatroskaFileTagEntry.java
   trunk/JEBML/src/org/ebml/matroska/MatroskaFileTrack.java
   trunk/JEBML/src/org/ebml/matroska/MatroskaFileWriter.java
   trunk/JEBML/src/org/ebml/sample/CommandLineSample.java
   trunk/JEBML/src/org/ebml/util/ArrayCopy.java
Log:
Added LGPL header.
Added new MatroskaSegment class to handle the special case of unknown segment sizes.

Modified: trunk/JEBML/JEBML.vjsproj
===================================================================
--- trunk/JEBML/JEBML.vjsproj	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/JEBML.vjsproj	2004-10-07 08:15:33 UTC (rev 865)
@@ -210,6 +210,11 @@
                     BuildAction = "Compile"
                 />
                 <File
+                    RelPath = "src\org\ebml\matroska\MatroskaSegment.java"
+                    SubType = "Code"
+                    BuildAction = "Compile"
+                />
+                <File
                     RelPath = "src\org\ebml\util\ArrayCopy.java"
                     SubType = "Code"
                     BuildAction = "Compile"

Modified: trunk/JEBML/src/org/ebml/BinaryElement.java
===================================================================
--- trunk/JEBML/src/org/ebml/BinaryElement.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/BinaryElement.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,13 +1,35 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
 /*
  * Element.java
  *
- * Created on November 19, 2002, 9:11 PM
+ * 
  */
 
 package org.ebml;
 
 /**
-     * Defines the basic EBML element.  Subclasses may provide child element access.
+ * Defines the basic EBML element.  Subclasses may provide child element 
+ * access.
+ * Created on November 19, 2002, 9:11 PM
  * @author  John Cannon
  */
 public class BinaryElement extends Element {

Modified: trunk/JEBML/src/org/ebml/DateElement.java
===================================================================
--- trunk/JEBML/src/org/ebml/DateElement.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/DateElement.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml;
 
 import java.io.*;
@@ -2,14 +21,7 @@
 import java.util.*;
-/**
- * <p>Title: JEBML</p>
- * <p>Description: Java Classes to Read EBML Elements</p>
- * <p>Copyright: Copyright (c) 2002-2004 John Cannon <[email protected]>, Jory Stone <[email protected]></p>
- * <p>Company: </p>
- * @author jcsston
- * @version 1.0
- */
 
-public class DateElement extends BinaryElement {
+public class DateElement extends SignedIntegerElement {
   //const uint64 EbmlDate::UnixEpochDelay = 978307200; // 2001/01/01 00:00:00 UTC
   public static long UnixEpochDelay = 978307200; // 2001/01/01 00:00:00 UTC
+  private static int MIN_SIZE_LENGTH = 8;
 
@@ -24,16 +36,8 @@
    * @param value Date to set
    */
   public void setDate(Date value) {
-    long val = (value.getTime() - UnixEpochDelay) * 100000;
-    try {
-      ByteArrayOutputStream bOS = new ByteArrayOutputStream(8);
-      DataOutputStream dOS = new DataOutputStream(bOS);
-      dOS.writeLong(val);
-      dOS.flush();
-      setData(bOS.toByteArray());
-    } catch (IOException ex) {
-      ex.printStackTrace();
-    }
+    long val = (value.getTime() - UnixEpochDelay) * 1000000000;
+    setData(packInt(val, MIN_SIZE_LENGTH));
   }
 
   /**
@@ -50,16 +54,17 @@
     long diff2 = end.getTime();
     long diff3 = Date.UTC(2001, 1, 1, 0, 0, 0) - Date.UTC(1970, 1, 1, 0, 0, 0);
     */
-    long val = 0;
-    try {
-      ByteArrayInputStream bIS = new ByteArrayInputStream(data);
-      DataInputStream dIS = new DataInputStream(bIS);
-      val = dIS.readLong();
-    } catch (IOException ex) {
-      ex.printStackTrace();
-    }
-    val = val/1000000000 + UnixEpochDelay;
+    long val = getValue();;      
+    val = val / 1000000000 + UnixEpochDelay;
     return new Date(val);
   }
 
+  /**
+   * It's not recommended to use this method.
+   * Use the setDate(Date) method instead.
+   */
+  public void setValue(long value) 
+  {
+    setData(packInt(value, MIN_SIZE_LENGTH));
+  }
 }
\ No newline at end of file

Modified: trunk/JEBML/src/org/ebml/DocType.java
===================================================================
--- trunk/JEBML/src/org/ebml/DocType.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/DocType.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,13 +1,23 @@
-package org.ebml;
-
 /**
- * <p>Title: JEBML</p>
- * <p>Description: Java Classes to Read EBML Elements</p>
- * <p>Copyright: Copyright (c) 2002-2004 John Cannon <[email protected]>, Jory Stone <[email protected]></p>
- * <p>Company: </p>
- * @author jcsston
- * @version 1.0
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+package org.ebml;
 
 public interface DocType {
   public ElementType getElements();

Modified: trunk/JEBML/src/org/ebml/EBMLReader.java
===================================================================
--- trunk/JEBML/src/org/ebml/EBMLReader.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/EBMLReader.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml;
 
 import org.ebml.io.*;

Modified: trunk/JEBML/src/org/ebml/EBMLWriter.java
===================================================================
--- trunk/JEBML/src/org/ebml/EBMLWriter.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/EBMLWriter.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml;
 
 import org.ebml.io.*;

Modified: trunk/JEBML/src/org/ebml/Element.java
===================================================================
--- trunk/JEBML/src/org/ebml/Element.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/Element.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,24 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+package org.ebml;
+
 /*
  * Element.java
  *
@@ -4,8 +25,6 @@
  * Created on November 19, 2002, 9:11 PM
  */
 
-package org.ebml;
-
 import org.ebml.io.*;
 
 /**
@@ -214,7 +233,7 @@
       mask <<= 8;
     }
     //The first size bits should be clear, otherwise we have an error in the size determination.
-    ret[0] |= 0x80 >> (size - 1);
+    ret[0] |= 0x80 >> (len - 1);
     return ret;
   }
 
@@ -297,9 +316,11 @@
   {    
     byte[] ret = new byte[size];
     long mask = 0x00000000000000FFL;
+    int b = size - 1;
     for (int i = 0; i < size; i++) 
     {
-      ret[i] = (byte)((value & mask) >>> (8 * i));
+      ret[b] = (byte)(((value >>> (8 * i)) & mask));
+      b--;
     }
     return ret;
   }

Modified: trunk/JEBML/src/org/ebml/ElementType.java
===================================================================
--- trunk/JEBML/src/org/ebml/ElementType.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/ElementType.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml;
 
 import org.ebml.util.*;
@@ -3,12 +22,4 @@
 import java.util.*;
 
-/**
- * <p>Title: JEBML</p>
- * <p>Description: Java Classes to Read EBML Elements</p>
- * <p>Copyright: Copyright (c) 2002-2004 John Cannon <[email protected]>, Jory Stone <[email protected]></p>
- * <p>Company: </p>
- * @author jcsston
- * @version 1.0
- */
 
 public class ElementType {

Modified: trunk/JEBML/src/org/ebml/FloatElement.java
===================================================================
--- trunk/JEBML/src/org/ebml/FloatElement.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/FloatElement.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml;
 
 import java.io.*;
@@ -2,11 +21,2 @@
 
-/**
- * <p>Title: JEBML</p>
- * <p>Description: Java Classes to Read EBML Elements</p>
- * <p>Copyright: Copyright (c) 2002-2004 John Cannon <[email protected]>, Jory Stone <[email protected]></p>
- * <p>Company: </p>
- * @author jcsston
- * @version 1.0
- */
-
 public class FloatElement extends BinaryElement {

Modified: trunk/JEBML/src/org/ebml/MasterElement.java
===================================================================
--- trunk/JEBML/src/org/ebml/MasterElement.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/MasterElement.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml;
 
 import org.ebml.io.*;
@@ -3,13 +22,4 @@
 import java.util.*;
 
-/**
- * <p>Title: JEBML</p>
- * <p>Description: Java Classes to Read EBML Elements</p>
- * <p>Copyright: Copyright (c) 2002-2004 John Cannon <[email protected]>, Jory Stone <[email protected]></p>
- * <p>Company: </p>
- * @author jcsston
- * @version 1.0
- */
-
 public class MasterElement extends Element {
   protected long usedSize;
@@ -45,12 +55,10 @@
   public long writeData(DataWriter writer) 
   {
     long len = 0;
-    //len += writer.writeElementHeaders(this);
     for (int i = 0; i < children.size(); i++) 
     {
       Element elem = (Element)children.get(i);
-      len += elem.writeHeaderData(writer);
-      len += elem.writeData(writer);
+      len += elem.writeElement(writer);
     }
     return len;
   }

Modified: trunk/JEBML/src/org/ebml/SignedIntegerElement.java
===================================================================
--- trunk/JEBML/src/org/ebml/SignedIntegerElement.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/SignedIntegerElement.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,24 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+package org.ebml;
+
 /*
  * SignedInteger.java
  *
@@ -4,8 +25,6 @@
  * Created on February 17, 2003, 1:54 PM
  */
 
-package org.ebml;
-
 /**
  * Basic class for the Signed Integer EBML data type.
  * @author  John Cannon

Modified: trunk/JEBML/src/org/ebml/StringElement.java
===================================================================
--- trunk/JEBML/src/org/ebml/StringElement.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/StringElement.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml;
 
 /**

Modified: trunk/JEBML/src/org/ebml/UnknownElementType.java
===================================================================
--- trunk/JEBML/src/org/ebml/UnknownElementType.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/UnknownElementType.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml;
 
 import org.ebml.util.*;
@@ -3,13 +22,4 @@
 import java.util.*;
 
-/**
- * <p>Title: JEBML</p>
- * <p>Description: Java Classes to Read EBML Elements</p>
- * <p>Copyright: Copyright (c) 2002-2004 John Cannon <[email protected]>, Jory Stone <[email protected]></p>
- * <p>Company: </p>
- * @author jcsston
- * @version 1.0
- */
-
 public class UnknownElementType extends ElementType {
   public UnknownElementType(byte [] id) {

Modified: trunk/JEBML/src/org/ebml/UnsignedIntegerElement.java
===================================================================
--- trunk/JEBML/src/org/ebml/UnsignedIntegerElement.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/UnsignedIntegerElement.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,24 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+package org.ebml;
+
 /*
  * UnsignedIntegerElement.java
  *
@@ -3,7 +24,4 @@
  * Created on February 15, 2003, 6:27 PM
  */
-
-package org.ebml;
-
 /**
  *  Basic class for the Unsigned Integer data type in EBML.

Modified: trunk/JEBML/src/org/ebml/io/DataSeekable.java
===================================================================
--- trunk/JEBML/src/org/ebml/io/DataSeekable.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/io/DataSeekable.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml.io;
 
 /**

Modified: trunk/JEBML/src/org/ebml/io/DataSource.java
===================================================================
--- trunk/JEBML/src/org/ebml/io/DataSource.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/io/DataSource.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml.io;
 
 /*

Modified: trunk/JEBML/src/org/ebml/io/DataWriter.java
===================================================================
--- trunk/JEBML/src/org/ebml/io/DataWriter.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/io/DataWriter.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml.io;
 
 /**

Modified: trunk/JEBML/src/org/ebml/io/FileDataSource.java
===================================================================
--- trunk/JEBML/src/org/ebml/io/FileDataSource.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/io/FileDataSource.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml.io;
 
 import java.io.*;
@@ -2,11 +21,2 @@
 
-/**
- * <p>Title: JEBML</p>
- * <p>Description: Java Classes to Read EBML Elements</p>
- * <p>Copyright: Copyright (c) 2002-2004 John Cannon <[email protected]>, Jory Stone <[email protected]></p>
- * <p>Company: </p>
- * @author jcsston
- * @version 1.0
- */
-
 public class FileDataSource implements DataSource {

Modified: trunk/JEBML/src/org/ebml/io/FileDataWriter.java
===================================================================
--- trunk/JEBML/src/org/ebml/io/FileDataWriter.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/io/FileDataWriter.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml.io;
 
 import java.io.*;
@@ -2,10 +21,2 @@
 
-  /**
-   * <p>Title: JEBML</p>
-   * <p>Description: Java Classes to Write EBML Elements</p>
-   * <p>Copyright: Copyright (c) 2004 Jory Stone <[email protected]></p>
-   * @author jcsston
-   * @version 1.0
-   */
-
 public class FileDataWriter implements DataWriter 

Modified: trunk/JEBML/src/org/ebml/io/InputStreamDataSource.java
===================================================================
--- trunk/JEBML/src/org/ebml/io/InputStreamDataSource.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/io/InputStreamDataSource.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,18 +1,33 @@
-/*
- * InputStreamDataSource.java
- *
- * Created on November 19, 2002, 9:35 PM
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-
 package org.ebml.io;
 
-/**
+import java.io.*;
+
+/*
+ * InputStreamDataSource
  *
+ * Created on November 19, 2002, 9:35 PM
+ *
  * @author  John Cannon
  */
-
-import java.io.*;
-
 public class InputStreamDataSource
     implements DataSource {
   protected InputStream in = null;

Modified: trunk/JEBML/src/org/ebml/matroska/MatroskaBlock.java
===================================================================
--- trunk/JEBML/src/org/ebml/matroska/MatroskaBlock.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/matroska/MatroskaBlock.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml.matroska;
 
 import org.ebml.*;
@@ -3,13 +22,4 @@
 import org.ebml.io.*;
 
-/**
- * <p>Title: JEBML</p>
- * <p>Description: Java Classes to Read EBML Elements</p>
- * <p>Copyright: Copyright (c) 2004 Jory Stone <[email protected]></p>
- *
- * @author jcsston
- * @version 1.0
- */
-
 public class MatroskaBlock extends BinaryElement {
   protected int [] Sizes = null;

Modified: trunk/JEBML/src/org/ebml/matroska/MatroskaDocType.java
===================================================================
--- trunk/JEBML/src/org/ebml/matroska/MatroskaDocType.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/matroska/MatroskaDocType.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml.matroska;
 
 import org.ebml.*;
@@ -4,17 +23,16 @@
 import org.ebml.util.*;
 import java.util.*;
 
-/**
- * <p>Title: JEBML</p>
- * <p>Description: Java Classes to Read EBML Elements</p>
- * <p>Copyright: Copyright (c) 2004 Jory Stone <[email protected]></p>
- * @author jcsston
- * @version 1.0
+/**
+ * DocType for Matroska files.
+ * This has all the element type id declares and also is in charge of 
+ * creating the correct element classes from the type id.
  */
-
-public class MatroskaDocType implements DocType {
+public class MatroskaDocType implements DocType 
+{
   // Custom Element Types
   static public short BLOCK_ELEMENT = (short)(ElementType.LAST_ELEMENT_TYPE + 1);
+  static public short SEGMENT_ELEMENT = (short)(ElementType.LAST_ELEMENT_TYPE + 2);
 
   // EBML Id's
   static public byte [] Void_Id = {(byte)0xEC};
@@ -226,7 +244,7 @@
       level0 = new ElementType("Segment",
                                (short)0,
                                Segment_Id,
-                               ElementType.MASTER_ELEMENT,
+                               MatroskaDocType.SEGMENT_ELEMENT,
                                new ArrayList());
 
       level1 = new ElementType("SeekHead",
@@ -818,10 +836,17 @@
     elem = type.createElement();
 
     if (elem == null) {
-      if (type.type == MatroskaDocType.BLOCK_ELEMENT) {
+      if (type.type == MatroskaDocType.BLOCK_ELEMENT) 
+      {
         elem = new MatroskaBlock(type.id);
+      } 
+      else if (type.type == MatroskaDocType.SEGMENT_ELEMENT) 
+      {
+        elem = new MatroskaSegment(type.id);
 
-      } else if (type.type == type.UNKNOWN_ELEMENT) {
+      } 
+      else if (type.type == type.UNKNOWN_ELEMENT) 
+      {
         elem = new BinaryElement(type.id);
 
       } else {

Modified: trunk/JEBML/src/org/ebml/matroska/MatroskaFile.java
===================================================================
--- trunk/JEBML/src/org/ebml/matroska/MatroskaFile.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/matroska/MatroskaFile.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml.matroska;
 
 import java.util.*;
@@ -5,13 +24,6 @@
 import org.ebml.io.*;
 import org.ebml.util.*;
 
-/**
- * <p>Title: JEBML</p>
- * <p>Description: Java Classes to Read EBML Elements</p>
- * <p>Copyright: Copyright (c) 2004 Jory Stone <[email protected]></p>
- * @author jcsston
- * @version 1.0
- */
 
 public class MatroskaFile {
   /**

Modified: trunk/JEBML/src/org/ebml/matroska/MatroskaFileFrame.java
===================================================================
--- trunk/JEBML/src/org/ebml/matroska/MatroskaFileFrame.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/matroska/MatroskaFileFrame.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml.matroska;
 
 /**

Modified: trunk/JEBML/src/org/ebml/matroska/MatroskaFileSimpleTag.java
===================================================================
--- trunk/JEBML/src/org/ebml/matroska/MatroskaFileSimpleTag.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/matroska/MatroskaFileSimpleTag.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml.matroska;
 
 import org.ebml.util.*;

Modified: trunk/JEBML/src/org/ebml/matroska/MatroskaFileTagEntry.java
===================================================================
--- trunk/JEBML/src/org/ebml/matroska/MatroskaFileTagEntry.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/matroska/MatroskaFileTagEntry.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml.matroska;
 
 import org.ebml.util.*;

Modified: trunk/JEBML/src/org/ebml/matroska/MatroskaFileTrack.java
===================================================================
--- trunk/JEBML/src/org/ebml/matroska/MatroskaFileTrack.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/matroska/MatroskaFileTrack.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,8 +1,27 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml.matroska;
 
-  /**
-   * Matroska Track Class
-   */
+/**
+  * Matroska Track Class
+  */
 public class MatroskaFileTrack 
 {
   public short TrackNo;

Modified: trunk/JEBML/src/org/ebml/matroska/MatroskaFileWriter.java
===================================================================
--- trunk/JEBML/src/org/ebml/matroska/MatroskaFileWriter.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/matroska/MatroskaFileWriter.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml.matroska;
 
 import org.ebml.*;
@@ -10,10 +29,14 @@
  */
 public class MatroskaFileWriter
 {
-  static public long TIMECODE_SCALE = 1000000;
   protected DataWriter ioDW;
   protected MatroskaDocType doc = new MatroskaDocType();
 
+  public long TimecodeScale = 1000000;
+  public double Duration = 60.0;
+  public Date SegmentDate = new Date();
+  public ArrayList TrackList = new ArrayList();
+
 	public MatroskaFileWriter(DataWriter outputDataWriter)
 	{
 		ioDW = outputDataWriter;
@@ -38,16 +61,17 @@
     ebmlHeaderElem.writeElement(ioDW);
   }
 
-  public void writeSegementHeader() 
+  public void writeSegmentHeader() 
   {
-    MasterElement segementElem = (MasterElement)doc.createElement(doc.Segment_Id);
-    segementElem.setSize(-1);
-    segementElem.writeHeaderData(ioDW);
+    MatroskaSegment segmentElem = (MatroskaSegment)doc.createElement(doc.Segment_Id);
+    //segmentElem.setSize(-1);
+    segmentElem.setUnknownSize(true);
+    segmentElem.writeHeaderData(ioDW);
   }
 
-  public void writeSegementInfo()
+  public void writeSegmentInfo()
   {
-    MasterElement segementInfoElem = (MasterElement)doc.createElement(doc.SegmentInfo_Id);
+    MasterElement segmentInfoElem = (MasterElement)doc.createElement(doc.SegmentInfo_Id);
     
     StringElement writingAppElem = (StringElement)doc.createElement(doc.WritingApp_Id);
     writingAppElem.setValue("MatroskaFileWriter v1.0");
@@ -56,21 +80,53 @@
     muxingAppElem.setValue("JEBML v1.0");
 
     DateElement dateElem = (DateElement)doc.createElement(doc.DateUTC_Id);
-    dateElem.setDate(new Date());
+    dateElem.setDate(SegmentDate);
 		
     //Add timecode scale
     UnsignedIntegerElement timecodescaleElem = (UnsignedIntegerElement)doc.createElement(doc.TimecodeScale_Id);
-    timecodescaleElem.setValue(TIMECODE_SCALE);
+    timecodescaleElem.setValue(TimecodeScale);
 										
     FloatElement durationElem = (FloatElement)doc.createElement(doc.Duration_Id);
-    durationElem.setValue(-1);
+    durationElem.setValue(Duration * 1000.0);
 	 
-    segementInfoElem.addChildElement(dateElem);
-    segementInfoElem.addChildElement(timecodescaleElem);
-    segementInfoElem.addChildElement(durationElem);
-    segementInfoElem.addChildElement(writingAppElem);
-    segementInfoElem.addChildElement(muxingAppElem);
+    segmentInfoElem.addChildElement(dateElem);
+    segmentInfoElem.addChildElement(timecodescaleElem);
+    segmentInfoElem.addChildElement(durationElem);
+    segmentInfoElem.addChildElement(writingAppElem);
+    segmentInfoElem.addChildElement(muxingAppElem);
 
-    segementInfoElem.writeElement(ioDW);
+    segmentInfoElem.writeElement(ioDW);
   }
+
+  public void writeTracks()
+  {
+    MasterElement tracksElem = (MasterElement)doc.createElement(doc.Tracks_Id);
+
+    for (int i = 0; i < TrackList.size(); i++) 
+    {
+      MatroskaFileTrack track = (MatroskaFileTrack)TrackList.get(i);
+      MasterElement trackEntryElem = (MasterElement)doc.createElement(doc.TrackEntry_Id);
+
+      UnsignedIntegerElement trackNoElem = (UnsignedIntegerElement)doc.createElement(doc.TrackNumber_Id);
+      trackNoElem.setValue(track.TrackNo);
+
+      UnsignedIntegerElement trackUIDElem = (UnsignedIntegerElement)doc.createElement(doc.TrackUID_Id);
+      trackUIDElem.setValue(track.TrackUID);
+
+      UnsignedIntegerElement trackTypeElem = (UnsignedIntegerElement)doc.createElement(doc.TrackType_Id);
+      trackTypeElem.setValue(track.TrackType);
+
+      StringElement trackNameElem = (StringElement)doc.createElement(doc.TrackName_Id);
+      trackNameElem.setValue(track.Name);
+
+      trackEntryElem.addChildElement(trackNoElem);
+      trackEntryElem.addChildElement(trackUIDElem);
+      trackEntryElem.addChildElement(trackTypeElem);
+      trackEntryElem.addChildElement(trackNameElem);
+
+      tracksElem.addChildElement(trackEntryElem);
+    }
+
+    tracksElem.writeElement(ioDW);
+  }
 }

Added: trunk/JEBML/src/org/ebml/matroska/MatroskaSegment.java
===================================================================
--- trunk/JEBML/src/org/ebml/matroska/MatroskaSegment.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/matroska/MatroskaSegment.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -0,0 +1,83 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+package org.ebml.matroska;
+
+import org.ebml.*;
+import org.ebml.io.*;
+
+/**
+ * Summary description for MatroskaSegment.
+ */
+public class MatroskaSegment extends MasterElement
+{
+  protected boolean bUnknownSize = false;
+
+  public MatroskaSegment(byte[] type) 
+  {
+    super(type);
+  }
+
+  /** Write the element header data.
+   *  The override will write the size as unknown if the flag is set.
+   */
+  public long writeHeaderData(DataWriter writer) 
+  {
+    long len = 0;
+
+    byte [] type = getType();
+    len += type.length;
+    writer.write(type);
+    
+    byte [] size;
+    if (bUnknownSize) 
+    {
+      size = new byte[5];
+      size[0] = (byte)(0xFF >>> (size.length-1));
+      for (int i = 1; i < size.length; i++)
+        size[i] = (byte)0xFF;
+    } 
+    else 
+    {
+      size = Element.makeEbmlCodedSize(getSize());
+    }    
+    
+    len += size.length;
+    writer.write(size);
+
+    return len;
+  }
+
+  /**
+   * Setter for Unknown Size flag.
+   * This is a special case for ebml. The size value is filled with 1's.
+   */
+  public void setUnknownSize(boolean bUnknownSize) 
+  {
+    this.bUnknownSize = bUnknownSize;
+  }
+
+  /**
+   * Getter for Unknown Size flag.
+   */
+  public boolean getUnknownSize() 
+  {
+    return bUnknownSize;
+  }
+}

Modified: trunk/JEBML/src/org/ebml/sample/CommandLineSample.java
===================================================================
--- trunk/JEBML/src/org/ebml/sample/CommandLineSample.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/sample/CommandLineSample.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -98,8 +98,18 @@
     FileDataWriter iFW = new FileDataWriter(filename);
     MatroskaFileWriter mFW = new MatroskaFileWriter(iFW);
     mFW.writeEBMLHeader();
-    mFW.writeSegementHeader();
-    mFW.writeSegementInfo();
+    mFW.writeSegmentHeader();
+    mFW.writeSegmentInfo();
+    for (int i = 0; i < 5; i++) 
+    {
+      MatroskaFileTrack track = new MatroskaFileTrack();
+      track.TrackNo = (short)i;
+      track.TrackUID = new java.util.Random().nextLong();
+      track.TrackType = 1;
+      track.Name = "Track " + Integer.toString(i);
+      mFW.TrackList.add(track);
+    }
+    mFW.writeTracks();
 
     System.out.println("Write complete");
   }

Modified: trunk/JEBML/src/org/ebml/util/ArrayCopy.java
===================================================================
--- trunk/JEBML/src/org/ebml/util/ArrayCopy.java	2004-10-05 02:46:31 UTC (rev 864)
+++ trunk/JEBML/src/org/ebml/util/ArrayCopy.java	2004-10-07 08:15:33 UTC (rev 865)
@@ -1,3 +1,22 @@
+/**
+ * JEBML - Java library to read/write EBML/Matroska elements.
+ * Copyright (C) 2004 Jory Stone <[email protected]>
+ * Based on Javatroska (C) 2002 John Cannon <[email protected]>
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
 package org.ebml.util;
 
 /**
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.