本文整理汇总了Java中org.red5.io.ITag.setBody方法的典型用法代码示例。如果您正苦于以下问题:Java ITag.setBody方法的具体用法?Java ITag.setBody怎么用?Java ITag.setBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.red5.io.ITag
的用法示例。
在下文中一共展示了ITag.setBody方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPreStreamingTags
import org.red5.io.ITag; //导入方法依赖的package包/类
/**
* Tag sequence
* MetaData, Audio config, remaining audio
*
* Packet prefixes:
* af 00 ... 06 = Audio extra data (first audio packet)
* af 01 = Audio frame
*
* Audio extra data(s):
* af 00 = Prefix
* 11 90 4f 14 = AAC Main = aottype 0
* 12 10 = AAC LC = aottype 1
* 13 90 56 e5 a5 48 00 = HE-AAC SBR = aottype 2
* 06 = Suffix
*
* Still not absolutely certain about this order or the bytes - need to verify later
*/
private void createPreStreamingTags() {
log.debug("Creating pre-streaming tags");
if (audioDecoderBytes != null) {
IoBuffer body = IoBuffer.allocate(audioDecoderBytes.length + 3);
body.put(new byte[] { (byte) 0xaf, (byte) 0 }); //prefix
if (log.isDebugEnabled()) {
log.debug("Audio decoder bytes: {}", HexDump.byteArrayToHexString(audioDecoderBytes));
}
body.put(audioDecoderBytes);
body.put((byte) 0x06); //suffix
ITag tag = new Tag(IoConstants.TYPE_AUDIO, 0, body.position(), null, prevFrameSize);
body.flip();
tag.setBody(body);
//add tag
firstTags.add(tag);
} else {
//default to aac-lc when the esds doesnt contain descripter bytes
log.warn("Audio decoder bytes were not available");
}
}
示例2: createPreStreamingTags
import org.red5.io.ITag; //导入方法依赖的package包/类
/**
* Tag sequence MetaData, Audio config, remaining audio
*
* Packet prefixes: af 00 ... 06 = Audio extra data (first audio packet) af 01 = Audio frame
*
* Audio extra data(s): af 00 = Prefix 11 90 4f 14 = AAC Main = aottype 0 12 10 = AAC LC = aottype 1 13 90 56 e5 a5 48 00 = HE-AAC SBR =
* aottype 2 06 = Suffix
*
* Still not absolutely certain about this order or the bytes - need to verify later
*/
private void createPreStreamingTags() {
log.debug("Creating pre-streaming tags");
if (audioDecoderBytes != null) {
IoBuffer body = IoBuffer.allocate(audioDecoderBytes.length + 3);
body.put(new byte[] { (byte) 0xaf, (byte) 0 }); //prefix
if (log.isDebugEnabled()) {
log.debug("Audio decoder bytes: {}", HexDump.byteArrayToHexString(audioDecoderBytes));
}
body.put(audioDecoderBytes);
body.put((byte) 0x06); //suffix
ITag tag = new Tag(IoConstants.TYPE_AUDIO, 0, body.position(), null, prevFrameSize);
body.flip();
tag.setBody(body);
//add tag
firstTags.add(tag);
} else {
//default to aac-lc when the esds doesnt contain descripter bytes
log.warn("Audio decoder bytes were not available");
}
}
示例3: createFileMeta
import org.red5.io.ITag; //导入方法依赖的package包/类
/**
* 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;
}
示例4: createFileMeta
import org.red5.io.ITag; //导入方法依赖的package包/类
/**
* 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("duration", frameMeta.timestamps[frameMeta.timestamps.length - 1] / 1000.0);
props.put("audiocodecid", IoConstants.FLAG_FORMAT_MP3);
if (dataRate > 0) {
props.put("audiodatarate", dataRate);
}
props.put("canSeekToEnd", true);
//set id3 meta data if it exists
if (metaData != null) {
props.put("artist", metaData.getArtist());
props.put("album", metaData.getAlbum());
props.put("songName", metaData.getSongName());
props.put("genre", metaData.getGenre());
props.put("year", metaData.getYear());
props.put("track", metaData.getTrack());
props.put("comment", metaData.getComment());
if (metaData.hasCoverImage()) {
Map<Object, Object> covr = new HashMap<Object, Object>(1);
covr.put("covr", new Object[] { metaData.getCovr() });
props.put("tags", covr);
}
//clear meta for gc
metaData = null;
}
out.writeMap(props);
in.flip();
ITag result = new Tag(IoConstants.TYPE_METADATA, 0, in.limit(), null, prevSize);
result.setBody(in);
return result;
}
示例5: write
import org.red5.io.ITag; //导入方法依赖的package包/类
protected void write(int timeStamp, byte type, IoBuffer data) throws IOException {
log.trace("timeStamp :: {}", timeStamp);
ITag tag = new Tag();
tag.setDataType(type);
tag.setBodySize(data.limit());
tag.setTimestamp(timeStamp);
tag.setBody(data);
writer.writeTag(tag);
}
示例6: createFileMeta
import org.red5.io.ITag; //导入方法依赖的package包/类
/**
* 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;
}
示例7: createFileMeta
import org.red5.io.ITag; //导入方法依赖的package包/类
/**
* 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("moovposition", moovOffset);
//tags will only appear if there is an "ilst" atom in the file
//props.put("tags", "");
props.put("canSeekToEnd", false);
out.writeMap(props, new Serializer());
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;
}
示例8: createFileMeta
import org.red5.io.ITag; //导入方法依赖的package包/类
/**
* 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("duration", frameMeta.timestamps[frameMeta.timestamps.length - 1] / 1000.0);
props.put("audiocodecid", IoConstants.FLAG_FORMAT_MP3);
if (dataRate > 0) {
props.put("audiodatarate", dataRate);
}
props.put("canSeekToEnd", true);
//set id3 meta data if it exists
if (metaData != null) {
props.put("artist", metaData.getArtist());
props.put("album", metaData.getAlbum());
props.put("songName", metaData.getSongName());
props.put("genre", metaData.getGenre());
props.put("year", metaData.getYear());
props.put("track", metaData.getTrack());
props.put("comment", metaData.getComment());
if (metaData.hasCoverImage()) {
Map<Object, Object> covr = new HashMap<Object, Object>(1);
covr.put("covr", new Object[] { metaData.getCovr() });
props.put("tags", covr);
}
//clear meta for gc
metaData = null;
}
out.writeMap(props, new Serializer());
in.flip();
ITag result = new Tag(IoConstants.TYPE_METADATA, 0, in.limit(), null, prevSize);
result.setBody(in);
return result;
}
示例9: readTag
import org.red5.io.ITag; //导入方法依赖的package包/类
/** {@inheritDoc} */
public ITag readTag() {
ITag tag = null;
try {
lock.acquire();
long oldPos = getCurrentPosition();
tag = readTagHeader();
if (tag != null) {
boolean isMetaData = tag.getDataType() == TYPE_METADATA;
log.debug("readTag, oldPos: {}, tag header: \n{}", oldPos, tag);
if (!metadataSent && !isMetaData && generateMetadata) {
// Generate initial metadata automatically
setCurrentPosition(oldPos);
KeyFrameMeta meta = analyzeKeyFrames();
if (meta != null) {
metadataSent = true;
return createFileMeta();
}
}
int bodySize = tag.getBodySize();
IoBuffer body = IoBuffer.allocate(bodySize, false);
// XXX Paul: this assists in 'properly' handling damaged FLV files
long newPosition = getCurrentPosition() + bodySize;
if (newPosition <= getTotalBytes()) {
int limit;
while (getCurrentPosition() < newPosition) {
fillBuffer(newPosition - getCurrentPosition());
if (getCurrentPosition() + in.remaining() > newPosition) {
limit = in.limit();
in.limit((int) (newPosition - getCurrentPosition()) + in.position());
body.put(in);
in.limit(limit);
} else {
body.put(in);
}
}
body.flip();
tag.setBody(body);
}
} else {
log.debug("Tag was null");
}
} catch (InterruptedException e) {
log.warn("Exception acquiring lock", e);
} finally {
lock.release();
}
return tag;
}
示例10: createFileMeta
import org.red5.io.ITag; //导入方法依赖的package包/类
/**
* 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;
}
示例11: write
import org.red5.io.ITag; //导入方法依赖的package包/类
/**
* Write incoming data to the file.
*
* @param timestamp adjusted timestamp
* @param msg stream data
*/
private final void write(int timestamp, IRTMPEvent msg) {
byte dataType = msg.getDataType();
log.debug("Write - timestamp: {} type: {}", timestamp, dataType);
//if the last message was a reset or we just started, use the header timer
if (startTimestamp == -1) {
startTimestamp = timestamp;
timestamp = 0;
} else {
timestamp -= startTimestamp;
}
// create a tag
ITag tag = new Tag();
tag.setDataType(dataType);
tag.setTimestamp(timestamp);
// get data bytes
IoBuffer data = ((IStreamData<?>) msg).getData().duplicate();
if (data != null) {
tag.setBodySize(data.limit());
tag.setBody(data);
}
// only allow blank tags if they are of audio type
if (tag.getBodySize() > 0 || dataType == ITag.TYPE_AUDIO) {
try {
if (timestamp >= 0) {
if (!writer.writeTag(tag)) {
log.warn("Tag was not written");
}
} else {
log.warn("Skipping message with negative timestamp.");
}
} catch (IOException e) {
log.error("Error writing tag", e);
} finally {
if (data != null) {
data.clear();
data.free();
}
}
}
data = null;
}