3 * Name: WebRTC Application
4 * Description: add a webrtc instance for video/audio
6 * Author: Stephen Mahood <https://friends.mayfirst.org/profile/marxistvegan>
7 * Author: Tobias Diekershoff <https://f.diekershoff.de/profile/tobias>
9 use Friendica\Core\Addon;
10 use Friendica\Core\Config;
12 function webrtc_install() {
13 Addon::registerHook('app_menu', 'addon/webrtc/webrtc.php', 'webrtc_app_menu');
16 function webrtc_uninstall() {
17 Addon::unregisterHook('app_menu', 'addon/webrtc/webrtc.php', 'webrtc_app_menu');
21 function webrtc_app_menu($a,&$b) {
22 $b['app_menu'][] = '<div class="app-title"><a href="webrtc">' . t('WebRTC Videochat') . '</a></div>';
25 function webrtc_plugin_admin (&$a, &$o) {
26 $t = get_markup_template( "admin.tpl", "addon/webrtc/" );
27 $o = replace_macros( $t, [
28 '$submit' => t('Save Settings'),
29 '$webrtcurl' => ['webrtcurl', t('WebRTC Base URL'), Config::get('webrtc','webrtcurl' ), t('Page your users will create a WebRTC chat room on. For example you could use https://live.mayfirst.org .')],
32 function webrtc_plugin_admin_post (&$a) {
33 $url = ((x($_POST, 'webrtcurl')) ? notags(trim($_POST['webrtcurl'])) : '');
34 Config::set('webrtc', 'webrtcurl', $url);
35 info( t('Settings updated.'). EOL);
38 function webrtc_module() {
42 function webrtc_content(&$a) {
45 /* landingpage to create chatrooms */
46 $webrtcurl = Config::get('webrtc','webrtcurl');
48 /* embedd the landing page in an iframe */
49 $o .= '<h2>'.t('Video Chat').'</h2>';
50 $o .= '<p>'.t('WebRTC is a video and audio conferencing tool that works with Firefox (version 21 and above) and Chrome/Chromium (version 25 and above). Just create a new chat room and send the link to someone you want to chat with.').'</p>';
51 if ($webrtcurl == '') {
52 $o .= '<p>'.t('Please contact your friendica admin and send a reminder to configure the WebRTC addon.').'</p>';
54 $o .= '<iframe src="'.$webrtcurl.'" width="600px" height="600px"></iframe>';