/* csvorbis * Copyright (C) 2000 ymnk, JCraft,Inc. * * Written by: 2000 ymnk * Ported to C# from JOrbis by: Mark Crichton * * Thanks go to the JOrbis team, for licencing the code under the * LGPL, making my job a lot easier. * * 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. */ using System; using System.Text; using csogg; namespace csvorbis { // the comments are not part of vorbis_info so that vorbis_info can be // static storage public class Comment { private static String _vorbis="vorbis"; //private static int OV_EFAULT=-129; private static int OV_EIMPL=-130; // unlimited user comment fields. libvorbis writes 'libvorbis' // whatever vendor is set to in encode 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) { Encoding AE = Encoding.UTF8; byte[] comment_byt = AE.GetBytes(comment); add(comment_byt); } private void add(byte[] comment) { byte[][] foo=new byte[comments+2][]; if(user_comments!=null) { Array.Copy(user_comments, 0, foo, 0, comments); } user_comments=foo; int[] goo=new int[comments+2]; if(comment_lengths!=null) { Array.Copy(comment_lengths, 0, goo, 0, comments); } comment_lengths=goo; byte[] bar=new byte[comment.Length+1]; Array.Copy(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); } /* private void add_tag(byte[] tag, byte[] contents){ byte[] foo=new byte[tag.length+contents.length+1]; int j=0; for(int i=0; i='A')u1=(byte)(u1-'A'+'a'); if(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) { Encoding AE = Encoding.UTF8; byte[] tag_byt = AE.GetBytes(tag); int foo=query(tag_byt, count); if(foo==-1)return null; byte[] comment=user_comments[foo]; for(int i=0; i