Package com.kurento.kmf.media

Examples of com.kurento.kmf.media.PlayerEndpoint


    }
  }

  private void internalStart(String sourceContentPath, String sinkContentPath) {
    MediaPipeline mediaPipeline = createMediaPipeline();
    PlayerEndpoint playerEndpoint = null;
    if (sourceContentPath != null) {
      playerEndpoint = createSourceEndpoint(mediaPipeline,
          sourceContentPath);
    }

    RecorderEndpoint recorderEndpoint = null;
    if (sinkContentPath != null) {
      recorderEndpoint = createSinkEndpoint(mediaPipeline,
          sinkContentPath);
    }

    SdpEndpoint sdpEndpoint = buildAndConnectSdpEndpoint(mediaPipeline,
        playerEndpoint, recorderEndpoint);

    if (playerEndpoint != null)
      playerEndpoint.play();

    if (recorderEndpoint != null)
      recorderEndpoint.record();

    activateMedia(sdpEndpoint, null); // TODO. Ask Jose if
View Full Code Here


  }

  private PlayerEndpoint createSourceEndpoint(MediaPipeline mediaPipeline,
      String contentPath) {
    getLogger().info("Creating PlayerEndpoint ...");
    PlayerEndpoint playerEndpoint = mediaPipeline.newPlayerEndpoint(
        contentPath).build();
    return playerEndpoint;
  }
View Full Code Here

      getLogger().info("mediaUrl {}", mediaUrl);

      MediaPipeline mp = contentSession.getMediaPipelineFactory()
          .create();
      contentSession.releaseOnTerminate(mp);
      PlayerEndpoint playerEndpoint = mp.newPlayerEndpoint(mediaUrl)
          .build();
      JackVaderFilter filter = mp.newJackVaderFilter().build();
      playerEndpoint.connect(filter);
      contentSession.setAttribute("player", playerEndpoint);
      HttpGetEndpoint httpEndpoint = mp.newHttpGetEndpoint()
          .terminateOnEOS().build();
      filter.connect(httpEndpoint);
      contentSession.start(httpEndpoint);
View Full Code Here

    }
  }

  @Override
  public void onContentStarted(HttpPlayerSession session) {
    PlayerEndpoint PlayerEndpoint = (PlayerEndpoint) session
        .getAttribute("player");
    PlayerEndpoint.play();
  }
View Full Code Here

      throws Exception {
    MediaPipelineFactory mpf = session.getMediaPipelineFactory();
    MediaPipeline mp = mpf.create();
    session.releaseOnTerminate(mp);

    PlayerEndpoint playerEndpoint = mp.newPlayerEndpoint(

    VideoURLs.map.get("zbar")).build();
    ZBarFilter filter = mp.newZBarFilter().build();
    playerEndpoint.connect(filter);

    filter.addCodeFoundListener(new MediaEventListener<CodeFoundEvent>() {

      @Override
      public void onEvent(CodeFoundEvent event) {
View Full Code Here

    session.start(httpEP);
  }

  @Override
  public void onContentStarted(HttpPlayerSession session) {
    PlayerEndpoint playerEndpoint = (PlayerEndpoint) session
        .getAttribute("player");
    playerEndpoint.play();
  }
View Full Code Here

  @Override
  public void onContentStarted(HttpPlayerSession contentSession)
      throws Exception {
    EventListener.addEvent();
    if (contentSession.getAttribute("player") != null) {
      PlayerEndpoint playerEndpoint = (PlayerEndpoint) contentSession
          .getAttribute("player");
      playerEndpoint.play();
    }
    super.onContentStarted(contentSession);
  }
View Full Code Here

  @Test
  public void testPlayerCrowdDetector() throws Exception {
    // Media Pipeline
    MediaPipeline mp = pipelineFactory.create();
    PlayerEndpoint playerEP = mp.newPlayerEndpoint(
        "http://files.kurento.org/video/crowd.mp4").build();
    HttpGetEndpoint httpEP = mp.newHttpGetEndpoint().terminateOnEOS()
        .build();

    List<RegionOfInterest> rois = newArrayList();
    List<RelativePoint> points = new ArrayList<RelativePoint>();

    points.add(new RelativePoint(0, 0));
    points.add(new RelativePoint((float) 0.5, 0));
    points.add(new RelativePoint((float) 0.5, (float) 0.5));
    points.add(new RelativePoint(0, (float) 0.5));

    RegionOfInterestConfig config = new RegionOfInterestConfig();

    config.setFluidityLevelMin(10);
    config.setFluidityLevelMed(35);
    config.setFluidityLevelMax(65);
    config.setFluidityNumFramesToEvent(5);
    config.setOccupancyLevelMin(10);
    config.setOccupancyLevelMed(35);
    config.setOccupancyLevelMax(65);
    config.setOccupancyNumFramesToEvent(5);
    config.setSendOpticalFlowEvent(false);
    config.setOpticalFlowNumFramesToEvent(3);
    config.setOpticalFlowNumFramesToReset(3);
    config.setOpticalFlowAngleOffset(0);

    rois.add(new RegionOfInterest(points, config, "roi0"));

    CrowdDetectorFilter crowdDetectorFilter = mp.newCrowdDetectorFilter(
        rois).build();
    playerEP.connect(crowdDetectorFilter);
    crowdDetectorFilter.connect(httpEP);

    final List<EndOfStreamEvent> eosEvents = new ArrayList<>();
    playerEP.addEndOfStreamListener(new MediaEventListener<EndOfStreamEvent>() {
      @Override
      public void onEvent(EndOfStreamEvent event) {
        eosEvents.add(event);
      }
    });

    final List<CrowdDetectorOccupancyEvent> crowdDetectedOccupancyEvents = new ArrayList<>();
    final List<CrowdDetectorFluidityEvent> crowdDetectedFluidityEvents = new ArrayList<>();

    crowdDetectorFilter
        .addCrowdDetectorOccupancyListener(new MediaEventListener<CrowdDetectorOccupancyEvent>() {
          @Override
          public void onEvent(CrowdDetectorOccupancyEvent event) {
            crowdDetectedOccupancyEvents.add(event);
          }
        });

    crowdDetectorFilter
        .addCrowdDetectorFluidityListener(new MediaEventListener<CrowdDetectorFluidityEvent>() {
          @Override
          public void onEvent(CrowdDetectorFluidityEvent event) {
            crowdDetectedFluidityEvents.add(event);
          }
        });

    // Test execution
    try (BrowserClient browser = new BrowserClient.Builder()
        .browser(Browser.CHROME).client(Client.PLAYER).build()) {
      browser.setURL(httpEP.getUrl());
      browser.subscribeEvents("playing", "ended");
      playerEP.play();
      browser.start();

      // Assertions
      Assert.assertTrue("Timeout waiting playing event",
          browser.waitForEvent("playing"));
View Full Code Here

      }

      MediaPipelineFactory mpf = session.getMediaPipelineFactory();
      MediaPipeline mp = mpf.create();
      session.releaseOnTerminate(mp);
      PlayerEndpoint playerEndpoint = mp.newPlayerEndpoint(url).build();
      HttpGetEndpoint httpEP = mp.newHttpGetEndpoint().terminateOnEOS()
          .build();
      if (contentId != null && contentId.equalsIgnoreCase("jack")) {
        // Jack Vader Filter
        JackVaderFilter filter = mp.newJackVaderFilter().build();
        playerEndpoint.connect(filter);
        filter.connect(httpEP);

      } else if (contentId != null && contentId.equalsIgnoreCase("zbar")) {
        // ZBar Filter
        ZBarFilter zBarFilter = mp.newZBarFilter().build();
        playerEndpoint.connect(zBarFilter);
        zBarFilter.connect(httpEP);
        session.setAttribute("eventValue", "");
        zBarFilter
            .addCodeFoundListener(new MediaEventListener<CodeFoundEvent>() {
              @Override
              public void onEvent(CodeFoundEvent event) {
                log.info("Code Found " + event.getValue());
                if (session.getAttribute("eventValue")
                    .toString().equals(event.getValue())) {
                  return;
                }
                session.setAttribute("eventValue",
                    event.getValue());
                session.publishEvent(new ContentEvent(event
                    .getType(), event.getValue()));
              }
            });
      }

      else if (contentId != null && contentId.equalsIgnoreCase("crowd")) {
        // Crowd Detector Filter
        List<RelativePoint> points = new ArrayList<RelativePoint>();
        points.add(new RelativePoint(0, 0));
        points.add(new RelativePoint(1, 0));
        points.add(new RelativePoint(1, 1));
        points.add(new RelativePoint(0, 1));
        RegionOfInterestConfig config = new RegionOfInterestConfig();
        config.setFluidityLevelMin(10);
        config.setFluidityLevelMed(35);
        config.setFluidityLevelMax(65);
        config.setFluidityNumFramesToEvent(5);
        config.setOccupancyLevelMin(10);
        config.setOccupancyLevelMed(35);
        config.setOccupancyLevelMax(65);
        config.setOccupancyNumFramesToEvent(5);
        config.setSendOpticalFlowEvent(false);

        List<RegionOfInterest> rois = newArrayList(new RegionOfInterest(
            points, config, "Roi"));
        CrowdDetectorFilter crowdDetector = mp.newCrowdDetectorFilter(
            rois).build();
        playerEndpoint.connect(crowdDetector);
        crowdDetector.connect(httpEP);
      }

      else if (contentId != null && contentId.equalsIgnoreCase("plate")) {
        // Plate Detector Filter
        PlateDetectorFilter plateDetectorFilter = mp
            .newPlateDetectorFilter().build();
        playerEndpoint.connect(plateDetectorFilter);
        plateDetectorFilter.connect(httpEP);
        session.setAttribute("plateValue", "");
        plateDetectorFilter
            .addPlateDetectedListener(new MediaEventListener<PlateDetectedEvent>() {
              @Override
              public void onEvent(PlateDetectedEvent event) {
                if (session.getAttribute("plateValue")
                    .toString().equals(event.getPlate())) {
                  return;
                }
                session.setAttribute("plateValue",
                    event.getPlate());
                session.publishEvent(new ContentEvent(event
                    .getType(), event.getPlate()));
              }
            });
      }

      else if (contentId != null && contentId.equalsIgnoreCase("pointer")) {
        // Pointer Detector Filter
        PointerDetectorFilter pointerDetectorFilter = mp
            .newPointerDetectorFilter().build();
        pointerDetectorFilter
            .addWindow(new PointerDetectorWindowMediaParam("goal",
                50, 50, 150, 150));
        pointerDetectorFilter
            .addWindowInListener(new MediaEventListener<WindowInEvent>() {
              @Override
              public void onEvent(WindowInEvent event) {
                session.publishEvent(new ContentEvent(event
                    .getType(), event.getWindowId()));
              }
            });

        playerEndpoint.connect(pointerDetectorFilter);
        pointerDetectorFilter.connect(httpEP);
      }

      else {
        // Player without filter
        playerEndpoint.connect(httpEP);
      }

      session.start(httpEP);
      session.setAttribute("player", playerEndpoint);
    }
View Full Code Here

  }

  public void doTest(Browser browserType) throws Exception {
    // Media Pipeline #1
    MediaPipeline mp = pipelineFactory.create();
    PlayerEndpoint playerEP = mp.newPlayerEndpoint(
        "http://files.kurento.org/video/fiwarecut.mp4").build();
    HttpGetEndpoint httpEP = mp.newHttpGetEndpoint().terminateOnEOS()
        .build();
    RecorderEndpoint recorderEP = mp.newRecorderEndpoint(
        FILE_SCHEMA + getDefaultFileForRecording()).build();
    final FaceOverlayFilter filter = mp.newFaceOverlayFilter().build();
    filter.setOverlayedImage(
        "http://files.kurento.org/imgs/mario-wings.png", -0.2F, -1.2F,
        1.6F, 1.6F);

    playerEP.connect(filter);
    filter.connect(httpEP);
    filter.connect(recorderEP);

    // Test execution #1. Play and record
    launchBrowser(browserType, httpEP, playerEP, recorderEP);

    // Media Pipeline #2
    PlayerEndpoint playerEP2 = mp.newPlayerEndpoint(
        FILE_SCHEMA + getDefaultFileForRecording()).build();
    HttpGetEndpoint httpEP2 = mp.newHttpGetEndpoint().terminateOnEOS()
        .build();
    playerEP2.connect(httpEP2);

    // Test execution #2. Play the recorded video
    launchBrowser(browserType, httpEP2, playerEP2, null);
  }
View Full Code Here

TOP

Related Classes of com.kurento.kmf.media.PlayerEndpoint

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.