Package net.sourceforge.jaad.mp4.api

Examples of net.sourceforge.jaad.mp4.api.Artwork


  private final Codec originalFormat;

  protected Protection(Box sinf) {
    //original format
    final long type = ((OriginalFormatBox) sinf.getChild(BoxTypes.ORIGINAL_FORMAT_BOX)).getOriginalFormat();
    Codec c;
    //TODO: currently it tests for audio and video codec, can do this any other way?
    if(!(c = AudioTrack.AudioCodec.forType(type)).equals(AudioTrack.AudioCodec.UNKNOWN_AUDIO_CODEC)) originalFormat = c;
    else if(!(c = VideoTrack.VideoCodec.forType(type)).equals(VideoTrack.VideoCodec.UNKNOWN_VIDEO_CODEC)) originalFormat = c;
    else originalFormat = null;
  }
View Full Code Here


  static Protection parse(Box sinf) {
    Protection p = null;
    if(sinf.hasChild(BoxTypes.SCHEME_TYPE_BOX)) {
      final SchemeTypeBox schm = (SchemeTypeBox) sinf.getChild(BoxTypes.SCHEME_TYPE_BOX);
      final long l = schm.getSchemeType();
      if(l==Scheme.ITUNES_FAIR_PLAY.type) p = new ITunesProtection(sinf);
    }

    if(p==null) p = new UnknownProtection(sinf);
    return p;
  }
View Full Code Here

  private Codec codec;

  public AudioTrack(Box trak, MP4InputStream in) {
    super(trak, in);

    final Box mdia = trak.getChild(BoxTypes.MEDIA_BOX);
    final Box minf = mdia.getChild(BoxTypes.MEDIA_INFORMATION_BOX);
    smhd = (SoundMediaHeaderBox) minf.getChild(BoxTypes.SOUND_MEDIA_HEADER_BOX);

    final Box stbl = minf.getChild(BoxTypes.SAMPLE_TABLE_BOX);

    //sample descriptions: 'mp4a' and 'enca' have an ESDBox, all others have a CodecSpecificBox
    final SampleDescriptionBox stsd = (SampleDescriptionBox) stbl.getChild(BoxTypes.SAMPLE_DESCRIPTION_BOX);
    if(stsd.getChildren().get(0) instanceof AudioSampleEntry) {
      sampleEntry = (AudioSampleEntry) stsd.getChildren().get(0);
      final long type = sampleEntry.getType();
      if(sampleEntry.hasChild(BoxTypes.ESD_BOX)) findDecoderSpecificInfo((ESDBox) sampleEntry.getChild(BoxTypes.ESD_BOX));
      else decoderInfo = DecoderInfo.parse((CodecSpecificBox) sampleEntry.getChildren().get(0));
View Full Code Here

  Track(Box trak, MP4InputStream in) {
    this.in = in;

    tkhd = (TrackHeaderBox) trak.getChild(BoxTypes.TRACK_HEADER_BOX);

    final Box mdia = trak.getChild(BoxTypes.MEDIA_BOX);
    mdhd = (MediaHeaderBox) mdia.getChild(BoxTypes.MEDIA_HEADER_BOX);
    final Box minf = mdia.getChild(BoxTypes.MEDIA_INFORMATION_BOX);

    final Box dinf = minf.getChild(BoxTypes.DATA_INFORMATION_BOX);
    final DataReferenceBox dref = (DataReferenceBox) dinf.getChild(BoxTypes.DATA_REFERENCE_BOX);
    //TODO: support URNs
    if(dref.hasChild(BoxTypes.DATA_ENTRY_URL_BOX)) {
      DataEntryUrlBox url = (DataEntryUrlBox) dref.getChild(BoxTypes.DATA_ENTRY_URL_BOX);
      inFile = url.isInFile();
      if(!inFile) {
        try {
          location = new URL(url.getLocation());
        }
        catch(MalformedURLException e) {
          Logger.getLogger("MP4 API").log(Level.WARNING, "Parsing URL-Box failed: {0}, url: {1}", new String[]{e.toString(), url.getLocation()});
          location = null;
        }
      }
    }
    /*else if(dref.containsChild(BoxTypes.DATA_ENTRY_URN_BOX)) {
    DataEntryUrnBox urn = (DataEntryUrnBox) dref.getChild(BoxTypes.DATA_ENTRY_URN_BOX);
    inFile = urn.isInFile();
    location = urn.getLocation();
    }*/
    else {
      inFile = true;
      location = null;
    }

    //sample table
    final Box stbl = minf.getChild(BoxTypes.SAMPLE_TABLE_BOX);
    if(stbl.hasChildren()) {
      frames = new ArrayList<Frame>();
      parseSampleTable(stbl);
    }
    else frames = Collections.emptyList();

View Full Code Here

  private final byte[] privateKey, initializationVector;

  public ITunesProtection(Box sinf) {
    super(sinf);

    final Box schi = sinf.getChild(BoxTypes.SCHEME_INFORMATION_BOX);
    userID = new String(((FairPlayDataBox) schi.getChild(BoxTypes.FAIRPLAY_USER_ID_BOX)).getData());
   
    //user name box is filled with 0
    final byte[] b = ((FairPlayDataBox) schi.getChild(BoxTypes.FAIRPLAY_USER_NAME_BOX)).getData();
    int i = 0;
    while(b[i]!=0) {
      i++;
    }
    userName = new String(b, 0, i-1);
   
    userKey = new String(((FairPlayDataBox) schi.getChild(BoxTypes.FAIRPLAY_USER_KEY_BOX)).getData());
    privateKey = ((FairPlayDataBox) schi.getChild(BoxTypes.FAIRPLAY_PRIVATE_KEY_BOX)).getData();
    initializationVector = ((FairPlayDataBox) schi.getChild(BoxTypes.FAIRPLAY_IV_BOX)).getData();
  }
View Full Code Here

  private final Codec codec;

  public VideoTrack(Box trak, MP4InputStream in) {
    super(trak, in);

    final Box minf = trak.getChild(BoxTypes.MEDIA_BOX).getChild(BoxTypes.MEDIA_INFORMATION_BOX);
    vmhd = (VideoMediaHeaderBox) minf.getChild(BoxTypes.VIDEO_MEDIA_HEADER_BOX);

    final Box stbl = minf.getChild(BoxTypes.SAMPLE_TABLE_BOX);

    //sample descriptions: 'mp4v' has an ESDBox, all others have a CodecSpecificBox
    final SampleDescriptionBox stsd = (SampleDescriptionBox) stbl.getChild(BoxTypes.SAMPLE_DESCRIPTION_BOX);
    if(stsd.getChildren().get(0) instanceof VideoSampleEntry) {
      sampleEntry = (VideoSampleEntry) stsd.getChildren().get(0);
      final long type = sampleEntry.getType();
      if(type==BoxTypes.MP4V_SAMPLE_ENTRY) findDecoderSpecificInfo((ESDBox) sampleEntry.getChild(BoxTypes.ESD_BOX));
      else if(type==BoxTypes.ENCRYPTED_VIDEO_SAMPLE_ENTRY||type==BoxTypes.DRMS_SAMPLE_ENTRY) {
View Full Code Here

    readContent();
  }

  private void readContent() throws IOException {
    //read all boxes
    Box box = null;
    long type;
    boolean moovFound = false;
    while(in.hasLeft()) {
      box = BoxFactory.parseBox(null, in);
      if(boxes.isEmpty()&&box.getType()!=BoxTypes.FILE_TYPE_BOX) throw new MP4Exception("no MP4 signature found");
      boxes.add(box);

      type = box.getType();
      if(type==BoxTypes.FILE_TYPE_BOX) {
        if(ftyp==null) ftyp = (FileTypeBox) box;
      }
      else if(type==BoxTypes.MOVIE_BOX) {
        if(movie==null) moov = box;
View Full Code Here

    //read metadata: moov.meta/moov.udta.meta
    metaData = new MetaData();
    if(moov.hasChild(BoxTypes.META_BOX)) metaData.parse(null, moov.getChild(BoxTypes.META_BOX));
    else if(moov.hasChild(BoxTypes.USER_DATA_BOX)) {
      final Box udta = moov.getChild(BoxTypes.USER_DATA_BOX);
      if(udta.hasChild(BoxTypes.META_BOX)) metaData.parse(udta, udta.getChild(BoxTypes.META_BOX));
    }

    //detect DRM
    protections = new ArrayList<Protection>();
    if(moov.hasChild(BoxTypes.ITEM_PROTECTION_BOX)) {
      Box ipro = moov.getChild(BoxTypes.ITEM_PROTECTION_BOX);
      for(Box sinf : ipro.getChildren(BoxTypes.PROTECTION_SCHEME_INFORMATION_BOX)) {
        protections.add(Protection.parse(sinf));
      }
    }
  }
View Full Code Here

    //sample sizes
    final long[] sampleSizes = ((SampleSizeBox) stbl.getChild(BoxTypes.SAMPLE_SIZE_BOX)).getSampleSizes();

    //chunk offsets
    final ChunkOffsetBox stco;
    if(stbl.hasChild(BoxTypes.CHUNK_OFFSET_BOX)) stco = (ChunkOffsetBox) stbl.getChild(BoxTypes.CHUNK_OFFSET_BOX);
    else stco = (ChunkOffsetBox) stbl.getChild(BoxTypes.CHUNK_LARGE_OFFSET_BOX);
    final long[] chunkOffsets = stco.getChunks();

    //samples to chunks
    final SampleToChunkBox stsc = ((SampleToChunkBox) stbl.getChild(BoxTypes.SAMPLE_TO_CHUNK_BOX));
    final long[] firstChunks = stsc.getFirstChunks();
    final long[] samplesPerChunk = stsc.getSamplesPerChunk();
View Full Code Here

   * ---tshd
   */
  void parse(Box udta, Box meta) {
    //standard boxes
    if(meta.hasChild(BoxTypes.COPYRIGHT_BOX)) {
      CopyrightBox cprt = (CopyrightBox) meta.getChild(BoxTypes.COPYRIGHT_BOX);
      put(Field.LANGUAGE, new Locale(cprt.getLanguageCode()));
      put(Field.COPYRIGHT, cprt.getNotice());
    }
    //3gpp user data
    if(udta!=null) parse3GPPData(udta);
    //id3, TODO: can be present in different languages
    if(meta.hasChild(BoxTypes.ID3_TAG_BOX)) parseID3((ID3TagBox) meta.getChild(BoxTypes.ID3_TAG_BOX));
View Full Code Here

TOP

Related Classes of net.sourceforge.jaad.mp4.api.Artwork

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.