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>
11 use Friendica\Core\Hook;
12 use Friendica\Core\Renderer;
15 function webrtc_install() {
16 Hook::register('app_menu', 'addon/webrtc/webrtc.php', 'webrtc_app_menu');
19 function webrtc_app_menu(App $a, array &$b)
21 $b['app_menu'][] = '<div class="app-title"><a href="webrtc">' . DI::l10n()->t('WebRTC Videochat') . '</a></div>';
24 function webrtc_addon_admin (App $a, &$o)
26 $t = Renderer::getMarkupTemplate( "admin.tpl", "addon/webrtc/" );
27 $o = Renderer::replaceMacros( $t, [
28 '$submit' => DI::l10n()->t('Save Settings'),
29 '$webrtcurl' => ['webrtcurl', DI::l10n()->t('WebRTC Base URL'), DI::config()->get('webrtc','webrtcurl' ), DI::l10n()->t('Page your users will create a WebRTC chat room on. For example you could use https://live.mayfirst.org .')],
32 function webrtc_addon_admin_post (App $a)
34 $url = trim($_POST['webrtcurl'] ?? '');
35 DI::config()->set('webrtc', 'webrtcurl', $url);
38 function webrtc_module() {
42 function webrtc_content(App $a)
46 /* landingpage to create chatrooms */
47 $webrtcurl = DI::config()->get('webrtc','webrtcurl');
49 /* embedd the landing page in an iframe */
50 $o .= '<h2>'.DI::l10n()->t('Video Chat').'</h2>';
51 $o .= '<p>'.DI::l10n()->t('WebRTC is a video and audio conferencing tool that works in all modern browsers. Just create a new chat room and send the link to someone you want to chat with.').'</p>';
52 if ($webrtcurl == '') {
53 $o .= '<p>'.DI::l10n()->t('Please contact your friendica admin and send a reminder to configure the WebRTC addon.').'</p>';
55 $o .= '<iframe src="'.$webrtcurl.'" width="600px" height="600px"></iframe>';