Kurento复合代码

时间:2017-08-06 07:36:38

标签: kurento

我正在尝试使用复合来制作同一用户的网格视图。我使用以下代码,但它给我单输出而不是网格。

try {
         // 1. Media logic (webRtcEndpoint in loopback)
         MediaPipeline pipeline = kurento.createMediaPipeline();
         WebRtcEndpoint webRtcEndpoint1 = new WebRtcEndpoint.Builder(pipeline).build();
         WebRtcEndpoint webRtcEndpoint2 = new WebRtcEndpoint.Builder(pipeline).build();

         WebRtcEndpoint endpointOut = new WebRtcEndpoint.Builder(pipeline).build();

         Composite composite = new Composite.Builder(pipeline).build();
         HubPort hubPort1 = new HubPort.Builder(composite).build();
         HubPort hubPort2 = new HubPort.Builder(composite).build();
         HubPort out = new HubPort.Builder(composite).build();


         webRtcEndpoint1.connect(hubPort1);
         webRtcEndpoint2.connect(hubPort2);

         out.connect(endpointOut);

         // 2. Store user session
         UserSession user = new UserSession();
         user.setMediaPipeline(pipeline);
         user.setWebRtcEndpoint(endpointOut);
         users.put(session.getId(), user);

         // 3. SDP negotiation
         String sdpOffer = jsonMessage.get("sdpOffer").getAsString();
         String sdpAnswer = endpointOut.processOffer(sdpOffer);

         JsonObject response = new JsonObject();
         response.addProperty("id", "startResponse");
         response.addProperty("sdpAnswer", sdpAnswer);

         synchronized (session) {
            session.sendMessage(new TextMessage(response.toString()));
         }

         // 4. Gather ICE candidates
         endpointOut.addIceCandidateFoundListener(new EventListener<IceCandidateFoundEvent>() {
            @Override
            public void onEvent(IceCandidateFoundEvent event) {
               JsonObject response = new JsonObject();
               response.addProperty("id", "iceCandidate");
               response.add("candidate", JsonUtils.toJsonObject(event.getCandidate()));
               try {
                  synchronized (session) {
                     session.sendMessage(new TextMessage(response.toString()));
                  }
               } catch (IOException e) {
                  log.error(e.getMessage());
               }
            }
         });
         endpointOut.gatherCandidates();

      } catch (Throwable t) {
         sendError(session, t.getMessage());
      }

有人可以帮忙吗?

我工作的项目与kurento.org网站上提供的hello world示例相同。

1 个答案:

答案 0 :(得分:0)

连接webRtcEndpoint1.connect(hubPort1)后; 还要编写hubport1.connect(webRtcEndpoint1);

这将提供已连接到webRtcEndpoint的组合的集线器端口媒体。