当前位置: 首页>>代码示例>>Java>>正文


Java ITag.getBodySize方法代码示例

本文整理汇总了Java中org.red5.io.ITag.getBodySize方法的典型用法代码示例。如果您正苦于以下问题:Java ITag.getBodySize方法的具体用法?Java ITag.getBodySize怎么用?Java ITag.getBodySize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.red5.io.ITag的用法示例。


在下文中一共展示了ITag.getBodySize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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;
}
 
开发者ID:Kyunghwa-Yoo,项目名称:StitchRTSP,代码行数:50,代码来源:FLVReader.java

示例2: write

import org.red5.io.ITag; //导入方法依赖的package包/类
/**
 * Adjust timestamp and write to the file.
 * 
 * @param queued
 *            queued data for write
 */
private final void write(QueuedData queued) {
    // get data type
    byte dataType = queued.getDataType();
    // get timestamp
    int timestamp = queued.getTimestamp();
    log.debug("Write - timestamp: {} type: {}", timestamp, dataType);
    // get queued
    ITag tag = queued.getData();
    if (tag != null) {
        // only allow blank tags if they are of audio type
        if (tag.getBodySize() > 0 || dataType == ITag.TYPE_AUDIO) {
            // 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;
            }
            // update the timestamp
            tag.setTimestamp(timestamp);
            try {
                if (timestamp >= 0) {
                    if (!writer.writeTag(tag)) {
                        log.warn("Tag was not written");
                    }
                } else {
                    log.warn("Skipping message with negative timestamp.");
                }
            } catch (ClosedChannelException cce) {
                // the channel we tried to write to is closed, we should not try
                // again on that writer
                log.error("The writer is no longer able to write to the file: {} writable: {}", path.getFileName(), path.toFile().canWrite());
            } catch (IOException e) {
                log.warn("Error writing tag", e);
                if (e.getCause() instanceof ClosedChannelException) {
                    // the channel we tried to write to is closed, we should not
                    // try again on that writer
                    log.error("The writer is no longer able to write to the file: {} writable: {}", path.getFileName(), path.toFile().canWrite());
                }
            } finally {
                queued.dispose();
            }
        }
    }
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:52,代码来源:FileConsumer.java

示例3: 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;
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:48,代码来源:FileConsumer.java


注:本文中的org.red5.io.ITag.getBodySize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。