Examples of IClientStream


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

   *
   * @param event          Event data
   */
  public void write(IRTMPEvent event) {
    if (!connection.isClosed()) {
      final IClientStream stream = connection.getStreamByChannelId(id);
      if (id > 3 && stream == null) {
        log.warn("Non-existant stream for channel id: {}, connection id: {} discarding: {}", id, connection.getSessionId());
      }
      // if the stream is non-existant, the event will go out with stream id == 0
      final int streamId = (stream == null) ? 0 : stream.getStreamId();
      write(event, streamId);
    } else {
      log.debug("Associated connection {} is closed, cannot write to channel: {}", connection.getSessionId(), id);
    }
  }
View Full Code Here

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

        if (lastPingTime > 0) {
          tardiness -= lastPingTime;
        }
        //subtract the buffer time
        int streamId = conn.getStreamIdForChannel(channelId);
        IClientStream stream = conn.getStreamById(streamId);
        if (stream != null) {
          int clientBufferDuration = stream.getClientBufferDuration();
          if (clientBufferDuration > 0) {
            //two times the buffer duration seems to work best with vod
            if (isLive) {
              tardiness -= clientBufferDuration;
            } else {
View Full Code Here

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

      try {
        message = packet.getMessage();
        final Header header = packet.getHeader();
        final int streamId = header.getStreamId();
        final Channel channel = conn.getChannel(header.getChannelId());
        final IClientStream stream = conn.getStreamById(streamId);
        log.trace("Message received - stream id: {} channel: {} header: {}", streamId, channel.getId(), header);
        // set stream id on the connection
        conn.setStreamId(streamId);
        // increase number of received messages
        conn.messageReceived();
View Full Code Here

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

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

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

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

  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

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

   */
  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

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

    }
  }

  /** {@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

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

  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

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

            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
TOP
Copyright © 2018 www.massapi.com. 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.