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


Java ITag.getTimestamp方法代码示例

本文整理汇总了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");
}
 
开发者ID:Red5,项目名称:red5-io,代码行数:33,代码来源:AVCVideoTest.java

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

示例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();
}
 
开发者ID:Red5,项目名称:red5-io,代码行数:71,代码来源:MetaService.java

示例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);

    }
}
 
开发者ID:Red5,项目名称:red5-server,代码行数:65,代码来源:MetaDataInjectionTest.java

示例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);

	}
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:64,代码来源:MetaDataInjectionTest.java


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