本文整理汇总了Java中org.red5.server.net.rtmp.message.Header.setDataType方法的典型用法代码示例。如果您正苦于以下问题:Java Header.setDataType方法的具体用法?Java Header.setDataType怎么用?Java Header.setDataType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.red5.server.net.rtmp.message.Header
的用法示例。
在下文中一共展示了Header.setDataType方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例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, 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);
}
示例3: 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);
}
示例4: testHeaders
import org.red5.server.net.rtmp.message.Header; //导入方法依赖的package包/类
public void testHeaders() {
RTMP rtmp = new RTMP();
Header header = new Header();
header.setChannelId((byte) 0x12);
header.setDataType(TYPE_INVOKE);
header.setStreamId(100);
header.setTimer(2);
header.setSize(320);
IoBuffer buf = encoder.encodeHeader(rtmp, header, null);
buf.flip();
log.debug(buf.getHexDump());
Assert.assertNotNull(buf);
Header result = decoder.decodeHeader(buf, null);
Assert.assertEquals(header, result);
}