Package org.red5.server.api.scope

Examples of org.red5.server.api.scope.IBroadcastScope


            sendNSFailed(streamConn, StatusCodes.NS_PUBLISH_BADNAME, "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     
        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) {
        stream = streamConn.newBroadcastStream(streamId);
        created = true;
      }
      IClientBroadcastStream bs = (IClientBroadcastStream) stream;
      try {
        // set publish name
        bs.setPublishedName(name);
        // set stream parameters if they exist
        if (params != null) {
          bs.setParameters(params);
        }
        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.setClientBroadcastStream(bs);
          if (conn instanceof BaseConnection) {
            ((BaseConnection) conn).registerBasicScope(bsScope);
          }
        }
        log.debug("Mode: {}", mode);
View Full Code Here


    //state.setWriteChunkSize(requestedChunkSize);
    // set on each of the streams
    for (IClientStream stream : conn.getStreams()) {
      if (stream instanceof IClientBroadcastStream) {
        IClientBroadcastStream bs = (IClientBroadcastStream) stream;
        IBroadcastScope scope = bs.getScope().getBroadcastScope(bs.getPublishedName());
        if (scope == null) {
          continue;
        }
        OOBControlMessage setChunkSize = new OOBControlMessage();
        setChunkSize.setTarget("ClientBroadcastStream");
        setChunkSize.setServiceName("chunkSize");
        if (setChunkSize.getServiceParamMap() == null) {
          setChunkSize.setServiceParamMap(new HashMap<String, Object>());
        }
        setChunkSize.getServiceParamMap().put("chunkSize", requestedChunkSize);
        scope.sendOOBControlMessage((IConsumer) null, setChunkSize);
        log.debug("Sending chunksize {} to {}", chunkSize, bs.getProvider());
      }
    }
  }
View Full Code Here

  /** {@inheritDoc} */
  public IMessageInput getLiveProviderInput(IScope scope, String name, boolean needCreate) {
    log.debug("Get live provider input for {} scope: {}", name, scope);
    //make sure the create is actually needed
    IBroadcastScope broadcastScope = scope.getBroadcastScope(name);
    if (broadcastScope == null) {
      if (needCreate) {
        synchronized(scope) {
          // re-check if another thread already created the scope
          broadcastScope = scope.getBroadcastScope(name);
View Full Code Here

  /** {@inheritDoc} */
  public boolean registerBroadcastStream(IScope scope, String name, IBroadcastStream bs) {
    log.debug("Registering - name: {} stream: {} scope: {}", new Object[] { name, bs, scope });
    ((Scope) scope).dump();
    IBroadcastScope broadcastScope = scope.getBroadcastScope(name);
    if (broadcastScope == null) {
      log.debug("Creating a new scope");
      broadcastScope = new BroadcastScope(scope, name);
      if (scope.addChildScope(broadcastScope)) {
        log.debug("Broadcast scope added");
      } else {
        log.warn("Broadcast scope was not added to {}", scope);
      }
    }
    log.debug("Subscribing scope {} to provider {}", broadcastScope, bs.getProvider());
    return broadcastScope.subscribe(bs.getProvider(), null);
  }
View Full Code Here

  /** {@inheritDoc} */
  public boolean unregisterBroadcastStream(IScope scope, String name, IBroadcastStream bs) {
    log.debug("Unregistering - name: {} stream: {} scope: {}", new Object[] { name, bs, scope });
    ((Scope) scope).dump();
    IBroadcastScope broadcastScope = scope.getBroadcastScope(name);
    if (bs != null) {
      log.debug("Unsubscribing scope {} from provider {}", broadcastScope, bs.getProvider());
      broadcastScope.unsubscribe(bs.getProvider());
    }
    // if the scope has no listeners try to remove it
    if (!((BasicScope) broadcastScope).hasEventListeners()) {
      log.debug("Scope has no event listeners attempting removal");
      scope.removeChildScope(broadcastScope);
View Full Code Here

    String publishName = rc.getStreamPublishName();
   
    if (rc.getIsScreenClient() && rc.isStartStreaming()) {
          IScope scope = conn.getScope();
          IBroadcastStream stream = getBroadcastStream(scope, publishName);
          IBroadcastScope bsScope = getBroadcastScope(scope, publishName);
          final StreamingProxy proxy = new StreamingProxy();
          proxy.setHost(host);
          proxy.setApp(app);
          proxy.setPort(1935);
          proxy.init();
          proxy.setExceptionHandler(new ClientExceptionHandler() {
        public void handleException(Throwable throwable) {
          result[0] = false;
          HashMap<String, Object> params = new HashMap<String, Object>();
          params.put("stopPublishing", true);
          params.put("error", throwable.getMessage());
          ((IServiceCapableConnection)conn).invoke(
            "screenSharerAction"
            , new Object[] { params }
            , ScopeApplicationAdapter.this);
        }
      });
          bsScope.subscribe(proxy, null);
          proxy.start(id, "live", null);
          streamingProxyMap.put(publishName, proxy);
          stream.addStreamListener(new IStreamListener() {
        public void packetReceived(IBroadcastStream stream, IStreamPacket packet) {
          try {
View Full Code Here

          IScope scope = current.getScope();
          IBroadcastStream stream = getBroadcastStream(scope, publishName);
      StreamingProxy proxy = streamingProxyMap.remove(publishName);
      if (proxy != null) {
        proxy.stop();
        IBroadcastScope bsScope = getBroadcastScope(scope, stream.getPublishedName());
        if (bsScope != null) {
          bsScope.unsubscribe(proxy);
        }
      }
    }
    }
View Full Code Here

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

    private void createPlayStream( IPendingServiceCallback callback ) {

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

      if (stream.getStreamListeners() != null) {
       
        for (Iterator<IStreamListener> iter = stream.getStreamListeners().iterator();iter.hasNext();) {
         
          IStreamListener iStreamListener = iter.next();
         
          ListenerAdapter listenerAdapter = (ListenerAdapter) iStreamListener;
         
          log.debug("Stream Closing ?? "+listenerAdapter.getFlvRecordingMetaDataId()+ " " +flvRecordingMetaDataId);
         
View Full Code Here

            if ( !( event instanceof IRTMPEvent ) ) {
                logger.debug( "skipping non rtmp event: " + event );
                return;
            }

            IRTMPEvent rtmpEvent = (IRTMPEvent) event;

            if ( logger.isDebugEnabled() ) {
                // logger.debug("rtmp event: " + rtmpEvent.getHeader() + ", " +
                // rtmpEvent.getClass().getSimpleName());
            }

            if ( !( rtmpEvent instanceof IStreamData ) ) {
                logger.debug( "skipping non stream data" );
                return;
            }

            if ( rtmpEvent.getHeader().getSize() == 0 ) {
                logger.debug( "skipping event where size == 0" );
                return;
            }

            if ( rtmpEvent instanceof VideoData ) {
View Full Code Here

TOP

Related Classes of org.red5.server.api.scope.IBroadcastScope

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.