Java Code Examples for org.red5.io.amf.Output#writeMap()
The following examples show how to use
org.red5.io.amf.Output#writeMap() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AxisTest.java From red5-rtsp-restreamer with Apache License 2.0 | 6 votes |
public Notify getMetaDataEvent() { IoBuffer buf = IoBuffer.allocate(1024); buf.setAutoExpand(true); Output out = new Output(buf); out.writeString("onMetaData"); Map<Object, Object> props = new HashMap<Object, Object>(); props.put("width", 160); props.put("height", 120); props.put("framerate", 15); props.put("videocodecid", 7); props.put("canSeekToEnd", false); out.writeMap(props); buf.flip(); return new Notify(buf); }
Example 2
Source File: ClientBroadcastStream.java From red5-server-common with Apache License 2.0 | 5 votes |
/** * Notifies handler on stream broadcast start */ private void notifyBroadcastStart() { IStreamAwareScopeHandler handler = getStreamAwareHandler(); if (handler != null) { try { handler.streamBroadcastStart(this); } catch (Throwable t) { log.error("Error in notifyBroadcastStart", t); } } // send metadata for creation and start dates IoBuffer buf = IoBuffer.allocate(256); buf.setAutoExpand(true); Output out = new Output(buf); out.writeString("onMetaData"); Map<Object, Object> params = new HashMap<>(); Calendar cal = GregorianCalendar.getInstance(); cal.setTimeInMillis(creationTime); params.put("creationdate", ZonedDateTime.ofInstant(cal.toInstant(), ZoneId.of("UTC")).format(DateTimeFormatter.ISO_INSTANT)); cal.setTimeInMillis(startTime); params.put("startdate", ZonedDateTime.ofInstant(cal.toInstant(), ZoneId.of("UTC")).format(DateTimeFormatter.ISO_INSTANT)); if (log.isDebugEnabled()) { log.debug("Params: {}", params); } out.writeMap(params); buf.flip(); Notify notify = new Notify(buf); notify.setAction("onMetaData"); notify.setHeader(new Header()); notify.getHeader().setDataType(Notify.TYPE_STREAM_METADATA); notify.getHeader().setStreamId(0); notify.setTimestamp(0); dispatchEvent(notify); }
Example 3
Source File: M4AReader.java From red5-io with Apache License 2.0 | 5 votes |
/** * Create tag for metadata event. * * @return Metadata event tag */ ITag createFileMeta() { log.debug("Creating onMetaData"); // Create tag for onMetaData event IoBuffer buf = IoBuffer.allocate(1024); buf.setAutoExpand(true); Output out = new Output(buf); out.writeString("onMetaData"); Map<Object, Object> props = new HashMap<Object, Object>(); // Duration property props.put("duration", ((double) duration / (double) timeScale)); // Audio codec id - watch for mp3 instead of aac props.put("audiocodecid", audioCodecId); props.put("aacaot", audioCodecType); props.put("audiosamplerate", audioTimeScale); props.put("audiochannels", audioChannels); props.put("canSeekToEnd", false); out.writeMap(props); buf.flip(); //now that all the meta properties are done, update the duration duration = Math.round(duration * 1000d); ITag result = new Tag(IoConstants.TYPE_METADATA, 0, buf.limit(), null, 0); result.setBody(buf); return result; }
Example 4
Source File: MP3Reader.java From red5-io with Apache License 2.0 | 4 votes |
/** * Creates file metadata object * * @return Tag */ private ITag createFileMeta() { log.debug("createFileMeta"); // create tag for onMetaData event IoBuffer in = IoBuffer.allocate(1024); in.setAutoExpand(true); Output out = new Output(in); out.writeString("onMetaData"); Map<Object, Object> props = new HashMap<Object, Object>(); props.put("audiocodecid", IoConstants.FLAG_FORMAT_MP3); props.put("canSeekToEnd", true); // set id3 meta data if it exists if (metaData != null) { if (metaData.artist != null) { props.put("artist", metaData.artist); } if (metaData.album != null) { props.put("album", metaData.album); } if (metaData.songName != null) { props.put("songName", metaData.songName); } if (metaData.genre != null) { props.put("genre", metaData.genre); } if (metaData.year != null) { props.put("year", metaData.year); } if (metaData.track != null) { props.put("track", metaData.track); } if (metaData.comment != null) { props.put("comment", metaData.comment); } if (metaData.duration != null) { props.put("duration", metaData.duration); } if (metaData.channels != null) { props.put("channels", metaData.channels); } if (metaData.sampleRate != null) { props.put("samplerate", metaData.sampleRate); } if (metaData.hasCoverImage()) { Map<Object, Object> covr = new HashMap<>(1); covr.put("covr", new Object[] { metaData.getCovr() }); props.put("tags", covr); } //clear meta for gc metaData = null; } log.debug("Metadata properties map: {}", props); // check for duration if (!props.containsKey("duration")) { // generate it from framemeta if (frameMeta != null) { props.put("duration", frameMeta.timestamps[frameMeta.timestamps.length - 1] / 1000.0); } else { log.debug("Frame meta was null"); } } // set datarate if (dataRate > 0) { props.put("audiodatarate", dataRate); } out.writeMap(props); in.flip(); // meta-data ITag result = new Tag(IoConstants.TYPE_METADATA, 0, in.limit(), null, prevSize); result.setBody(in); return result; }