Package com.kurento.kmf.repository

Examples of com.kurento.kmf.repository.RepositoryHttpPlayer


    if (repositoryItem == null) {
      String message = "Repository item " + contentId + " does no exist";
      getLogger().warn(message);
      contentSession.terminate(404, message);
    } else {
      RepositoryHttpPlayer player = repositoryItem
          .createRepositoryHttpPlayer();
      String mediaUrl = contentSession.getHttpServletRequest()
          .getScheme()
          + "://"
          + config.getHandlerAddress()
          + ":"
          + contentSession.getHttpServletRequest().getServerPort()
          + player.getURL();
      getLogger().info("mediaUrl {}", mediaUrl);

      MediaPipeline mp = contentSession.getMediaPipelineFactory()
          .create();
      contentSession.releaseOnTerminate(mp);
View Full Code Here


  protected File downloadFromRepoItemId(String id) throws Exception {

    RepositoryItem newRepositoryItem = getRepository()
        .findRepositoryItemById(id);

    RepositoryHttpPlayer player = newRepositoryItem
        .createRepositoryHttpPlayer();

    File downloadedFile = new File("test-files/tmp/" + id);

    if (downloadedFile.exists()) {
      boolean success = downloadedFile.delete();
      if (!success) {
        throw new RuntimeException("The existing file "
            + downloadedFile + " cannot be deleted");
      }
    }

    downloadFromURL(player.getURL(), downloadedFile);

    return downloadedFile;
  }
View Full Code Here

      InterruptedException {

    RepositoryItem newRepositoryItem = getRepository()
        .findRepositoryItemById(id);

    RepositoryHttpPlayer player = newRepositoryItem
        .createRepositoryHttpPlayer();

    final CountDownLatch started = new CountDownLatch(1);
    player.addSessionStartedListener(new RepositoryHttpEventListener<HttpSessionStartedEvent>() {
      @Override
      public void onEvent(HttpSessionStartedEvent event) {
        started.countDown();
      }
    });

    final CountDownLatch terminated = new CountDownLatch(1);
    player.addSessionTerminatedListener(new RepositoryHttpEventListener<HttpSessionTerminatedEvent>() {
      @Override
      public void onEvent(HttpSessionTerminatedEvent event) {
        terminated.countDown();
      }
    });

    File downloadedFile = new File("test-files/tmp/" + id);
    downloadFromURL(player.getURL(), downloadedFile);

    // TODO We need to be sure that this events appear in the order
    // specified. This test doesn't control this

    assertTrue("Started event didn't sent in 10 seconds",
View Full Code Here

    } catch (NoSuchElementException e) {
      item = getRepository().createRepositoryItem(id);
      uploadFile(new File("test-files/" + id), item);
    }

    RepositoryHttpPlayer player = item.createRepositoryHttpPlayer();

    String url = player.getURL();

    player.setAutoTerminationTimeout(100000);

    // Following sample
    // http://stackoverflow.com/questions/8293687/sample-http-range-request-session

    RestTemplate httpClient = getRestTemplate();
View Full Code Here

    String id = uploadFile(new File("test-files/sample.txt"));

    log.info("File uploaded");

    RepositoryHttpPlayer player = getRepository()
        .findRepositoryItemById(id).createRepositoryHttpPlayer();

    player.setAutoTerminationTimeout(1000);

    RestTemplate template = getRestTemplate();

    assertEquals(HttpStatus.OK,
        template.getForEntity(player.getURL(), byte[].class)
            .getStatusCode());
    log.info("Request 1 Passed");

    Thread.sleep(300);

    assertEquals(HttpStatus.OK,
        template.getForEntity(player.getURL(), byte[].class)
            .getStatusCode());
    log.info("Request 2 Passed");

    Thread.sleep(1500);

    assertEquals(HttpStatus.NOT_FOUND,
        template.getForEntity(player.getURL(), byte[].class)
            .getStatusCode());
    log.info("Request 3 Passed");

  }
View Full Code Here

    }
  }

  private void prepareToDownloadVideo(RepositoryItem repositoryItem)
      throws InterruptedException {
    RepositoryHttpPlayer player = repositoryItem
        .createRepositoryHttpPlayer("video-download");
    log.info("The video can be downloaded with GET from the URL: "
        + player.getURL());

    player.setAutoTerminationTimeout(30 * 60 * 1000);
    log.info("The player will be auto-terminated 30 min after the last downloading of content (http GET)");

    final CountDownLatch terminatedLatch = new CountDownLatch(1);

    player.addSessionStartedListener(new RepositoryHttpEventListener<HttpSessionStartedEvent>() {
      @Override
      public void onEvent(HttpSessionStartedEvent event) {
        log.info("Downloading started");
      }
    });

    player.addSessionTerminatedListener(new RepositoryHttpEventListener<HttpSessionTerminatedEvent>() {
      @Override
      public void onEvent(HttpSessionTerminatedEvent event) {
        log.info("Downloading terminated");
        terminatedLatch.countDown();
      }
View Full Code Here

TOP

Related Classes of com.kurento.kmf.repository.RepositoryHttpPlayer

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.