Package org.red5.server.api.scope

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


  /** {@inheritDoc} */
  public void saveAs(String name, boolean isAppend) throws IOException {
    // one recording listener at a time via this entry point
    if (recordingListener == null) {
      IScope scope = getScope();
      // create a recording listener
      IRecordingListener listener = (IRecordingListener) ScopeUtils.getScopeService(scope, IRecordingListener.class, RecordingListener.class);
      // initialize the listener
      if (listener.init(scope, name, isAppend)) {
        // get decoder info if it exists for the stream
View Full Code Here


    }
    if (publishedName == null) {
      throw new IllegalStateException("A published name is needed to start");
    }
    try {
      IScope scope = getScope();
      IContext context = scope.getContext();
      providerService = (IProviderService) context.getBean(IProviderService.BEAN_NAME);
      // publish this server-side stream
      providerService.registerBroadcastStream(scope, publishedName, this);
      scheduler = (ISchedulingService) context.getBean(ISchedulingService.BEAN_NAME);
    } catch (NullPointerException npe) {
View Full Code Here

      final boolean andReturn = !status.getCode().equals(StatusCodes.NS_DATA_START);
      final Invoke event = new Invoke();
      if (andReturn) {
        final PendingCall call = new PendingCall(null, CALL_ON_STATUS, new Object[] { status });
        if (status.getCode().equals(StatusCodes.NS_PLAY_START)) {
          IScope scope = connection.getScope();
          if (scope.getContext().getApplicationContext().containsBean(IRtmpSampleAccess.BEAN_NAME)) {
            IRtmpSampleAccess sampleAccess = (IRtmpSampleAccess) scope.getContext().getApplicationContext().getBean(IRtmpSampleAccess.BEAN_NAME);
            boolean videoAccess = sampleAccess.isVideoAllowed(scope);
            boolean audioAccess = sampleAccess.isAudioAllowed(scope);
            if (videoAccess || audioAccess) {
              final Call call2 = new Call(null, "|RtmpSampleAccess", null);
              Notify notify = new Notify();
View Full Code Here

     * @param scope            Scope
     * @return                 Directory based on relative scope path
     */
    private String getStreamDirectory(IScope scope) {
    final StringBuilder result = new StringBuilder();
    final IScope app = ScopeUtils.findApplication(scope);
    final String prefix = "streams/";
    while (scope != null && scope != app) {
      result.insert(0, scope.getName() + "/");
      scope = scope.getParent();
    }
View Full Code Here

  }

  /** {@inheritDoc} */
  public void saveAs(String name, boolean isAppend) throws IOException, ResourceNotFoundException, ResourceExistException {
    try {
      IScope scope = getScope();
      IStreamFilenameGenerator generator = (IStreamFilenameGenerator) ScopeUtils.getScopeService(scope, IStreamFilenameGenerator.class, DefaultStreamFilenameGenerator.class);

      String filename = generator.generateFilename(scope, name, ".flv", GenerationType.RECORD);
      Resource res = scope.getContext().getResource(filename);
      if (!isAppend) {
        if (res.exists()) {
          // Per livedoc of FCS/FMS:
          // When "live" or "record" is used,
          // any previously recorded stream with the same stream
          // URI is deleted.
          if (!res.getFile().delete())
            throw new IOException("file could not be deleted");
        }
      } else {
        if (!res.exists()) {
          // Per livedoc of FCS/FMS:
          // If a recorded stream at the same URI does not already
          // exist,
          // "append" creates the stream as though "record" was
          // passed.
          isAppend = false;
        }
      }

      if (!res.exists()) {
        // Make sure the destination directory exists
        try {
          String path = res.getFile().getAbsolutePath();
          int slashPos = path.lastIndexOf(File.separator);
          if (slashPos != -1) {
            path = path.substring(0, slashPos);
          }
          File tmp = new File(path);
          if (!tmp.isDirectory()) {
            tmp.mkdirs();
          }
        } catch (IOException err) {
          log.error("Could not create destination directory.", err);
        }
        res = scope.getResource(filename);
      }

      if (!res.exists()) {
        if (!res.getFile().canWrite()) {
          log.warn("File cannot be written to " + res.getFile().getCanonicalPath());
View Full Code Here

    System.setProperty("red5.config_root", "file:" + userDir + "/src/main/server/conf");
 
 
  @Before
  public void setUp() throws Exception {
    IScope scope = (WebScope) applicationContext.getBean("web.scope");
    serverStream = StreamUtils.createServerStream(scope, "test");
  }
View Full Code Here

    final String message = "This is a test";

    //create our sender conn and set local
    IClientRegistry dummyReg = (IClientRegistry) applicationContext.getBean("global.clientRegistry");

    final IScope scp = (WebScope) applicationContext.getBean("web.scope"); //conn.getScope();
    final IContext ctx = (Context) applicationContext.getBean("web.context"); //scope.getContext();

    final IConnection recipient = new SvcCapableTestConnection("localhost", "/junit", "1");//host, path, session id
    IClient rClient = dummyReg.newClient(new Object[] { "recipient" });
    ((TestConnection) recipient).setClient(rClient);
    ((TestConnection) recipient).setScope((Scope) scp);
    ((DummyClient) rClient).registerConnection(recipient);

    final IConnection sender = new SvcCapableTestConnection("localhost", "/junit", "2");//host, path, session id
    IClient sClient = dummyReg.newClient(new Object[] { "sender" });
    ((TestConnection) sender).setClient(sClient);
    ((TestConnection) sender).setScope((Scope) scp);
    ((DummyClient) sClient).registerConnection(sender);

    Thread r = new Thread(new Runnable() {
      public void run() {
        Red5.setConnectionLocal(recipient);
        IConnection conn = Red5.getConnectionLocal();
        assertTrue(scp.connect(conn));
        try {
          Thread.sleep(120L);
        } catch (InterruptedException e) {
        }
        log.debug("Check s/c -\n s1: {} s2: {}\n c1: {} c2: {}", new Object[] { scp, conn.getScope(), ctx, conn.getScope().getContext() });
      }
    });
    Thread s = new Thread(new Runnable() {
      public void run() {
        Red5.setConnectionLocal(sender);
        IConnection conn = Red5.getConnectionLocal();
        assertTrue(scp.connect(conn));
        try {
          Thread.sleep(10L);
        } catch (InterruptedException e) {
        }
        Object[] sendobj = new Object[] { conn.getClient().getId(), message };
View Full Code Here

  private IConnection createConnection(int id) {
    //create our sender conn and set local
    IClientRegistry dummyReg = (IClientRegistry) applicationContext.getBean("global.clientRegistry");

    IScope scp = (WebScope) applicationContext.getBean("web.scope");
    //IContext ctx = (Context) applicationContext.getBean("web.context");

    IConnection conn = new SvcCapableTestConnection("localhost", "/junit", id + "");//host, path, session id
    IClient rClient = dummyReg.newClient(new Object[] { "client-" + id });
    ((TestConnection) conn).setClient(rClient);
View Full Code Here

  }

  public void start() {
    //ensure the play engine exists
    if (engine == null) {
      IScope scope = getScope();
      if (scope != null) {
        IContext ctx = scope.getContext();
        if (ctx.hasBean(ISchedulingService.BEAN_NAME)) {
          schedulingService = (ISchedulingService) ctx.getBean(ISchedulingService.BEAN_NAME);
        } else {
          //try the parent
          schedulingService = (ISchedulingService) scope.getParent().getContext().getBean(ISchedulingService.BEAN_NAME);
        }
        IConsumerService consumerService = null;
        if (ctx.hasBean(IConsumerService.KEY)) {
          consumerService = (IConsumerService) ctx.getBean(IConsumerService.KEY);
        } else {
          //try the parent
          consumerService = (IConsumerService) scope.getParent().getContext().getBean(IConsumerService.KEY);
        }
        IProviderService providerService = null;
        if (ctx.hasBean(IProviderService.BEAN_NAME)) {
          providerService = (IProviderService) ctx.getBean(IProviderService.BEAN_NAME);
        } else {
          //try the parent
          providerService = (IProviderService) scope.getParent().getContext().getBean(IProviderService.BEAN_NAME);
        }
        engine = new PlayEngine.Builder(this, schedulingService, consumerService, providerService).build();
      } else {
        log.info("Scope was null on start");
      }
View Full Code Here

    @SuppressWarnings("deprecation")
    public void runTest() throws Throwable {
      Red5.setConnectionLocal(conn);

      IClient client = conn.getClient();
      IScope scope = (WebScope) conn.getScope();
      IContext context = (Context) scope.getContext();

      IClientRegistry reg = context.getClientRegistry();

      IServiceCapableConnection serviceCapCon = null;
View Full Code Here

TOP

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

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.