List of usage examples for org.apache.commons.lang.builder ToStringBuilder reflectionToString
public static String reflectionToString(Object object)
Forwards to ReflectionToStringBuilder
.
From source file:org.pentaho.platform.monitoring.subscribers.MonitoringDeadEventSubscriber.java
@Subscribe public void handleDeadEvent(DeadEvent e) { logger.error(e != null ? ToStringBuilder.reflectionToString(e.getEvent()) : "null object"); }
From source file:org.projectforge.business.humanresources.HRPlanningDao.java
public QueryFilter buildQueryFilter(final HRPlanningFilter filter) { final QueryFilter queryFilter = new QueryFilter(filter); if (filter.getUserId() != null) { final PFUserDO user = new PFUserDO(); user.setId(filter.getUserId());//from ww w . j ava2s . co m queryFilter.add(Restrictions.eq("user", user)); } if (filter.getStartTime() != null && filter.getStopTime() != null) { queryFilter.add(Restrictions.between("week", filter.getStartTime(), filter.getStopTime())); } else if (filter.getStartTime() != null) { queryFilter.add(Restrictions.ge("week", filter.getStartTime())); } else if (filter.getStopTime() != null) { queryFilter.add(Restrictions.le("week", filter.getStopTime())); } if (filter.getProjektId() != null) { queryFilter.add(Restrictions.eq("projekt.id", filter.getProjektId())); } queryFilter.addOrder(Order.desc("week")); if (log.isDebugEnabled() == true) { log.debug(ToStringBuilder.reflectionToString(filter)); } return queryFilter; }
From source file:org.projectforge.business.humanresources.HRPlanningEntryDao.java
public QueryFilter buildQueryFilter(final HRPlanningFilter filter) { final QueryFilter queryFilter = new QueryFilter(filter); queryFilter.createAlias("planning", "p").createAlias("p.user", "u"); if (filter.getUserId() != null) { final PFUserDO user = new PFUserDO(); user.setId(filter.getUserId());//www . j a va 2 s. c o m queryFilter.add(Restrictions.eq("p.user", user)); } if (filter.getStartTime() != null && filter.getStopTime() != null) { queryFilter.add(Restrictions.between("p.week", filter.getStartTime(), filter.getStopTime())); } else if (filter.getStartTime() != null) { queryFilter.add(Restrictions.ge("p.week", filter.getStartTime())); } else if (filter.getStopTime() != null) { queryFilter.add(Restrictions.le("p.week", filter.getStopTime())); } if (filter.getProjektId() != null) { queryFilter.add(Restrictions.eq("projekt.id", filter.getProjektId())); } queryFilter.addOrder(Order.desc("p.week")).addOrder(Order.asc("u.firstname")); if (log.isDebugEnabled() == true) { log.debug(ToStringBuilder.reflectionToString(filter)); } return queryFilter; }
From source file:org.projectforge.business.teamcal.event.TeamEventDao.java
/** * The time period of the filter will be extended by one day. This is needed due to all day events which are stored in * UTC. The additional events in the result list not matching the time period have to be removed by caller! * * @param filter//from w ww.jav a 2 s . com * @return */ private QueryFilter buildQueryFilter(final TeamEventFilter filter) { final QueryFilter queryFilter = new QueryFilter(filter); final Collection<Integer> cals = filter.getTeamCals(); if (CollectionUtils.isNotEmpty(cals) == true) { queryFilter.add(Restrictions.in("calendar.id", cals)); } else if (filter.getTeamCalId() != null) { queryFilter.add(Restrictions.eq("calendar.id", filter.getTeamCalId())); } // Following period extension is needed due to all day events which are stored in UTC. The additional events in the result list not // matching the time period have to be removed by caller! Date startDate = filter.getStartDate(); if (startDate != null) { startDate = new Date(startDate.getTime() - ONE_DAY); } Date endDate = filter.getEndDate(); if (endDate != null) { endDate = new Date(endDate.getTime() + ONE_DAY); } // limit events to load to chosen date view. if (startDate != null && endDate != null) { if (filter.isOnlyRecurrence() == false) { queryFilter.add(Restrictions.or( (Restrictions.or(Restrictions.between("startDate", startDate, endDate), Restrictions.between("endDate", startDate, endDate))), // get events whose duration overlap with chosen duration. (Restrictions.and(Restrictions.le("startDate", startDate), Restrictions.ge("endDate", endDate))))); } else { queryFilter.add( // "startDate" < endDate && ("recurrenceUntil" == null ||"recurrenceUntil" > startDate) (Restrictions.and(Restrictions.lt("startDate", endDate), Restrictions.or(Restrictions.isNull("recurrenceUntil"), Restrictions.gt("recurrenceUntil", startDate))))); } } else if (startDate != null) { if (filter.isOnlyRecurrence() == false) { queryFilter.add(Restrictions.ge("startDate", startDate)); } else { // This branch is reached for subscriptions and calendar downloads. queryFilter.add( // "recurrenceUntil" == null ||"recurrenceUntil" > startDate Restrictions.or(Restrictions.isNull("recurrenceUntil"), Restrictions.gt("recurrenceUntil", startDate))); } } else if (endDate != null) { queryFilter.add(Restrictions.le("startDate", endDate)); } queryFilter.addOrder(Order.desc("startDate")); if (log.isDebugEnabled() == true) { log.debug(ToStringBuilder.reflectionToString(filter)); } return queryFilter; }
From source file:org.projectforge.business.timesheet.TimesheetDao.java
public QueryFilter buildQueryFilter(final TimesheetFilter filter) { final QueryFilter queryFilter = new QueryFilter(filter); if (filter.getUserId() != null) { final PFUserDO user = new PFUserDO(); user.setId(filter.getUserId());/*from w w w .j a v a2s .c o m*/ queryFilter.add(Restrictions.eq("user", user)); } if (filter.getStartTime() != null && filter.getStopTime() != null) { queryFilter.add(Restrictions.and(Restrictions.ge("stopTime", filter.getStartTime()), Restrictions.le("startTime", filter.getStopTime()))); } else if (filter.getStartTime() != null) { queryFilter.add(Restrictions.ge("startTime", filter.getStartTime())); } else if (filter.getStopTime() != null) { queryFilter.add(Restrictions.le("startTime", filter.getStopTime())); } if (filter.getTaskId() != null) { if (filter.isRecursive() == true) { final TaskNode node = TaskTreeHelper.getTaskTree().getTaskNodeById(filter.getTaskId()); final List<Integer> taskIds = node.getDescendantIds(); taskIds.add(node.getId()); queryFilter.add(Restrictions.in("task.id", taskIds)); if (log.isDebugEnabled() == true) { log.debug("search in tasks: " + taskIds); } } else { queryFilter.add(Restrictions.eq("task.id", filter.getTaskId())); } } if (filter.getOrderType() == OrderDirection.DESC) { queryFilter.addOrder(Order.desc("startTime")); } else { queryFilter.addOrder(Order.asc("startTime")); } if (log.isDebugEnabled() == true) { log.debug(ToStringBuilder.reflectionToString(filter)); } return queryFilter; }
From source file:org.projectforge.plugins.teamcal.event.TeamEventDao.java
/** * The time period of the filter will be extended by one day. This is needed due to all day events which are stored in UTC. The additional * events in the result list not matching the time period have to be removed by caller! * @param filter/*from ww w . ja v a 2s. c o m*/ * @param allDay * @return */ private QueryFilter buildQueryFilter(final TeamEventFilter filter) { final QueryFilter queryFilter = new QueryFilter(filter); final Collection<Integer> cals = filter.getTeamCals(); if (CollectionUtils.isNotEmpty(cals) == true) { queryFilter.add(Restrictions.in("calendar.id", cals)); } else if (filter.getTeamCalId() != null) { queryFilter.add(Restrictions.eq("calendar.id", filter.getTeamCalId())); } // Following period extension is needed due to all day events which are stored in UTC. The additional events in the result list not // matching the time period have to be removed by caller! Date startDate = filter.getStartDate(); if (startDate != null) { startDate = new Date(startDate.getTime() - ONE_DAY); } Date endDate = filter.getEndDate(); if (endDate != null) { endDate = new Date(endDate.getTime() + ONE_DAY); } // limit events to load to chosen date view. if (startDate != null && endDate != null) { if (filter.isOnlyRecurrence() == false) { queryFilter.add(Restrictions.or( (Restrictions.or(Restrictions.between("startDate", startDate, endDate), Restrictions.between("endDate", startDate, endDate))), // get events whose duration overlap with chosen duration. (Restrictions.and(Restrictions.le("startDate", startDate), Restrictions.ge("endDate", endDate))))); } else { queryFilter.add( // "startDate" < endDate && ("recurrenceUntil" == null ||"recurrenceUnti" > startDate) (Restrictions.and(Restrictions.lt("startDate", endDate), Restrictions.or(Restrictions.isNull("recurrenceUntil"), Restrictions.gt("recurrenceUntil", startDate))))); } } else if (startDate != null) { queryFilter.add(Restrictions.ge("startDate", startDate)); } else if (endDate != null) { queryFilter.add(Restrictions.le("startDate", endDate)); } queryFilter.addOrder(Order.desc("startDate")); if (log.isDebugEnabled() == true) { log.debug(ToStringBuilder.reflectionToString(filter)); } return queryFilter; }
From source file:org.projectforge.timesheet.TimesheetDao.java
public QueryFilter buildQueryFilter(final TimesheetFilter filter) { final QueryFilter queryFilter = new QueryFilter(filter); if (filter.getUserId() != null) { final PFUserDO user = new PFUserDO(); user.setId(filter.getUserId());/* w ww .ja va 2 s . co m*/ queryFilter.add(Restrictions.eq("user", user)); } if (filter.getStartTime() != null && filter.getStopTime() != null) { queryFilter.add(Restrictions.between("startTime", filter.getStartTime(), filter.getStopTime())); } else if (filter.getStartTime() != null) { queryFilter.add(Restrictions.ge("startTime", filter.getStartTime())); } else if (filter.getStopTime() != null) { queryFilter.add(Restrictions.le("startTime", filter.getStopTime())); } if (filter.getTaskId() != null) { if (filter.isRecursive() == true) { final TaskNode node = taskTree.getTaskNodeById(filter.getTaskId()); final List<Integer> taskIds = node.getDescendantIds(); taskIds.add(node.getId()); queryFilter.add(Restrictions.in("task.id", taskIds)); if (log.isDebugEnabled() == true) { log.debug("search in tasks: " + taskIds); } } else { queryFilter.add(Restrictions.eq("task.id", filter.getTaskId())); } } if (filter.getOrderType() == OrderDirection.DESC) { queryFilter.addOrder(Order.desc("startTime")); } else { queryFilter.addOrder(Order.asc("startTime")); } if (log.isDebugEnabled() == true) { log.debug(ToStringBuilder.reflectionToString(filter)); } return queryFilter; }
From source file:org.red5.io.mp4.MP4Reader.java
/** * Creates MP4 reader from file input stream, sets up metadata generation flag. * * @param f File input stream *///from w w w. j av a 2 s . c o m public MP4Reader(File f) throws IOException { if (null == f) { log.warn("Reader was passed a null file"); log.debug("{}", ToStringBuilder.reflectionToString(this)); } this.file = f; this.fis = new MP4DataStream(new FileInputStream(f)); channel = fis.getChannel(); //decode all the info that we want from the atoms decodeHeader(); //analyze the samples/chunks and build the keyframe meta data analyzeFrames(); //add meta data firstTags.add(createFileMeta()); //create / add the pre-streaming (decoder config) tags createPreStreamingTags(0, false); }
From source file:org.red5.io.mp4.MP4Reader.java
/** * This handles the moov atom being at the beginning or end of the file, so the mdat may also * be before or after the moov atom./* ww w . j ava2 s. c om*/ */ public void decodeHeader() { try { // the first atom will/should be the type MP4Atom type = MP4Atom.createAtom(fis); // expect ftyp log.debug("Type {}", MP4Atom.intToType(type.getType())); //log.debug("Atom int types - free={} wide={}", MP4Atom.typeToInt("free"), MP4Atom.typeToInt("wide")); // keep a running count of the number of atoms found at the "top" levels int topAtoms = 0; // we want a moov and an mdat, anything else throw the invalid file type error while (topAtoms < 2) { MP4Atom atom = MP4Atom.createAtom(fis); switch (atom.getType()) { case 1836019574: //moov topAtoms++; MP4Atom moov = atom; // expect moov log.debug("Type {}", MP4Atom.intToType(moov.getType())); log.debug("moov children: {}", moov.getChildren()); moovOffset = fis.getOffset() - moov.getSize(); MP4Atom mvhd = moov.lookup(MP4Atom.typeToInt("mvhd"), 0); if (mvhd != null) { log.debug("Movie header atom found"); //get the initial timescale timeScale = mvhd.getTimeScale(); duration = mvhd.getDuration(); log.debug("Time scale {} Duration {}", timeScale, duration); } /* nothing needed here yet MP4Atom meta = moov.lookup(MP4Atom.typeToInt("meta"), 0); if (meta != null) { log.debug("Meta atom found"); log.debug("{}", ToStringBuilder.reflectionToString(meta)); } */ //we would like to have two tracks, but it shouldn't be a requirement int loops = 0; int tracks = 0; do { MP4Atom trak = moov.lookup(MP4Atom.typeToInt("trak"), loops); if (trak != null) { log.debug("Track atom found"); log.debug("trak children: {}", trak.getChildren()); // trak: tkhd, edts, mdia MP4Atom tkhd = trak.lookup(MP4Atom.typeToInt("tkhd"), 0); if (tkhd != null) { log.debug("Track header atom found"); log.debug("tkhd children: {}", tkhd.getChildren()); if (tkhd.getWidth() > 0) { width = tkhd.getWidth(); height = tkhd.getHeight(); log.debug("Width {} x Height {}", width, height); } } MP4Atom edts = trak.lookup(MP4Atom.typeToInt("edts"), 0); if (edts != null) { log.debug("Edit atom found"); log.debug("edts children: {}", edts.getChildren()); //log.debug("Width {} x Height {}", edts.getWidth(), edts.getHeight()); } MP4Atom mdia = trak.lookup(MP4Atom.typeToInt("mdia"), 0); if (mdia != null) { log.debug("Media atom found"); // mdia: mdhd, hdlr, minf int scale = 0; //get the media header atom MP4Atom mdhd = mdia.lookup(MP4Atom.typeToInt("mdhd"), 0); if (mdhd != null) { log.debug("Media data header atom found"); //this will be for either video or audio depending media info scale = mdhd.getTimeScale(); log.debug("Time scale {}", scale); } MP4Atom hdlr = mdia.lookup(MP4Atom.typeToInt("hdlr"), 0); if (hdlr != null) { log.debug("Handler ref atom found"); // soun or vide log.debug("Handler type: {}", MP4Atom.intToType(hdlr.getHandlerType())); String hdlrType = MP4Atom.intToType(hdlr.getHandlerType()); if ("vide".equals(hdlrType)) { hasVideo = true; if (scale > 0) { videoTimeScale = scale * 1.0; log.debug("Video time scale: {}", videoTimeScale); } } else if ("soun".equals(hdlrType)) { hasAudio = true; if (scale > 0) { audioTimeScale = scale * 1.0; log.debug("Audio time scale: {}", audioTimeScale); } } tracks++; } MP4Atom minf = mdia.lookup(MP4Atom.typeToInt("minf"), 0); if (minf != null) { log.debug("Media info atom found"); // minf: (audio) smhd, dinf, stbl / (video) vmhd, // dinf, stbl MP4Atom smhd = minf.lookup(MP4Atom.typeToInt("smhd"), 0); if (smhd != null) { log.debug("Sound header atom found"); MP4Atom dinf = minf.lookup(MP4Atom.typeToInt("dinf"), 0); if (dinf != null) { log.debug("Data info atom found"); // dinf: dref log.debug("Sound dinf children: {}", dinf.getChildren()); MP4Atom dref = dinf.lookup(MP4Atom.typeToInt("dref"), 0); if (dref != null) { log.debug("Data reference atom found"); } } MP4Atom stbl = minf.lookup(MP4Atom.typeToInt("stbl"), 0); if (stbl != null) { log.debug("Sample table atom found"); // stbl: stsd, stts, stss, stsc, stsz, stco, // stsh log.debug("Sound stbl children: {}", stbl.getChildren()); // stsd - sample description // stts - time to sample // stsc - sample to chunk // stsz - sample size // stco - chunk offset //stsd - has codec child MP4Atom stsd = stbl.lookup(MP4Atom.typeToInt("stsd"), 0); if (stsd != null) { //stsd: mp4a log.debug("Sample description atom found"); MP4Atom mp4a = stsd.getChildren().get(0); //could set the audio codec here setAudioCodecId(MP4Atom.intToType(mp4a.getType())); //log.debug("{}", ToStringBuilder.reflectionToString(mp4a)); log.debug("Sample size: {}", mp4a.getSampleSize()); int ats = mp4a.getTimeScale(); //skip invalid audio time scale if (ats > 0) { audioTimeScale = ats * 1.0; } audioChannels = mp4a.getChannelCount(); log.debug("Sample rate (audio time scale): {}", audioTimeScale); log.debug("Channels: {}", audioChannels); //mp4a: esds if (mp4a.getChildren().size() > 0) { log.debug("Elementary stream descriptor atom found"); MP4Atom esds = mp4a.getChildren().get(0); log.debug("{}", ToStringBuilder.reflectionToString(esds)); MP4Descriptor descriptor = esds.getEsd_descriptor(); log.debug("{}", ToStringBuilder.reflectionToString(descriptor)); if (descriptor != null) { Vector<MP4Descriptor> children = descriptor.getChildren(); for (int e = 0; e < children.size(); e++) { MP4Descriptor descr = children.get(e); log.debug("{}", ToStringBuilder.reflectionToString(descr)); if (descr.getChildren().size() > 0) { Vector<MP4Descriptor> children2 = descr .getChildren(); for (int e2 = 0; e2 < children2.size(); e2++) { MP4Descriptor descr2 = children2.get(e2); log.debug("{}", ToStringBuilder .reflectionToString(descr2)); if (descr2 .getType() == MP4Descriptor.MP4DecSpecificInfoDescriptorTag) { //we only want the MP4DecSpecificInfoDescriptorTag audioDecoderBytes = descr2.getDSID(); //compare the bytes to get the aacaot/aottype //match first byte switch (audioDecoderBytes[0]) { case 0x12: default: //AAC LC - 12 10 audioCodecType = 1; break; case 0x0a: //AAC Main - 0A 10 audioCodecType = 0; break; case 0x11: case 0x13: //AAC LC SBR - 11 90 & 13 xx audioCodecType = 2; break; } //we want to break out of top level for loop e = 99; break; } } } } } } } //stsc - has Records MP4Atom stsc = stbl.lookup(MP4Atom.typeToInt("stsc"), 0); if (stsc != null) { log.debug("Sample to chunk atom found"); audioSamplesToChunks = stsc.getRecords(); log.debug("Record count: {}", audioSamplesToChunks.size()); MP4Atom.Record rec = audioSamplesToChunks.firstElement(); log.debug("Record data: Description index={} Samples per chunk={}", rec.getSampleDescriptionIndex(), rec.getSamplesPerChunk()); } //stsz - has Samples MP4Atom stsz = stbl.lookup(MP4Atom.typeToInt("stsz"), 0); if (stsz != null) { log.debug("Sample size atom found"); audioSamples = stsz.getSamples(); //vector full of integers log.debug("Sample size: {}", stsz.getSampleSize()); log.debug("Sample count: {}", audioSamples.size()); } //stco - has Chunks MP4Atom stco = stbl.lookup(MP4Atom.typeToInt("stco"), 0); if (stco != null) { log.debug("Chunk offset atom found"); //vector full of integers audioChunkOffsets = stco.getChunks(); log.debug("Chunk count: {}", audioChunkOffsets.size()); } //stts - has TimeSampleRecords MP4Atom stts = stbl.lookup(MP4Atom.typeToInt("stts"), 0); if (stts != null) { log.debug("Time to sample atom found"); Vector<MP4Atom.TimeSampleRecord> records = stts .getTimeToSamplesRecords(); log.debug("Record count: {}", records.size()); MP4Atom.TimeSampleRecord rec = records.firstElement(); log.debug("Record data: Consecutive samples={} Duration={}", rec.getConsecutiveSamples(), rec.getSampleDuration()); //if we have 1 record then all samples have the same duration if (records.size() > 1) { //TODO: handle audio samples with varying durations log.info( "Audio samples have differing durations, audio playback may fail"); } audioSampleDuration = rec.getSampleDuration(); } } } MP4Atom vmhd = minf.lookup(MP4Atom.typeToInt("vmhd"), 0); if (vmhd != null) { log.debug("Video header atom found"); MP4Atom dinf = minf.lookup(MP4Atom.typeToInt("dinf"), 0); if (dinf != null) { log.debug("Data info atom found"); // dinf: dref log.debug("Video dinf children: {}", dinf.getChildren()); MP4Atom dref = dinf.lookup(MP4Atom.typeToInt("dref"), 0); if (dref != null) { log.debug("Data reference atom found"); } } MP4Atom stbl = minf.lookup(MP4Atom.typeToInt("stbl"), 0); if (stbl != null) { log.debug("Sample table atom found"); // stbl: stsd, stts, stss, stsc, stsz, stco, // stsh log.debug("Video stbl children: {}", stbl.getChildren()); // stsd - sample description // stts - (decoding) time to sample // stsc - sample to chunk // stsz - sample size // stco - chunk offset // ctts - (composition) time to sample // stss - sync sample // sdtp - independent and disposable samples //stsd - has codec child MP4Atom stsd = stbl.lookup(MP4Atom.typeToInt("stsd"), 0); if (stsd != null) { log.debug("Sample description atom found"); log.debug("Sample description (video) stsd children: {}", stsd.getChildren()); MP4Atom avc1 = stsd.lookup(MP4Atom.typeToInt("avc1"), 0); if (avc1 != null) { log.debug("AVC1 children: {}", avc1.getChildren()); //set the video codec here - may be avc1 or mp4v setVideoCodecId(MP4Atom.intToType(avc1.getType())); //video decoder config //TODO may need to be generic later MP4Atom codecChild = avc1.lookup(MP4Atom.typeToInt("avcC"), 0); if (codecChild != null) { avcLevel = codecChild.getAvcLevel(); log.debug("AVC level: {}", avcLevel); avcProfile = codecChild.getAvcProfile(); log.debug("AVC Profile: {}", avcProfile); log.debug("AVCC size: {}", codecChild.getSize()); videoDecoderBytes = codecChild.getVideoConfigBytes(); log.debug("Video config bytes: {}", ToStringBuilder .reflectionToString(videoDecoderBytes)); } else { //quicktime and ipods use a pixel aspect atom //since we have no avcC check for this and avcC may //be a child MP4Atom pasp = avc1.lookup(MP4Atom.typeToInt("pasp"), 0); if (pasp != null) { log.debug("PASP children: {}", pasp.getChildren()); codecChild = pasp.lookup(MP4Atom.typeToInt("avcC"), 0); if (codecChild != null) { avcLevel = codecChild.getAvcLevel(); log.debug("AVC level: {}", avcLevel); avcProfile = codecChild.getAvcProfile(); log.debug("AVC Profile: {}", avcProfile); log.debug("AVCC size: {}", codecChild.getSize()); videoDecoderBytes = codecChild .getVideoConfigBytes(); log.debug("Video config bytes: {}", ToStringBuilder .reflectionToString(videoDecoderBytes)); } } } } else { //look for mp4v MP4Atom mp4v = stsd.lookup(MP4Atom.typeToInt("mp4v"), 0); if (mp4v != null) { log.debug("MP4V children: {}", mp4v.getChildren()); //set the video codec here - may be avc1 or mp4v setVideoCodecId(MP4Atom.intToType(mp4v.getType())); //look for esds MP4Atom codecChild = mp4v.lookup(MP4Atom.typeToInt("esds"), 0); if (codecChild != null) { //look for descriptors MP4Descriptor descriptor = codecChild .getEsd_descriptor(); log.debug("{}", ToStringBuilder.reflectionToString(descriptor)); if (descriptor != null) { Vector<MP4Descriptor> children = descriptor .getChildren(); for (int e = 0; e < children.size(); e++) { MP4Descriptor descr = children.get(e); log.debug("{}", ToStringBuilder .reflectionToString(descr)); if (descr.getChildren().size() > 0) { Vector<MP4Descriptor> children2 = descr .getChildren(); for (int e2 = 0; e2 < children2 .size(); e2++) { MP4Descriptor descr2 = children2 .get(e2); log.debug("{}", ToStringBuilder .reflectionToString(descr2)); if (descr2 .getType() == MP4Descriptor.MP4DecSpecificInfoDescriptorTag) { //we only want the MP4DecSpecificInfoDescriptorTag videoDecoderBytes = new byte[descr2 .getDSID().length - 8]; System.arraycopy(descr2.getDSID(), 8, videoDecoderBytes, 0, videoDecoderBytes.length); log.debug("Video config bytes: {}", ToStringBuilder .reflectionToString( videoDecoderBytes)); //we want to break out of top level for loop e = 99; break; } } } } } } } } log.debug("{}", ToStringBuilder.reflectionToString(avc1)); } //stsc - has Records MP4Atom stsc = stbl.lookup(MP4Atom.typeToInt("stsc"), 0); if (stsc != null) { log.debug("Sample to chunk atom found"); videoSamplesToChunks = stsc.getRecords(); log.debug("Record count: {}", videoSamplesToChunks.size()); MP4Atom.Record rec = videoSamplesToChunks.firstElement(); log.debug("Record data: Description index={} Samples per chunk={}", rec.getSampleDescriptionIndex(), rec.getSamplesPerChunk()); } //stsz - has Samples MP4Atom stsz = stbl.lookup(MP4Atom.typeToInt("stsz"), 0); if (stsz != null) { log.debug("Sample size atom found"); //vector full of integers videoSamples = stsz.getSamples(); //if sample size is 0 then the table must be checked due //to variable sample sizes log.debug("Sample size: {}", stsz.getSampleSize()); videoSampleCount = videoSamples.size(); log.debug("Sample count: {}", videoSampleCount); } //stco - has Chunks MP4Atom stco = stbl.lookup(MP4Atom.typeToInt("stco"), 0); if (stco != null) { log.debug("Chunk offset atom found"); //vector full of integers videoChunkOffsets = stco.getChunks(); log.debug("Chunk count: {}", videoChunkOffsets.size()); } //stss - has Sync - no sync means all samples are keyframes MP4Atom stss = stbl.lookup(MP4Atom.typeToInt("stss"), 0); if (stss != null) { log.debug("Sync sample atom found"); //vector full of integers syncSamples = stss.getSyncSamples(); log.debug("Keyframes: {}", syncSamples.size()); } //stts - has TimeSampleRecords MP4Atom stts = stbl.lookup(MP4Atom.typeToInt("stts"), 0); if (stts != null) { log.debug("Time to sample atom found"); Vector<MP4Atom.TimeSampleRecord> records = stts .getTimeToSamplesRecords(); log.debug("Record count: {}", records.size()); MP4Atom.TimeSampleRecord rec = records.firstElement(); log.debug("Record data: Consecutive samples={} Duration={}", rec.getConsecutiveSamples(), rec.getSampleDuration()); //if we have 1 record then all samples have the same duration if (records.size() > 1) { //TODO: handle video samples with varying durations log.info( "Video samples have differing durations, video playback may fail"); } videoSampleDuration = rec.getSampleDuration(); } //ctts - (composition) time to sample MP4Atom ctts = stbl.lookup(MP4Atom.typeToInt("ctts"), 0); if (ctts != null) { log.debug("Composition time to sample atom found"); //vector full of integers compositionTimes = ctts.getCompositionTimeToSamplesRecords(); log.debug("Record count: {}", compositionTimes.size()); if (log.isTraceEnabled()) { for (CompositionTimeSampleRecord rec : compositionTimes) { double offset = rec.getSampleOffset(); if (scale > 0d) { offset = (offset / (double) scale) * 1000.0; rec.setSampleOffset((int) offset); } log.trace("Record data: Consecutive samples={} Offset={}", rec.getConsecutiveSamples(), rec.getSampleOffset()); } } } } } } } } loops++; } while (loops < 3); log.trace("Busted out of track loop with {} tracks after {} loops", tracks, loops); //calculate FPS fps = (videoSampleCount * timeScale) / (double) duration; log.debug("FPS calc: ({} * {}) / {}", new Object[] { videoSampleCount, timeScale, duration }); log.debug("FPS: {}", fps); //real duration StringBuilder sb = new StringBuilder(); double videoTime = ((double) duration / (double) timeScale); log.debug("Video time: {}", videoTime); int minutes = (int) (videoTime / 60); if (minutes > 0) { sb.append(minutes); sb.append('.'); } //formatter for seconds / millis NumberFormat df = DecimalFormat.getInstance(); df.setMaximumFractionDigits(2); sb.append(df.format((videoTime % 60))); formattedDuration = sb.toString(); log.debug("Time: {}", formattedDuration); break; case 1835295092: //mdat topAtoms++; long dataSize = 0L; MP4Atom mdat = atom; dataSize = mdat.getSize(); log.debug("{}", ToStringBuilder.reflectionToString(mdat)); mdatOffset = fis.getOffset() - dataSize; log.debug("File size: {} mdat size: {}", file.length(), dataSize); break; case 1718773093: //free case 2003395685: //wide break; default: log.warn("Unexpected atom: {}", MP4Atom.intToType(atom.getType())); } } //add the tag name (size) to the offsets moovOffset += 8; mdatOffset += 8; log.debug("Offsets moov: {} mdat: {}", moovOffset, mdatOffset); } catch (IOException e) { log.error("Exception decoding header / atoms", e); } }
From source file:org.springframework.http.converter.obm.AvroHttpMessageConverterTest.java
@Test public void testSimpleIntegration() throws Throwable { RestIntegrationTestUtils.startServiceAndConnect(MyService.class, new RestIntegrationTestUtils.ServerExecutionCallback() { @Override//from w ww . j ava 2 s . co m public void doWithServer(RestTemplate restTemplate, Server server) throws Throwable { Assert.assertNotNull(restTemplate); int id = 344; Map<String, Object> mapOfVars = new HashMap<String, Object>(); mapOfVars.put("cid", id); Customer customer = restTemplate .getForEntity("http://localhost:8080/ws/customers/{cid}", Customer.class, mapOfVars) .getBody(); Assert.assertTrue(customer.id == id); Assert.assertTrue(customer.firstName.toString().equals(fn)); Assert.assertTrue(customer.lastName.toString().equals(ln)); Assert.assertTrue(customer.email.toString().equals(email)); if (log.isDebugEnabled()) { log.debug("response payload: " + ToStringBuilder.reflectionToString(customer)); } } }); }