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

Java Header类代码示例

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

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



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

示例1: getHeaderType

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
/**
 * Determine type of header to use.
 * 
 * @param header RTMP message header
 * @param lastHeader Previous header
 * @return Header type to use
 */
private byte getHeaderType(final Header header, final Header lastHeader) {
    //int lastFullTs = ((RTMPConnection) Red5.getConnectionLocal()).getState().getLastFullTimestampWritten(header.getChannelId());
    if (lastHeader == null || header.getStreamId() != lastHeader.getStreamId() || header.getTimer() < lastHeader.getTimer()) {
        // new header mark if header for another stream
        return HEADER_NEW;
    } else if (header.getSize() != lastHeader.getSize() || header.getDataType() != lastHeader.getDataType()) {
        // same source header if last header data type or size differ
        return HEADER_SAME_SOURCE;
    } else if (header.getTimer() != lastHeader.getTimer()) {
        // timer change marker if there's time gap between header time stamps
        return HEADER_TIMER_CHANGE;
    }
    // continue encoding
    return  HEADER_CONTINUE;
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:23,代码来源:RTMPProtocolEncoder.java


示例2: write

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
/**
 * Writes packet from event data to RTMP connection and stream id.
 *
 * @param event
 *            Event data
 * @param streamId
 *            Stream id
 */
private void write(IRTMPEvent event, Number streamId) {
    log.trace("write to stream id: {} channel: {}", streamId, id);
    final Header header = new Header();
    final Packet packet = new Packet(header, event);
    // set the channel id
    header.setChannelId(id);
    int ts = event.getTimestamp();
    if (ts != 0) {
        header.setTimer(event.getTimestamp());
    }
    header.setStreamId(streamId);
    header.setDataType(event.getDataType());
    // should use RTMPConnection specific method.. 
    //log.trace("Connection type for write: {}", connection.getClass().getName());
    connection.write(packet);
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:25,代码来源:Channel.java


示例3: messageReceived

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void messageReceived(IoSession session, Object in) {
    if (log.isDebugEnabled()) {
        if (in instanceof IoBuffer) {
            log.debug("Handskake");
            return;
        }
        try {
            final Packet packet = (Packet) in;
            final Object message = packet.getMessage();
            final Header source = packet.getHeader();
            log.debug("{}", source);
            log.debug("{}", message);
        } catch (RuntimeException e) {
            log.error("Exception", e);
        }
    }
}
 
开发者ID:Red5,项目名称:red5-server,代码行数:20,代码来源:DebugProxyHandler.java


示例4: onSharedObject

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void onSharedObject(RTMPConnection conn, Channel channel, Header source, SharedObjectMessage object) {
    log.trace("onSharedObject");
    ClientSharedObject so = sharedObjects.get(object.getName());
    if (so != null) {
        if (so.isPersistent() == object.isPersistent()) {
            log.debug("Received SO request: {}", object);
            so.dispatchEvent(object);
        } else {
            log.error("Ignoring request for wrong-persistent SO: {}", object);
        }
    } else {
        log.error("Ignoring request for non-existend SO: {}", object);
    }
}
 
开发者ID:Red5,项目名称:red5-client,代码行数:17,代码来源:BaseRTMPClientHandler.java


示例5: onCommand

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected void onCommand(RTMPConnection conn, Channel channel, Header header, Notify notify) {
    super.onCommand(conn, channel, header, notify);
    System.out.println("onInvoke, header = " + header.toString());
    System.out.println("onInvoke, notify = " + notify.toString());
    Object obj = notify.getCall().getArguments().length > 0 ? notify.getCall().getArguments()[0] : null;
    if (obj instanceof Map) {
        Map<String, String> map = (Map<String, String>) obj;
        String code = map.get("code");
        if (StatusCodes.NS_PLAY_STOP.equals(code)) {
            synchronized (RTMPTSClientTest.class) {
                finished = true;
                RTMPTSClientTest.class.notifyAll();
            }
            disconnect();
            System.out.println("Disconnected");
        }
    }

}
 
开发者ID:Red5,项目名称:red5-client,代码行数:21,代码来源:RTMPTSClientTest.java


示例6: onCommand

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected void onCommand(RTMPConnection conn, Channel channel, Header header, Notify notify) {
    super.onCommand(conn, channel, header, notify);
    System.out.println("onInvoke, header = " + header.toString());
    System.out.println("onInvoke, notify = " + notify.toString());
    Object obj = notify.getCall().getArguments().length > 0 ? notify.getCall().getArguments()[0] : null;
    if (obj instanceof Map) {
        Map<String, String> map = (Map<String, String>) obj;
        String code = map.get("code");
        if (StatusCodes.NS_PLAY_STOP.equals(code)) {
            synchronized (RTMPTClientTest.class) {
                finished = true;
                RTMPTClientTest.class.notifyAll();
            }
            disconnect();
            System.out.println("Disconnected");
        }
    }

}
 
开发者ID:Red5,项目名称:red5-client,代码行数:21,代码来源:RTMPTClientTest.java


示例7: write

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
/**
	 * Writes packet from event data to RTMP connection and stream id.
	 *
	 * @param event           Event data
	 * @param streamId        Stream id
	 */
	private void write(IRTMPEvent event, int streamId) {
		log.trace("write channel: {} stream id: {}", id, streamId);
		final Header header = new Header();
		final Packet packet = new Packet(header, event);
		header.setChannelId(id);
		int ts = event.getTimestamp();
		if (ts != 0) {
			header.setTimer(event.getTimestamp());			
		} else {
			// TODO may need to add generated timestamps at some point
//			int timestamp = connection.getTimer();
//			header.setTimerBase(timestamp);
//			event.setTimestamp(timestamp);
		}
		header.setStreamId(streamId);
		header.setDataType(event.getDataType());
		// should use RTMPConnection specific method.. 
		//log.trace("Connection type for write: {}", connection.getClass().getName());
		connection.write(packet);
	}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:27,代码来源:Channel.java


示例8: onChunkSize

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void onChunkSize(RTMPConnection conn, Channel channel, Header source, ChunkSize chunkSize) {
	for (IClientStream stream : conn.getStreams()) {
		if (stream instanceof IClientBroadcastStream) {
			IClientBroadcastStream bs = (IClientBroadcastStream) stream;
			IBroadcastScope scope = bs.getScope().getBroadcastScope(bs.getPublishedName());
			if (scope == null) {
				continue;
			}
			OOBControlMessage setChunkSize = new OOBControlMessage();
			setChunkSize.setTarget("ClientBroadcastStream");
			setChunkSize.setServiceName("chunkSize");
			if (setChunkSize.getServiceParamMap() == null) {
				setChunkSize.setServiceParamMap(new HashMap<String, Object>());
			}
			setChunkSize.getServiceParamMap().put("chunkSize", chunkSize.getSize());
			scope.sendOOBControlMessage((IConsumer) null, setChunkSize);
			log.debug("Sending chunksize {} to {}", chunkSize, bs.getProvider());
		}
	}
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:23,代码来源:RTMPHandler.java


示例9: messageReceived

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void messageReceived(IoSession session, Object in) {
	if (log.isDebugEnabled()) {
		if (in instanceof IoBuffer) {
			log.debug("Handskake");
			return;
		}
		try {
			final Packet packet = (Packet) in;
			final Object message = packet.getMessage();
			final Header source = packet.getHeader();

			log.debug("{}", source);
			log.debug("{}", message);
		} catch (RuntimeException e) {
			log.error("Exception", e);
		}
	}
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:21,代码来源:DebugProxyHandler.java


示例10: buildVideoFrame

import org.red5.server.net.rtmp.message.Header; //导入依赖的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


示例11: notifyBroadcastStart

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
/**
 * Notifies handler on stream broadcast start
 */
private void notifyBroadcastStart() {
    IStreamAwareScopeHandler handler = getStreamAwareHandler();
    if (handler != null) {
        try {
            handler.streamBroadcastStart(this);
        } catch (Throwable t) {
            log.error("Error in notifyBroadcastStart", t);
        }
    }
    // send metadata for creation and start dates
    IoBuffer buf = IoBuffer.allocate(256);
    buf.setAutoExpand(true);
    Output out = new Output(buf);
    out.writeString("onMetaData");
    Map<Object, Object> params = new HashMap<>();
    Calendar cal = GregorianCalendar.getInstance();
    cal.setTimeInMillis(creationTime);
    params.put("creationdate", ZonedDateTime.ofInstant(cal.toInstant(), ZoneId.of("UTC")).format(DateTimeFormatter.ISO_INSTANT));
    cal.setTimeInMillis(startTime);
    params.put("startdate", ZonedDateTime.ofInstant(cal.toInstant(), ZoneId.of("UTC")).format(DateTimeFormatter.ISO_INSTANT));
    if (log.isDebugEnabled()) {
        log.debug("Params: {}", params);
    }
    out.writeMap(params);
    buf.flip();
    Notify notify = new Notify(buf);
    notify.setAction("onMetaData");
    notify.setHeader(new Header());
    notify.getHeader().setDataType(Notify.TYPE_STREAM_METADATA);
    notify.getHeader().setStreamId(0);
    notify.setTimestamp(0);
    dispatchEvent(notify);
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:37,代码来源:ClientBroadcastStream.java


示例12: calculateHeaderSize

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
/**
 * Calculate number of bytes necessary to encode the header.
 * 
 * @param header
 *            RTMP message header
 * @param lastHeader
 *            Previous header
 * @return Calculated size
 */
private int calculateHeaderSize(final Header header, final Header lastHeader) {
    final byte headerType = getHeaderType(header, lastHeader);
    int channelIdAdd = 0;
    int channelId = header.getChannelId();
    if (channelId > 320) {
        channelIdAdd = 2;
    } else if (channelId > 63) {
        channelIdAdd = 1;
    }
    return RTMPUtils.getHeaderLength(headerType) + channelIdAdd;
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:21,代码来源:RTMPProtocolEncoder.java


示例13: onChunkSize

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void onChunkSize(RTMPConnection conn, Channel channel, Header source, ChunkSize chunkSize) {
    int requestedChunkSize = chunkSize.getSize();
    log.debug("Chunk size: {}", requestedChunkSize);
    // set chunk size on the connection
    RTMP state = conn.getState();
    // set only the read chunk size since it came from the client
    state.setReadChunkSize(requestedChunkSize);
    //state.setWriteChunkSize(requestedChunkSize);
    // set on each of the streams
    for (IClientStream stream : conn.getStreams()) {
        if (stream instanceof IClientBroadcastStream) {
            IClientBroadcastStream bs = (IClientBroadcastStream) stream;
            IBroadcastScope scope = bs.getScope().getBroadcastScope(bs.getPublishedName());
            if (scope == null) {
                continue;
            }
            OOBControlMessage setChunkSize = new OOBControlMessage();
            setChunkSize.setTarget("ClientBroadcastStream");
            setChunkSize.setServiceName("chunkSize");
            if (setChunkSize.getServiceParamMap() == null) {
                setChunkSize.setServiceParamMap(new HashMap<String, Object>());
            }
            setChunkSize.getServiceParamMap().put("chunkSize", requestedChunkSize);
            scope.sendOOBControlMessage((IConsumer) null, setChunkSize);
            log.debug("Sending chunksize {} to {}", chunkSize, bs.getProvider());
        }
    }
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:31,代码来源:RTMPHandler.java


示例14: onPing

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void onPing(RTMPConnection conn, Channel channel, Header source, Ping ping) {
    switch (ping.getEventType()) {
        case Ping.CLIENT_BUFFER:
            SetBuffer setBuffer = (SetBuffer) ping;
            // get the stream id
            int streamId = setBuffer.getStreamId();
            // get requested buffer size in milliseconds
            int buffer = setBuffer.getBufferLength();
            log.debug("Client sent a buffer size: {} ms for stream id: {}", buffer, streamId);
            IClientStream stream = null;
            if (streamId != 0) {
                // The client wants to set the buffer time
                stream = conn.getStreamById(streamId);
                if (stream != null) {
                    stream.setClientBufferDuration(buffer);
                    log.trace("Stream type: {}", stream.getClass().getName());
                }
            }
            //catch-all to make sure buffer size is set
            if (stream == null) {
                // Remember buffer time until stream is created
                conn.rememberStreamBufferDuration(streamId, buffer);
                log.debug("Remembering client buffer on stream: {}", buffer);
            }
            break;
        case Ping.PONG_SERVER:
            // This is the response to an IConnection.ping request
            conn.pingReceived(ping);
            break;
        default:
            log.warn("Unhandled ping: {}", ping);
    }
}
 
开发者ID:Red5,项目名称:red5-server-common,代码行数:36,代码来源:RTMPHandler.java


示例15: getAVCDecoderConfig

import org.red5.server.net.rtmp.message.Header; //导入依赖的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


示例16: handleBadRequest

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
/**
 * Return an error message to the client.
 * 
 * @param message
 *            Message
 * @param resp
 *            Servlet response
 * @throws IOException
 *             on IO error
 */
protected void handleBadRequest(String message, HttpServletResponse resp) throws IOException {
    log.debug("handleBadRequest {}", message);
    //		resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    //		resp.setHeader("Connection", "Keep-Alive");
    //		resp.setHeader("Cache-Control", "no-cache");
    //		resp.setContentType("text/plain");
    //		resp.setContentLength(message.length());
    //		resp.getWriter().write(message);
    //		resp.flushBuffer();

    // create and send a rejected status
    Status status = new Status(StatusCodes.NC_CONNECT_REJECTED, Status.ERROR, message);
    PendingCall call = new PendingCall(null, "onStatus", new Object[] { status });
    Invoke event = new Invoke();
    event.setCall(call);
    Header header = new Header();
    Packet packet = new Packet(header, event);
    header.setDataType(event.getDataType());
    // create dummy connection if local is empty
    RTMPConnection conn = (RTMPConnection) Red5.getConnectionLocal();
    if (conn == null) {
        try {
            conn = ((RTMPConnManager) manager).createConnectionInstance(RTMPTConnection.class);
            Red5.setConnectionLocal(conn);
        } catch (Exception e) {
        }
    }
    // encode the data
    RTMPProtocolEncoder encoder = new RTMPProtocolEncoder();
    IoBuffer out = encoder.encodePacket(packet);
    // send the response
    returnMessage(null, out, resp);
    // clear local
    Red5.setConnectionLocal(null);
}
 
开发者ID:Red5,项目名称:red5-server,代码行数:46,代码来源:RTMPTServlet.java


示例17: onChunkSize

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected void onChunkSize(RTMPConnection conn, Channel channel, Header source, ChunkSize chunkSize) {
    log.debug("onChunkSize");
    // set read and write chunk sizes
    RTMP state = conn.getState();
    state.setReadChunkSize(chunkSize.getSize());
    state.setWriteChunkSize(chunkSize.getSize());
    log.info("ChunkSize is not fully implemented: {}", chunkSize);
}
 
开发者ID:Red5,项目名称:red5-client,代码行数:11,代码来源:BaseRTMPClientHandler.java


示例18: onCommand

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected void onCommand(RTMPConnection conn, Channel channel, Header header, Notify notify) {
    super.onCommand(conn, channel, header, notify);
    System.out.println("onInvoke - header: " + header.toString() + " notify: " + notify.toString());
    Object obj = notify.getCall().getArguments().length > 0 ? notify.getCall().getArguments()[0] : null;
    if (obj instanceof Map) {
        Map<String, String> map = (Map<String, String>) obj;
        String code = map.get("code");
        if (StatusCodes.NS_PLAY_STOP.equals(code)) {
            finished = true;
            disconnect();
            System.out.println("Disconnected");
        }
    }
}
 
开发者ID:Red5,项目名称:red5-client,代码行数:16,代码来源:ClientTest.java


示例19: getHeaderType

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
/**
 * Determine type of header to use.
 * 
 * @param rtmp        The protocol state
 * @param header      RTMP message header
 * @param lastHeader  Previous header
 * @return            Header type to use.
 */
private byte getHeaderType(final RTMP rtmp, final Header header, final Header lastHeader) {
	if (lastHeader == null) {
		return HEADER_NEW;
	}
	final Integer lastFullTs = rtmp.getLastFullTimestampWritten(header.getChannelId());
	if (lastFullTs == null) {
		return HEADER_NEW;
	}
	final byte headerType;
	final long diff = RTMPUtils.diffTimestamps(header.getTimer(), lastHeader.getTimer());
	final long timeSinceFullTs = RTMPUtils.diffTimestamps(header.getTimer(), lastFullTs);
	if (header.getStreamId() != lastHeader.getStreamId() || diff < 0 || timeSinceFullTs >= 250) {
		// New header mark if header for another stream
		headerType = HEADER_NEW;
	} else if (header.getSize() != lastHeader.getSize() || header.getDataType() != lastHeader.getDataType()) {
		// Same source header if last header data type or size differ
		headerType = HEADER_SAME_SOURCE;
	} else if (header.getTimer() != lastHeader.getTimer() + lastHeader.getTimerDelta()) {
		// Timer change marker if there's time gap between header time stamps
		headerType = HEADER_TIMER_CHANGE;
	} else {
		// Continue encoding
		headerType = HEADER_CONTINUE;
	}
	return headerType;
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:35,代码来源:RTMPProtocolEncoder.java


示例20: calculateHeaderSize

import org.red5.server.net.rtmp.message.Header; //导入依赖的package包/类
/**
 * Calculate number of bytes necessary to encode the header.
 * 
 * @param rtmp        The protocol state
 * @param header      RTMP message header
 * @param lastHeader  Previous header
 * @return            Calculated size
 */
private int calculateHeaderSize(final RTMP rtmp, final Header header, final Header lastHeader) {
	final byte headerType = getHeaderType(rtmp, header, lastHeader);
	int channelIdAdd = 0;
	int channelId = header.getChannelId();
	if (channelId > 320) {
		channelIdAdd = 2;
	} else if (channelId > 63) {
		channelIdAdd = 1;
	}
	return RTMPUtils.getHeaderLength(headerType) + channelIdAdd;
}
 
开发者ID:cwpenhale,项目名称:red5-mobileconsole,代码行数:20,代码来源:RTMPProtocolEncoder.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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