diff options
Diffstat (limited to 'isoparser/src/main/java/com/googlecode/mp4parser/util/.svn')
7 files changed, 0 insertions, 516 deletions
diff --git a/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/all-wcprops b/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/all-wcprops deleted file mode 100644 index 6decd2f..0000000 --- a/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/all-wcprops +++ /dev/null @@ -1,35 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 77 -/svn/!svn/ver/647/trunk/isoparser/src/main/java/com/googlecode/mp4parser/util -END -Math.java -K 25 -svn:wc:ra_dav:version-url -V 87 -/svn/!svn/ver/591/trunk/isoparser/src/main/java/com/googlecode/mp4parser/util/Math.java -END -ByteBufferByteChannel.java -K 25 -svn:wc:ra_dav:version-url -V 104 -/svn/!svn/ver/505/trunk/isoparser/src/main/java/com/googlecode/mp4parser/util/ByteBufferByteChannel.java -END -CastUtils.java -K 25 -svn:wc:ra_dav:version-url -V 92 -/svn/!svn/ver/505/trunk/isoparser/src/main/java/com/googlecode/mp4parser/util/CastUtils.java -END -Path.java -K 25 -svn:wc:ra_dav:version-url -V 87 -/svn/!svn/ver/647/trunk/isoparser/src/main/java/com/googlecode/mp4parser/util/Path.java -END -UUIDConverter.java -K 25 -svn:wc:ra_dav:version-url -V 96 -/svn/!svn/ver/418/trunk/isoparser/src/main/java/com/googlecode/mp4parser/util/UUIDConverter.java -END diff --git a/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/entries b/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/entries deleted file mode 100644 index df7f2b0..0000000 --- a/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/entries +++ /dev/null @@ -1,198 +0,0 @@ -10 - -dir -778 -http://mp4parser.googlecode.com/svn/trunk/isoparser/src/main/java/com/googlecode/mp4parser/util -http://mp4parser.googlecode.com/svn - - - -2012-05-27T05:36:06.980381Z -647 -Sebastian.Annies@gmail.com - - - - - - - - - - - - - - -7decde4b-c250-0410-a0da-51896bc88be6 - -Math.java -file - - - - -2012-09-14T17:27:51.667235Z -be07b5a338a5ad8f6491ffec0f4d5e11 -2012-05-07T16:21:15.288279Z -591 -Sebastian.Annies@gmail.com - - - - - - - - - - - - - - - - - - - - - -619 - -ByteBufferByteChannel.java -file - - - - -2012-09-14T17:27:51.667235Z -8e8bdec08e05ef5d4dbeb46b7e1d35c2 -2012-04-21T21:18:31.685061Z -505 -Sebastian.Annies@gmail.com - - - - - - - - - - - - - - - - - - - - - -1654 - -CastUtils.java -file - - - - -2012-09-14T17:27:51.667235Z -8cda078221f55ca06cf0cdc49e2cbbba -2012-04-21T21:18:31.685061Z -505 -Sebastian.Annies@gmail.com - - - - - - - - - - - - - - - - - - - - - -1326 - -Path.java -file - - - - -2012-09-14T17:27:51.667235Z -f0ae3de018d1fb2645b0eb2beefeeb01 -2012-05-27T05:36:06.980381Z -647 -Sebastian.Annies@gmail.com - - - - - - - - - - - - - - - - - - - - - -3884 - -UUIDConverter.java -file - - - - -2012-09-14T17:27:51.667235Z -d9d8f271318ba9ee779efd10904d7ad3 -2012-03-11T20:54:45.638478Z -418 -Sebastian.Annies@gmail.com - - - - - - - - - - - - - - - - - - - - - -1413 - diff --git a/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/text-base/ByteBufferByteChannel.java.svn-base b/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/text-base/ByteBufferByteChannel.java.svn-base deleted file mode 100644 index 9f3264b..0000000 --- a/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/text-base/ByteBufferByteChannel.java.svn-base +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.util; - -import java.io.EOFException; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.nio.channels.ByteChannel; - -/** - * Creates a <code>ReadableByteChannel</code> that is backed by a <code>ByteBuffer</code>. - */ -public class ByteBufferByteChannel implements ByteChannel { - ByteBuffer byteBuffer; - - public ByteBufferByteChannel(ByteBuffer byteBuffer) { - this.byteBuffer = byteBuffer; - } - - public int read(ByteBuffer dst) throws IOException { - byte[] b = dst.array(); - int r = dst.remaining(); - if (byteBuffer.remaining() >= r) { - byteBuffer.get(b, dst.position(), r); - return r; - } else { - throw new EOFException("Reading beyond end of stream"); - } - } - - public boolean isOpen() { - return true; - } - - public void close() throws IOException { - } - - public int write(ByteBuffer src) throws IOException { - int r = src.remaining(); - byteBuffer.put(src); - return r; - } -} diff --git a/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/text-base/CastUtils.java.svn-base b/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/text-base/CastUtils.java.svn-base deleted file mode 100644 index 2dd011a..0000000 --- a/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/text-base/CastUtils.java.svn-base +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.util; - - -public class CastUtils { - /** - * Casts a long to an int. In many cases I use a long for a UInt32 but this cannot be used to allocate - * ByteBuffers or arrays since they restricted to <code>Integer.MAX_VALUE</code> this cast-method will throw - * a RuntimeException if the cast would cause a loss of information. - * - * @param l the long value - * @return the long value as int - */ - public static int l2i(long l) { - if (l > Integer.MAX_VALUE || l < Integer.MIN_VALUE) { - throw new RuntimeException("A cast to int has gone wrong. Please contact the mp4parser discussion group (" + l + ")"); - } - return (int) l; - } -} diff --git a/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/text-base/Math.java.svn-base b/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/text-base/Math.java.svn-base deleted file mode 100644 index 27fd4b2..0000000 --- a/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/text-base/Math.java.svn-base +++ /dev/null @@ -1,30 +0,0 @@ -package com.googlecode.mp4parser.util; - -public class Math { - public static long gcd(long a, long b) { - while (b > 0) { - long temp = b; - b = a % b; // % is remainder - a = temp; - } - return a; - } - - public static int gcd(int a, int b) { - while (b > 0) { - int temp = b; - b = a % b; // % is remainder - a = temp; - } - return a; - } - - public static long lcm(long a, long b) { - return a * (b / gcd(a, b)); - } - - public static int lcm(int a, int b) { - return a * (b / gcd(a, b)); - } - -} diff --git a/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/text-base/Path.java.svn-base b/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/text-base/Path.java.svn-base deleted file mode 100644 index a6066c8..0000000 --- a/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/text-base/Path.java.svn-base +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.util; - - -import com.coremedia.iso.IsoFile; -import com.coremedia.iso.boxes.Box; -import com.coremedia.iso.boxes.ContainerBox; - -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class Path { - - private Path() { - } - - static Pattern component = Pattern.compile("(....|\\.\\.)(\\[(.*)\\])?"); - - public static String createPath(Box box) { - return createPath(box, ""); - } - - private static String createPath(Box box, String path) { - if (box instanceof IsoFile) { - return path; - } else { - List<?> boxesOfBoxType = box.getParent().getBoxes(box.getClass()); - int index = boxesOfBoxType.indexOf(box); - path = String.format("/%s[%d]", box.getType(), index) + path; - - return createPath(box.getParent(), path); - } - } - - public static Box getPath(Box box, String path) { - List<Box> all = getPaths(box, path); - return all.isEmpty() ? null : all.get(0); - } - - - public static List<Box> getPaths(Box box, String path) { - if (path.startsWith("/")) { - Box isoFile = box; - while (isoFile.getParent() != null) { - isoFile = isoFile.getParent(); - } - assert isoFile instanceof IsoFile : isoFile.getType() + " has no parent"; - return getPaths(isoFile, path.substring(1)); - } else if (path.isEmpty()) { - return Collections.singletonList(box); - } else { - String later; - String now; - if (path.contains("/")) { - later = path.substring(path.indexOf('/') + 1); - now = path.substring(0, path.indexOf('/')); - } else { - now = path; - later = ""; - } - - Matcher m = component.matcher(now); - if (m.matches()) { - String type = m.group(1); - if ("..".equals(type)) { - return getPaths(box.getParent(), later); - } else { - int index = -1; - if (m.group(2) != null) { - // we have a specific index - String indexString = m.group(3); - index = Integer.parseInt(indexString); - } - List<Box> children = new LinkedList<Box>(); - int currentIndex = 0; - for (Box box1 : ((ContainerBox) box).getBoxes()) { - if (box1.getType().matches(type)) { - if (index == -1 || index == currentIndex) { - children.addAll(getPaths(box1, later)); - } - currentIndex++; - } - } - return children; - } - } else { - throw new RuntimeException(now + " is invalid path."); - } - } - - } - - - public static boolean isContained(Box box, String path) { - assert path.startsWith("/") : "Absolute path required"; - return getPaths(box, path).contains(box); - } -} diff --git a/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/text-base/UUIDConverter.java.svn-base b/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/text-base/UUIDConverter.java.svn-base deleted file mode 100644 index 635e4c1..0000000 --- a/isoparser/src/main/java/com/googlecode/mp4parser/util/.svn/text-base/UUIDConverter.java.svn-base +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2012 Sebastian Annies, Hamburg - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.googlecode.mp4parser.util; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.UUID; - -/** - * UUID from/to byte array. - */ -public class UUIDConverter { - public static byte[] convert(UUID uuid) { - - long msb = uuid.getMostSignificantBits(); - long lsb = uuid.getLeastSignificantBits(); - byte[] buffer = new byte[16]; - - for (int i = 0; i < 8; i++) { - buffer[i] = (byte) (msb >>> 8 * (7 - i)); - } - for (int i = 8; i < 16; i++) { - buffer[i] = (byte) (lsb >>> 8 * (7 - i)); - } - - return buffer; - - } - - public static UUID convert(byte[] uuidBytes) { - ByteBuffer b = ByteBuffer.wrap(uuidBytes); - b.order(ByteOrder.BIG_ENDIAN); - return new UUID(b.getLong(), b.getLong()); - } -} |