• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.googlecode.mp4parser.authoring.tracks;
2 
3 import com.coremedia.iso.boxes.*;
4 import com.googlecode.mp4parser.authoring.Mp4TrackImpl;
5 import com.googlecode.mp4parser.authoring.Track;
6 import com.googlecode.mp4parser.authoring.TrackMetaData;
7 
8 import java.nio.ByteBuffer;
9 import java.util.Collections;
10 import java.util.LinkedList;
11 import java.util.List;
12 
13 /**
14  * This is just a basic idea how things could work but they don't.
15  */
16 public class SilenceTrackImpl implements Track {
17     Track source;
18 
19     List<ByteBuffer> samples = new LinkedList<ByteBuffer>();
20     TimeToSampleBox.Entry entry;
21 
SilenceTrackImpl(Track ofType, long ms)22     public SilenceTrackImpl(Track ofType, long ms) {
23         source = ofType;
24         if ("mp4a".equals(ofType.getSampleDescriptionBox().getSampleEntry().getType())) {
25             long numFrames = getTrackMetaData().getTimescale() * ms / 1000 / 1024;
26             long standZeit = getTrackMetaData().getTimescale() * ms / numFrames / 1000;
27             entry = new TimeToSampleBox.Entry(numFrames, standZeit);
28 
29 
30             while (numFrames-- > 0) {
31                 samples.add((ByteBuffer) ByteBuffer.wrap(new byte[]{
32                         0x21, 0x10, 0x04, 0x60, (byte) 0x8c, 0x1c,
33                 }).rewind());
34             }
35 
36         } else {
37             throw new RuntimeException("Tracks of type " + ofType.getClass().getSimpleName() + " are not supported");
38         }
39     }
40 
getSampleDescriptionBox()41     public SampleDescriptionBox getSampleDescriptionBox() {
42         return source.getSampleDescriptionBox();
43     }
44 
getDecodingTimeEntries()45     public List<TimeToSampleBox.Entry> getDecodingTimeEntries() {
46         return Collections.singletonList(entry);
47 
48     }
49 
getTrackMetaData()50     public TrackMetaData getTrackMetaData() {
51         return source.getTrackMetaData();
52     }
53 
getHandler()54     public String getHandler() {
55         return source.getHandler();
56     }
57 
isEnabled()58     public boolean isEnabled() {
59         return source.isEnabled();
60     }
61 
isInMovie()62     public boolean isInMovie() {
63         return source.isInMovie();
64     }
65 
isInPreview()66     public boolean isInPreview() {
67         return source.isInPreview();
68     }
69 
isInPoster()70     public boolean isInPoster() {
71         return source.isInPoster();
72     }
73 
getSamples()74     public List<ByteBuffer> getSamples() {
75         return samples;
76     }
77 
getMediaHeaderBox()78     public Box getMediaHeaderBox() {
79         return source.getMediaHeaderBox();
80     }
81 
getSubsampleInformationBox()82     public SubSampleInformationBox getSubsampleInformationBox() {
83         return null;
84     }
85 
getCompositionTimeEntries()86     public List<CompositionTimeToSample.Entry> getCompositionTimeEntries() {
87         return null;
88     }
89 
getSyncSamples()90     public long[] getSyncSamples() {
91         return null;
92     }
93 
getSampleDependencies()94     public List<SampleDependencyTypeBox.Entry> getSampleDependencies() {
95         return null;
96     }
97 
98 }
99