Package org.red5.server.api.stream

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


    if (!dontStop) {
      IConnection conn = Red5.getConnectionLocal();
      if (!(conn instanceof IStreamCapableConnection)) {
        return;
      }
      IStreamCapableConnection streamConn = (IStreamCapableConnection) conn;
      int streamId = getCurrentStreamId();
      IClientStream stream = streamConn.getStreamById(streamId);
      if (stream != null) {
        stream.stop();
      }
    }
  }
View Full Code Here


    if (!dontStop) {
      IConnection conn = Red5.getConnectionLocal();
      if (!(conn instanceof IStreamCapableConnection)) {
        return;
      }
      IStreamCapableConnection streamConn = (IStreamCapableConnection) conn;
      int streamId = getCurrentStreamId();
      IClientStream stream = streamConn.getStreamById(streamId);
      if (!(stream instanceof IBroadcastStream)) {
        return;
      }
      IBroadcastStream bs = (IBroadcastStream) stream;
      if (bs.getPublishedName() == null) {
        return;
      }
      IBroadcastScope bsScope = getBroadcastScope(conn.getScope(), bs
          .getPublishedName());
      if (bsScope != null) {
        bsScope.unsubscribe(bs.getProvider());
        if (conn instanceof BaseConnection) {
          ((BaseConnection) conn).unregisterBasicScope(bsScope);
        }
      }
      bs.close();
      streamConn.deleteStreamById(streamId);
    }
  }
View Full Code Here

    if (!(conn instanceof IStreamCapableConnection)) {
      return;
    }
   
    IScope scope = conn.getScope();
    IStreamCapableConnection streamConn = (IStreamCapableConnection) conn;
    int streamId = getCurrentStreamId();
    if (name == null || "".equals(name)) {
      sendNSFailed((RTMPConnection) streamConn, "The stream name may not be empty.", name, streamId);
      return;
    }

    IStreamSecurityService security = (IStreamSecurityService) ScopeUtils.getScopeService(scope, IStreamSecurityService.class);
    if (security != null) {
      Set<IStreamPublishSecurity> handlers = security.getStreamPublishSecurity();
      for (IStreamPublishSecurity handler: handlers) {
        if (!handler.isPublishAllowed(scope, name, mode)) {
          sendNSFailed((RTMPConnection) streamConn, "You are not allowed to publish the stream.", name, streamId);
          return;
        }
      }
    }
   
    IBroadcastScope bsScope = getBroadcastScope(scope, name);
    if (bsScope != null && !bsScope.getProviders().isEmpty()) {
      // Another stream with that name is already published.
      Status badName = new Status(StatusCodes.NS_PUBLISH_BADNAME);
      badName.setClientid(streamId);
      badName.setDetails(name);
      badName.setLevel("error");

      // FIXME: there should be a direct way to send the status
      Channel channel = ((RTMPConnection) streamConn).getChannel((byte) (4 + ((streamId-1) * 5)));
      channel.sendStatus(badName);
      return;
    }

    IClientStream stream = streamConn.getStreamById(streamId);
    if (stream != null && !(stream instanceof IClientBroadcastStream)) {
      return;
    }
    boolean created = false;
    if (stream == null) {
      stream = streamConn.newBroadcastStream(streamId);
      created = true;
    }

    IClientBroadcastStream bs = (IClientBroadcastStream) stream;
    try {
      bs.setPublishedName(name);
      IContext context = conn.getScope().getContext();
      IProviderService providerService = (IProviderService) context
          .getBean(IProviderService.BEAN_NAME);
      // TODO handle registration failure
      if (providerService.registerBroadcastStream(conn.getScope(),
          name, bs)) {
        bsScope = getBroadcastScope(conn.getScope(), name);
        bsScope.setAttribute(IBroadcastScope.STREAM_ATTRIBUTE, bs);
        if (conn instanceof BaseConnection) {
          ((BaseConnection) conn).registerBasicScope(bsScope);
        }
      }
      if (IClientStream.MODE_RECORD.equals(mode)) {
        bs.start();
        bs.saveAs(name, false);
      } else if (IClientStream.MODE_APPEND.equals(mode)) {
        bs.start();
        bs.saveAs(name, true);
      } else if (IClientStream.MODE_LIVE.equals(mode)) {
        bs.start();
      }
      bs.startPublishing();
    } catch (IOException e) {
      Status accessDenied = new Status(StatusCodes.NS_RECORD_NOACCESS);
      accessDenied.setClientid(streamId);
      accessDenied.setDesciption("The file could not be created/written to.");
      accessDenied.setDetails(name);
      accessDenied.setLevel("error");

      // FIXME: there should be a direct way to send the status
      Channel channel = ((RTMPConnection) streamConn).getChannel((byte) (4 + ((streamId-1) * 5)));
      channel.sendStatus(accessDenied);
      bs.close();
      if (created)
        streamConn.deleteStreamById(streamId);
      return;
    } catch (Exception e) {
      logger.warn("publish caught Exception");
    }
  }
View Full Code Here

    public void seek(int position) {
    IConnection conn = Red5.getConnectionLocal();
    if (!(conn instanceof IStreamCapableConnection)) {
      return;
    }
    IStreamCapableConnection streamConn = (IStreamCapableConnection) conn;
    int streamId = getCurrentStreamId();
    IClientStream stream = streamConn.getStreamById(streamId);
    if (stream == null || !(stream instanceof ISubscriberStream)) {
      return;
    }
    ISubscriberStream subscriberStream = (ISubscriberStream) stream;
    try {
View Full Code Here

    public void receiveVideo(boolean receive) {
    IConnection conn = Red5.getConnectionLocal();
    if (!(conn instanceof IStreamCapableConnection)) {
      return;
    }
    IStreamCapableConnection streamConn = (IStreamCapableConnection) conn;
    int streamId = getCurrentStreamId();
    IClientStream stream = streamConn.getStreamById(streamId);
    if (stream == null || !(stream instanceof ISubscriberStream)) {
      return;
    }
    ISubscriberStream subscriberStream = (ISubscriberStream) stream;
    subscriberStream.receiveVideo(receive);
View Full Code Here

    public void receiveAudio(boolean receive) {
    IConnection conn = Red5.getConnectionLocal();
    if (!(conn instanceof IStreamCapableConnection)) {
      return;
    }
    IStreamCapableConnection streamConn = (IStreamCapableConnection) conn;
    int streamId = getCurrentStreamId();
    IClientStream stream = streamConn.getStreamById(streamId);
    if (stream == null || !(stream instanceof ISubscriberStream)) {
      return;
    }
    ISubscriberStream subscriberStream = (ISubscriberStream) stream;
    subscriberStream.receiveAudio(receive);
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)) {
      return null;
    }
    RTMPConnection conn = (RTMPConnection) streamConn;
    // TODO Better manage channels.
View Full Code Here

      ResourceNotFoundException, ResourceExistException {
    if (log.isDebugEnabled()) {
      log.debug("SaveAs - name: {} append: {}", name, isAppend);
    }
    // Get stream scope
    IStreamCapableConnection conn = getConnection();
    if (conn == null) {
      // TODO: throw other exception here?
      throw new IOException("stream is no longer connected");
    }
    IScope scope = conn.getScope();
    // Get stream filename generator
    IStreamFilenameGenerator generator = (IStreamFilenameGenerator) ScopeUtils
        .getScopeService(scope, IStreamFilenameGenerator.class,
            DefaultStreamFilenameGenerator.class);
View Full Code Here

    @Override
  public boolean appConnect(IConnection conn, Object[] params) {
    // Trigger calling of "onBWDone", required for some FLV players
    measureBandwidth(conn);
    if (conn instanceof IStreamCapableConnection) {
      IStreamCapableConnection streamConn = (IStreamCapableConnection) conn;
      SimpleConnectionBWConfig bwConfig = new SimpleConnectionBWConfig();
      bwConfig.getChannelBandwidth()[IBandwidthConfigure.OVERALL_CHANNEL] =
        1024 * 1024;
      bwConfig.getChannelInitialBurst()[IBandwidthConfigure.OVERALL_CHANNEL] =
        128 * 1024;
      streamConn.setBandwidthConfigure(bwConfig);
    }
    
    return super.appConnect(conn, params);
  }
View Full Code Here

    @Override
  public boolean appConnect(IConnection conn, Object[] params) {
    // Trigger calling of "onBWDone", required for some FLV players
    measureBandwidth(conn);
    if (conn instanceof IStreamCapableConnection) {
      IStreamCapableConnection streamConn = (IStreamCapableConnection) conn;
      SimpleConnectionBWConfig bwConfig = new SimpleConnectionBWConfig();
      bwConfig.getChannelBandwidth()[IBandwidthConfigure.OVERALL_CHANNEL] =
        1024 * 1024;
      bwConfig.getChannelInitialBurst()[IBandwidthConfigure.OVERALL_CHANNEL] =
        128 * 1024;
      streamConn.setBandwidthConfigure(bwConfig);
    }
    
    return super.appConnect(conn, params);
  }
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.