com.jcraft.jorbis.Comment Maven / Gradle / Ivy
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
/* JOrbis
* Copyright (C) 2000 ymnk, JCraft,Inc.
*
* Written by: 2000 ymnk
*
* Many thanks to
* Monty and
* The XIPHOPHORUS Company http://www.xiph.org/ .
* JOrbis has been based on their awesome works, Vorbis codec.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* This program 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 Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package com.jcraft.jorbis;
import com.jcraft.jogg.Buffer;
import com.jcraft.jogg.Packet;
// the comments are not part of vorbis_info so that vorbis_info can be
// static storage
public class Comment{
private static byte[] _vorbis="vorbis".getBytes();
private static byte[] _vendor="Xiphophorus libVorbis I 20000508".getBytes();
private static final int OV_EIMPL=-130;
// unlimited user comment fields.
public byte[][] user_comments;
public int[] comment_lengths;
public int comments;
public byte[] vendor;
public void init(){
user_comments=null;
comments=0;
vendor=null;
}
public void add(String comment){
add(comment.getBytes());
}
private void add(byte[] comment){
byte[][] foo=new byte[comments+2][];
if(user_comments!=null){
System.arraycopy(user_comments, 0, foo, 0, comments);
}
user_comments=foo;
int[] goo=new int[comments+2];
if(comment_lengths!=null){
System.arraycopy(comment_lengths, 0, goo, 0, comments);
}
comment_lengths=goo;
byte[] bar=new byte[comment.length+1];
System.arraycopy(comment, 0, bar, 0, comment.length);
user_comments[comments]=bar;
comment_lengths[comments]=comment.length;
comments++;
user_comments[comments]=null;
}
public void add_tag(String tag, String contents){
if(contents==null)
contents="";
add(tag+"="+contents);
}
static boolean tagcompare(byte[] s1, byte[] s2, int n){
int c=0;
byte u1, u2;
while(c=u1&&u1>='A')
u1=(byte)(u1-'A'+'a');
if('Z'>=u2&&u2>='A')
u2=(byte)(u2-'A'+'a');
if(u1!=u2){
return false;
}
c++;
}
return true;
}
public String query(String tag){
return query(tag, 0);
}
public String query(String tag, int count){
int foo=query(tag.getBytes(), count);
if(foo==-1)
return null;
byte[] comment=user_comments[foo];
for(int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy