1 7 8 package org.jboss.media.format.audio.oggvorbis; 9 10 import java.io.IOException ; 11 import java.io.InputStream ; 12 import java.util.HashMap ; 13 import java.util.Map ; 14 15 import javax.emb.MediaException; 16 import javax.emb.MediaHeader; 17 18 27 public class OggVorbisHeader implements MediaHeader 28 { 29 private final static String CHANNELS_KEY = "channels"; 31 private final static String RATE_KEY = "rate"; 32 private final static String BITRATE_KEY = "bitRate"; 33 private final static String COMMENTS_KEY = "comments"; 34 35 private final Map fieldMap = new HashMap (4); 37 38 41 public OggVorbisHeader(InputStream content) throws MediaException 42 { 43 try 44 { 45 VorbisInfo info = new VorbisInfo(content); 47 48 fieldMap.put(CHANNELS_KEY, new Integer (info.getChannels())); 49 fieldMap.put(RATE_KEY, new Long (info.getRate())); 50 fieldMap.put(BITRATE_KEY, new Long (info.getBitrate())); 51 fieldMap.put(COMMENTS_KEY, info.getComments()); 52 } 53 catch (IOException e) 54 { 55 throw new MediaException("Error creating VorbisInfo helper object", e); 56 } 57 } 58 59 62 public String [] getFieldNames() 63 { 64 return (String []) fieldMap.keySet().toArray(new String [0]); 65 } 66 67 70 public Object getField(String fieldName) 71 { 72 return fieldMap.get(fieldName); 73 } 74 } | Popular Tags |