• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java VideoData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.red5.server.net.rtmp.event.VideoData的典型用法代码示例。如果您正苦于以下问题:Java VideoData类的具体用法?Java VideoData怎么用?Java VideoData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



VideoData类属于org.red5.server.net.rtmp.event包,在下文中一共展示了VideoData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: encode

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
@Override
public synchronized VideoData encode(int[][] img) throws IOException {
	ba.reset();
	Rectangle imgArea = new Rectangle(img.length, img[0].length);
	Rectangle area = getNextBlock(imgArea, null);
	boolean isKeyFrame = (frameCount++ % keyFrameIndex) == 0 || last == null;

	//header
	ba.write(getTag(isKeyFrame ? FLAG_FRAMETYPE_KEYFRAME : FLAG_FRAMETYPE_INTERFRAME, FLAG_CODEC_SCREEN));
	writeShort(ba, imgArea.width + ((blockSize / 16 - 1) << 12));
	writeShort(ba, imgArea.height + ((blockSize / 16 - 1) << 12));

	while (area.width > 0 && area.height > 0) {
		writeBytesIfChanged(ba, isKeyFrame, img, area);
		area = getNextBlock(imgArea, area);
	}
	last = img;
	return getData(ba.toByteArray());
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:20,代码来源:ScreenV1Encoder.java


示例2: packetReceived

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
@Override
public void packetReceived(IBroadcastStream broadcastStream, IStreamPacket streampacket) {
	try {
		CachedEvent cachedEvent = new CachedEvent();
		cachedEvent.setData(streampacket.getData().duplicate());
		cachedEvent.setDataType(streampacket.getDataType());
		cachedEvent.setTimestamp(streampacket.getTimestamp());
		cachedEvent.setCurrentTime(new Date());
		if (streampacket instanceof VideoData) {
			cachedEvent.setFrameType(((VideoData) streampacket).getFrameType());
		}

		if (log.isTraceEnabled()) {
			log.trace("##REC:: Packet recieved. type: {} frame type: {}", cachedEvent.getDataType(), cachedEvent.getFrameType());
		}
		streamWriter.append(cachedEvent);
	} catch (Exception e) {
		log.error("##REC:: [packetReceived]", e);
	}
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:21,代码来源:StreamListener.java


示例3: pushVideo

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
public void pushVideo(VideoData data, int ts) {
	if (startPublish) {
		if (Red5.getConnectionLocal() == null) {
			Red5.setConnectionLocal(client.getConnection());
		}
		RTMPMessage rtmpMsg = RTMPMessage.build(data, ts);
		client.publishStreamData(streamId, rtmpMsg);
	}
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:10,代码来源:CaptureScreen.java


示例4: execute

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
	JobDataMap data = context.getJobDetail().getJobDataMap();
	CaptureScreen capture = (CaptureScreen)data.get(CAPTURE_KEY);
	if (screen == null) {
		dim = capture.getDim();
		screen = new Rectangle(dim.getSpinnerX(), dim.getSpinnerY()
				, dim.getSpinnerWidth(), dim.getSpinnerHeight());
	}

	long start = 0;
	if (log.isTraceEnabled()) {
		start = System.currentTimeMillis();
	}
	image = ScreenV1Encoder.getImage(dim, screen, robot);
	if (log.isTraceEnabled()) {
		log.trace(String.format("encode: Image was captured in %s ms, size %sk", System.currentTimeMillis() - start, 4 * image.length * image[0].length / 1024));
		start = System.currentTimeMillis();
	}
	try {
		VideoData vData = capture.getEncoder().encode(image);
		if (log.isTraceEnabled()) {
			long now = System.currentTimeMillis();
			log.trace(String.format("encode: Image was encoded in %s ms, timestamp is %s", now - start, now - capture.getStartTime()));
		}
		capture.getFrames().offer(vData);
		capture.getEncoder().createUnalteredFrame();
	} catch (Exception e) {
		log.error("Error while encoding: ", e);
	}
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:32,代码来源:EncodeJob.java


示例5: getData

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
private static VideoData getData(byte[] data) {
	IoBuffer buf = IoBuffer.allocate(data.length);
	buf.clear();
	buf.put(data);
	buf.flip();
	return new VideoData(buf);
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:8,代码来源:ScreenV1Encoder.java


示例6: getUnalteredFrame

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
@Override
public VideoData getUnalteredFrame() {
	if (unalteredFrame != null && (frameCount % keyFrameIndex) != 0) {
		frameCount++;
	}
	return unalteredFrame;
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:8,代码来源:ScreenV1Encoder.java


示例7: buildVideoFrame

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
/**
 * Builds a video frame (non-config).
 * 
 * <pre>
 * flv tagged h264 encoded bytes resemble this sequence: 23 01 00 00 00 00 00 00 02 09 16 00 00 00 15 06 00...
 * |--Header--|--Presentation offset--|--Size of packet + 1 --|--Encoded data 
 *  0x17 0x01  0x0 0x0 0x0             0x00 0x00 0x00 0x02      0x0916 bytes of data
 * </pre>
 * 
 * @param timestamp
 * @param frameSize
 * @return
 */
private static VideoData buildVideoFrame(int timestamp, int frameSize) {
	log.debug("buildVideoFrame - slice count: {}", frameSlices.size());
	// determine if the set of slices are of IDR type 
	boolean isIdr = (frameSlices.getFirst()[4] & 0x1f) == 7; // (SPS will actual be the first slice, if its an IDR set)
	// size the flv video data array
	IoBuffer framedData = IoBuffer.allocate(frameSize + 5 + 1); // 5 bytes header and 1 byte trailer
	framedData.setAutoExpand(true);
	log.debug("Frame data initial size: {}", framedData.limit());
	// write prefix bytes
	framedData.put((byte) (isIdr ? 0x17 : 0x27)); // 0x10 - key frame; 0x07 - H264_CODEC_ID
	framedData.put((byte) 0x01); // 0: AVC sequence header; 1: AVC NALU; 2: AVC end of sequence
	// presentation off set
	framedData.put((byte) 0);
	framedData.put((byte) 0);
	framedData.put((byte) 0);
	// copy in encoded bytes
	for (byte[] frame : frameSlices) {
		framedData.put(frame);
	}
	// write end byte
	framedData.put((byte) 0);
	// flip it
	framedData.flip();
	log.debug("Frame data final size: {}", framedData.limit());
	// create the video data obj
	VideoData video = new VideoData(framedData);
	video.setHeader(new Header());
	video.getHeader().setTimer((int) timestamp);
	video.setTimestamp((int) timestamp);
	return video;
}
 
开发者ID:mondain,项目名称:h264app,代码行数:45,代码来源:RTMPVideoRenderer.java


示例8: playVOD

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
/**
 * Performs the processes needed for VOD / pre-recorded streams.
 * 
 * @param withReset
 *            whether or not to perform reset on the stream
 * @param itemLength
 *            length of the item to be played
 * @return message for the consumer
 * @throws IOException
 */
private final IMessage playVOD(boolean withReset, long itemLength) throws IOException {
    IMessage msg = null;
    // change state
    subscriberStream.setState(StreamState.PLAYING);
    if (withReset) {
        releasePendingMessage();
    }
    sendVODInitCM(currentItem);
    // Don't use pullAndPush to detect IOExceptions prior to sending NetStream.Play.Start
    if (currentItem.getStart() > 0) {
        streamOffset = sendVODSeekCM((int) currentItem.getStart());
        // We seeked to the nearest keyframe so use real timestamp now
        if (streamOffset == -1) {
            streamOffset = (int) currentItem.getStart();
        }
    }
    IMessageInput in = msgInReference.get();
    msg = in.pullMessage();
    if (msg instanceof RTMPMessage) {
        // Only send first video frame
        IRTMPEvent body = ((RTMPMessage) msg).getBody();
        if (itemLength == 0) {
            while (body != null && !(body instanceof VideoData)) {
                msg = in.pullMessage();
                if (msg != null && msg instanceof RTMPMessage) {
                    body = ((RTMPMessage) msg).getBody();
                } else {
                    break;
                }
            }
        }
        if (body != null) {
            // Adjust timestamp when playing lists
            body.setTimestamp(body.getTimestamp() + timestampOffset);
        }
    }
    return msg;
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:49,代码来源:PlayEngine.java


示例9: writingMessage

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
/**
 * Mark message as being written.
 * 
 * @param message
 *            Message to mark
 */
protected void writingMessage(Packet message) {
    if (message.getMessage() instanceof VideoData) {
        Number streamId = message.getHeader().getStreamId();
        final AtomicInteger value = new AtomicInteger();
        AtomicInteger old = pendingVideos.putIfAbsent(streamId.doubleValue(), value);
        if (old == null) {
            old = value;
        }
        old.incrementAndGet();
    }
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:18,代码来源:RTMPConnection.java


示例10: messageSent

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
/**
 * Mark message as sent.
 * 
 * @param message
 *            Message to mark
 */
public void messageSent(Packet message) {
    if (message.getMessage() instanceof VideoData) {
        Number streamId = message.getHeader().getStreamId();
        AtomicInteger pending = pendingVideos.get(streamId.doubleValue());
        if (log.isTraceEnabled()) {
            log.trace("Stream id: {} pending: {} total pending videos: {}", streamId, pending, pendingVideos.size());
        }
        if (pending != null) {
            pending.decrementAndGet();
        }
    }
    writtenMessages.incrementAndGet();
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:20,代码来源:RTMPConnection.java


示例11: getAVCDecoderConfig

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
public IRTMPEvent getAVCDecoderConfig() {
	IoBuffer buffV = IoBuffer.allocate(_pCodecSetup.length);
	buffV.setAutoExpand(true);
	for (int p = 0; p < _pCodecSetup.length; p++)
		buffV.put((byte) _pCodecSetup[p]);
	buffV.flip();
	buffV.position(0);
	IRTMPEvent video = new VideoData(buffV);
	video.setHeader(new Header());
	return video;
}
 
开发者ID:Red5,项目名称:red5-rtsp-restreamer,代码行数:12,代码来源:AxisTest.java


示例12: writingMessage

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
/**
 * Mark message as being written.
 * 
 * @param message
 *            Message to mark
 */
protected void writingMessage(Packet message) {
	if (message.getMessage() instanceof VideoData) {
		int streamId = message.getHeader().getStreamId();
		final AtomicInteger value = new AtomicInteger();
		AtomicInteger old = pendingVideos.putIfAbsent(streamId, value);
		if (old == null) {
			old = value;
		}
		old.incrementAndGet();
	}
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:18,代码来源:RTMPConnection.java


示例13: messageSent

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
/**
 * Mark message as sent.
 * 
 * @param message
 *            Message to mark
 */
public void messageSent(Packet message) {
	if (message.getMessage() instanceof VideoData) {
		int streamId = message.getHeader().getStreamId();
		AtomicInteger pending = pendingVideos.get(streamId);
		if (pending != null) {
			pending.decrementAndGet();
		}
	}
	writtenMessages.incrementAndGet();
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:17,代码来源:RTMPConnection.java


示例14: setUp

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void setUp() throws Exception {
	super.setUp();
	VideoData message = new VideoData(IoBuffer.allocate(100));
	playBuffer = new PlayBuffer(1000);
	rtmpMessage = RTMPMessage.build(message);
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:9,代码来源:PlayBufferTest.java


示例15: getFrames

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
public Queue<VideoData> getFrames() {
	return frames;
}
 
开发者ID:apache,项目名称:openmeetings,代码行数:4,代码来源:CaptureScreen.java


示例16: buildVideoConfigFrame

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
/**
 * Builds a configuration video frame.
 * 
 * C++ example http://pastebin.com/fTHENikp
 *
 * @param timestamp
 * @return
 */
private static void buildVideoConfigFrame(int timestamp) {
	log.debug("buildConfig");
	int cursor = 0;
	// avc header 5, sps header 8, sps len, pps header 3, pps len
	byte[] avcConfig = new byte[13 + sps.length + 3 + pps.length];
	// write prefix bytes
	avcConfig[cursor++] = (byte) 0x17; // 0x10 - key frame; 0x07 - H264_CODEC_ID
	avcConfig[cursor++] = (byte) 0; // 0: AVC sequence header; 1: AVC NALU; 2: AVC end of sequence
	avcConfig[cursor++] = (byte) 0; // composition time
	avcConfig[cursor++] = (byte) 0; // composition time
	avcConfig[cursor++] = (byte) 0; // composition time
	// sps
	avcConfig[cursor++] = (byte) 1; // configurationVersion
	avcConfig[cursor++] = (byte) sps[1]; // profile
	avcConfig[cursor++] = (byte) sps[2]; // profile compat
	avcConfig[cursor++] = (byte) sps[3]; // level
	// reserved bytes - adobe doesn't write these
	avcConfig[cursor++] = (byte) 0xff; // 6 bits reserved (111111) + 2 bits nal size length - 1 (11), lengthSizeMinusOne
	avcConfig[cursor++] = (byte) 0xe1; // 3 bits reserved (111) + 5 bits number of sps (00001), numOfSequenceParameterSets
	// sps length
	avcConfig[cursor++] = (byte) ((sps.length >> 8) & 0xff);
	avcConfig[cursor++] = (byte) (sps.length & 0xff);
	// sps data
	for (int k = 0; k < sps.length; k++) {
		avcConfig[cursor++] = sps[k];
	}
	// pps
	avcConfig[cursor++] = 1; // numOfPictureParameterSets
	// pps length - short to big endian
	avcConfig[cursor++] = (byte) ((pps.length >> 8) & 0x000000ff);
	avcConfig[cursor++] = (byte) (pps.length & 0x000000ff);
	// pps data
	for (int k = 0; k < pps.length; k++) {
		avcConfig[cursor++] = pps[k];
	}
	// testing
	if (log.isDebugEnabled()) {
		log.debug("AVC config: {}", Arrays.toString(avcConfig));
	}
	videoConfig = new VideoData(IoBuffer.wrap(avcConfig));
	videoConfig.setHeader(new Header());
	videoConfig.getHeader().setTimer((int) timestamp);
	videoConfig.setTimestamp((int) timestamp);
	// testing
	if (log.isDebugEnabled()) {
		AvcConfigBox avcC = new AvcConfigBox(ByteBuffer.wrap(avcConfig), true);
		log.debug("Box: {}", avcC);
	}
}
 
开发者ID:mondain,项目名称:h264app,代码行数:58,代码来源:RTMPVideoRenderer.java


示例17: canSendPacket

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
/** {@inheritDoc} */
public boolean canSendPacket(RTMPMessage message, long pending) {
    IRTMPEvent packet = message.getBody();
    boolean result = true;
    // We currently only drop video packets.
    if (packet instanceof VideoData) {
        VideoData video = (VideoData) packet;
        FrameType type = video.getFrameType();
        switch (state) {
            case SEND_ALL:
                // All packets will be sent
                break;
            case SEND_INTERFRAMES:
                // Only keyframes and interframes will be sent.
                if (type == FrameType.KEYFRAME) {
                    if (pending == 0) {
                        // Send all frames from now on.
                        state = SEND_ALL;
                    }
                } else if (type == FrameType.INTERFRAME) {
                }
                break;
            case SEND_KEYFRAMES:
                // Only keyframes will be sent.
                result = (type == FrameType.KEYFRAME);
                if (result && pending == 0) {
                    // Maybe switch back to SEND_INTERFRAMES after the next keyframe
                    state = SEND_KEYFRAMES_CHECK;
                }
                break;
            case SEND_KEYFRAMES_CHECK:
                // Only keyframes will be sent.
                result = (type == FrameType.KEYFRAME);
                if (result && pending == 0) {
                    // Continue with sending interframes as well
                    state = SEND_INTERFRAMES;
                }
                break;
            default:
        }
    }
    return result;
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:44,代码来源:VideoFrameDropper.java


示例18: dropPacket

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
/** {@inheritDoc} */
public void dropPacket(RTMPMessage message) {
    IRTMPEvent packet = message.getBody();
    // Only check video packets.
    if (packet instanceof VideoData) {
        VideoData video = (VideoData) packet;
        FrameType type = video.getFrameType();
        switch (state) {
            case SEND_ALL:
                if (type == FrameType.DISPOSABLE_INTERFRAME) {
                    // Remain in state, packet is safe to drop.
                    return;
                } else if (type == FrameType.INTERFRAME) {
                    // Drop all frames until the next keyframe.
                    state = SEND_KEYFRAMES;
                    return;
                } else if (type == FrameType.KEYFRAME) {
                    // Drop all frames until the next keyframe.
                    state = SEND_KEYFRAMES;
                    return;
                }
                break;
            case SEND_INTERFRAMES:
                if (type == FrameType.INTERFRAME) {
                    // Drop all frames until the next keyframe.
                    state = SEND_KEYFRAMES_CHECK;
                    return;
                } else if (type == FrameType.KEYFRAME) {
                    // Drop all frames until the next keyframe.
                    state = SEND_KEYFRAMES;
                    return;
                }
                break;
            case SEND_KEYFRAMES:
                // Remain in state.
                break;
            case SEND_KEYFRAMES_CHECK:
                if (type == FrameType.KEYFRAME) {
                    // Switch back to sending keyframes, but don't move to
                    // SEND_INTERFRAMES afterwards.
                    state = SEND_KEYFRAMES;
                    return;
                }
                break;
            default:
        }
    }
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:49,代码来源:VideoFrameDropper.java


示例19: encodeVideoData

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
/** {@inheritDoc} */
public IoBuffer encodeVideoData(VideoData videoData) {
    final IoBuffer result = videoData.getData();
    return result;
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:6,代码来源:RTMPProtocolEncoder.java


示例20: decodeVideoData

import org.red5.server.net.rtmp.event.VideoData; //导入依赖的package包/类
/** {@inheritDoc} */
public VideoData decodeVideoData(IoBuffer in) {
    return new VideoData(in.asReadOnlyBuffer());
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:5,代码来源:RTMPProtocolDecoder.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CharTypes类代码示例发布时间:2022-05-23
下一篇:
Java Path类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap