Commit a5a9c914 authored by Marcello Pivanti's avatar Marcello Pivanti
Browse files

Initial Commit

parents
# Videoconference Plugin #
Plugin for E015 common modules.
## Installation
### 1. The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```bash
composer require elitedivision/amos-videoconference
```
or add this row
```
"elitedivision/amos-videoconference": "dev-master"
```
to the require section of your `composer.json` file.
### 2. Add module to your main config in common:
```php
<?php
'modules' => [
'videoconference' => [
'class' => 'elitedivision\amos\videoconference\AmosVideoconference',
'rbacEnabled' => false,
],
],
```
### 3. Apply migrations
```bash
php yii migrate/up --migrationPath=@vendor/elitedivision/amos-videoconference/src/migrations
```
or add this row to your migrations config in console:
```php
<?php
return [
'@vendor/elitedivision/amos-videoconference/src/migrations',
];
```
### 4. Configuration for sending email from console
insert in /console/component-others.php
```php
'urlManager' => [
'class' => 'yii\web\UrlManager',
'baseUrl' => '/',
'hostInfo' => 'http://example.org',
// Disable index.php
'showScriptName' => false,
// Disable r= routes
'enablePrettyUrl' => true,
'rules' => array(
'<module:[\w-]+>/<controller:[\w-]+>/<action:[\w-]+>/<id:\d+>] => <module>/<controller>/<action>',
),
],
```
change the paramater 'hostInfo' with the base url of your application, it is required for insert images inside the email template.
### 5. Console command for crons
The console command to launch the cron is:
```bash
php yii videoconference/cron/start_video_conference
```
```bash
php yii videoconference/cron/send_email_reminder
```
{
"name": "arter/amos-videoconference",
"description": "Amos Videoconference",
"keywords": [
"amos",
"video",
"conference"
],
"homepage": "http://www.elitedivision.it/",
"type": "component",
"require": {
"php": ">=5.4.0",
"arter/amos-core": ">=1.9",
"arter/amos-notify": ">=1.4",
"softark/yii2-dual-listbox": "^1.0"
},
"autoload": {
"psr-4": {
"elitedivision\\amos\\videoconference\\": "src"
}
},
"fxp-asset": {
"installer-paths": {
"npm-asset-library": "vendor/npm",
"bower-asset-library": "vendor/bower"
}
}
}
\ No newline at end of file
# Jitsi Server #
[Jitsi.org](https://jitsi.org/)
## Dizionario ##
- **XMPP/Jabber**: Extensible Messaging and Presence Protocol (XMPP) is an open XML technology for real-time communication (<https://xmpp.org/about/>)
Prosody: XMPP Server (<http://prosody.im/>)
- **Jicofo**: Jitsi Conference Focus, it is responsible for managing media sessions between each of the participants and the videobridge (<https://github.com/jitsi/jicofo>)
- **Jibri**: Jibri is a set of tools for recording and/or streaming a Jitsi Meet conference. It is currently very experimental. (<https://github.com/jitsi/jibri>)
- **JVB/Videobridge**: Jitsi Videobridge is an XMPP server component that allows for multiuser video communication.
- **BOSH (protocol)**: Bidirectional-streams Over Synchronous HTTP, is a transport protocol that emulates a bidirectional stream between two entities (such as a client and a server) by using multiple synchronous HTTP request/response pairs without requiring the use of polling or asynchronous chunking.
- **TURN**: Traversal Using Relays around NAT, is a protocol that assists in traversal of network address translators (NAT) or firewalls for multimedia applications. UDP and TCP
## Struttura Server ##
<https://github.com/jitsi/jitsi-meet/blob/master/doc/manual-install.md>
- Web app: jitsi-meet-web
- Web server: Jitty (default), Nginx, Apache
- Video bridge: jitsi-videobridge (aka jvb)
- Controller: jicofo
- XMPP server: prosody
## JVB ##
Jitsi-Videobridge can run behind a NAT, provided that all required ports are routed (forwarded) to the machine that it runs on.
By default these ports are (TCP/443 or TCP/4443 and UDP 10000-20000).
How to enable TURN server support in one-to-one calls in Jitsi Meet.
Per due partecipanti sarebbe più efficiente usare un P2P, per evitari casini occorre passare per un server turn (nella conf attuale ci sono quelli offerti da google)
<https://github.com/jitsi/jitsi-meet/blob/master/doc/turn.md>
**Configuration**
/etc/jitsi/videobridge/config
## Prosody ##
Prosody XMPP Server
**Configuration**<br>
/etc/prosody/prosody.cfg.lua + /etc/prosody/conf.d/*.cfg.lua
<http://prosody.im/doc/configure><br />
<https://github.com/jitsi/jitsi-meet/blob/master/doc/example-config-files/prosody.cfg.lua.example>
Autenticated and guest user: <br /><https://github.com/jitsi/jicofo#secure-domain> <br />
<http://lists.jitsi.org/pipermail/dev/2014-November/022609.html>
**jitsi-meet-tokens**<br>
<https://github.com/jitsi/lib-jitsi-meet/blob/master/doc/tokens.md><br>
Prima di procedere all'installazione occorre aggiornare Prosody dal trunk.<br>
Il token è di tipo JWT <https://jwt.io/#libraries-io><br>
Occorre poi avere un secondo dominio "guest" che non possa creare la room ma accetti interlocutori senza token.
## Meet ##
Web app in /usr/share/jitsi-meet/
**Configuration**<br>
/etc/jitsi/meet/config.js (oppure {serverName}-config.js)
vedi: <https://github.com/jitsi/jitsi-meet/blob/master/config.js>
/usr/share/jitsi-meet/interface_config.js: configurazione di cosa visualizzare o meno nella web-app <https://github.com/jitsi/jitsi-meet/blob/master/interface_config.js>
Questi due configurazioni vengono sovrascritte dalla configurazione locale di Open.
Alcune note:
//DEFAULT_REMOTE_DISPLAY_NAME: 'User',//Questo è come mi chiamo io nella mia visuale
//DEFAULT_LOCAL_DISPLAY_NAME: 'Smart.it Test',//Questo è come chiamo chi non ha un nikname (displayName)
Se voglio cambiare il displayName usare
```
api.executeCommand('displayName', 'Nik Name');
```
Se voglio cambiare l'avatar
```
api.executeCommand('avatarUrl', 'https://server.smart/avatar/smart.png');
```
Esistono hook di evento come
```
api.addEventListener('readyToClose',function(){
api.dispose();
document.location = 'meeting-end.html';
});
```
/usr/share/jitsi-meet/logging_config.js: livello di logging javascript <https://github.com/jitsi/jitsi-meet/blob/master/config.js>
Possibilità di embed della webapp tramite javascript tramite le jitsi-meet api.
{serverName}/libs/external_api.min.js
```javascript
var domain = "jitsi.server";
var options = {
roomName: "roomKey",
configOverwrite: {
/* vedi config.js */
},
interfaceConfigOverwrite: {
/* vedi interface_config.js */
}
}
var api = new JitsiMeetExternalAPI(domain, options);
```
## Lib ##
__[TODO]__ Approfondire:
<https://github.com/jitsi/lib-jitsi-meet/blob/master/doc/API.md>
## Link Documentazione ##
- **Jitsi Videobridge**
<https://github.com/jitsi/jitsi-videobridge/tree/master/doc>
Use JVB per servire Meet: <https://github.com/jitsi/jitsi-videobridge/blob/master/doc/http.md>
- **Jitsi Meet API**
<https://github.com/jitsi/jitsi-meet/blob/master/doc/api.md>
- **Lib Jitsi Meet API**
<https://github.com/jitsi/lib-jitsi-meet/blob/master/doc/API.md>
- **Lib Jitsi Meet JWT token**
<https://github.com/jitsi/lib-jitsi-meet/blob/master/doc/tokens.md>
Prosody authentication provider that verifies client connection based on JWT token. It allows to use any external form of authentication with lib-jitsi-meet.
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
*
* @package elitedivision\amos\videoconference
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace elitedivision\amos\videoconference;
use elitedivision\amos\core\module\AmosModule;
use elitedivision\amos\core\module\ModuleInterface;
use Yii;
/**
* Class AmosVideoconference
* @package elitedivision\amos\videoconference
*/
class AmosVideoconference extends AmosModule implements ModuleInterface
{
public static $CONFIG_FOLDER = 'config';
/**
* @var string|boolean the layout that should be applied for views within this module. This refers to a view name
* relative to [[layoutPath]]. If this is not set, it means the layout value of the [[module|parent module]]
* will be taken. If this is false, layout will be disabled within this module.
*/
public $layout = 'main';
public $name = 'Videoconference';
public $controllerNamespace = 'elitedivision\amos\videoconference\controllers';
public $config = [];
/** @var int used to send a reminder X minute before the start of the videoconference */
public $minuteReminder = 60;
/**
* If is false you can invite to videoconference users that aren't in your user network
* @var bool
*/
public $onlyNetworkUsers = true;
//Url without http:// of the jitsi installation
public $jitsiDomain;
/**
* @inheritdoc
*/
public static function getModuleName()
{
return "videoconference";
}
/**
* @inheritdoc
*/
public function init()
{
parent::init();
\Yii::setAlias('@elitedivision/amos/' . static::getModuleName() . '/controllers/', __DIR__ . '/controllers/');
// initialize the module with the configuration loaded from config.php
$config = require(__DIR__ . DIRECTORY_SEPARATOR . self::$CONFIG_FOLDER . DIRECTORY_SEPARATOR . 'config.php');
Yii::configure($this,$config );
}
/**
* @inheritdoc
*/
public function getWidgetIcons()
{
return [
];
}
/**
* @inheritdoc
*/
public function getWidgetGraphics()
{
return [
];
}
/**
* @inheritdoc
*/
protected function getDefaultModels()
{
return [
];
}
}
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
*
* @package elitedivision\amos\moodle\assets
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace elitedivision\amos\videoconference\assets;
use yii\web\AssetBundle;
use Yii;
/**
* Class VideoconferenceAsset
* @package elitedivision\amos\videoconference\assets
*/
class VideoconferenceAsset extends AssetBundle {
/**
* @inheritdoc
*/
public $sourcePath = '@vendor/elitedivision/amos-videoconference/src/assets/web';
public $publishOptions = [
'forceCopy' => YII_DEBUG,
];
/**
* @inheritdoc
*/
public $css = [
];
/**
* @inheritdoc
*/
public $js = [
//"https://jitsi01.smart.it/libs/external_api.min.js",
//'js/videoconference.js'
];
/**
* @inheritdoc
*/
public $depends = [
'yii\web\JqueryAsset',
];
public function init() {
$jitsiDomain = Yii::$app->getModule('videoconference')->jitsiDomain ?: null;
$this->js = [
"https://".$jitsiDomain."/libs/external_api.min.js",
'js/videoconference.js'
];
parent::init();
}
}
var videoconfId = $("#videoconf-id").text();
var meetingEndUrl = $("#meeting-end").attr("href");
$.ajax({
type: "get",
url: "/videoconference/videoconf/json-videoconf-data",
data: "id=" + videoconfId,
dataType: "json",
success: function (response, status) {
showVideoconference(response);
},
});
function showVideoconference(data) {
var domain = data.domain+"?lang=it";
var options = {
roomName: data.roomName,
width: '100%',
height: '100%',
parentNode: document.querySelector('#meet'),
configOverwrite: {},
interfaceConfigOverwrite: {
filmStripOnly: false,
VERTICAL_FILMSTRIP: false,
FILM_STRIP_MAX_HEIGHT: 200,
MOBILE_APP_PROMO: false,
TOOLBAR_BUTTONS: [
// main toolbar
'microphone', 'camera', 'desktop', 'invite', 'fullscreen', 'fodeviceselection', 'hangup',
// extended toolbar
'contacts', 'chat', 'recording', 'etherpad', 'sharedvideo', 'settings', 'raisehand', 'videoquality', 'filmstrip'],
/**
* Main Toolbar Buttons
* All of them should be in TOOLBAR_BUTTONS
*/
MAIN_TOOLBAR_BUTTONS: ['microphone', 'camera', 'desktop', 'fullscreen', 'fodeviceselection', 'hangup']
}
}
var api = new JitsiMeetExternalAPI(domain, options);
api.executeCommand('avatarUrl', data.avatar);
api.executeCommand('displayName', data.displayName);
api.addEventListener('readyToClose', function () {
api.dispose();
document.location = meetingEndUrl;
});
}
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
*
* @package elitedivision\amos\videoconference
* @category CategoryName
* @author Elite Division S.r.l.
*/
$jitsiDomain = "meet.test.demotestwip.it";
return [
'config' => [
],
'params' => [
//active the search
'searchParams' => [
],
//active the order
'orderParams' => [
],
]
];
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
* @package Open20Package
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace elitedivision\amos\videoconference\controllers;
//namespace console\controllers;
use elitedivision\amos\admin\models\UserProfile;
use elitedivision\amos\videoconference\AmosVideoconference;
use elitedivision\amos\videoconference\models\Videoconf;
use elitedivision\amos\videoconference\models\VideoconfUsersMm;
use elitedivision\amos\videoconference\utils\EmailUtil;
use yii\console\Controller;
use yii\helpers\Console;
use Yii;
class CronController extends Controller
{
public function actionStart_video_conference(){
$programmedConferences = Videoconf::find()->andWhere(['status' => Videoconf::STATUS_FUTURE])->all();
Console::stdout("*** CRON START VIDEO CONFERENCE ***" . "\n");
$count = 0;
/** @var $videoConference Videoconf */
foreach ($programmedConferences as $videoConference) {
if($videoConference->isVideoConferenceActivable() && empty($videoConference->id_room_videoconference)) {
$videoConference->setIdRoomVideoconference();
if($videoConference->save(false)) {
Console::stdout("videoconferences started: ID:" . print_r($videoConference->id, true) . " title: " . print_r($videoConference->title, true) . "\n");
$count++;
}
}
}
Console::stdout("n. videoconferences started: " . print_r($count,true) . "\n");
Console::stdout("*** END CRON ***" . "\n");
}
/**
*
*/
public function actionSend_email_reminder()
{
$module = \Yii::$app->getModule(AmosVideoconference::getModuleName());
// find scheduled videoconferences which haven't been sent a reminder
$programmedConferences = Videoconf::find()
->andWhere(['status' => Videoconf::STATUS_FUTURE])
->andWhere(['reminder_sent' => 0])->all();
$now = new \DateTime();
Console::stdout("*** CRON SEND EMAIL REMINDER VIDEOCONFERENCE ***" . "\n");
$count = 0;
/** @var $videoconference Videoconf */
foreach ($programmedConferences as $videoconference) {
$notification_before_conference = !empty($videoconference->notification_before_conference) ? $videoconference->notification_before_conference : $module->minuteReminder;
$intervalReminder = new \DateInterval('PT' . trim($notification_before_conference) . 'M');
$dateHourReminder = new \DateTime($videoconference->begin_date_hour);
$dateHourReminder->sub($intervalReminder);
if($videoconference->status == Videoconf::STATUS_FUTURE) {
if($now >= $dateHourReminder) {
$collegati = $videoconference->getVideoconfUsersMms()->all();
/** @var $u VideoconfUsersMm */
foreach ((array)$collegati as $u) {
$profile = UserProfile::findOne([$u->user_profile_id]);
$sent = EmailUtil::sendNotification($videoconference, $profile->user);
if($sent) {
Console::stdout( print_r($videoconference->id, true) . " - reminder sent to: user_profile_id:" . print_r($profile->id, true) . " email: " . print_r($profile->user->email, true) . "\n");
$count++;
}
}
$videoconference->reminder_sent = 1;
$videoconference->save(false);
}
}
}
Console::stdout("n. Email sent: " . print_r($count,true) . "\n");
Console::stdout("*** END CRON ***" . "\n");
}
}
\ No newline at end of file
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
*
* @package elitedivision\amos\videoconference\controllers
* @category CategoryName
* @author Elite Division S.r.l.
*/
namespace elitedivision\amos\videoconference\controllers;
use elitedivision\amos\dashboard\controllers\base\DashboardController;
use Yii;
use yii\helpers\Url;
use yii\helpers\ArrayHelper;
use yii\filters\AccessControl;
class DefaultController extends DashboardController {
/**
* @var string $layout Layout per la dashboard interna.
*/
public $layout = "@vendor/elitedivision/amos-core/views/layouts/dashboard_interna";
/**
* Lists all Videoconference models.
* @return mixed
*/
public function actionIndex() {
return $this->redirect(['/videoconference/videoconf/index']);
/* Url::remember();
$params = [
'currentDashboard' => $this->getCurrentDashboard()
];
return $this->render('index', $params);*/
}
}
This diff is collapsed.
<?php
/**
* Art-ER Attrattività, ricerca e territorio dell’Emilia-Romagna
* OPEN 2.0
*
*
* @package elitedivision\amos\videoconference\i18n\en-GB
* @category CategoryName
* @author Elite Division S.r.l.
*/