Search in sources :

Example 1 with HandlerReference

use of cbit.vcell.export.gloworm.atoms.HandlerReference in project vcell by virtualcell.

the class MediaMethods method makeMediaInformation.

/**
 * This method was created in VisualAge.
 * @return TrackAtom
 * @param track Track
 */
private static final MediaInformation makeMediaInformation(MediaTrack track) throws DataFormatException {
    SampleTableDescription stsd = new SampleTableDescription(track.getSampleDescriptionEntries());
    TimeToSample stts = new TimeToSample(track.getSampleDurations());
    SyncSample stss = new SyncSample(track.getKeyFrames());
    SampleToChunk stsc = new SampleToChunk(track.getChunkIDs());
    SampleSize stsz = new SampleSize(track.getSampleSizes());
    ChunkOffset stco = new ChunkOffset(track.getChunkOffsets());
    SampleTable stbl = new SampleTable(stsd, stts, stss, stsc, stsz, stco);
    DataReferenceEntry[] entries = new DataReferenceEntry[track.getDataReferences().length];
    for (int i = 0; i < track.getDataReferences().length; i++) entries[i] = new DataReferenceEntry(track.getDataReferences()[i], track.getDataReferenceTypes()[i]);
    DataReference dref = new DataReference(entries);
    DataInformation dinf = new DataInformation(dref);
    HandlerReference dhlr = new HandlerReference("dhlr", AtomConstants.COMPONENT_SUBTYPE_FILE_ALIAS);
    if (track.getMediaType().equals(AtomConstants.MEDIA_TYPE_VIDEO)) {
        VideoMediaInformationHeader vmhd = new VideoMediaInformationHeader();
        return new VideoMediaInformation(vmhd, dhlr, dinf, stbl);
    } else if (track.getMediaType().equals(AtomConstants.MEDIA_TYPE_OBJECT) || track.getMediaType().equals(AtomConstants.MEDIA_TYPE_QTVR)) {
        BaseMediaInfo gmin = new BaseMediaInfo();
        BaseMediaHeader gmhd = new BaseMediaHeader(gmin);
        return new BaseMediaInformation(gmhd, dhlr, dinf, stbl);
    } else {
        throw new DataFormatException("Unknown media type");
    }
}
Also used : DataInformation(cbit.vcell.export.gloworm.atoms.DataInformation) VideoMediaInformation(cbit.vcell.export.gloworm.atoms.VideoMediaInformation) SampleTable(cbit.vcell.export.gloworm.atoms.SampleTable) TimeToSample(cbit.vcell.export.gloworm.atoms.TimeToSample) SampleTableDescription(cbit.vcell.export.gloworm.atoms.SampleTableDescription) BaseMediaInfo(cbit.vcell.export.gloworm.atoms.BaseMediaInfo) ChunkOffset(cbit.vcell.export.gloworm.atoms.ChunkOffset) BaseMediaInformation(cbit.vcell.export.gloworm.atoms.BaseMediaInformation) SampleToChunk(cbit.vcell.export.gloworm.atoms.SampleToChunk) SampleSize(cbit.vcell.export.gloworm.atoms.SampleSize) HandlerReference(cbit.vcell.export.gloworm.atoms.HandlerReference) DataFormatException(java.util.zip.DataFormatException) VideoMediaInformationHeader(cbit.vcell.export.gloworm.atoms.VideoMediaInformationHeader) SyncSample(cbit.vcell.export.gloworm.atoms.SyncSample) BaseMediaHeader(cbit.vcell.export.gloworm.atoms.BaseMediaHeader) DataReferenceEntry(cbit.vcell.export.gloworm.atoms.DataReferenceEntry) DataReference(cbit.vcell.export.gloworm.atoms.DataReference)

Example 2 with HandlerReference

use of cbit.vcell.export.gloworm.atoms.HandlerReference in project vcell by virtualcell.

the class MediaMethods method makeTrackAtom.

/**
 * This method was created in VisualAge.
 * @return TrackAtom
 * @param movie Movie
 * @param track Track
 */
private static final TrackAtom makeTrackAtom(MediaMovie movie, int trackIndex) throws DataFormatException {
    if ((0 <= trackIndex) && (trackIndex < movie.getTracks().length)) {
        MediaTrack track = movie.getTracks()[trackIndex];
        MediaInformation minf = MediaMethods.makeMediaInformation(track);
        int componentSubtype = 0;
        if (track.getMediaType().equals(AtomConstants.MEDIA_TYPE_VIDEO))
            componentSubtype = AtomConstants.COMPONENT_SUBTYPE_VIDEO;
        if (track.getMediaType().equals(AtomConstants.MEDIA_TYPE_OBJECT))
            componentSubtype = AtomConstants.COMPONENT_SUBTYPE_OBJECT;
        if (track.getMediaType().equals(AtomConstants.MEDIA_TYPE_QTVR))
            componentSubtype = AtomConstants.COMPONENT_SUBTYPE_QTVR;
        HandlerReference mhlr = new HandlerReference("mhlr", componentSubtype);
        MediaHeader mdhd = new MediaHeader(movie.getTimeScale(), track.getDuration());
        MediaAtom mdia = new MediaAtom(mdhd, mhlr, minf);
        TrackHeader tkhd = new TrackHeader(trackIndex + 1, track.getDuration(), track.getWidth(), track.getHeight());
        Edit[] edits;
        if (track.getEdits() == null)
            edits = new Edit[] { new Edit(track.getDuration()) };
        else
            edits = track.getEdits();
        EditList elst = new EditList(edits);
        EditAtom edts = new EditAtom(elst);
        TrackAtom trak = null;
        if (movie instanceof VRMediaMovie) {
            TrackReference trakRef = ((VRMediaMovie) movie).getTrackReference(trackIndex);
            trak = new TrackAtom(tkhd, null, null, edts, trakRef, null, null, mdia, null);
        } else {
            trak = new TrackAtom(tkhd, edts, mdia);
        }
        return trak;
    } else
        throw new DataFormatException("Track index out of bounds !");
}
Also used : MediaHeader(cbit.vcell.export.gloworm.atoms.MediaHeader) BaseMediaHeader(cbit.vcell.export.gloworm.atoms.BaseMediaHeader) MediaInformation(cbit.vcell.export.gloworm.atoms.MediaInformation) BaseMediaInformation(cbit.vcell.export.gloworm.atoms.BaseMediaInformation) VideoMediaInformation(cbit.vcell.export.gloworm.atoms.VideoMediaInformation) MediaAtom(cbit.vcell.export.gloworm.atoms.MediaAtom) TrackHeader(cbit.vcell.export.gloworm.atoms.TrackHeader) HandlerReference(cbit.vcell.export.gloworm.atoms.HandlerReference) DataFormatException(java.util.zip.DataFormatException) EditAtom(cbit.vcell.export.gloworm.atoms.EditAtom) TrackAtom(cbit.vcell.export.gloworm.atoms.TrackAtom) EditList(cbit.vcell.export.gloworm.atoms.EditList) TrackReference(cbit.vcell.export.gloworm.atoms.TrackReference)

Aggregations

BaseMediaHeader (cbit.vcell.export.gloworm.atoms.BaseMediaHeader)2 BaseMediaInformation (cbit.vcell.export.gloworm.atoms.BaseMediaInformation)2 HandlerReference (cbit.vcell.export.gloworm.atoms.HandlerReference)2 VideoMediaInformation (cbit.vcell.export.gloworm.atoms.VideoMediaInformation)2 DataFormatException (java.util.zip.DataFormatException)2 BaseMediaInfo (cbit.vcell.export.gloworm.atoms.BaseMediaInfo)1 ChunkOffset (cbit.vcell.export.gloworm.atoms.ChunkOffset)1 DataInformation (cbit.vcell.export.gloworm.atoms.DataInformation)1 DataReference (cbit.vcell.export.gloworm.atoms.DataReference)1 DataReferenceEntry (cbit.vcell.export.gloworm.atoms.DataReferenceEntry)1 EditAtom (cbit.vcell.export.gloworm.atoms.EditAtom)1 EditList (cbit.vcell.export.gloworm.atoms.EditList)1 MediaAtom (cbit.vcell.export.gloworm.atoms.MediaAtom)1 MediaHeader (cbit.vcell.export.gloworm.atoms.MediaHeader)1 MediaInformation (cbit.vcell.export.gloworm.atoms.MediaInformation)1 SampleSize (cbit.vcell.export.gloworm.atoms.SampleSize)1 SampleTable (cbit.vcell.export.gloworm.atoms.SampleTable)1 SampleTableDescription (cbit.vcell.export.gloworm.atoms.SampleTableDescription)1 SampleToChunk (cbit.vcell.export.gloworm.atoms.SampleToChunk)1 SyncSample (cbit.vcell.export.gloworm.atoms.SyncSample)1