本文整理汇总了Java中org.kurento.client.ErrorEvent类的典型用法代码示例。如果您正苦于以下问题:Java ErrorEvent类的具体用法?Java ErrorEvent怎么用?Java ErrorEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ErrorEvent类属于org.kurento.client包,在下文中一共展示了ErrorEvent类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PlayMediaPipeline
import org.kurento.client.ErrorEvent; //导入依赖的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: createPipeline
import org.kurento.client.ErrorEvent; //导入依赖的package包/类
public void createPipeline() {
synchronized (pipelineCreateLock) {
if (pipeline != null) {
return;
}
log.info("Session '{}': Creating MediaPipeline-{}", room, description);
try {
pipeline = kurento.createMediaPipeline();
pipelineLatch.countDown();
log.debug("Session '{}': Created MediaPipeline-{}", room, description);
} catch (Exception e) {
log.error("Unable to create MediaPipeline-{} for Session '{}'", description, room, e);
pipelineLatch.countDown();
}
if (getPipeline() == null) {
throw new RuntimeException("Unable to create MediaPipeline-" + description
+ " for session '" + room + "'");
}
pipeline.addErrorListener(new EventListener<ErrorEvent>() {
@Override
public void onEvent(ErrorEvent event) {
String desc = event.getType() + ": " + event.getDescription() + "(errCode="
+ event.getErrorCode() + ")";
log.warn("Session '{}': Pipeline error encountered for MediaPipeline-{}: {}", room,
description, desc);
}
});
}
}
示例3: registerElemErrListener
import org.kurento.client.ErrorEvent; //导入依赖的package包/类
/**
* Registers a listener for when the {@link MediaElement} triggers an {@link ErrorEvent}. Notifies
* the owner with the error.
*
* @param element
* the {@link MediaElement}
* @return {@link ListenerSubscription} that can be used to deregister the listener
*/
protected ListenerSubscription registerElemErrListener(MediaElement element) {
return element.addErrorListener(new EventListener<ErrorEvent>() {
@Override
public void onEvent(ErrorEvent event) {
owner.sendMediaError(event);
}
});
}
示例4: pipelineError
import org.kurento.client.ErrorEvent; //导入依赖的package包/类
@Test
public void pipelineError() {
joinManyUsersOneRoom();
// verifies pipeline error listener is added to room
verify(pipeline, times(1)).addErrorListener(pipelineErrorEventCaptor.capture());
// stub sendNotification of type MEDIAERROR_METHOD
final String expectedErrorMessage = "TEST_PP_ERR: Fake pipeline error(errCode=505)";
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
assertThat(args.length, is(3));
assertThat(args[0], instanceOf(String.class));
String participantId = (String) args[0];
assertThat(usersParticipantRequests.keySet(), hasItem(participantId));
assertThat(participantId, is(not(userx)));
assertThat(args[2], instanceOf(JsonObject.class));
JsonObject params = (JsonObject) args[2];
assertNotNull(params.get(ProtocolElements.MEDIAERROR_ERROR_PARAM));
String error = params.get(ProtocolElements.MEDIAERROR_ERROR_PARAM).getAsString();
assertThat(error, is(expectedErrorMessage));
return null;
}
}).when(notificationService).sendNotification(anyString(),
eq(ProtocolElements.MEDIAERROR_METHOD), Matchers.isA(JsonObject.class));
// triggers the last captured listener
pipelineErrorEventCaptor.getValue().onEvent(
new ErrorEvent(pipeline, "12345", null, "Fake pipeline error", 505, "TEST_PP_ERR"));
// the error was "triggered" one time and all participants get notified
verifyNotificationService(users.length, 0, usersParticipantRequests.size(),
ProtocolElements.MEDIAERROR_METHOD);
}
示例5: test
import org.kurento.client.ErrorEvent; //导入依赖的package包/类
@Test
public void test() throws InterruptedException {
// Media Pipeline
MediaPipeline mp = kurentoClient.createMediaPipeline();
String videoPath = "file://" + getTestFilesDiskPath() + "/video/filter/barcodes.webm";
PlayerEndpoint p = new PlayerEndpoint.Builder(mp, videoPath).build();
final CountDownLatch latch = new CountDownLatch(1);
p.addErrorListener(new EventListener<ErrorEvent>() {
@Override
public void onEvent(ErrorEvent event) {
log.warn("Error un player: " + event.getDescription());
latch.countDown();
}
});
p.play();
if (latch.await(5, TimeUnit.SECONDS)) {
fail("Player error");
}
// Release Media Pipeline
mp.release();
}
示例6: sendMediaError
import org.kurento.client.ErrorEvent; //导入依赖的package包/类
public void sendMediaError(ErrorEvent event) {
String desc =
event.getType() + ": " + event.getDescription() + "(errCode=" + event.getErrorCode() + ")";
log.warn("PARTICIPANT {}: Media error encountered: {}", name, desc);
room.sendMediaError(id, desc);
}
示例7: createPipeline
import org.kurento.client.ErrorEvent; //导入依赖的package包/类
private void createPipeline() {
synchronized (pipelineCreateLock) {
if (pipeline != null) {
return;
}
log.info("ROOM {}: Creating MediaPipeline", name);
try {
kurentoClient.createMediaPipeline(new Continuation<MediaPipeline>() {
@Override
public void onSuccess(MediaPipeline result) throws Exception {
pipeline = result;
pipelineLatch.countDown();
log.debug("ROOM {}: Created MediaPipeline", name);
}
@Override
public void onError(Throwable cause) throws Exception {
pipelineLatch.countDown();
log.error("ROOM {}: Failed to create MediaPipeline", name, cause);
}
});
} catch (Exception e) {
log.error("Unable to create media pipeline for room '{}'", name, e);
pipelineLatch.countDown();
}
if (getPipeline() == null) {
throw new RoomException(Code.ROOM_CANNOT_BE_CREATED_ERROR_CODE,
"Unable to create media pipeline for room '" + name + "'");
}
pipeline.addErrorListener(new EventListener<ErrorEvent>() {
@Override
public void onEvent(ErrorEvent event) {
String desc =
event.getType() + ": " + event.getDescription() + "(errCode=" + event.getErrorCode()
+ ")";
log.warn("ROOM {}: Pipeline error encountered: {}", name, desc);
roomHandler.onPipelineError(name, getParticipantIds(), desc);
}
});
}
}
示例8: pipelineError
import org.kurento.client.ErrorEvent; //导入依赖的package包/类
@Test
public void pipelineError() {
joinManyUsersOneRoom();
// verifies pipeline error listener is added to room
verify(pipeline, times(1)).addErrorListener(pipelineErrorEventCaptor.capture());
final String expectedErrorMessage = "TEST_PP_ERR: Fake pipeline error(errCode=505)";
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
Object[] args = invocation.getArguments();
assertThat(args.length, is(3));
// first arg : roomName
assertThat(args[0], instanceOf(String.class));
assertEquals(roomx, args[0]);
// second arg : participantIds
assertThat(args[1], instanceOf(Set.class));
Set<String> pids = new HashSet<String>();
for (Object o : (Set<?>) args[1]) {
assertThat(o, instanceOf(String.class));
pids.add((String) o);
}
assertThat(
pids,
CoreMatchers.hasItems(usersParticipantIds.values().toArray(
new String[usersParticipantIds.size()])));
// third arg : error description
assertThat(args[2], instanceOf(String.class));
assertEquals(expectedErrorMessage, args[2]);
return null;
}
}).when(roomHandler).onPipelineError(anyString(), Matchers.<Set<String>> any(), anyString());
// triggers the last captured listener
pipelineErrorEventCaptor.getValue().onEvent(
new ErrorEvent(pipeline, "12345", null, "Fake pipeline error", 505, "TEST_PP_ERR"));
// verifies the handler's method was called only once (one captor event)
verify(roomHandler, times(1)).onPipelineError(anyString(), Matchers.<Set<String>> any(),
anyString());;
}
示例9: doTest
import org.kurento.client.ErrorEvent; //导入依赖的package包/类
public void doTest(MediaProfileSpecType mediaProfileSpecType, String expectedVideoCodec,
String expectedAudioCodec, String extension, String[] mediaUrls, Color[] expectedColors)
throws Exception {
// Media Pipeline #1
MediaPipeline mp = kurentoClient.createMediaPipeline();
final CountDownLatch errorPipelinelatch = new CountDownLatch(1);
mp.addErrorListener(new EventListener<ErrorEvent>() {
@Override
public void onEvent(ErrorEvent event) {
msgError = "Description:" + event.getDescription() + "; Error code:" + event.getType();
errorPipelinelatch.countDown();
}
});
int numPlayers = mediaUrls.length;
PlayerEndpoint[] players = new PlayerEndpoint[numPlayers];
for (int i = 0; i < numPlayers; i++) {
players[i] = new PlayerEndpoint.Builder(mp, mediaUrls[i]).build();
}
WebRtcEndpoint webRtcEp = new WebRtcEndpoint.Builder(mp).build();
final CountDownLatch recorderLatch = new CountDownLatch(1);
String recordingFile = getRecordUrl(extension);
RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFile)
.withMediaProfile(mediaProfileSpecType).build();
// Test execution
getPage().subscribeEvents("playing");
getPage().initWebRtc(webRtcEp, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.RCV_ONLY);
boolean startRecord = false;
for (int i = 0; i < numPlayers; i++) {
players[i].connect(webRtcEp);
players[i].connect(recorderEp);
players[i].play();
if (!startRecord) {
Assert.assertTrue("Not received media (timeout waiting playing event)",
getPage().waitForEvent("playing"));
recorderEp.record();
startRecord = true;
}
waitSeconds(PLAYTIME / numPlayers);
}
// Release Media Pipeline #1
saveGstreamerDot(mp);
recorderEp.stopAndWait(new Continuation<Void>() {
@Override
public void onSuccess(Void result) throws Exception {
recorderLatch.countDown();
}
@Override
public void onError(Throwable cause) throws Exception {
recorderLatch.countDown();
}
});
Assert.assertTrue("Not stop properly",
recorderLatch.await(getPage().getTimeout(), TimeUnit.SECONDS));
mp.release();
Assert.assertTrue(msgError, errorPipelinelatch.getCount() == 1);
// Reloading browser
getPage().reload();
checkRecordingFile(recordingFile, "browser", expectedColors, PLAYTIME, expectedVideoCodec,
expectedAudioCodec);
success = true;
}
示例10: doTestWithPlayer
import org.kurento.client.ErrorEvent; //导入依赖的package包/类
public void doTestWithPlayer(MediaProfileSpecType mediaProfileSpecType, String expectedVideoCodec,
String expectedAudioCodec, String extension, String mediaUrlPlayer) throws Exception {
// Media Pipeline #1
getPage(BROWSER2).close();
MediaPipeline mp = kurentoClient.createMediaPipeline();
final CountDownLatch errorPipelinelatch = new CountDownLatch(1);
mp.addErrorListener(new EventListener<ErrorEvent>() {
@Override
public void onEvent(ErrorEvent event) {
msgError = "Description:" + event.getDescription() + "; Error code:" + event.getType();
errorPipelinelatch.countDown();
}
});
WebRtcEndpoint webRtcEpRed = new WebRtcEndpoint.Builder(mp).build();
PlayerEndpoint playerEp = new PlayerEndpoint.Builder(mp, mediaUrlPlayer).build();
String recordingFile = getRecordUrl(extension);
RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFile)
.withMediaProfile(mediaProfileSpecType).build();
PassThrough passThrough = new PassThrough.Builder(mp).build();
passThrough.connect(recorderEp);
// Test execution
getPage(BROWSER1).subscribeLocalEvents("playing");
long startWebrtc = System.currentTimeMillis();
getPage(BROWSER1).initWebRtc(webRtcEpRed, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY);
webRtcEpRed.connect(passThrough);
recorderEp.record();
Assert.assertTrue("Not received media (timeout waiting playing event)",
getPage(BROWSER1).waitForEvent("playing"));
long webrtcRedConnectionTime = System.currentTimeMillis() - startWebrtc;
Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER);
startWebrtc = System.currentTimeMillis();
playerEp.play();
playerEp.connect(passThrough);
long playerEpConnectionTime = System.currentTimeMillis() - startWebrtc;
Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER);
webRtcEpRed.connect(passThrough);
Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER);
// Release Media Pipeline #1
saveGstreamerDot(mp);
final CountDownLatch recorderLatch = new CountDownLatch(1);
recorderEp.stopAndWait(new Continuation<Void>() {
@Override
public void onSuccess(Void result) throws Exception {
recorderLatch.countDown();
}
@Override
public void onError(Throwable cause) throws Exception {
recorderLatch.countDown();
}
});
Assert.assertTrue("Not stop properly",
recorderLatch.await(getPage(BROWSER1).getTimeout(), TimeUnit.SECONDS));
mp.release();
Assert.assertTrue(msgError, errorPipelinelatch.getCount() == 1);
final long playtime = PLAYTIME
+ TimeUnit.MILLISECONDS.toSeconds((2 * webrtcRedConnectionTime) + playerEpConnectionTime);
checkRecordingFile(recordingFile, BROWSER3, EXPECTED_COLORS, playtime, expectedVideoCodec,
expectedAudioCodec);
success = true;
}
开发者ID:Kurento,项目名称:kurento-java,代码行数:80,代码来源:RecorderSwitchWebRtcWebRtcPlayerWithPassThroughTest.java
示例11: doTestWithPlayer
import org.kurento.client.ErrorEvent; //导入依赖的package包/类
public void doTestWithPlayer(MediaProfileSpecType mediaProfileSpecType, String expectedVideoCodec,
String expectedAudioCodec, String extension, String mediaUrlPlayer) throws Exception {
// Media Pipeline #1
getPage(BROWSER2).close();
MediaPipeline mp = kurentoClient.createMediaPipeline();
final CountDownLatch errorPipelinelatch = new CountDownLatch(1);
mp.addErrorListener(new EventListener<ErrorEvent>() {
@Override
public void onEvent(ErrorEvent event) {
msgError = "Description:" + event.getDescription() + "; Error code:" + event.getType();
errorPipelinelatch.countDown();
}
});
WebRtcEndpoint webRtcEpRed = new WebRtcEndpoint.Builder(mp).build();
PlayerEndpoint playerEp = new PlayerEndpoint.Builder(mp, mediaUrlPlayer).build();
String recordingFile = getRecordUrl(extension);
RecorderEndpoint recorderEp = new RecorderEndpoint.Builder(mp, recordingFile)
.withMediaProfile(mediaProfileSpecType).build();
// Test execution
getPage(BROWSER1).subscribeLocalEvents("playing");
long startWebrtc = System.currentTimeMillis();
getPage(BROWSER1).initWebRtc(webRtcEpRed, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.SEND_ONLY);
webRtcEpRed.connect(recorderEp);
recorderEp.record();
Assert.assertTrue("Not received media (timeout waiting playing event)",
getPage(BROWSER1).waitForEvent("playing"));
long webrtcRedConnectionTime = System.currentTimeMillis() - startWebrtc;
Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER);
startWebrtc = System.currentTimeMillis();
playerEp.play();
playerEp.connect(recorderEp);
long playerEpConnectionTime = System.currentTimeMillis() - startWebrtc;
Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER);
webRtcEpRed.connect(recorderEp);
Thread.sleep(TimeUnit.SECONDS.toMillis(PLAYTIME) / N_PLAYER);
// Release Media Pipeline #1
saveGstreamerDot(mp);
final CountDownLatch recorderLatch = new CountDownLatch(1);
recorderEp.stopAndWait(new Continuation<Void>() {
@Override
public void onSuccess(Void result) throws Exception {
recorderLatch.countDown();
}
@Override
public void onError(Throwable cause) throws Exception {
recorderLatch.countDown();
}
});
Assert.assertTrue("Not stop properly",
recorderLatch.await(getPage(BROWSER1).getTimeout(), TimeUnit.SECONDS));
mp.release();
Assert.assertTrue(msgError, errorPipelinelatch.getCount() == 1);
final long playtime = PLAYTIME
+ TimeUnit.MILLISECONDS.toSeconds((2 * webrtcRedConnectionTime) + playerEpConnectionTime);
checkRecordingFile(recordingFile, BROWSER3, EXPECTED_COLORS, playtime, expectedVideoCodec,
expectedAudioCodec);
success = true;
}
示例12: doTest
import org.kurento.client.ErrorEvent; //导入依赖的package包/类
public void doTest(final MediaProfileSpecType mediaProfileSpecType, String expectedAudioCodec,
final String extension) throws Exception {
long testDurationMillis =
PropertiesManager.getProperty(TEST_DURATION_PROPERTY, DEFAULT_TEST_DURATION);
MediaPipeline mp = kurentoClient.createMediaPipeline();
final CountDownLatch errorPipelinelatch = new CountDownLatch(1);
mp.addErrorListener(new EventListener<ErrorEvent>() {
@Override
public void onEvent(ErrorEvent event) {
msgError = "Description:" + event.getDescription() + "; Error code:" + event.getType();
log.error(msgError);
errorPipelinelatch.countDown();
}
});
final WebRtcEndpoint webRtcSender = new WebRtcEndpoint.Builder(mp).build();
// WebRTC sender negotiation
getPage().subscribeLocalEvents("playing");
getPage().initWebRtc(webRtcSender, WebRtcChannel.AUDIO_ONLY, WebRtcMode.SEND_ONLY);
Assert.assertTrue("Not received media in sender webrtc", getPage().waitForEvent("playing"));
// Recorder
String recordingFile = getRecordUrl(extension);
RecorderEndpoint recorder = new RecorderEndpoint.Builder(mp, recordingFile)
.withMediaProfile(mediaProfileSpecType).build();
webRtcSender.connect(recorder);
// Start recorder
recorder.record();
// Wait recording time
Thread.sleep(testDurationMillis);
// Stop recorder
final CountDownLatch recorderLatch = new CountDownLatch(1);
recorder.stopAndWait(new Continuation<Void>() {
@Override
public void onSuccess(Void result) throws Exception {
recorderLatch.countDown();
}
@Override
public void onError(Throwable cause) throws Exception {
recorderLatch.countDown();
}
});
// Release Media Pipeline
Assert.assertTrue("Not stop properly",
recorderLatch.await(getPage().getTimeout(), TimeUnit.SECONDS));
if (mp != null) {
mp.release();
}
Assert.assertTrue(msgError, errorPipelinelatch.getCount() == 1);
waitForFileExists(recordingFile);
// Assessments
AssertMedia.assertDuration(recordingFile, testDurationMillis, THRESHOLD_MS);
}