本文整理汇总了Java中org.red5.server.api.stream.IClientBroadcastStream类的典型用法代码示例。如果您正苦于以下问题:Java IClientBroadcastStream类的具体用法?Java IClientBroadcastStream怎么用?Java IClientBroadcastStream使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IClientBroadcastStream类属于org.red5.server.api.stream包,在下文中一共展示了IClientBroadcastStream类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initStream
import org.red5.server.api.stream.IClientBroadcastStream; //导入依赖的package包/类
/** {@inheritDoc} */
public void initStream(Number streamId) {
IConnection conn = Red5.getConnectionLocal();
log.info("initStream stream id: {} current stream id: {} connection: {}", streamId, conn.getStreamId(), conn.getSessionId());
if (conn instanceof IStreamCapableConnection) {
((IStreamCapableConnection) conn).reserveStreamId(streamId);
IClientStream stream = ((IStreamCapableConnection) conn).getStreamById(streamId);
if (stream != null) {
if (stream instanceof IClientBroadcastStream) {
IClientBroadcastStream bs = (IClientBroadcastStream) stream;
IBroadcastScope bsScope = getBroadcastScope(conn.getScope(), bs.getPublishedName());
if (bsScope != null && conn instanceof BaseConnection) {
((BaseConnection) conn).unregisterBasicScope(bsScope);
}
}
stream.close();
}
((IStreamCapableConnection) conn).deleteStreamById(streamId);
} else {
log.warn("ERROR in initStream, connection is not stream capable");
}
}
示例2: initStream
import org.red5.server.api.stream.IClientBroadcastStream; //导入依赖的package包/类
/** {@inheritDoc} */
public void initStream(int streamId) {
IConnection conn = Red5.getConnectionLocal();
if (conn instanceof IStreamCapableConnection) {
((IStreamCapableConnection) conn).reserveStreamId(streamId);
IClientStream stream = ((IStreamCapableConnection) conn).getStreamById(getCurrentStreamId());
if (stream != null) {
if (stream instanceof IClientBroadcastStream) {
IClientBroadcastStream bs = (IClientBroadcastStream) stream;
IBroadcastScope bsScope = getBroadcastScope(conn.getScope(), bs.getPublishedName());
if (bsScope != null && conn instanceof BaseConnection) {
((BaseConnection) conn).unregisterBasicScope(bsScope);
}
}
stream.close();
}
((IStreamCapableConnection) conn).deleteStreamById(getCurrentStreamId());
} else {
log.warn("ERROR in intiStream, connection is not stream capable");
}
}
示例3: newBroadcastStream
import org.red5.server.api.stream.IClientBroadcastStream; //导入依赖的package包/类
/** {@inheritDoc} */
public IClientBroadcastStream newBroadcastStream(int streamId) {
if (isValidStreamId(streamId)) {
// get ClientBroadcastStream defined as a prototype in red5-common.xml
ClientBroadcastStream cbs = (ClientBroadcastStream) scope.getContext().getBean("clientBroadcastStream");
Integer buffer = streamBuffers.get(streamId - 1);
if (buffer != null) {
cbs.setClientBufferDuration(buffer);
}
cbs.setStreamId(streamId);
cbs.setConnection(this);
cbs.setName(createStreamName());
cbs.setScope(this.getScope());
registerStream(cbs);
usedStreams.incrementAndGet();
return cbs;
}
return null;
}
示例4: onChunkSize
import org.red5.server.api.stream.IClientBroadcastStream; //导入依赖的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());
}
}
}
示例5: deleteStream
import org.red5.server.api.stream.IClientBroadcastStream; //导入依赖的package包/类
/** {@inheritDoc} */
public void deleteStream(IStreamCapableConnection conn, Number streamId) {
IClientStream stream = conn.getStreamById(streamId);
if (stream != null) {
if (stream instanceof IClientBroadcastStream) {
IClientBroadcastStream bs = (IClientBroadcastStream) stream;
IBroadcastScope bsScope = getBroadcastScope(conn.getScope(), bs.getPublishedName());
if (bsScope != null && conn instanceof BaseConnection) {
((BaseConnection) conn).unregisterBasicScope(bsScope);
}
}
stream.close();
}
conn.unreserveStreamId(streamId);
}
示例6: newBroadcastStream
import org.red5.server.api.stream.IClientBroadcastStream; //导入依赖的package包/类
/** {@inheritDoc} */
public IClientBroadcastStream newBroadcastStream(Number streamId) {
if (isValidStreamId(streamId)) {
// get ClientBroadcastStream defined as a prototype in red5-common.xml
ClientBroadcastStream cbs = (ClientBroadcastStream) scope.getContext().getBean("clientBroadcastStream");
customizeStream(streamId, cbs);
if (!registerStream(cbs)) {
cbs = null;
}
return cbs;
}
return null;
}
示例7: onChunkSize
import org.red5.server.api.stream.IClientBroadcastStream; //导入依赖的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());
}
}
}
示例8: setClientBroadcastStream
import org.red5.server.api.stream.IClientBroadcastStream; //导入依赖的package包/类
/**
* Sets the client broadcast stream
*
* @param clientBroadcastStream
* stream
*/
public void setClientBroadcastStream(IClientBroadcastStream clientBroadcastStream) {
if (this.clientBroadcastStream != null) {
log.info("ClientBroadcastStream already exists: {} new: {}", this.clientBroadcastStream, clientBroadcastStream);
}
this.clientBroadcastStream = clientBroadcastStream;
}
示例9: deleteStream
import org.red5.server.api.stream.IClientBroadcastStream; //导入依赖的package包/类
/** {@inheritDoc} */
public void deleteStream(IStreamCapableConnection conn, int streamId) {
IClientStream stream = conn.getStreamById(streamId);
if (stream != null) {
if (stream instanceof IClientBroadcastStream) {
IClientBroadcastStream bs = (IClientBroadcastStream) stream;
IBroadcastScope bsScope = getBroadcastScope(conn.getScope(), bs.getPublishedName());
if (bsScope != null && conn instanceof BaseConnection) {
((BaseConnection) conn).unregisterBasicScope(bsScope);
}
}
stream.close();
}
conn.unreserveStreamId(streamId);
}
示例10: getClientBroadcastStream
import org.red5.server.api.stream.IClientBroadcastStream; //导入依赖的package包/类
/**
* Returns the client broadcast stream
*/
public IClientBroadcastStream getClientBroadcastStream() {
return clientBroadcastStream;
}
示例11: getClientBroadcastStream
import org.red5.server.api.stream.IClientBroadcastStream; //导入依赖的package包/类
/**
* Returns the client broadcast stream
*/
public IClientBroadcastStream getClientBroadcastStream() {
return clientBroadcastStream;
}
示例12: closeStream
import org.red5.server.api.stream.IClientBroadcastStream; //导入依赖的package包/类
/**
* Close stream. This method can close both IClientBroadcastStream (coming from Flash Player to Red5) and ISubscriberStream (from Red5
* to Flash Player). Corresponding application handlers (streamSubscriberClose, etc.) are called as if close was initiated by Flash
* Player.
*
* It is recommended to remember stream id in application handlers, ex.:
*
* <pre>
* public void streamBroadcastStart(IBroadcastStream stream) {
* super.streamBroadcastStart(stream);
* if (stream instanceof IClientBroadcastStream) {
* int publishedStreamId = ((ClientBroadcastStream) stream).getStreamId();
* Red5.getConnectionLocal().setAttribute(PUBLISHED_STREAM_ID_ATTRIBUTE, publishedStreamId);
* }
* }
* </pre>
*
* <pre>
* public void streamPlaylistItemPlay(IPlaylistSubscriberStream stream, IPlayItem item, boolean isLive) {
* super.streamPlaylistItemPlay(stream, item, isLive);
* Red5.getConnectionLocal().setAttribute(WATCHED_STREAM_ID_ATTRIBUTE, stream.getStreamId());
* }
* </pre>
*
* When stream is closed, corresponding NetStream status will be sent to stream provider / consumers. Implementation is based on Red5's
* StreamService.close()
*
* @param conn
* client connection
* @param streamId
* stream ID (number: 1,2,...)
*/
public void closeStream(IConnection conn, Number streamId) {
log.info("closeStream stream id: {} connection: {}", streamId, conn.getSessionId());
if (conn instanceof IStreamCapableConnection) {
IStreamCapableConnection scConn = (IStreamCapableConnection) conn;
IClientStream stream = scConn.getStreamById(streamId);
if (stream != null) {
if (stream instanceof IClientBroadcastStream) {
// this is a broadcasting stream (from Flash Player to Red5)
IClientBroadcastStream bs = (IClientBroadcastStream) stream;
IBroadcastScope bsScope = getBroadcastScope(conn.getScope(), bs.getPublishedName());
if (bsScope != null && conn instanceof BaseConnection) {
((BaseConnection) conn).unregisterBasicScope(bsScope);
}
}
stream.close();
scConn.deleteStreamById(streamId);
// in case of broadcasting stream, status is sent automatically by Red5
if (!(stream instanceof IClientBroadcastStream)) {
StreamService.sendNetStreamStatus(conn, StatusCodes.NS_PLAY_STOP, "Stream closed by server", stream.getName(), Status.STATUS, streamId);
}
} else {
log.info("Stream not found - streamId: {} connection: {}", streamId, conn.getSessionId());
}
} else {
log.warn("Connection is not instance of IStreamCapableConnection: {}", conn);
}
}
示例13: closeStream
import org.red5.server.api.stream.IClientBroadcastStream; //导入依赖的package包/类
/**
* Close stream.
* This method can close both IClientBroadcastStream (coming from Flash Player to Red5)
* and ISubscriberStream (from Red5 to Flash Player).
* Corresponding application handlers (streamSubscriberClose, etc.) are called as if close was initiated by Flash Player.
*
* It is recommended to remember stream id in application handlers, ex.:
* <pre>
* public void streamBroadcastStart(IBroadcastStream stream) {
* super.streamBroadcastStart(stream);
* if (stream instanceof IClientBroadcastStream) {
* int publishedStreamId = ((ClientBroadcastStream)stream).getStreamId();
* Red5.getConnectionLocal().setAttribute(PUBLISHED_STREAM_ID_ATTRIBUTE, publishedStreamId);
* }
* }
* </pre>
* <pre>
* public void streamPlaylistItemPlay(IPlaylistSubscriberStream stream, IPlayItem item, boolean isLive) {
* super.streamPlaylistItemPlay(stream, item, isLive);
* Red5.getConnectionLocal().setAttribute(WATCHED_STREAM_ID_ATTRIBUTE, stream.getStreamId());
* }
* </pre>
* When stream is closed, corresponding NetStream status will be sent to stream provider / consumers.
* Implementation is based on Red5's StreamService.close()
*
* @param connection client connection
* @param streamId stream ID (number: 1,2,...)
*/
public void closeStream(IConnection connection, int streamId) {
if (connection instanceof IStreamCapableConnection) {
IStreamCapableConnection scConnection = (IStreamCapableConnection) connection;
IClientStream stream = scConnection.getStreamById(streamId);
if (stream != null) {
if (stream instanceof IClientBroadcastStream) {
// this is a broadcasting stream (from Flash Player to Red5)
IClientBroadcastStream bs = (IClientBroadcastStream) stream;
IBroadcastScope bsScope = connection.getScope().getBroadcastScope(bs.getPublishedName());
if (bsScope != null && connection instanceof BaseConnection) {
((BaseConnection) connection).unregisterBasicScope(bsScope);
}
}
stream.close();
scConnection.deleteStreamById(streamId);
// in case of broadcasting stream, status is sent automatically by Red5
if (!(stream instanceof IClientBroadcastStream)) {
StreamService.sendNetStreamStatus(connection, StatusCodes.NS_PLAY_STOP, "Stream closed by server", stream.getName(), Status.STATUS, streamId);
}
} else {
log.info("Stream not found: streamId={}, connection={}", streamId, connection);
}
} else {
log.warn("Connection is not instance of IStreamCapableConnection: {}", connection);
}
}
示例14: setClientBroadcastStream
import org.red5.server.api.stream.IClientBroadcastStream; //导入依赖的package包/类
/**
* Sets the client broadcast stream
*
* @param clientBroadcastStream
*/
public void setClientBroadcastStream(IClientBroadcastStream clientBroadcastStream) {
this.clientBroadcastStream = clientBroadcastStream;
}
示例15: getClientBroadcastStream
import org.red5.server.api.stream.IClientBroadcastStream; //导入依赖的package包/类
public IClientBroadcastStream getClientBroadcastStream();