本文整理汇总了Java中org.red5.server.api.stream.StreamState类的典型用法代码示例。如果您正苦于以下问题:Java StreamState类的具体用法?Java StreamState怎么用?Java StreamState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StreamState类属于org.red5.server.api.stream包,在下文中一共展示了StreamState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.red5.server.api.stream.StreamState; //导入依赖的package包/类
/**
* Starts stream, creates pipes, connects
*/
public void start() {
//log.info("Stream start: {}", publishedName);
checkVideoCodec = true;
checkAudioCodec = true;
firstPacketTime = -1;
latestTimeStamp = -1;
bytesReceived = 0;
IConsumerService consumerManager = (IConsumerService) getScope().getContext().getBean(IConsumerService.KEY);
connMsgOut = consumerManager.getConsumerOutput(this);
if (connMsgOut != null && connMsgOut.subscribe(this, null)) {
// technically this would be a 'start' time
startTime = System.currentTimeMillis();
closed = false;
} else {
log.warn("Subscribe failed");
}
setState(StreamState.STARTED);
}
示例2: start
import org.red5.server.api.stream.StreamState; //导入依赖的package包/类
/**
* Start stream
*/
public void start() {
if (log.isDebugEnabled()) {
log.debug("start - subscriber stream state: {}", (subscriberStream != null ? subscriberStream.getState() : null));
}
switch (subscriberStream.getState()) {
case UNINIT:
// allow start if uninitialized and change state to stopped
subscriberStream.setState(StreamState.STOPPED);
IMessageOutput out = consumerService.getConsumerOutput(subscriberStream);
if (msgOutReference.compareAndSet(null, out)) {
out.subscribe(this, null);
} else if (log.isDebugEnabled()) {
log.debug("Message output was already set for stream: {}", subscriberStream);
}
break;
default:
throw new IllegalStateException(String.format("Cannot start in current state: %s", subscriberStream.getState()));
}
}
示例3: pause
import org.red5.server.api.stream.StreamState; //导入依赖的package包/类
/**
* Pause at position
*
* @param position
* Position in file
* @throws IllegalStateException
* If stream is stopped
*/
public void pause(int position) throws IllegalStateException {
// allow pause if playing or stopped
switch (subscriberStream.getState()) {
case PLAYING:
case STOPPED:
subscriberStream.setState(StreamState.PAUSED);
clearWaitJobs();
sendPauseStatus(currentItem);
sendClearPing();
subscriberStream.onChange(StreamState.PAUSED, currentItem, position);
break;
default:
throw new IllegalStateException("Cannot pause in current state");
}
}
示例4: close
import org.red5.server.api.stream.StreamState; //导入依赖的package包/类
/** {@inheritDoc} */
public void close() {
if (log.isDebugEnabled()) {
log.debug("close");
}
if (engine != null) {
// before or on close we may need to allow the queued messages a chance to clear
engine.close();
onChange(StreamState.CLOSED);
items.clear();
// clear jobs
if (schedulingService != null && !jobs.isEmpty()) {
for (String jobName : jobs) {
schedulingService.removeScheduledJob(jobName);
}
jobs.clear();
}
}
}
示例5: start
import org.red5.server.api.stream.StreamState; //导入依赖的package包/类
/**
* Start this server-side stream
*/
public void start() {
if (state != StreamState.UNINIT) {
throw new IllegalStateException("State " + state + " not valid to start");
}
if (items.size() == 0) {
throw new IllegalStateException("At least one item should be specified to start");
}
if (publishedName == null) {
throw new IllegalStateException("A published name is needed to start");
}
try {
IScope scope = getScope();
IContext context = scope.getContext();
providerService = (IProviderService) context.getBean(IProviderService.BEAN_NAME);
// publish this server-side stream
providerService.registerBroadcastStream(scope, publishedName, this);
scheduler = (ISchedulingService) context.getBean(ISchedulingService.BEAN_NAME);
} catch (NullPointerException npe) {
log.warn("Context beans were not available; this is ok during unit testing", npe);
}
setState(StreamState.STOPPED);
currentItemIndex = -1;
nextItem();
}
示例6: stop
import org.red5.server.api.stream.StreamState; //导入依赖的package包/类
/**
* Stop this server-side stream
*/
public void stop() {
if (state == StreamState.PLAYING || state == StreamState.PAUSED) {
if (liveJobName != null) {
scheduler.removeScheduledJob(liveJobName);
liveJobName = null;
}
if (vodJobName != null) {
scheduler.removeScheduledJob(vodJobName);
vodJobName = null;
}
if (msgIn != null) {
msgIn.unsubscribe(this);
msgIn = null;
}
if (nextRTMPMessage != null) {
nextRTMPMessage.getBody().release();
}
stopRecording();
setState(StreamState.STOPPED);
}
}
示例7: start
import org.red5.server.api.stream.StreamState; //导入依赖的package包/类
/**
* Start stream
*/
public void start() {
switch (subscriberStream.getState()) {
case UNINIT:
// allow start if uninitialized
// change state to stopped
subscriberStream.setState(StreamState.STOPPED);
if (msgOut == null) {
msgOut = consumerService.getConsumerOutput(subscriberStream);
msgOut.subscribe(this, null);
}
break;
default:
throw new IllegalStateException(String.format("Cannot start in current state: %s", subscriberStream.getState()));
}
}
示例8: pause
import org.red5.server.api.stream.StreamState; //导入依赖的package包/类
/**
* Pause at position
*
* @param position Position in file
* @throws IllegalStateException If stream is stopped
*/
public void pause(int position) throws IllegalStateException {
switch (subscriberStream.getState()) {
// allow pause if playing or stopped
case PLAYING:
case STOPPED:
subscriberStream.setState(StreamState.PAUSED);
clearWaitJobs();
sendClearPing();
sendPauseStatus(currentItem);
subscriberStream.onChange(StreamState.PAUSED, currentItem, position);
break;
default:
throw new IllegalStateException("Cannot pause in current state");
}
}
示例9: close
import org.red5.server.api.stream.StreamState; //导入依赖的package包/类
/**
* Close stream
*/
public void close() {
if (!subscriberStream.getState().equals(StreamState.CLOSED)) {
if (msgIn != null) {
msgIn.unsubscribe(this);
msgIn = null;
}
subscriberStream.setState(StreamState.CLOSED);
clearWaitJobs();
releasePendingMessage();
lastMessageTs = 0;
sendClearPing();
} else {
log.debug("Stream is already in closed state");
}
}
示例10: stop
import org.red5.server.api.stream.StreamState; //导入依赖的package包/类
/**
* Stop this server-side stream
*/
public void stop() {
if (state == StreamState.PLAYING || state == StreamState.PAUSED) {
if (liveJobName != null) {
scheduler.removeScheduledJob(liveJobName);
liveJobName = null;
}
if (vodJobName != null) {
scheduler.removeScheduledJob(vodJobName);
vodJobName = null;
}
if (msgIn != null) {
msgIn.unsubscribe(this);
msgIn = null;
}
if (nextRTMPMessage != null) {
nextRTMPMessage.getBody().release();
}
setState(StreamState.STOPPED);
}
}
示例11: close
import org.red5.server.api.stream.StreamState; //导入依赖的package包/类
/**
* Closes stream, unsubscribes provides, sends stoppage notifications and broadcast close notification.
*/
public void close() {
//log.debug("Stream close: {}", publishedName);
if (closed) {
//log.debug("{} already closed", publishedName);
return;
}
closed = true;
if (livePipe != null) {
livePipe.unsubscribe((IProvider) this);
}
// if we have a recording listener, inform that this stream is done
if (recordingListener != null) {
sendRecordStopNotify();
notifyRecordingStop();
// inform the listener to finish and close
recordingListener.get().stop();
}
sendPublishStopNotify();
// TODO: can we send the client something to make sure he stops sending data?
if (connMsgOut != null) {
connMsgOut.unsubscribe(this);
}
notifyBroadcastClose();
// clear the listener after all the notifications have been sent
if (recordingListener != null) {
recordingListener.clear();
}
// clear listeners
if (!listeners.isEmpty()) {
listeners.clear();
}
// deregister with jmx
unregisterJMX();
setState(StreamState.CLOSED);
}
示例12: sendPublishStartNotify
import org.red5.server.api.stream.StreamState; //导入依赖的package包/类
/**
* Sends publish start notifications
*/
private void sendPublishStartNotify() {
Status publishStatus = new Status(StatusCodes.NS_PUBLISH_START);
publishStatus.setClientid(getStreamId());
publishStatus.setDetails(getPublishedName());
StatusMessage startMsg = new StatusMessage();
startMsg.setBody(publishStatus);
pushMessage(startMsg);
setState(StreamState.PUBLISHING);
}
示例13: sendPublishStopNotify
import org.red5.server.api.stream.StreamState; //导入依赖的package包/类
/**
* Sends publish stop notifications
*/
private void sendPublishStopNotify() {
Status stopStatus = new Status(StatusCodes.NS_UNPUBLISHED_SUCCESS);
stopStatus.setClientid(getStreamId());
stopStatus.setDetails(getPublishedName());
StatusMessage stopMsg = new StatusMessage();
stopMsg.setBody(stopStatus);
pushMessage(stopMsg);
setState(StreamState.STOPPED);
}
示例14: stop
import org.red5.server.api.stream.StreamState; //导入依赖的package包/类
/** {@inheritDoc} */
public void stop() {
//log.info("Stream stop: {}", publishedName);
setState(StreamState.STOPPED);
stopRecording();
close();
}
示例15: close
import org.red5.server.api.stream.StreamState; //导入依赖的package包/类
public void close() {
engine.close();
onChange(StreamState.CLOSED);
// clear jobs
if (schedulingService != null && !jobs.isEmpty()) {
for (String jobName : jobs) {
schedulingService.removeScheduledJob(jobName);
}
jobs.clear();
}
}