/* * (C) Copyright 2015 Kurento (http://kurento.org/) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package org.kurento.test.stability.player; import java.awt.Color; import java.util.Collection; import java.util.concurrent.TimeUnit; import org.junit.Assert; import org.junit.Test; import org.junit.runners.Parameterized.Parameters; import org.kurento.client.MediaPipeline; import org.kurento.client.PlayerEndpoint; import org.kurento.client.WebRtcEndpoint; import org.kurento.test.base.StabilityTest; import org.kurento.test.browser.WebRtcChannel; import org.kurento.test.browser.WebRtcMode; import org.kurento.test.config.TestScenario; /** * Test of multiple pauses in a PlayerEndpoint. * </p> * Media Pipeline(s): * <ul> * <li>PlayerEndpoint -> WebRtcEndpoint</li> * </ul> * Browser(s): * <ul> * <li>Chrome</li> * <li>Firefox</li> * </ul> * Test logic: * <ol> * <li>(KMS) During the playback of a stream from a PlayerEndpoint to a WebRtcEndpoint, the * PlayerEndpoint is paused many times</li> * <li>(Browser) WebRtcPeer in rcv-only receives media</li> * </ol> * Main assertion(s): * <ul> * <li>Color or the video should remain when a video is paused</li> * </ul> * Secondary assertion(s): * <ul> * <li>Playing event should be received in remote video tag</li> * </ul> * * @author Boni Garcia (bgarcia@gsyc.es) * @since 6.1.1 */ public class PlayerMultiplePauseTest extends StabilityTest { @Parameters(name = "{index}: {0}") public static Collection<Object[]> data() { return TestScenario.localChromeAndFirefox(); } @Test public void testPlayerMultiplePause() throws Exception { // Test data final String mediaUrl = "http://" + getTestFilesHttpPath() + "/video/60sec/red.webm"; final Color expectedColor = Color.RED; final int playTimeSeconds = 2; final int pauseTimeSeconds = 2; final int numPauses = 30; // Media Pipeline MediaPipeline mp = kurentoClient.createMediaPipeline(); PlayerEndpoint playerEp = new PlayerEndpoint.Builder(mp, mediaUrl).build(); WebRtcEndpoint webRtcEp = new WebRtcEndpoint.Builder(mp).build(); playerEp.connect(webRtcEp); // WebRTC in receive-only mode getPage().subscribeEvents("playing"); getPage().initWebRtc(webRtcEp, WebRtcChannel.AUDIO_AND_VIDEO, WebRtcMode.RCV_ONLY); playerEp.play(); Assert.assertTrue("Not received media (timeout waiting playing event)", getPage().waitForEvent("playing")); for (int i = 0; i < numPauses; i++) { // Assert color Assert.assertTrue("The color of the video should be " + expectedColor, getPage().similarColor(expectedColor)); // Pause and wait playerEp.pause(); Thread.sleep(TimeUnit.SECONDS.toMillis(pauseTimeSeconds)); // Resume video playerEp.play(); Thread.sleep(TimeUnit.SECONDS.toMillis(playTimeSeconds)); } // Release Media Pipeline mp.release(); } }