| 1360 | | if action == 16: |
| 1361 | | # action sent by vidal_joshur at gva dot es |
| 1362 | | # start video broadcast mode |
| 1363 | | # Stream to single client unicast |
| 1364 | | eth=self.main.config.GetVar("network_interface") |
| 1365 | | |
| 1366 | | if len(connected_users) == 0 or connected_users[0] == shared.NO_LOGIN_MSG: |
| 1367 | | shared.error_msg ( _("Can't send video broadcast, user is not logged") ) |
| 1368 | | return |
| 1369 | | |
| 1370 | | str_scapes=[" ", "(", ")", "*", "!", "?", "\"", "`", "[", "]", "{", "}", ";", ":", ",", "=", "$"] |
| 1371 | | lock="disable" |
| 1372 | | volume="85" |
| 1373 | | |
| 1374 | | if self.main.pref_vlc_method_send.get_active() == 0: |
| 1375 | | vcodec=shared.vcodecs[0] |
| 1376 | | venc=shared.vencs[0] |
| 1377 | | acodec=shared.acodecs[0] |
| 1378 | | aenc=shared.aencs[0] |
| 1379 | | access=shared.accesss[0] |
| 1380 | | mux=shared.muxs[0] |
| 1381 | | elif self.main.pref_vlc_method_send.get_active() == 1: |
| 1382 | | vcodec=shared.vcodecs[1] |
| 1383 | | venc=shared.vencs[0] |
| 1384 | | acodec=shared.acodecs[0] |
| 1385 | | aenc=shared.aencs[0] |
| 1386 | | access=shared.accesss[0] |
| 1387 | | mux=shared.muxs[0] |
| 1388 | | elif self.main.pref_vlc_method_send.get_active() == 2: |
| 1389 | | vcodec=shared.vcodecs[2] |
| 1390 | | venc=shared.vencs[1] |
| 1391 | | acodec=shared.acodecs[0] |
| 1392 | | aenc=shared.aencs[0] |
| 1393 | | access=shared.accesss[0] |
| 1394 | | mux=shared.muxs[0] |
| 1395 | | elif self.main.pref_vlc_method_send.get_active() == 3: |
| 1396 | | vcodec=shared.vcodecs[3] |
| 1397 | | venc=shared.vencs[2] |
| 1398 | | acodec=shared.acodecs[1] |
| 1399 | | aenc=shared.aencs[1] |
| 1400 | | access=shared.accesss[1] |
| 1401 | | mux=shared.muxs[1] |
| 1402 | | elif self.main.pref_vlc_method_send.get_active() == 4: |
| 1403 | | vcodec=shared.vcodecs[1] |
| 1404 | | venc=shared.vencs[0] |
| 1405 | | acodec=shared.acodecs[1] |
| 1406 | | aenc=shared.aencs[1] |
| 1407 | | access=shared.accesss[1] |
| 1408 | | mux=shared.muxs[1] |
| 1409 | | |
| 1410 | | |
| 1411 | | if access == "udp": |
| 1412 | | if client_type == "tcos": |
| 1413 | | max_uip=255 |
| 1414 | | uip=0 |
| 1415 | | while uip <= max_uip: |
| 1416 | | uip_cmd="239.255.%s.0" %(uip) |
| 1417 | | cmd=("LC_ALL=C LC_MESSAGES=C netstat -putan 2>/dev/null | grep -c %s" %(uip_cmd) ) |
| 1418 | | print_debug("Check broadcast ip %s." %(uip_cmd) ) |
| 1419 | | output=self.main.common.exe_cmd(cmd) |
| 1420 | | uip+=1 |
| 1421 | | if output == "0": |
| 1422 | | print_debug("Broadcast ip found: %s" %(uip_cmd)) |
| 1423 | | ip_unicast="%s:1234" %uip_cmd |
| 1424 | | break |
| 1425 | | elif uip == max_uip: |
| 1426 | | print_debug("Not found an available broadcast ip") |
| 1427 | | return |
| 1428 | | remote_cmd="vlc udp://@%s --udp-caching=1000 --aout=alsa --brightness=2.000000 --no-x11-shm --no-xvideo-shm --volume=300 --aspect-ratio=4:3" %(ip_unicast) |
| 1429 | | else: |
| 1430 | | ip_unicast="%s:1234" %self.main.selected_ip |
| 1431 | | remote_cmd="vlc udp://@:1234 --udp-caching=1000 --aout=alsa --brightness=2.000000 --no-x11-shm --no-xvideo-shm --volume=300 --fullscreen --aspect-ratio=4:3" |
| 1432 | | else: |
| 1433 | | max_uip=50255 |
| 1434 | | uip=50000 |
| 1435 | | while uip <= max_uip: |
| 1436 | | uip_cmd=":%s" %(uip) |
| 1437 | | cmd=("LC_ALL=C LC_MESSAGES=C netstat -putan 2>/dev/null | grep -c %s" %(uip_cmd) ) |
| 1438 | | print_debug("Check broadcast ip %s." %(uip_cmd) ) |
| 1439 | | output=self.main.common.exe_cmd(cmd) |
| 1440 | | uip+=1 |
| 1441 | | if output == "0": |
| 1442 | | print_debug("Broadcast ip found: %s" %(uip_cmd)) |
| 1443 | | ip_unicast=uip_cmd |
| 1444 | | break |
| 1445 | | elif uip == max_uip: |
| 1446 | | print_debug("Not found an available broadcast ip") |
| 1447 | | return |
| 1448 | | if client_type == "tcos": |
| 1449 | | remote_cmd="vlc http://localhost%s --aout=alsa --brightness=2.000000 --no-x11-shm --no-xvideo-shm --volume=300 --aspect-ratio=4:3" %(ip_unicast) |
| 1450 | | |
| 1451 | | dialog = gtk.FileChooserDialog(_("Select audio/video file.."), |
| 1452 | | None, |
| 1453 | | gtk.FILE_CHOOSER_ACTION_OPEN, |
| 1454 | | (_("Play DVD"), 1, |
| 1455 | | _("Play SVCD/VCD"), 2, |
| 1456 | | _("Play AudioCD"), 3, |
| 1457 | | gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, |
| 1458 | | gtk.STOCK_OPEN, gtk.RESPONSE_OK)) |
| 1459 | | dialog.set_default_response(gtk.RESPONSE_OK) |
| 1460 | | self.folder = self._folder = os.environ['HOME'] |
| 1461 | | dialog.set_current_folder(self.folder) |
| 1462 | | filter = gtk.FileFilter() |
| 1463 | | filter.set_name("Media Files ( *.avi, *.mpg, *.mpeg, *.mp3, *.wav, etc.. )") |
| 1464 | | file_types=["*.avi", "*.mpg", "*.mpeg", "*.ogg", "*.ogm", "*.asf", "*.divx", |
| 1465 | | "*.wmv", "*.vob", "*.m2v", "*.m4v", "*.mp2", "*.mp4", "*.ac3", |
| 1466 | | "*.ogg", "*.mp1", "*.mp2", "*.mp3", "*.wav", "*.wma"] |
| 1467 | | for elem in file_types: |
| 1468 | | filter.add_pattern( elem ) |
| 1469 | | |
| 1470 | | dialog.add_filter(filter) |
| 1471 | | |
| 1472 | | filter = gtk.FileFilter() |
| 1473 | | filter.set_name("All Files") |
| 1474 | | filter.add_pattern("*.*") |
| 1475 | | dialog.add_filter(filter) |
| 1476 | | response = dialog.run() |
| 1477 | | if response == gtk.RESPONSE_OK or response == 1 or response == 2 or response == 3: |
| 1478 | | |
| 1479 | | filename=dialog.get_filename() |
| 1480 | | dialog.destroy() |
| 1481 | | |
| 1482 | | if filename.find(" ") != -1: |
| 1483 | | msg=_("Not allowed white spaces in \"%s\".\nPlease rename it." %os.path.basename(filename) ) |
| 1484 | | shared.info_msg( msg ) |
| 1485 | | return |
| 1486 | | |
| 1487 | | for scape in str_scapes: |
| 1488 | | filename=filename.replace("%s" %scape, "\%s" %scape) |
| 1489 | | |
| 1490 | | if response == gtk.RESPONSE_OK: |
| 1491 | | p=subprocess.Popen(["vlc", "file://%s" %filename, "--sout=#duplicate{dst=display{delay=1000},dst=\"transcode{vcodec=%s,venc=%s,acodec=%s,aenc=%s,vb=800,ab=112,channels=2,soverlay}:standard{access=%s,mux=%s,dst=%s}\"}" %(vcodec, venc, acodec, aenc, access, mux, ip_unicast), "--miface=%s" %eth, "--ttl=12", "--brightness=2.000000", "--no-x11-shm", "--no-xvideo-shm"], shell=False, bufsize=0, close_fds=True) |
| 1492 | | elif response == 1: |
| 1493 | | p=subprocess.Popen(["vlc", "dvd://", "--sout=#duplicate{dst=display{delay=1000},dst=\"transcode{vcodec=%s,venc=%s,acodec=%s,aenc=%s,vb=800,ab=112,channels=2,soverlay}:standard{access=%s,mux=%s,dst=%s}\"}" %(vcodec, venc, acodec, aenc, access, mux, ip_unicast), "--miface=%s" %eth, "--ttl=12", "--loop", "--brightness=2.000000", "--no-x11-shm", "--no-xvideo-shm"], shell=False, bufsize=0, close_fds=True) |
| 1494 | | elif response == 2: |
| 1495 | | p=subprocess.Popen(["vlc", "vcd://", "--sout=#duplicate{dst=display{delay=1000},dst=\"transcode{vcodec=%s,venc=%s,acodec=%s,aenc=%s,vb=800,ab=112,channels=2,soverlay}:standard{access=%s,mux=%s,dst=%s}\"}" %(vcodec, venc, acodec, aenc, access, mux, ip_unicast), "--miface=%s" %eth, "--ttl=12", "--brightness=2.000000", "--no-x11-shm", "--no-xvideo-shm"], shell=False, bufsize=0, close_fds=True) |
| 1496 | | elif response == 3: |
| 1497 | | p=subprocess.Popen(["vlc", "cdda:///dev/cdrom", "--sout=#duplicate{dst=display,dst=\"transcode{vcodec=%s,venc=%s,acodec=%s,aenc=%s,vb=200,ab=112,channels=2}:standard{access=%s,mux=%s,dst=%s}\"}" %(vcodec, venc, acodec, aenc, access, mux, ip_unicast), "--miface=%s" %eth, "--ttl=12", "--no-x11-shm", "--no-xvideo-shm"], shell=False, bufsize=0, close_fds=True) |
| 1498 | | # exec this app on client |
| 1499 | | |
| 1500 | | self.main.write_into_statusbar( _("Waiting for start video transmission...") ) |
| 1501 | | |
| 1502 | | msg=_("First select the DVD chapter or play movie\nthen press enter to send clients..." ) |
| 1503 | | shared.info_msg( msg ) |
| 1504 | | |
| 1505 | | # check if vlc is running or fail like check ping in demo mode |
| 1506 | | running = p.poll() is None |
| 1507 | | if not running: |
| 1508 | | self.main.write_into_statusbar( _("Error while exec app")) |
| 1509 | | return |
| 1510 | | |
| 1511 | | msg=_( "Lock keyboard and mouse on client?" ) |
| 1512 | | if shared.ask_msg ( msg ): |
| 1513 | | lock="enable" |
| 1514 | | |
| 1515 | | newusernames=[] |
| 1516 | | |
| 1517 | | for user in connected_users: |
| 1518 | | if user.find(":") != -1: |
| 1519 | | # we have a standalone user... |
| 1520 | | if access == "http": |
| 1521 | | server=self.main.xmlrpc.GetStandalone("get_server") |
| 1522 | | remote_cmd="vlc http://%s%s --aout=alsa --brightness=2.000000 --no-x11-shm --no-xvideo-shm --volume=300 --fullscreen --aspect-ratio=4:3" %(server, ip_unicast) |
| 1523 | | self.main.xmlrpc.DBus("exec", remote_cmd ) |
| 1524 | | else: |
| 1525 | | newusernames.append(user) |
| 1526 | | |
| 1527 | | result = self.main.dbus_action.do_exec( newusernames ,remote_cmd ) |
| 1528 | | |
| 1529 | | if not result: |
| 1530 | | shared.error_msg ( _("Error while exec remote app:\nReason:%s") %( self.main.dbus_action.get_error_msg() ) ) |
| 1531 | | |
| 1532 | | self.main.xmlrpc.vlc( self.main.selected_ip, volume, lock ) |
| 1533 | | |
| 1534 | | self.main.write_into_statusbar( _("Running in broadcast video transmission.") ) |
| 1535 | | # new mode to Stop Button |
| 1536 | | self.add_progressbox( {"target": "vlc", "pid":p.pid, "lock":lock, "allclients":newallclients}, _("Running in broadcast video transmission to host %s") %(host)) |
| 1537 | | else: |
| 1538 | | dialog.destroy() |
| | 1360 | # if action == 16: |
| | 1361 | # # action sent by vidal_joshur at gva dot es |
| | 1362 | # # start video broadcast mode |
| | 1363 | # # Stream to single client unicast |
| | 1364 | # eth=self.main.config.GetVar("network_interface") |
| | 1365 | # |
| | 1366 | # if len(connected_users) == 0 or connected_users[0] == shared.NO_LOGIN_MSG: |
| | 1367 | # shared.error_msg ( _("Can't send video broadcast, user is not logged") ) |
| | 1368 | # return |
| | 1369 | # |
| | 1370 | # str_scapes=[" ", "(", ")", "*", "!", "?", "\"", "`", "[", "]", "{", "}", ";", ":", ",", "=", "$"] |
| | 1371 | # lock="disable" |
| | 1372 | # volume="85" |
| | 1373 | # |
| | 1374 | # if self.main.pref_vlc_method_send.get_active() == 0: |
| | 1375 | # vcodec=shared.vcodecs[0] |
| | 1376 | # venc=shared.vencs[0] |
| | 1377 | # acodec=shared.acodecs[0] |
| | 1378 | # aenc=shared.aencs[0] |
| | 1379 | # access=shared.accesss[0] |
| | 1380 | # mux=shared.muxs[0] |
| | 1381 | # elif self.main.pref_vlc_method_send.get_active() == 1: |
| | 1382 | # vcodec=shared.vcodecs[1] |
| | 1383 | # venc=shared.vencs[0] |
| | 1384 | # acodec=shared.acodecs[0] |
| | 1385 | # aenc=shared.aencs[0] |
| | 1386 | # access=shared.accesss[0] |
| | 1387 | # mux=shared.muxs[0] |
| | 1388 | # elif self.main.pref_vlc_method_send.get_active() == 2: |
| | 1389 | # vcodec=shared.vcodecs[2] |
| | 1390 | # venc=shared.vencs[1] |
| | 1391 | # acodec=shared.acodecs[0] |
| | 1392 | # aenc=shared.aencs[0] |
| | 1393 | # access=shared.accesss[0] |
| | 1394 | # mux=shared.muxs[0] |
| | 1395 | # elif self.main.pref_vlc_method_send.get_active() == 3: |
| | 1396 | # vcodec=shared.vcodecs[3] |
| | 1397 | # venc=shared.vencs[2] |
| | 1398 | # acodec=shared.acodecs[1] |
| | 1399 | # aenc=shared.aencs[1] |
| | 1400 | # access=shared.accesss[1] |
| | 1401 | # mux=shared.muxs[1] |
| | 1402 | # elif self.main.pref_vlc_method_send.get_active() == 4: |
| | 1403 | # vcodec=shared.vcodecs[1] |
| | 1404 | # venc=shared.vencs[0] |
| | 1405 | # acodec=shared.acodecs[1] |
| | 1406 | # aenc=shared.aencs[1] |
| | 1407 | # access=shared.accesss[1] |
| | 1408 | # mux=shared.muxs[1] |
| | 1409 | # |
| | 1410 | # |
| | 1411 | # if access == "udp": |
| | 1412 | # if client_type == "tcos": |
| | 1413 | # max_uip=255 |
| | 1414 | # uip=0 |
| | 1415 | # while uip <= max_uip: |
| | 1416 | # uip_cmd="239.255.%s.0" %(uip) |
| | 1417 | # cmd=("LC_ALL=C LC_MESSAGES=C netstat -putan 2>/dev/null | grep -c %s" %(uip_cmd) ) |
| | 1418 | # print_debug("Check broadcast ip %s." %(uip_cmd) ) |
| | 1419 | # output=self.main.common.exe_cmd(cmd) |
| | 1420 | # uip+=1 |
| | 1421 | # if output == "0": |
| | 1422 | # print_debug("Broadcast ip found: %s" %(uip_cmd)) |
| | 1423 | # ip_unicast="%s:1234" %uip_cmd |
| | 1424 | # break |
| | 1425 | # elif uip == max_uip: |
| | 1426 | # print_debug("Not found an available broadcast ip") |
| | 1427 | # return |
| | 1428 | # remote_cmd="vlc udp://@%s --udp-caching=1000 --aout=alsa --brightness=2.000000 --no-x11-shm --no-xvideo-shm --volume=300 --aspect-ratio=4:3" %(ip_unicast) |
| | 1429 | # else: |
| | 1430 | # ip_unicast="%s:1234" %self.main.selected_ip |
| | 1431 | # remote_cmd="vlc udp://@:1234 --udp-caching=1000 --aout=alsa --brightness=2.000000 --no-x11-shm --no-xvideo-shm --volume=300 --fullscreen --aspect-ratio=4:3" |
| | 1432 | # else: |
| | 1433 | # max_uip=50255 |
| | 1434 | # uip=50000 |
| | 1435 | # while uip <= max_uip: |
| | 1436 | # uip_cmd=":%s" %(uip) |
| | 1437 | # cmd=("LC_ALL=C LC_MESSAGES=C netstat -putan 2>/dev/null | grep -c %s" %(uip_cmd) ) |
| | 1438 | # print_debug("Check broadcast ip %s." %(uip_cmd) ) |
| | 1439 | # output=self.main.common.exe_cmd(cmd) |
| | 1440 | # uip+=1 |
| | 1441 | # if output == "0": |
| | 1442 | # print_debug("Broadcast ip found: %s" %(uip_cmd)) |
| | 1443 | # ip_unicast=uip_cmd |
| | 1444 | # break |
| | 1445 | # elif uip == max_uip: |
| | 1446 | # print_debug("Not found an available broadcast ip") |
| | 1447 | # return |
| | 1448 | # if client_type == "tcos": |
| | 1449 | # remote_cmd="vlc http://localhost%s --aout=alsa --brightness=2.000000 --no-x11-shm --no-xvideo-shm --volume=300 --aspect-ratio=4:3" %(ip_unicast) |
| | 1450 | # |
| | 1451 | # dialog = gtk.FileChooserDialog(_("Select audio/video file.."), |
| | 1452 | # None, |
| | 1453 | # gtk.FILE_CHOOSER_ACTION_OPEN, |
| | 1454 | # (_("Play DVD"), 1, |
| | 1455 | # _("Play SVCD/VCD"), 2, |
| | 1456 | # _("Play AudioCD"), 3, |
| | 1457 | # gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, |
| | 1458 | # gtk.STOCK_OPEN, gtk.RESPONSE_OK)) |
| | 1459 | # dialog.set_default_response(gtk.RESPONSE_OK) |
| | 1460 | # self.folder = self._folder = os.environ['HOME'] |
| | 1461 | # dialog.set_current_folder(self.folder) |
| | 1462 | # filter = gtk.FileFilter() |
| | 1463 | # filter.set_name("Media Files ( *.avi, *.mpg, *.mpeg, *.mp3, *.wav, etc.. )") |
| | 1464 | # file_types=["*.avi", "*.mpg", "*.mpeg", "*.ogg", "*.ogm", "*.asf", "*.divx", |
| | 1465 | # "*.wmv", "*.vob", "*.m2v", "*.m4v", "*.mp2", "*.mp4", "*.ac3", |
| | 1466 | # "*.ogg", "*.mp1", "*.mp2", "*.mp3", "*.wav", "*.wma"] |
| | 1467 | # for elem in file_types: |
| | 1468 | # filter.add_pattern( elem ) |
| | 1469 | # |
| | 1470 | # dialog.add_filter(filter) |
| | 1471 | # |
| | 1472 | # filter = gtk.FileFilter() |
| | 1473 | # filter.set_name("All Files") |
| | 1474 | # filter.add_pattern("*.*") |
| | 1475 | # dialog.add_filter(filter) |
| | 1476 | # response = dialog.run() |
| | 1477 | # if response == gtk.RESPONSE_OK or response == 1 or response == 2 or response == 3: |
| | 1478 | # |
| | 1479 | # filename=dialog.get_filename() |
| | 1480 | # dialog.destroy() |
| | 1481 | # |
| | 1482 | # if filename.find(" ") != -1: |
| | 1483 | # msg=_("Not allowed white spaces in \"%s\".\nPlease rename it." %os.path.basename(filename) ) |
| | 1484 | # shared.info_msg( msg ) |
| | 1485 | # return |
| | 1486 | # |
| | 1487 | # for scape in str_scapes: |
| | 1488 | # filename=filename.replace("%s" %scape, "\%s" %scape) |
| | 1489 | # |
| | 1490 | # if response == gtk.RESPONSE_OK: |
| | 1491 | # p=subprocess.Popen(["vlc", "file://%s" %filename, "--sout=#duplicate{dst=display{delay=1000},dst=\"transcode{vcodec=%s,venc=%s,acodec=%s,aenc=%s,vb=800,ab=112,channels=2,soverlay}:standard{access=%s,mux=%s,dst=%s}\"}" %(vcodec, venc, acodec, aenc, access, mux, ip_unicast), "--miface=%s" %eth, "--ttl=12", "--brightness=2.000000", "--no-x11-shm", "--no-xvideo-shm"], shell=False, bufsize=0, close_fds=True) |
| | 1492 | # elif response == 1: |
| | 1493 | # p=subprocess.Popen(["vlc", "dvd://", "--sout=#duplicate{dst=display{delay=1000},dst=\"transcode{vcodec=%s,venc=%s,acodec=%s,aenc=%s,vb=800,ab=112,channels=2,soverlay}:standard{access=%s,mux=%s,dst=%s}\"}" %(vcodec, venc, acodec, aenc, access, mux, ip_unicast), "--miface=%s" %eth, "--ttl=12", "--loop", "--brightness=2.000000", "--no-x11-shm", "--no-xvideo-shm"], shell=False, bufsize=0, close_fds=True) |
| | 1494 | # elif response == 2: |
| | 1495 | # p=subprocess.Popen(["vlc", "vcd://", "--sout=#duplicate{dst=display{delay=1000},dst=\"transcode{vcodec=%s,venc=%s,acodec=%s,aenc=%s,vb=800,ab=112,channels=2,soverlay}:standard{access=%s,mux=%s,dst=%s}\"}" %(vcodec, venc, acodec, aenc, access, mux, ip_unicast), "--miface=%s" %eth, "--ttl=12", "--brightness=2.000000", "--no-x11-shm", "--no-xvideo-shm"], shell=False, bufsize=0, close_fds=True) |
| | 1496 | # elif response == 3: |
| | 1497 | # p=subprocess.Popen(["vlc", "cdda:///dev/cdrom", "--sout=#duplicate{dst=display,dst=\"transcode{vcodec=%s,venc=%s,acodec=%s,aenc=%s,vb=200,ab=112,channels=2}:standard{access=%s,mux=%s,dst=%s}\"}" %(vcodec, venc, acodec, aenc, access, mux, ip_unicast), "--miface=%s" %eth, "--ttl=12", "--no-x11-shm", "--no-xvideo-shm"], shell=False, bufsize=0, close_fds=True) |
| | 1498 | # # exec this app on client |
| | 1499 | # |
| | 1500 | # self.main.write_into_statusbar( _("Waiting for start video transmission...") ) |
| | 1501 | # |
| | 1502 | # msg=_("First select the DVD chapter or play movie\nthen press enter to send clients..." ) |
| | 1503 | # shared.info_msg( msg ) |
| | 1504 | # |
| | 1505 | # # check if vlc is running or fail like check ping in demo mode |
| | 1506 | # running = p.poll() is None |
| | 1507 | # if not running: |
| | 1508 | # self.main.write_into_statusbar( _("Error while exec app")) |
| | 1509 | # return |
| | 1510 | # |
| | 1511 | # msg=_( "Lock keyboard and mouse on client?" ) |
| | 1512 | # if shared.ask_msg ( msg ): |
| | 1513 | # lock="enable" |
| | 1514 | # |
| | 1515 | #< |