本文整理汇总了Java中org.kurento.client.WebRtcEndpoint类的典型用法代码示例。如果您正苦于以下问题:Java WebRtcEndpoint类的具体用法?Java WebRtcEndpoint怎么用?Java WebRtcEndpoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebRtcEndpoint类属于org.kurento.client包,在下文中一共展示了WebRtcEndpoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PlayMediaPipeline
import org.kurento.client.WebRtcEndpoint; //导入依赖的package包/类
public PlayMediaPipeline(KurentoClient kurento, String user, final WebSocketSession session) {
// Media pipeline
pipeline = kurento.createMediaPipeline();
// Media Elements (WebRtcEndpoint, PlayerEndpoint)
webRtc = new WebRtcEndpoint.Builder(pipeline).build();
player = new PlayerEndpoint.Builder(pipeline, RECORDING_PATH + user + RECORDING_EXT).build();
// Connection
player.connect(webRtc);
// Player listeners
player.addErrorListener(new EventListener<ErrorEvent>() {
@Override
public void onEvent(ErrorEvent event) {
log.info("ErrorEvent: {}", event.getDescription());
sendPlayEnd(session);
}
});
}
示例2: CallMediaPipeline
import org.kurento.client.WebRtcEndpoint; //导入依赖的package包/类
public CallMediaPipeline(KurentoClient kurento, String from, String to) {
// Media pipeline
pipeline = kurento.createMediaPipeline();
// Media Elements (WebRtcEndpoint, RecorderEndpoint)
webRtcCaller = new WebRtcEndpoint.Builder(pipeline).build();
webRtcCallee = new WebRtcEndpoint.Builder(pipeline).build();
recorderCaller = new RecorderEndpoint.Builder(pipeline, RECORDING_PATH + from + RECORDING_EXT)
.build();
recorderCallee = new RecorderEndpoint.Builder(pipeline, RECORDING_PATH + to + RECORDING_EXT)
.build();
// Connections
webRtcCaller.connect(webRtcCallee);
webRtcCaller.connect(recorderCaller);
webRtcCallee.connect(webRtcCaller);
webRtcCallee.connect(recorderCallee);
}
示例3: cancelVideoFrom
import org.kurento.client.WebRtcEndpoint; //导入依赖的package包/类
public void cancelVideoFrom(final String senderName) {
log.debug("PARTICIPANT {}: canceling video reception from {}", this.name, senderName);
final WebRtcEndpoint incoming = incomingMedia.remove(senderName);
log.debug("PARTICIPANT {}: removing endpoint for {}", this.name, senderName);
if (incoming != null) {
incoming.release(new Continuation<Void>() {
@Override
public void onSuccess(Void result) throws Exception {
log.trace("PARTICIPANT {}: Released successfully incoming EP for {}",
UserSession.this.name, senderName);
}
@Override
public void onError(Throwable cause) throws Exception {
log.warn("PARTICIPANT {}: Could not release incoming EP for {}", UserSession.this.name,
senderName);
}
});
}
}
示例4: gatherStatistics
import org.kurento.client.WebRtcEndpoint; //导入依赖的package包/类
public void gatherStatistics(WebSocketSession session, long conversationId) throws IOException {
Call call = callManager.getCall(conversationId);
Map<String, Map<String, Stats>> statistics = new HashMap<>();
call.getParticipants().stream().forEach(participant -> {
statistics.put(
participant.getUserName(),
participant.getUserCall().getOutgoingMediaEndpoint() != null ? participant.getUserCall().getOutgoingMediaEndpoint().getStats() : null
);
Map<Long, WebRtcEndpoint> e = participant.getUserCall().getIncomingMediaEndpoints();
e.forEach((p, val) ->
statistics.put(participant.getUserName() + " - " + p,
val.getStats())
);
}
);
sender.sendAnonymous(session, "stats.gather", statistics);
}
示例5: cancelVideoFrom
import org.kurento.client.WebRtcEndpoint; //导入依赖的package包/类
/**
* Release the incoming stream from the user who is transmitting the media (used when the transmitting user
* is leaving the call)
* @param senderId
*/
public void cancelVideoFrom(long senderId) {
if(!incomingMedia.containsKey(senderId)) return;
log.debug("PARTICIPANT {}: canceling video reception from {}", userSession.getUserId(), senderId);
WebRtcEndpoint incoming = incomingMedia.remove(senderId);
log.debug("PARTICIPANT {}: removing endpoint for {}", userSession.getUserId(), senderId);
incoming.release(new Continuation<Void>() {
@Override
public void onSuccess(Void result) throws Exception {
log.trace("PARTICIPANT {}: Released successfully incoming EP for {}", userSession.getUserId(), senderId);
}
@Override
public void onError(Throwable cause) throws Exception {
log.warn("PARTICIPANT {}: Could not release incoming EP for {}", userSession.getUserId(), senderId);
}
});
}
示例6: releaseIncomingMediaEndpoints
import org.kurento.client.WebRtcEndpoint; //导入依赖的package包/类
/**
* Release incoming media endpoints - it can now happen only when user
* finishes, because user cannot be part of the call with just transmitting and not receiving the media.
*/
private void releaseIncomingMediaEndpoints() {
log.debug("PARTICIPANT {}: Releasing resources", userSession.getUserId());
for (final long remoteParticipantId : incomingMedia.keySet()) {
log.trace("PARTICIPANT {}: Released incoming EP for {}", userSession.getUserId(), remoteParticipantId);
final WebRtcEndpoint ep = this.incomingMedia.get(remoteParticipantId); //@todo if it would be remove instead of get, it could replace with cancelVideoFrom
ep.release(new Continuation<Void>() {
@Override
public void onSuccess(Void result) throws Exception {
log.trace("PARTICIPANT {}: Released successfully incoming EP for {}",
userSession.getUserId(), remoteParticipantId);
}
@Override
public void onError(Throwable cause) throws Exception {
log.warn("PARTICIPANT {}: Could not release incoming EP for {}", userSession.getUserId(),
remoteParticipantId);
}
});
}
}
示例7: cancelVideoFrom
import org.kurento.client.WebRtcEndpoint; //导入依赖的package包/类
public void cancelVideoFrom(final String senderName) {
log.debug("PARTICIPANT {}: canceling video reception from {}", this.name, senderName);
final WebRtcEndpoint incoming = incomingMedia.remove(senderName);
log.debug("PARTICIPANT {}: removing endpoint for {}", this.name, senderName);
incoming.release(new Continuation<Void>() {
@Override
public void onSuccess(Void result) throws Exception {
log.trace("PARTICIPANT {}: Released successfully incoming EP for {}",
UserSession.this.name, senderName);
}
@Override
public void onError(Throwable cause) throws Exception {
log.warn("PARTICIPANT {}: Could not release incoming EP for {}", UserSession.this.name,
senderName);
}
});
}
示例8: connectAccordingToProfile
import org.kurento.client.WebRtcEndpoint; //导入依赖的package包/类
private void connectAccordingToProfile(WebRtcEndpoint webRtcEndpoint, RecorderEndpoint recorder,
MediaProfileSpecType profile) {
switch (profile) {
case WEBM:
webRtcEndpoint.connect(recorder, MediaType.AUDIO);
webRtcEndpoint.connect(recorder, MediaType.VIDEO);
break;
case WEBM_AUDIO_ONLY:
webRtcEndpoint.connect(recorder, MediaType.AUDIO);
break;
case WEBM_VIDEO_ONLY:
webRtcEndpoint.connect(recorder, MediaType.VIDEO);
break;
default:
throw new UnsupportedOperationException("Unsupported profile for this tutorial: " + profile);
}
}
示例9: crunchPipeline
import org.kurento.client.WebRtcEndpoint; //导入依赖的package包/类
private void crunchPipeline(MediaPipeline p) {
try {
List<MediaObject> mediaObjects = p.getChilds();
numElements.addSample(mediaObjects.size());
for (MediaObject o : mediaObjects) {
if (o.getId().indexOf("WebRtcEndpoint") >= 0) {
WebRtcEndpoint webRtcEndpoint = (WebRtcEndpoint) o;
numWebRtcEndpoints.addSample(1);
crunchWebRtcEndpoint(webRtcEndpoint);
}
}
} catch (Throwable t) {
// The pipeline may have been released. This does not need to be a
// "severe" problem
// TODO log t just in case
t.printStackTrace();
}
}
示例10: subscribe
import org.kurento.client.WebRtcEndpoint; //导入依赖的package包/类
public synchronized void subscribe(String remoteName) {
try {
if (peerEndpoints.containsKey(remoteName)) {
log.warn("Already subscribed to {}", remoteName);
return;
}
String sdpOffer = createWebRtcForPeer(remoteName);
String sdpAnswer = jsonRpcClient.receiveVideoFrom(peerStreams.get(remoteName), sdpOffer);
WebRtcEndpoint peer = peerEndpoints.get(remoteName);
if (peer == null) {
throw new Exception("Receiving endpoint not found for peer " + remoteName);
}
peer.processAnswer(sdpAnswer);
peer.gatherCandidates();
log.debug("Subscribed to '{}' in room '{}'", peerStreams.get(remoteName), room);
log.trace("Subscribed to '{}' in room '{}' - SDP OFFER:\n{}\nSDP ANSWER:\n{}",
peerStreams.get(remoteName), room, sdpOffer, sdpAnswer);
} catch (Exception e) {
log.warn("Unable to subscribe in room '{}' to '{}'", room, remoteName, e);
Assert.fail("Unable to subscribe: " + e.getMessage());
}
}
示例11: unsubscribe
import org.kurento.client.WebRtcEndpoint; //导入依赖的package包/类
public synchronized void unsubscribe(String remoteName) {
WebRtcEndpoint peer = null;
try {
peer = peerEndpoints.get(remoteName);
if (peer == null) {
log.warn("No local peer found for remote {}", remoteName);
}
jsonRpcClient.unsubscribeFromVideo(peerStreams.get(remoteName));
log.debug("Unsubscribed from {}", peerStreams.get(remoteName));
} catch (IOException e) {
log.warn("Unable to unsubscribe in room '{}' from '{}'", room, remoteName, e);
Assert.fail("Unable to unsubscribe: " + e.getMessage());
} finally {
if (peer != null) {
peer.release();
}
peerEndpoints.remove(remoteName);
peerLatches.remove(remoteName);
}
}
示例12: publishWithLoopbackError
import org.kurento.client.WebRtcEndpoint; //导入依赖的package包/类
@Test
public void publishWithLoopbackError() {
joinManyUsersOneRoom();
String participantId0 = usersParticipantIds.get(users[0]);
doThrow(
new RoomException(Code.MEDIA_WEBRTC_ENDPOINT_ERROR_CODE, "Loopback connection error test"))
.when(passThru).connect(any(WebRtcEndpoint.class), Matchers.<Continuation<Void>> any());
exception.expect(RoomException.class);
exception.expectMessage(containsString("Loopback connection error test"));
assertEquals("SDP answer doesn't match", SDP_WEB_ANSWER,
manager.publishMedia(participantId0, true, SDP_WEB_OFFER, true));
assertThat(manager.getPublishers(roomx).size(), is(0));
assertThat(manager.getSubscribers(roomx).size(), is(0));
}
示例13: RoomParticipant
import org.kurento.client.WebRtcEndpoint; //导入依赖的package包/类
public RoomParticipant(String name, Room room, WebSocketSession session, MediaPipeline pipeline) {
this.pipeline = pipeline;
this.name = name;
this.session = session;
this.room = room;
this.receivingEndpoint = new WebRtcEndpoint.Builder(pipeline).build();
this.senderThread = new Thread("sender:" + name) {
@Override
public void run() {
try {
internalSendMessage();
} catch (InterruptedException e) {
return;
}
}
};
this.senderThread.start();
}
示例14: releaseAllFakePipelines
import org.kurento.client.WebRtcEndpoint; //导入依赖的package包/类
public void releaseAllFakePipelines(long timeBetweenClientMs, SystemMonitorManager monitor) {
for (WebRtcEndpoint fakeWebRtc : fakeWebRtcList) {
monitor.decrementNumClients();
waitMs(timeBetweenClientMs);
}
for (WebRtcEndpoint fakeBrowser : fakeBrowserList) {
fakeBrowser.release();
waitMs(timeBetweenClientMs);
}
for (MediaPipeline fakeMediaPipeline : fakeMediaPipelineList) {
fakeMediaPipeline.release();
}
fakeWebRtcList = new ArrayList<>();
fakeBrowserList = new ArrayList<>();
fakeMediaPipelineList = new ArrayList<MediaPipeline>();
}
示例15: getEndpointForUser
import org.kurento.client.WebRtcEndpoint; //导入依赖的package包/类
private WebRtcEndpoint getEndpointForUser(final UserSession sender) {
if (sender.getName().equals(name)) {
log.debug("PARTICIPANT {}: configuring loopback", this.name);
return outgoingMedia;
}
log.debug("PARTICIPANT {}: receiving video from {}", this.name, sender.getName());
WebRtcEndpoint incoming = incomingMedia.get(sender.getName());
if (incoming == null) {
log.debug("PARTICIPANT {}: creating new endpoint for {}", this.name, sender.getName());
incoming = new WebRtcEndpoint.Builder(pipeline).build();
incoming.addIceCandidateFoundListener(new EventListener<IceCandidateFoundEvent>() {
@Override
public void onEvent(IceCandidateFoundEvent event) {
JsonObject response = new JsonObject();
response.addProperty("id", "iceCandidate");
response.addProperty("name", sender.getName());
response.add("candidate", JsonUtils.toJsonObject(event.getCandidate()));
try {
synchronized (session) {
session.sendMessage(new TextMessage(response.toString()));
}
} catch (IOException e) {
log.debug(e.getMessage());
}
}
});
incomingMedia.put(sender.getName(), incoming);
}
log.debug("PARTICIPANT {}: obtained endpoint for {}", this.name, sender.getName());
sender.getOutgoingWebRtcPeer().connect(incoming);
return incoming;
}