• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2011 castLabs, Berlin
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 
17 package com.googlecode.mp4parser.boxes.basemediaformat;
18 
19 import com.googlecode.mp4parser.AbstractBox;
20 import com.coremedia.iso.boxes.h264.AvcConfigurationBox;
21 
22 import java.io.ByteArrayOutputStream;
23 import java.nio.ByteBuffer;
24 import java.util.Arrays;
25 import java.util.List;
26 
27 import static com.googlecode.mp4parser.util.CastUtils.l2i;
28 
29 /**
30  * The AVC NAL Unit Storage Box SHALL contain an AVCDecoderConfigurationRecord,
31  * as defined in section 5.2.4.1 of the ISO 14496-12.
32  */
33 public class AvcNalUnitStorageBox extends AbstractBox {
34     AvcConfigurationBox.AVCDecoderConfigurationRecord avcDecoderConfigurationRecord;
35 
AvcNalUnitStorageBox()36     public AvcNalUnitStorageBox() {
37         super("avcn");
38     }
39 
AvcNalUnitStorageBox(AvcConfigurationBox avcConfigurationBox)40     public AvcNalUnitStorageBox(AvcConfigurationBox avcConfigurationBox) {
41         super("avcn");
42         this.avcDecoderConfigurationRecord = avcConfigurationBox.getavcDecoderConfigurationRecord();
43     }
44 
getAvcDecoderConfigurationRecord()45     public AvcConfigurationBox.AVCDecoderConfigurationRecord getAvcDecoderConfigurationRecord() {
46         return avcDecoderConfigurationRecord;
47     }
48 
49     // just to display sps in isoviewer no practical use
getLengthSizeMinusOne()50     public int getLengthSizeMinusOne() {
51         return avcDecoderConfigurationRecord.lengthSizeMinusOne;
52     }
53 
getSPS()54     public String[] getSPS() {
55         return avcDecoderConfigurationRecord.getSPS();
56     }
57 
getPPS()58     public String[] getPPS() {
59         return avcDecoderConfigurationRecord.getPPS();
60     }
61 
getSequenceParameterSetsAsStrings()62     public List<String> getSequenceParameterSetsAsStrings() {
63         return avcDecoderConfigurationRecord.getSequenceParameterSetsAsStrings();
64     }
65 
getSequenceParameterSetExtsAsStrings()66     public List<String> getSequenceParameterSetExtsAsStrings() {
67         return avcDecoderConfigurationRecord.getSequenceParameterSetExtsAsStrings();
68     }
69 
getPictureParameterSetsAsStrings()70     public List<String> getPictureParameterSetsAsStrings() {
71         return avcDecoderConfigurationRecord.getPictureParameterSetsAsStrings();
72     }
73 
74     @Override
getContentSize()75     protected long getContentSize() {
76         return avcDecoderConfigurationRecord.getContentSize();
77     }
78 
79     @Override
_parseDetails(ByteBuffer content)80     public void _parseDetails(ByteBuffer content) {
81         this.avcDecoderConfigurationRecord = new AvcConfigurationBox.AVCDecoderConfigurationRecord(content);
82     }
83 
84     @Override
getContent(ByteBuffer byteBuffer)85     protected void getContent(ByteBuffer byteBuffer) {
86         this.avcDecoderConfigurationRecord.getContent(byteBuffer);
87     }
88 
89     @Override
toString()90     public String toString() {
91         return "AvcNalUnitStorageBox{" +
92                 "SPS=" + avcDecoderConfigurationRecord.getSequenceParameterSetsAsStrings() +
93                 ",PPS=" + avcDecoderConfigurationRecord.getPictureParameterSetsAsStrings() +
94                 ",lengthSize=" + (avcDecoderConfigurationRecord.lengthSizeMinusOne + 1) +
95                 '}';
96     }
97 }
98