| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
package org.jaudiotagger.audio.ogg; |
| 20 | |
|
| 21 | |
import org.jaudiotagger.audio.ogg.util.VorbisHeader; |
| 22 | |
import org.jaudiotagger.audio.ogg.util.VorbisPacketType; |
| 23 | |
import org.jaudiotagger.tag.Tag; |
| 24 | |
import org.jaudiotagger.tag.vorbiscomment.VorbisCommentCreator; |
| 25 | |
|
| 26 | |
import java.io.UnsupportedEncodingException; |
| 27 | |
import java.nio.ByteBuffer; |
| 28 | |
import java.util.logging.Logger; |
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | 42 | public class OggVorbisCommentTagCreator |
| 37 | |
{ |
| 38 | |
|
| 39 | 42 | public static Logger logger = Logger.getLogger("org.jaudiotagger.audio.ogg"); |
| 40 | |
|
| 41 | |
public static final int FIELD_FRAMING_BIT_LENGTH = 1; |
| 42 | |
public static final byte FRAMING_BIT_VALID_VALUE = (byte) 0x01; |
| 43 | 42 | private VorbisCommentCreator creator = new VorbisCommentCreator(); |
| 44 | |
|
| 45 | |
|
| 46 | |
public ByteBuffer convert(Tag tag) throws UnsupportedEncodingException |
| 47 | |
{ |
| 48 | 22 | ByteBuffer ogg = creator.convert(tag); |
| 49 | 22 | int tagLength = ogg.capacity() + VorbisHeader.FIELD_PACKET_TYPE_LENGTH + VorbisHeader.FIELD_CAPTURE_PATTERN_LENGTH + OggVorbisCommentTagCreator.FIELD_FRAMING_BIT_LENGTH; |
| 50 | |
|
| 51 | 22 | ByteBuffer buf = ByteBuffer.allocate(tagLength); |
| 52 | |
|
| 53 | |
|
| 54 | 22 | buf.put((byte) VorbisPacketType.COMMENT_HEADER.getType()); |
| 55 | 22 | buf.put(VorbisHeader.CAPTURE_PATTERN_AS_BYTES); |
| 56 | |
|
| 57 | |
|
| 58 | 22 | buf.put(ogg); |
| 59 | |
|
| 60 | |
|
| 61 | 22 | buf.put(FRAMING_BIT_VALID_VALUE); |
| 62 | |
|
| 63 | 22 | buf.rewind(); |
| 64 | 22 | return buf; |
| 65 | |
} |
| 66 | |
} |