Package org.red5.server.api.stream

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


      }
      Red5.setConnectionLocal(this);
      IStreamService streamService = (IStreamService) ScopeUtils.getScopeService(scope, IStreamService.class, StreamService.class);
      if (streamService != null) {
        for (Map.Entry<Integer, IClientStream> entry : streams.entrySet()) {
          IClientStream stream = entry.getValue();
          if (stream != null) {
            if (log.isDebugEnabled())
              log.debug("Closing stream: {}", stream.getStreamId());
            streamService.deleteStream(this, stream.getStreamId());
            usedStreams.decrementAndGet();
          }
        }
      } else {
        if (log.isDebugEnabled())
View Full Code Here


  public void initStream(int streamId) {
    IConnection conn = Red5.getConnectionLocal();
    log.info("initStream: id={} current id: {} connection={}", streamId, conn.getStreamId(), conn);
    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 intiStream, connection is not stream capable");
    }
View Full Code Here

   */
  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 {
        log.info("Stream not found: streamId={}, connection={}", streamId, conn);
      }
    } else {
View Full Code Here

    }
  }

  /** {@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);
  }
View Full Code Here

  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

            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);
        }
      }
View Full Code Here

    if (!dontStop) {
      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.stop();
        }
      }
    }
  }
View Full Code Here

    if (!dontStop) {
      IConnection conn = Red5.getConnectionLocal();
      if (conn instanceof IStreamCapableConnection) {
        IStreamCapableConnection streamConn = (IStreamCapableConnection) conn;
        int streamId = conn.getStreamId();
        IClientStream stream = streamConn.getStreamById(streamId);
        if (stream instanceof IBroadcastStream) {
          IBroadcastStream bs = (IBroadcastStream) stream;
          if (bs.getPublishedName() != null) {
            IBroadcastScope bsScope = getBroadcastScope(conn.getScope(), bs.getPublishedName());
            if (bsScope != null) {
View Full Code Here

      if (bsScope != null && !bsScope.getProviders().isEmpty()) {
        // another stream with that name is already published     
        sendNSFailed(streamConn, StatusCodes.NS_PUBLISH_BADNAME, name, name, streamId);
        return;
      }
      IClientStream stream = streamConn.getStreamById(streamId);
      if (stream != null && !(stream instanceof IClientBroadcastStream)) {
        return;
      }
      boolean created = false;
      if (stream == null) {
View Full Code Here

    log.trace("seek - position:{}", 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;
        try {
          subscriberStream.seek(position);
        } catch (OperationNotSupportedException err) {
          sendNSFailed(streamConn, StatusCodes.NS_SEEK_FAILED, "The stream doesn't support seeking.", stream.getName(), streamId);
        }
      }
    }
  }
View Full Code Here

TOP

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

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.