本文整理汇总了Java中org.red5.io.ITag.getTimestamp方法的典型用法代码示例。如果您正苦于以下问题:Java ITag.getTimestamp方法的具体用法?Java ITag.getTimestamp怎么用?Java ITag.getTimestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.red5.io.ITag
的用法示例。
在下文中一共展示了ITag.getTimestamp方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testA7SliceBug
import org.red5.io.ITag; //导入方法依赖的package包/类
@Test
public void testA7SliceBug() {
log.info("\n testA7SliceBug");
Path path = Paths.get("target/test-classes/fixtures/ipadmini-A7.flv");
try {
File file = path.toFile();
log.info("Reading: {}", file.getName());
FLVReader reader = new FLVReader(file, true);
ITag tag = null;
AVCVideo video = new AVCVideo();
while (reader.hasMoreTags()) {
tag = reader.readTag();
int timestamp = tag.getTimestamp();
log.debug("Tag: {} timestamp: {}", tag.getDataType(), timestamp);
if (tag.getDataType() == 9) {
IoBuffer buf = tag.getBody();
if (video.canHandleData(buf)) {
video.addData(buf, tag.getTimestamp());
}
}
// when the audio comes in for ts 2176, check for the 2 proceeding sliced keyframes
if (timestamp == 2176) {
assertTrue(video.getKeyframes().length == 2);
}
}
reader.close();
log.info("Finished reading: {}\n", file.getName());
} catch (IOException e) {
e.printStackTrace();
}
log.info("testA7SliceBug end\n");
}
示例2: write
import org.red5.io.ITag; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void write(IMetaData<?, ?> meta) throws IOException {
// Get cue points, FLV reader and writer
IMetaCue[] metaArr = meta.getMetaCue();
FLVReader reader = new FLVReader(file, false);
FLVWriter writer = new FLVWriter(file, false);
ITag tag = null;
// Read first tag
if (reader.hasMoreTags()) {
tag = reader.readTag();
if (tag.getDataType() == IoConstants.TYPE_METADATA) {
if (!reader.hasMoreTags()) {
throw new IOException("File we're writing is metadata only?");
}
}
}
if (tag == null) {
throw new IOException("Tag was null");
}
meta.setDuration(((double) reader.getDuration() / 1000));
meta.setVideoCodecId(reader.getVideoCodecId());
meta.setAudioCodecId(reader.getAudioCodecId());
ITag injectedTag = injectMetaData(meta, tag);
injectedTag.setPreviousTagSize(0);
tag.setPreviousTagSize(injectedTag.getBodySize());
// TODO look into why this fails in the unit test
try {
writer.writeTag(injectedTag);
writer.writeTag(tag);
} catch (Exception e) {
log.warn("Metadata insert failed", e);
return;
}
int cuePointTimeStamp = 0;
int counter = 0;
if (metaArr != null) {
Arrays.sort(metaArr);
cuePointTimeStamp = getTimeInMilliseconds(metaArr[0]);
}
while (reader.hasMoreTags()) {
tag = reader.readTag();
// if there are cuePoints in the array
if (counter < metaArr.length) {
// If the tag has a greater timestamp than the
// cuePointTimeStamp, then inject the tag
while (tag.getTimestamp() > cuePointTimeStamp) {
injectedTag = injectMetaCue(metaArr[counter], tag);
writer.writeTag(injectedTag);
tag.setPreviousTagSize(injectedTag.getBodySize());
// Advance to the next CuePoint
counter++;
if (counter > (metaArr.length - 1)) {
break;
}
cuePointTimeStamp = getTimeInMilliseconds(metaArr[counter]);
}
}
if (tag.getDataType() != IoConstants.TYPE_METADATA) {
writer.writeTag(tag);
}
}
writer.close();
}
示例3: write
import org.red5.io.ITag; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void write(IMetaData<?, ?> meta) throws IOException {
// Get cue points, FLV reader and writer
IMetaCue[] metaArr = meta.getMetaCue();
FLVReader reader = new FLVReader(file, false);
FLVWriter writer = new FLVWriter(file, false);
ITag tag = null;
// Read first tag
if (reader.hasMoreTags()) {
tag = reader.readTag();
if (tag.getDataType() == IoConstants.TYPE_METADATA) {
if (!reader.hasMoreTags()) {
throw new IOException("File we're writing is metadata only?");
}
}
}
if (tag == null) {
throw new IOException("Tag was null");
}
meta.setDuration(((double) reader.getDuration() / 1000));
meta.setVideoCodecId(reader.getVideoCodecId());
meta.setAudioCodecId(reader.getAudioCodecId());
ITag injectedTag = injectMetaData(meta, tag);
injectedTag.setPreviousTagSize(0);
tag.setPreviousTagSize(injectedTag.getBodySize());
// TODO look into why this fails in the unit test
try {
writer.writeTag(injectedTag);
writer.writeTag(tag);
} catch (Exception e) {
log.warn("Metadata insert failed", e);
return;
}
int cuePointTimeStamp = 0;
int counter = 0;
if (metaArr != null) {
Arrays.sort(metaArr);
cuePointTimeStamp = getTimeInMilliseconds(metaArr[0]);
}
while (reader.hasMoreTags()) {
tag = reader.readTag();
// if there are cuePoints in the array
if (counter < metaArr.length) {
// If the tag has a greater timestamp than the
// cuePointTimeStamp, then inject the tag
while (tag.getTimestamp() > cuePointTimeStamp) {
injectedTag = injectMetaCue(metaArr[counter], tag);
writer.writeTag(injectedTag);
tag.setPreviousTagSize(injectedTag.getBodySize());
// Advance to the next CuePoint
counter++;
if (counter > (metaArr.length - 1)) {
break;
}
cuePointTimeStamp = getTimeInMilliseconds(metaArr[counter]);
}
}
if (tag.getDataType() != IoConstants.TYPE_METADATA) {
writer.writeTag(tag);
}
}
writer.close();
}
示例4: writeTagsWithInjection
import org.red5.io.ITag; //导入方法依赖的package包/类
/**
* Write FLV tags and inject Cue Points
*
* @param reader
* @param writer
* @throws IOException
*/
private void writeTagsWithInjection(ITagReader reader, ITagWriter writer) throws IOException {
IMetaCue cp = new MetaCue<Object, Object>();
cp.setName("cue_1");
cp.setTime(0.01);
cp.setType(ICueType.EVENT);
IMetaCue cp1 = new MetaCue<Object, Object>();
cp1.setName("cue_1");
cp1.setTime(2.01);
cp1.setType(ICueType.EVENT);
// Place in TreeSet for sorting
TreeSet<IMetaCue> ts = new TreeSet<IMetaCue>();
ts.add(cp);
ts.add(cp1);
int cuePointTimeStamp = getTimeInMilliseconds(ts.first());
ITag tag = null;
ITag injectedTag = null;
while (reader.hasMoreTags()) {
tag = reader.readTag();
if (tag.getDataType() != IoConstants.TYPE_METADATA) {
//injectNewMetaData();
} else {
//in
}
// if there are cuePoints in the TreeSet
if (!ts.isEmpty()) {
// If the tag has a greater timestamp than the
// cuePointTimeStamp, then inject the tag
while (tag.getTimestamp() > cuePointTimeStamp) {
injectedTag = injectMetaData(ts.first(), tag);
writer.writeTag(injectedTag);
tag.setPreviousTagSize((injectedTag.getBodySize() + 11));
// Advance to the next CuePoint
ts.remove(ts.first());
if (ts.isEmpty()) {
break;
}
cuePointTimeStamp = getTimeInMilliseconds(ts.first());
}
}
writer.writeTag(tag);
}
}
示例5: writeTagsWithInjection
import org.red5.io.ITag; //导入方法依赖的package包/类
/**
* Write FLV tags and inject Cue Points
* @param reader
* @param writer
* @throws IOException
*/
private void writeTagsWithInjection(ITagReader reader, ITagWriter writer) throws IOException {
IMetaCue cp = new MetaCue<Object, Object>();
cp.setName("cue_1");
cp.setTime(0.01);
cp.setType(ICueType.EVENT);
IMetaCue cp1 = new MetaCue<Object, Object>();
cp1.setName("cue_1");
cp1.setTime(2.01);
cp1.setType(ICueType.EVENT);
// Place in TreeSet for sorting
TreeSet<IMetaCue> ts = new TreeSet<IMetaCue>();
ts.add(cp);
ts.add(cp1);
int cuePointTimeStamp = getTimeInMilliseconds(ts.first());
ITag tag = null;
ITag injectedTag = null;
while(reader.hasMoreTags()) {
tag = reader.readTag();
if(tag.getDataType() != IoConstants.TYPE_METADATA) {
//injectNewMetaData();
} else {
//in
}
// if there are cuePoints in the TreeSet
if(!ts.isEmpty()) {
// If the tag has a greater timestamp than the
// cuePointTimeStamp, then inject the tag
while(tag.getTimestamp() > cuePointTimeStamp) {
injectedTag = injectMetaData(ts.first(), tag);
writer.writeTag(injectedTag);
tag.setPreviousTagSize((injectedTag.getBodySize() + 11));
// Advance to the next CuePoint
ts.remove(ts.first());
if(ts.isEmpty()) {
break;
}
cuePointTimeStamp = getTimeInMilliseconds(ts.first());
}
}
writer.writeTag(tag);
}
}