class TestThunderPlayerInfoWSAPI(unittest.TestCase): def setUp(self): self.__cpe_ip = sys.argv[1] self.__thunder_handler = ThunderWSAPI() self.__thunder_handler.open_ws_connection(self.__cpe_ip + ":9998/jsonrpc") self.__thunder_handler.controller_activate_plugin("PlayerInfo") def tearDown(self): self.__thunder_handler.close_ws_connection() def test_G1_verify_playerinfo_plugin(self): with self.subTest(msg="Fail while checking: PlayerInfo plugin"): codecs_list = [ "VideoH263", "VideoH264", "VideoH265", "VideoMpeg", "VideoVp8", "VideoVp9" ] msg_prefix = "Method: playerinfo_videocodecs" result = self.__thunder_handler.playerinfo_videocodecs() self.assertFalse("error" in result, msg_prefix + " return error") self.assertEqual( len(result['result']), len(codecs_list), msg_prefix + " return unexpected number of video codecs") for codec in codecs_list: self.assertTrue( codec in result['result'], msg_prefix + " didn't return video codec: " + codec) with self.subTest(msg="Fail while checking: PlayerInfo plugin"): codecs_list = [ "AudioAac", "AudioAc3", "AudioAc3Plus", "AudioDts", "AudioMpeg1", "AudioMpeg2", "AudioMpeg3", "AudioMpeg4", "AudioOpus", "AudioVorbisOgg" ] # exclude "AudioUndefined", msg_prefix = "Method: playerinfo_audiocodecs" result = self.__thunder_handler.playerinfo_audiocodecs() self.assertFalse("error" in result, msg_prefix + " return error") self.assertEqual( len(result['result']), len(codecs_list), msg_prefix + " return unexpected number of audio codecs") for codec in codecs_list: self.assertTrue( codec in result['result'], msg_prefix + " didn't return audio codec: " + codec) with self.subTest(msg="Fail while checking: PlayerInfo plugin"): pfx = "FMP" pid = "MyPlayer" url = "http://wowzaec2demo.streamlock.net/vod/_definst_/ElephantsDream/smil:ElephantsDream.smil/manifest_mvtime.mpd" self.assertFalse("error" in result, pfx + " return error") self.__thunder_handler.controller_activate_plugin("OCDM") self.__thunder_handler.controller_activate_plugin( "org.rdk.FireboltMediaPlayer") result = self.__thunder_handler.fmp_create(pid) result = self.__thunder_handler.fmp_load(pid, url, False) self.assertFalse("error" in result, pfx + " return error") result = self.__thunder_handler.fmp_play(pid) self.assertFalse("error" in result, pfx + " return error") time.sleep(5) validate_list = [ "Resolution480I", "Resolution480P", "Resolution576I", "Resolution576P", "Resolution720P", "Resolution1080I", "Resolution1080P", "Resolution2160P30", "Resolution2160P60" ] # exclude "ResolutionUnknown" msg_prefix = "Method: playerinfo_resolution" result = self.__thunder_handler.playerinfo_resolution() self.assertFalse("error" in result, msg_prefix + " return error") self.assertTrue( result['result'] in validate_list, msg_prefix + " return unexpected value: " + str(result['result'])) result = self.__thunder_handler.fmp_stop(pid) self.assertFalse("error" in result, pfx + " return error at stop") result = self.__thunder_handler.fmp_release(pid) self.assertFalse("error" in result, pfx + " return error at release") with self.subTest(msg="Fail while checking: PlayerInfo plugin"): msg_prefix = "Method: playerinfo_isaudioequivalenceenabled" result = self.__thunder_handler.playerinfo_isaudioequivalenceenabled( ) self.assertFalse("error" in result, msg_prefix + " return error") self.assertTrue( type(result['result']) is bool, msg_prefix + " result is not boolen value") with self.subTest(msg="Fail while checking: PlayerInfo plugin"): msg_prefix = "Method: playerinfo_dolby_atmosmetadata" result = self.__thunder_handler.playerinfo_dolby_atmosmetadata() self.assertFalse("error" in result, msg_prefix + " return error") self.assertTrue( type(result['result']) is bool, msg_prefix + " result is not boolen value") with self.subTest(msg="Fail while checking: PlayerInfo plugin"): validate_list = ["Mono", "Stereo", "Surround", "Passthru"] # exclude "Unknown" msg_prefix = "Method: playerinfo_dolby_soundmode" result = self.__thunder_handler.playerinfo_dolby_soundmode() self.assertFalse("error" in result, msg_prefix + " return error") self.assertTrue( result['result'] in validate_list, msg_prefix + " return unexpected value: " + str(result['result'])) with self.subTest(msg="Fail while checking: PlayerInfo plugin"): msg_prefix = "Method: playerinfo_dolby_enableatmosoutput" result = self.__thunder_handler.playerinfo_dolby_enableatmosoutput( True) self.assertFalse("error" in result, msg_prefix + " return error") result = self.__thunder_handler.playerinfo_dolby_enableatmosoutput( False) self.assertFalse("error" in result, msg_prefix + " return error") with self.subTest(msg="Fail while checking: PlayerInfo plugin"): validate_list = [ "DigitalPcm", "DigitalPlus", "DigitalAc3", "Auto", "Ms12" ] msg_prefix = "Method: playerinfo_dolby_get_mode" result = self.__thunder_handler.playerinfo_dolby_get_mode() self.assertFalse("error" in result, msg_prefix + " return error") self.assertTrue( result['result'] in validate_list, msg_prefix + " return unexpected value: " + str(result['result'])) for dolby_mode in validate_list: result = self.__thunder_handler.playerinfo_dolby_set_mode( dolby_mode) msg_prefix = "Method: playerinfo_dolby_set_mode" self.assertFalse("error" in result, msg_prefix + " return error") result = self.__thunder_handler.playerinfo_dolby_get_mode() msg_prefix = "Method: playerinfo_dolby_get_mode" self.assertEqual( result['result'], dolby_mode, msg_prefix + " return " + str(result['result']) + " instead of " + dolby_mode)
class TestThunderFmpWSAPI(unittest.TestCase): def setUp(self): self.pid = "MyPlayer" self.handler = FmpEventHandler(self.pid) self.__cpe_ip = sys.argv[1] self.__thunder_handler = ThunderWSAPI() self.__thunder_handler.open_ws_connection( self.__cpe_ip + ":9998/jsonrpc", self.handler) self.__thunder_handler.controller_activate_plugin("OCDM") self.__thunder_handler.controller_activate_plugin( "org.rdk.FireboltMediaPlayer") def tearDown(self): self.__thunder_handler.controller_deactivate_plugin( "org.rdk.FireboltMediaPlayer") self.__thunder_handler.controller_deactivate_plugin("OCDM") self.__thunder_handler.close_ws_connection() def checkState(self, expected): with self.subTest(msg="Check state"): state = self.handler.get('state') self.assertEqual(state, expected, "Wrong state") def checkSpeed(self, expected): with self.subTest(msg="Check speed"): speed = self.handler.get('speed') self.assertEqual(speed, expected, "Wrong speed") def checkPositionGt(self, expectedSec): with self.subTest(msg="Check position"): pos = self.handler.get('positionMiliseconds') self.assertGreater(pos, expectedSec * 1000, "Wrong position") def checkPositionLs(self, expectedSec): with self.subTest(msg="Check position"): pos = self.handler.get('positionMiliseconds') self.assertLess(pos, expectedSec * 1000, "Wrong position") def checkPlayback(self, url): pfx = "FMP" pid = self.pid pos1 = 20 pos2 = 10 result = self.__thunder_handler.fmp_create(pid) self.assertFalse("error" in result, pfx + " return error") with self.subTest(msg="Register event handler"): result = self.__thunder_handler.fmp_register_event( "playbackStarted", "org.rdk.FirebolMediaPlayer.1") self.assertFalse("error" in result, pfx + " return error") result = self.__thunder_handler.fmp_register_event( "playbackStateChanged", "org.rdk.FirebolMediaPlayer.1") self.assertFalse("error" in result, pfx + " return error") result = self.__thunder_handler.fmp_register_event( "playbackProgressUpdate", "org.rdk.FirebolMediaPlayer.1") self.assertFalse("error" in result, pfx + " return error") result = self.__thunder_handler.fmp_register_event( "bufferingChanged", "org.rdk.FirebolMediaPlayer.1") self.assertFalse("error" in result, pfx + " return error") result = self.__thunder_handler.fmp_register_event( "playbackSpeedChanged", "org.rdk.FirebolMediaPlayer.1") self.assertFalse("error" in result, pfx + " return error") result = self.__thunder_handler.fmp_register_event( "playbackFailed", "org.rdk.FirebolMediaPlayer.1") self.assertFalse("error" in result, pfx + " return error") print("Load '" + url + "'") result = self.__thunder_handler.fmp_load(pid, url, False) self.assertFalse("error" in result, pfx + " return error") result = self.__thunder_handler.fmp_play(pid) self.assertFalse("error" in result, pfx + " return error") with self.subTest(msg="Seek forward"): print("Wait before seek..") time.sleep(3) result = self.__thunder_handler.fmp_seek(pid, pos1) self.assertFalse("error" in result, pfx + " return error at seek") print("Wait after seek..") time.sleep(5) self.checkState(8) self.checkSpeed(1) self.checkPositionGt(pos1) with self.subTest(msg="Pause then play"): result = self.__thunder_handler.fmp_pause(pid) self.assertFalse("error" in result, pfx + " return error at pause") print("Wait before resume..") time.sleep(3) self.checkState(6) self.checkSpeed(0) result = self.__thunder_handler.fmp_play(pid) self.assertFalse("error" in result, pfx + " return error at play") with self.subTest(msg="Seek backward"): print("Wait before seek..") time.sleep(3) result = self.__thunder_handler.fmp_seek(pid, pos2) self.assertFalse("error" in result, pfx + " return error at seek") print("Wait after seek..") time.sleep(5) self.checkPositionLs(pos1) self.checkPositionGt(pos2) with self.subTest(msg="Stop"): print("Wait before stop..") time.sleep(3) result = self.__thunder_handler.fmp_stop(pid) self.assertFalse("error" in result, pfx + " return error at stop") result = self.__thunder_handler.fmp_release(pid) self.assertFalse("error" in result, pfx + " return error at release") def test_J1_verify_fmp_hls_playback(self): self.checkPlayback( "http://demo.unified-streaming.com/video/tears-of-steel/tears-of-steel.ism/.m3u8" ) def test_J2_verify_fmp_dash_playback(self): self.checkPlayback( "http://amssamples.streaming.mediaservices.windows.net/bf657309-71d9-4436-b94b-8ac0d2ca222b/SintelTrailer.ism/manifest(format=mpd-time-csf)" )