org.red5.server.messaging.IPipe Java Examples
The following examples show how to use
org.red5.server.messaging.IPipe.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConnectionConsumer.java From red5-server-common with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ public void onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg) { if ("ConnectionConsumer".equals(oobCtrlMsg.getTarget())) { String serviceName = oobCtrlMsg.getServiceName(); log.trace("Service name: {}", serviceName); if ("pendingCount".equals(serviceName)) { oobCtrlMsg.setResult(conn.getPendingMessages()); } else if ("pendingVideoCount".equals(serviceName)) { IClientStream stream = conn.getStreamByChannelId(video.getId()); if (stream != null) { oobCtrlMsg.setResult(conn.getPendingVideoMessages(stream.getStreamId())); } else { oobCtrlMsg.setResult(0L); } } else if ("writeDelta".equals(serviceName)) { //TODO: Revisit the max stream value later long maxStream = 120 * 1024; // Return the current delta between sent bytes and bytes the client // reported to have received, and the interval the client should use // for generating BytesRead messages (half of the allowed bandwidth). oobCtrlMsg.setResult(new Long[] { conn.getWrittenBytes() - conn.getClientBytesRead(), maxStream / 2 }); } else if ("chunkSize".equals(serviceName)) { int newSize = (Integer) oobCtrlMsg.getServiceParamMap().get("chunkSize"); if (newSize != chunkSize) { chunkSize = newSize; chunkSizeSent.set(false); sendChunkSize(); } } } }
Example #2
Source File: ClientBroadcastStream.java From red5-server-common with Apache License 2.0 | 5 votes |
/** * Out-of-band control message handler * * @param source * OOB message source * @param pipe * Pipe that used to send OOB message * @param oobCtrlMsg * Out-of-band control message */ public void onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg) { String target = oobCtrlMsg.getTarget(); if ("ClientBroadcastStream".equals(target)) { String serviceName = oobCtrlMsg.getServiceName(); if ("chunkSize".equals(serviceName)) { chunkSize = (Integer) oobCtrlMsg.getServiceParamMap().get("chunkSize"); notifyChunkSize(); } else { log.debug("Unhandled OOB control message for service: {}", serviceName); } } else { log.debug("Unhandled OOB control message to target: {}", target); } }
Example #3
Source File: PlayEngine.java From red5-server-common with Apache License 2.0 | 5 votes |
/** {@inheritDoc} */ public void onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg) { if ("ConnectionConsumer".equals(oobCtrlMsg.getTarget())) { if (source instanceof IProvider) { IMessageOutput out = msgOutReference.get(); if (out != null) { out.sendOOBControlMessage((IProvider) source, oobCtrlMsg); } else { // this may occur when a client attempts to play and then disconnects log.warn("Output is not available, message cannot be sent"); close(); } } } }
Example #4
Source File: ICYStream.java From red5-rtsp-restreamer with Apache License 2.0 | 5 votes |
@Override public void onPipeConnectionEvent(PipeConnectionEvent event) { switch (event.getType()) { case PipeConnectionEvent.PROVIDER_CONNECT_PUSH: if ((event.getProvider() == this) && (event.getParamMap() == null)) { mLivePipe = (IPipe) event.getSource(); log.debug("mLivePipe {}", mLivePipe); for (@SuppressWarnings("unused") IConsumer consumer : mLivePipe.getConsumers()) { subscriberStats.increment(); } } break; case PipeConnectionEvent.PROVIDER_DISCONNECT: if (mLivePipe == event.getSource()) { mLivePipe = null; } break; case PipeConnectionEvent.CONSUMER_CONNECT_PUSH: if (mLivePipe != null) { List<IConsumer> consumers = mLivePipe.getConsumers(); int count = consumers.size(); if (count > 0) { newComsumers.add(consumers.get(count - 1)); } subscriberStats.increment(); } break; case PipeConnectionEvent.CONSUMER_DISCONNECT: subscriberStats.decrement(); break; default: break; } }
Example #5
Source File: StreamingProxy.java From red5-client with Apache License 2.0 | 5 votes |
@Override public void pushMessage(IPipe pipe, IMessage message) throws IOException { if (isPublished() && message instanceof RTMPMessage) { RTMPMessage rtmpMsg = (RTMPMessage) message; rtmpClient.publishStreamData(streamId, rtmpMsg); } else { log.trace("Adding message to buffer. Current size: {}", frameBuffer.size()); frameBuffer.add(message); } }
Example #6
Source File: SlicedFileConsumer.java From red5-server-common with Apache License 2.0 | 4 votes |
/** * Push message through pipe * * @param pipe * Pipe * @param message * Message to push * @throws IOException * if message could not be written */ @SuppressWarnings("rawtypes") public void pushMessage(IPipe pipe, IMessage message) throws IOException { if (message instanceof RTMPMessage) { final IRTMPEvent msg = ((RTMPMessage) message).getBody(); // get the type byte dataType = msg.getDataType(); // get the timestamp int timestamp = msg.getTimestamp(); log.trace("Data type: {} timestamp: {}", dataType, timestamp); // if writes are delayed, queue the data and sort it by time if (queue == null) { // if we plan to use a queue, create one queue = new PriorityQueue<QueuedMediaData>(queueThreshold <= 0 ? 11 : queueThreshold); } QueuedMediaData queued = null; if (msg instanceof IStreamData) { if (log.isTraceEnabled()) { log.trace("Stream data, body saved. Data type: {} class type: {}", dataType, msg.getClass().getName()); } // ensure that our first video frame written is a key frame if (msg instanceof VideoData) { log.debug("pushMessage video - waitForVideoKeyframe: {} gotVideoKeyframe: {}", waitForVideoKeyframe, gotVideoKeyframe); if (!gotVideoKeyframe) { VideoData video = (VideoData) msg; if (video.getFrameType() == FrameType.KEYFRAME) { log.debug("Got our first keyframe"); gotVideoKeyframe = true; } if (waitForVideoKeyframe && !gotVideoKeyframe) { // skip this frame bail out log.debug("Skipping video data since keyframe has not been written yet"); return; } } } queued = new QueuedMediaData(timestamp, dataType, (IStreamData) msg); } else { // XXX what type of message are we saving that has no body data?? if (log.isTraceEnabled()) { log.trace("Non-stream data, body not saved. Data type: {} class type: {}", dataType, msg.getClass().getName()); } queued = new QueuedMediaData(timestamp, dataType); } if (queued != null) { writeLock.lock(); try { // add to the queue queue.add(queued); } finally { writeLock.unlock(); } } int queueSize = 0; readLock.lock(); try { queueSize = queue.size(); } finally { readLock.unlock(); } // initialize a writer if (writer == null) { init(); if (msg instanceof VideoData) { writeQueuedDataSlice(createTimestampLimitedSlice(msg.getTimestamp())); } else if (queueThreshold >= 0 && queueSize >= queueThreshold) { writeQueuedDataSlice(createFixedLengthSlice(queueThreshold / (100 / percentage))); } } } else if (message instanceof ResetMessage) { startTimestamp = -1; } else if (log.isDebugEnabled()) { log.debug("Ignoring pushed message: {}", message); } }
Example #7
Source File: ClientBroadcastStream.java From red5-server-common with Apache License 2.0 | 4 votes |
/** * Pipe connection event handler * * @param event * Pipe connection event */ @SuppressWarnings("unused") public void onPipeConnectionEvent(PipeConnectionEvent event) { switch (event.getType()) { case PROVIDER_CONNECT_PUSH: //log.debug("Provider connect"); if (event.getProvider() == this && event.getSource() != connMsgOut && (event.getParamMap() == null || !event.getParamMap().containsKey("record"))) { livePipe = (IPipe) event.getSource(); //log.debug("Provider: {}", livePipe.getClass().getName()); for (IConsumer consumer : livePipe.getConsumers()) { subscriberStats.increment(); } } break; case PROVIDER_DISCONNECT: //log.debug("Provider disconnect"); //if (log.isDebugEnabled() && livePipe != null) { //log.debug("Provider: {}", livePipe.getClass().getName()); //} if (livePipe == event.getSource()) { livePipe = null; } break; case CONSUMER_CONNECT_PUSH: //log.debug("Consumer connect"); IPipe pipe = (IPipe) event.getSource(); //if (log.isDebugEnabled() && pipe != null) { //log.debug("Consumer: {}", pipe.getClass().getName()); //} if (livePipe == pipe) { notifyChunkSize(); } subscriberStats.increment(); break; case CONSUMER_DISCONNECT: //log.debug("Consumer disconnect: {}", event.getSource().getClass().getName()); subscriberStats.decrement(); break; default: } }
Example #8
Source File: StreamingProxy.java From red5-client with Apache License 2.0 | 4 votes |
@Override public void onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg) { log.debug("onOOBControlMessage: {}", oobCtrlMsg); }
Example #9
Source File: SlicedFileConsumer.java From red5-server-common with Apache License 2.0 | 2 votes |
/** * Out-of-band control message handler * * @param source * Source of message * @param pipe * Pipe that is used to transmit OOB message * @param oobCtrlMsg * OOB control message */ public void onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg) { }
Example #10
Source File: FileConsumer.java From red5-server-common with Apache License 2.0 | 2 votes |
/** * Out-of-band control message handler * * @param source * Source of message * @param pipe * Pipe that is used to transmit OOB message * @param oobCtrlMsg * OOB control message */ public void onOOBControlMessage(IMessageComponent source, IPipe pipe, OOBControlMessage oobCtrlMsg) { }
Example #11
Source File: ClientBroadcastStream.java From red5-server-common with Apache License 2.0 | 2 votes |
/** * Currently not implemented * * @param pipe * Pipe * @param message * Message */ public void pushMessage(IPipe pipe, IMessage message) { }
Example #12
Source File: ICYStream.java From red5-rtsp-restreamer with Apache License 2.0 | 2 votes |
@Override public void onOOBControlMessage(IMessageComponent arg0, IPipe arg1, OOBControlMessage arg2) { }