Package org.red5.server.api.stream

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


      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);
        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 {
          bs.start();
        }
        bs.startPublishing();
      } catch (IOException e) {
        log.warn("Stream I/O exception", e);
        sendNSFailed(streamConn, StatusCodes.NS_RECORD_NOACCESS, "The file could not be created/written to.", name, streamId);
        bs.close();
        if (created) {
          streamConn.deleteStreamById(streamId);
        }
      } catch (Exception e) {
        log.warn("Exception on publish", e);
View Full Code Here


    state.setReadChunkSize(requestedChunkSize);
    //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

          msgIn = liveInput;
          // Drop all frames up to the next keyframe
          videoFrameDropper.reset(IFrameDropper.SEND_KEYFRAMES_CHECK);
          if (msgIn instanceof IBroadcastScope) {
            // Send initial keyframe
            IClientBroadcastStream stream = (IClientBroadcastStream) ((IBroadcastScope) msgIn)
                .getAttribute(IBroadcastScope.STREAM_ATTRIBUTE);
            if (stream != null && stream.getCodecInfo() != null) {
              IVideoStreamCodec videoCodec = stream
                  .getCodecInfo().getVideoCodec();
              if (videoCodec != null) {
                ByteBuffer keyFrame = videoCodec.getKeyframe();
                if (keyFrame != null) {
                  VideoData video = new VideoData(keyFrame);
View Full Code Here

        int size = ((IStreamData) body).getData().limit();
        if (body instanceof VideoData) {
          IVideoStreamCodec videoCodec = null;
          if (msgIn instanceof IBroadcastScope) {
            IClientBroadcastStream stream = (IClientBroadcastStream) ((IBroadcastScope) msgIn)
                .getAttribute(IBroadcastScope.STREAM_ATTRIBUTE);
            if (stream != null && stream.getCodecInfo() != null) {
              videoCodec = stream.getCodecInfo().getVideoCodec();
            }
          }

          if (videoCodec == null || videoCodec.canDropFrames()) {
            if (state == State.PAUSED) {
View Full Code Here

    }
    IClientStream stream = ((IStreamCapableConnection) conn)
        .getStreamById(getCurrentStreamId());
    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);
        }
      }
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);
        }
      }
View Full Code Here

    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

  @Override
  protected void onChunkSize(RTMPConnection conn, Channel channel,
      Header source, ChunkSize chunkSize) {
    for (IClientStream stream : conn.getStreams()) {
      if (stream instanceof IClientBroadcastStream) {
        IClientBroadcastStream bs = (IClientBroadcastStream) stream;
        IBroadcastScope scope = (IBroadcastScope) bs.getScope()
            .getBasicScope(IBroadcastScope.TYPE,
                bs.getPublishedName());
        if (scope == null) {
          continue;
        }

        OOBControlMessage setChunkSize = new OOBControlMessage();
        setChunkSize.setTarget("ClientBroadcastStream");
        setChunkSize.setServiceName("chunkSize");
        if (setChunkSize.getServiceParamMap() == null) {
          setChunkSize.setServiceParamMap(new HashMap());
        }
        setChunkSize.getServiceParamMap().put("chunkSize",
            chunkSize.getSize());
        scope.sendOOBControlMessage((IConsumer) null, setChunkSize);
        if (log.isDebugEnabled()) {
          log.debug("Sending chunksize " + chunkSize + " to "
              + bs.getProvider());
        }
      }
    }
  }
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.stream.IClientBroadcastStream

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.