/**
   * A hook to record a sample stream. A file is written in webapps/sip/streams/
   *
   * @param stream
   */
  private void recordStream(IBroadcastStream stream) {
    IConnection conn = Red5.getConnectionLocal();
    String streamName = stream.getPublishedName();

    try {
      ClientBroadcastStream cstream =
          (ClientBroadcastStream)
              this.getBroadcastStream(conn.getScope(), stream.getPublishedName());
      cstream.saveAs(streamName, false);
    } catch (Exception e) {
      System.out.println("ERROR while recording stream " + e.getMessage());
      e.printStackTrace();
    }
  }
Exemple #2
0
  /** {@inheritDoc} */
  public IClientBroadcastStream newBroadcastStream(int streamId) {
    getReadLock().lock();
    try {
      int index = streamId - 1;
      if (index < 0 || !reservedStreams.get(index)) {
        // StreamId has not been reserved before
        return null;
      }
    } finally {
      getReadLock().unlock();
    }

    if (streams.get(streamId - 1) != null) {
      // Another stream already exists with this id
      return null;
    }
    /** Picking up the ClientBroadcastStream defined as a spring prototype in red5-common.xml */
    ClientBroadcastStream cbs =
        (ClientBroadcastStream) scope.getContext().getBean("clientBroadcastStream");
    Integer buffer = streamBuffers.get(streamId - 1);
    if (buffer != null) {
      cbs.setClientBufferDuration(buffer);
    }
    cbs.setStreamId(streamId);
    cbs.setConnection(this);
    cbs.setName(createStreamName());
    cbs.setScope(this.getScope());

    registerStream(cbs);
    usedStreams.incrementAndGet();
    return cbs;
  }