/** * Injects metadata (other than Cue points) into a tag * * @param meta Metadata * @param tag Tag * @return New tag with injected metadata */ private ITag injectMetaData(IMetaData<?, ?> meta, ITag tag) { IoBuffer bb = IoBuffer.allocate(1000); bb.setAutoExpand(true); Output out = new Output(bb); Serializer.serialize(out, "onMetaData"); Serializer.serialize(out, meta); IoBuffer tmpBody = out.buf().flip(); int tmpBodySize = out.buf().limit(); int tmpPreviousTagSize = tag.getPreviousTagSize(); return new Tag(IoConstants.TYPE_METADATA, 0, tmpBodySize, tmpBody, tmpPreviousTagSize); }
/** * Injects metadata (Cue Points) into a tag * * @param meta Metadata (cue points) * @param tag Tag * @return ITag tag New tag with injected metadata */ private ITag injectMetaCue(IMetaCue meta, ITag tag) { // IMeta meta = (MetaCue) cue; Output out = new Output(IoBuffer.allocate(1000)); Serializer.serialize(out, "onCuePoint"); Serializer.serialize(out, meta); IoBuffer tmpBody = out.buf().flip(); int tmpBodySize = out.buf().limit(); int tmpPreviousTagSize = tag.getPreviousTagSize(); int tmpTimestamp = getTimeInMilliseconds(meta); return new Tag( IoConstants.TYPE_METADATA, tmpTimestamp, tmpBodySize, tmpBody, tmpPreviousTagSize); }
/** * Create tag for metadata event. * * @return Metadata event tag */ private ITag createFileMeta() { // Create tag for onMetaData event ByteBuffer buf = ByteBuffer.allocate(1024); buf.setAutoExpand(true); Output out = new Output(buf); // Duration property out.writeString("onMetaData"); Map<Object, Object> props = new HashMap<Object, Object>(); props.put("duration", duration / 1000.0); if (firstVideoTag != -1) { long old = getCurrentPosition(); setCurrentPosition(firstVideoTag); readTagHeader(); fillBuffer(1); byte frametype = in.get(); // Video codec id props.put("videocodecid", frametype & MASK_VIDEO_CODEC); setCurrentPosition(old); } if (firstAudioTag != -1) { long old = getCurrentPosition(); setCurrentPosition(firstAudioTag); readTagHeader(); fillBuffer(1); byte frametype = in.get(); // Audio codec id props.put("audiocodecid", (frametype & MASK_SOUND_FORMAT) >> 4); setCurrentPosition(old); } props.put("canSeekToEnd", true); out.writeMap(props, new Serializer()); buf.flip(); ITag result = new Tag(IoConstants.TYPE_METADATA, 0, buf.limit(), null, 0); result.setBody(buf); return result; }