1/*
2 * Copyright 2008 CoreMedia AG, Hamburg
3 *
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.coremedia.iso.boxes.vodafone;
18
19import com.coremedia.iso.IsoTypeReader;
20import com.coremedia.iso.Utf8;
21import com.googlecode.mp4parser.AbstractFullBox;
22
23import java.nio.ByteBuffer;
24
25/**
26 * A box in the {@link com.coremedia.iso.boxes.UserDataBox} containing information about the lyric location.
27 * Invented by Vodafone.
28 */
29public class LyricsUriBox extends AbstractFullBox {
30    public static final String TYPE = "lrcu";
31
32    private String lyricsUri;
33
34    public LyricsUriBox() {
35        super(TYPE);
36    }
37
38    public String getLyricsUri() {
39        return lyricsUri;
40    }
41
42    public void setLyricsUri(String lyricsUri) {
43        this.lyricsUri = lyricsUri;
44    }
45
46    protected long getContentSize() {
47        return Utf8.utf8StringLengthInBytes(lyricsUri) + 5;
48    }
49
50    @Override
51    public void _parseDetails(ByteBuffer content) {
52        parseVersionAndFlags(content);
53        lyricsUri = IsoTypeReader.readString(content);
54    }
55
56    @Override
57    protected void getContent(ByteBuffer byteBuffer) {
58        writeVersionAndFlags(byteBuffer);
59        byteBuffer.put(Utf8.convert(lyricsUri));
60        byteBuffer.put((byte) 0);
61    }
62
63    public String toString() {
64        return "LyricsUriBox[lyricsUri=" + getLyricsUri() + "]";
65    }
66}
67