Package org.red5.server.api.stream

Examples of org.red5.server.api.stream.IStreamCapableConnection


    // ------------------------------------------------------------------------

    private void createPlayStream( IPendingServiceCallback callback ) {

        logger.debug( "create play stream" );
        IPendingServiceCallback wrapper = new CreatePlayStreamCallBack( callback );
        invoke( "createStream", null, wrapper );
    }
View Full Code Here


public class DummyConsumerService implements IConsumerService {

  /** {@inheritDoc} */
  public IMessageOutput getConsumerOutput(IClientStream stream) {
    IStreamCapableConnection streamConn = stream.getConnection();
    if (streamConn != null) {
      Channel data = new Channel(null, 4);
      Channel video = new Channel(null, 5);
      Channel audio = new Channel(null, 6);
      IPipe pipe = new InMemoryPushPushPipe();
View Full Code Here

   * @throws IOException           File could not be created/written to
   */
  public void saveAs(String name, boolean isAppend) throws IOException {
    log.debug("SaveAs - name: {} append: {}", name, isAppend);
    // get connection to check if client is still streaming
    IStreamCapableConnection conn = getConnection();
    if (conn == null) {
      throw new IOException("Stream is no longer connected");
    }
    // one recording listener at a time via this entry point
    if (recordingListener == null) {
View Full Code Here

    }
    return null;
  }

  public Map<String, Object> checkBandwidth(Object[] params) {
    final IStreamCapableConnection stats = getStats();
    Map<String, Object> statsValues = new HashMap<String, Object>();
    Integer time = (Integer) (params.length > 0 ? params[0] : 0);
    statsValues.put("cOutBytes", stats.getReadBytes());
    statsValues.put("cInBytes", stats.getWrittenBytes());
    statsValues.put("time", time);
    log.debug("cOutBytes: {} cInBytes: {} time: {}", new Object[] { stats.getReadBytes(), stats.getWrittenBytes(), time });
    return statsValues;
  }
View Full Code Here

*/
public class ConsumerService implements IConsumerService {

  /** {@inheritDoc} */
    public IMessageOutput getConsumerOutput(IClientStream stream) {
    IStreamCapableConnection streamConn = stream.getConnection();
    if (streamConn != null && streamConn instanceof RTMPConnection) {
      RTMPConnection conn = (RTMPConnection) streamConn;
      // TODO Better manage channels.
      // now we use OutputStream as a channel wrapper.
      OutputStream o = conn.createOutputStream(stream.getStreamId());
View Full Code Here

   * @param streamId stream ID (number: 1,2,...)
   */
  public void closeStream(IConnection conn, int streamId) {
    log.info("closeStream: streamId={}, connection={}", streamId, conn);
    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 {
View Full Code Here

  /** {@inheritDoc} */
  public void deleteStream(int streamId) {
    IConnection conn = Red5.getConnectionLocal();
    if (conn instanceof IStreamCapableConnection) {
      IStreamCapableConnection streamConn = (IStreamCapableConnection) conn;
      deleteStream(streamConn, streamId);
    }
  }
View Full Code Here

   * @param position              Pause position
   */
  public void pause(Boolean pausePlayback, int position) {
    IConnection conn = Red5.getConnectionLocal();
    if (conn instanceof IStreamCapableConnection) {
      IStreamCapableConnection streamConn = (IStreamCapableConnection) conn;
      int streamId = conn.getStreamId();
      IClientStream stream = streamConn.getStreamById(streamId);
      if (stream != null && stream instanceof ISubscriberStream) {
        ISubscriberStream subscriberStream = (ISubscriberStream) stream;
        // pausePlayback can be "null" if "pause" is called without any parameters from flash
        if (pausePlayback == null) {
          pausePlayback = !subscriberStream.isPaused();
View Full Code Here

      if (reset instanceof Integer) {
        int value = (Integer) reset;
        switch (value) {
          case 0:
            //adds the stream to a playlist
            IStreamCapableConnection streamConn = (IStreamCapableConnection) Red5.getConnectionLocal();
            IPlaylistSubscriberStream playlistStream = (IPlaylistSubscriberStream) streamConn.getStreamById(streamConn.getStreamId());
            IPlayItem item = SimplePlayItem.build(name);
            playlistStream.addItem(item);
            play(name, start, length, false);
            break;
          case 2:
View Full Code Here

  public void play(String name, int start, int length, boolean flushPlaylist) {
    log.debug("Play called - name: {} start: {} length: {} flush playlist: {}", new Object[] { name, start, length, flushPlaylist });
    IConnection conn = Red5.getConnectionLocal();
    if (conn instanceof IStreamCapableConnection) {
      IScope scope = conn.getScope();
      IStreamCapableConnection streamConn = (IStreamCapableConnection) conn;
      int streamId = conn.getStreamId();
      if (StringUtils.isEmpty(name)) {
        sendNSFailed(streamConn, StatusCodes.NS_FAILED, "The stream name may not be empty.", name, streamId);
        return;
      }
      IStreamSecurityService security = (IStreamSecurityService) ScopeUtils.getScopeService(scope, IStreamSecurityService.class);
      if (security != null) {
        Set<IStreamPlaybackSecurity> handlers = security.getStreamPlaybackSecurity();
        for (IStreamPlaybackSecurity handler : handlers) {
          if (!handler.isPlaybackAllowed(scope, name, start, length, flushPlaylist)) {
            sendNSFailed(streamConn, StatusCodes.NS_FAILED, "You are not allowed to play the stream.", name, streamId);
            return;
          }
        }
      }
      boolean created = false;
      IClientStream stream = streamConn.getStreamById(streamId);
      if (stream == null) {
        if (streamId <= 0) {
          streamId = streamConn.reserveStreamId();
        }
        stream = streamConn.newPlaylistSubscriberStream(streamId);
        stream.setBroadcastStreamPublishName(name);
        stream.start();
        created = true;
      }
      if (stream != null && stream instanceof ISubscriberStream) {
        ISubscriberStream subscriberStream = (ISubscriberStream) stream;
        IPlayItem item = simplePlayback.get() ? SimplePlayItem.build(name, start, length) : DynamicPlayItem.build(name, start, length);
        if (subscriberStream instanceof IPlaylistSubscriberStream) {
          IPlaylistSubscriberStream playlistStream = (IPlaylistSubscriberStream) subscriberStream;
          if (flushPlaylist) {
            playlistStream.removeAllItems();
          }
          playlistStream.addItem(item);
        } else if (subscriberStream instanceof ISingleItemSubscriberStream) {
          ISingleItemSubscriberStream singleStream = (ISingleItemSubscriberStream) subscriberStream;
          singleStream.setPlayItem(item);
        } else {
          // not supported by this stream service
          log.warn("Stream instance type: {} is not supported", subscriberStream.getClass().getName());
          return;
        }
        try {
          subscriberStream.play();
        } catch (IOException err) {
          if (created) {
            stream.close();
            streamConn.deleteStreamById(streamId);
          }
          sendNSFailed(streamConn, StatusCodes.NS_FAILED, err.getMessage(), name, streamId);
        }
      }
    } else {
View Full Code Here

TOP

Related Classes of org.red5.server.api.stream.IStreamCapableConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.