}
public void doTest(Browser browserType, String video, Color color)
throws InterruptedException {
// Media Pipeline #1
MediaPipeline mp = pipelineFactory.create();
WebRtcEndpoint webRtcEP = mp.newWebRtcEndpoint().build();
RecorderEndpoint recorderEP = mp.newRecorderEndpoint(
FILE_SCHEMA + getDefaultFileForRecording()).build();
webRtcEP.connect(webRtcEP);
webRtcEP.connect(recorderEP);
// Test execution #1. WewbRTC in loopback while it is recorded
BrowserClient.Builder builder = new BrowserClient.Builder().browser(
browserType).client(Client.WEBRTC);
if (video != null) {
builder = builder.video(video);
}
try (BrowserClient browser = builder.build()) {
browser.subscribeEvents("playing");
browser.connectToWebRtcEndpoint(webRtcEP,
WebRtcChannel.AUDIO_AND_VIDEO);
recorderEP.record();
// Wait until event playing in the remote stream
Assert.assertTrue("Timeout waiting playing event",
browser.waitForEvent("playing"));
// Guard time to play the video
Thread.sleep(PLAYTIME * 1000);
// Assert play time
double currentTime = browser.getCurrentTime();
Assert.assertTrue("Error in play time of HTTP player (expected: "
+ PLAYTIME + " sec, real: " + currentTime + " sec)",
compare(PLAYTIME, currentTime));
// Assert color
if (color != null) {
Assert.assertTrue("The color of the video should be " + color,
browser.colorSimilarTo(color));
}
}
// Stop and release media elements
recorderEP.stop();
webRtcEP.release();
recorderEP.release();
// Media Pipeline #2
PlayerEndpoint playerEP = mp.newPlayerEndpoint(
FILE_SCHEMA + getDefaultFileForRecording()).build();
HttpGetEndpoint httpEP = mp.newHttpGetEndpoint().terminateOnEOS()
.build();
playerEP.connect(httpEP);
// Test execution #2. Play the recorded video
try (BrowserClient browser = new BrowserClient.Builder()