<?php
require_once("admin/inc/protecao-final.php");

$total_avisos_ativos = mysqli_num_rows(mysqli_query($conexao,"SELECT * FROM avisos WHERE area = 'streaming'"));
$checar_status_aviso = mysqli_num_rows(mysqli_query($conexao,"SELECT * FROM avisos_desativados WHERE area = 'streaming' AND login = '".$dados_stm["login"]."'"));
$total_avisos_exibir = ($total_avisos_ativos > $checar_status_aviso) ? $total_avisos_ativos-$checar_status_aviso : 0;

if(query_string('1') == "FMLE") {

$dominio = dominio_servidor($conexao,$dados_servidor["nome"]);
$login = $dados_stm["login"];
$stream = ($dados_stm["aplicacao"] == 'tvstation') ? "live" : $dados_stm["login"];

header('Content-disposition: attachment; filename=profile_fmle_'.$dados_stm["login"].'.xml');
header ("Content-Type:text/xml"); 
echo '<?xml version="1.0" encoding="UTF-8"?>
<flashmedialiveencoder_profile>
    <preset>
        <name>Custom</name>
        <description></description>
    </preset>
    <process>
        <video>
        <preserve_aspect></preserve_aspect>
        </video>
    </process>
    <capture>
        <video>
        <device></device>
        <crossbar_input>0</crossbar_input>
        <frame_rate>29.97</frame_rate>
        <size>
            <width></width>
            <height></height>
        </size>
        </video>
        <audio>
        <device></device>
        <crossbar_input>0</crossbar_input>
        <sample_rate>44100</sample_rate>
        <channels>2</channels>
        <input_volume>100</input_volume>
        </audio>
    </capture>
    <encode>
        <video>
        <format>H.264</format>
        <datarate>200;</datarate>
        <outputsize>320x240;</outputsize>
        <advanced>
            <profile>Baseline</profile>
            <level>3.1</level>
            <keyframe_frequency>5 Seconds</keyframe_frequency>
        </advanced>
        <autoadjust>
            <enable>false</enable>
            <maxbuffersize>1</maxbuffersize>
            <dropframes>
            <enable>false</enable>
            </dropframes>
            <degradequality>
            <enable>false</enable>
            <minvideobitrate></minvideobitrate>
            <preservepfq>false</preservepfq>
            </degradequality>
        </autoadjust>
        </video>
        <audio>
        <format>MP3</format>
        <datarate>96</datarate>
        </audio>
    </encode>
    <output>
        <rtmp>
        <url>rtmp://'.$dominio.':1935/'.$login.'</url>
        <backup_url></backup_url>
        <stream>'.$stream.'</stream>
        </rtmp>
    </output>
    <preview>
        <video>
        <input>
            <zoom>100%</zoom>
        </input>
        <output>
            <zoom>100%</zoom>
        </output>
        </video>
        <audio></audio>
    </preview>
</flashmedialiveencoder_profile>';
header("Expires: 0");
exit();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title>Streaming <?php echo $dados_stm["login"]; ?></title>
  <link rel="stylesheet" href="/inc/materialdesignicons.min.css">
  <link rel="stylesheet" href="/inc/font-awesome.min.css">
  <link rel="stylesheet" href="/inc/vendor.bundle.base.css">
  <link rel="stylesheet" href="/inc/vendor.bundle.addons.css">  
  <?php if($dados_stm["tema_dark"] == "sim") { ?>
  <link rel="stylesheet" href="/inc/theme-dark.css">
  <?php } else { ?>
  <link rel="stylesheet" href="/inc/theme.css">
  <?php } ?>
  <link rel="shortcut icon" href="/img/favicon.ico" />
  <script type="text/javascript" src="/inc/ajax-streaming.js"></script>
  <script type="text/javascript" src="/inc/javascript.js"></script>
</head>
<body>
  <div class="container-scroller">
    <nav class="navbar col-lg-12 col-12 p-0 fixed-top d-flex flex-row">
      <div class="text-center navbar-brand-wrapper d-flex align-items-center justify-content-center">
        <?php if($dados_revenda["url_logo"]) { ?>
        <a class="navbar-brand brand-logo" href="/dashboard"><img id="logo" src="<?php echo $dados_revenda["url_logo"]; ?>" title="Painel" height="60" border="0"></a>
        <?php } else { ?>
        <a class="navbar-brand brand-logo" href="/dashboard"><span>Painel Streaming</span></a>
        <?php } ?>
        <a class="navbar-brand brand-logo-mini" href="/dashboard"><i class="fa fa-video-camera text-muted"></i></a>
      </div>
      <div class="navbar-menu-wrapper d-flex align-items-center justify-content-end justify-content-lg-start">
        <button class="navbar-toggler navbar-toggler align-self-center" type="button" data-toggle="minimize">
          <span class="mdi mdi-menu text-icones"></span>
        </button>
        <ul class="navbar-nav navbar-nav-right">
          <li class="nav-item nav-profile dropdown show">
            <a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" id="profileDropdown" aria-expanded="true">
              <i class="fa fa-power-off f-18 text-icones" data-toggle="tooltip" data-placement="bottom" title="<?php echo $lang['lang_botao_titulo_ligar']; ?>/<?php echo $lang['lang_botao_titulo_desligar']; ?>"></i>
            </a>
            <div class="dropdown-menu dropdown-menu-right navbar-dropdown" aria-labelledby="profileDropdown">
              <a class="dropdown-item text-success" href="javascript:ligar_streaming('<?php echo $login_code; ?>');"> <?php echo $lang['lang_botao_titulo_ligar']; ?> Streaming</a>
              <a class="dropdown-item text-warning" href="javascript:reiniciar_streaming('<?php echo $login_code; ?>');"> <?php echo $lang['lang_botao_titulo_reiniciar']; ?> Streaming</a>
            </div>
          </li>
          <li class="nav-item dropdown">
            <a class="nav-link count-indicator dropdown-toggle d-flex align-items-center justify-content-center" id="notificationDropdown" href="#" data-toggle="dropdown" aria-expanded="false">
              <i class="mdi mdi-bell f-22 text-icones" data-toggle="tooltip" data-placement="bottom" title="<?php echo $lang['lang_info_pagina_informacoes_tab_avisos']; ?>"></i>
              <?php if($total_avisos_exibir > 0) { ?><span class="count bg-success"><?php echo $total_avisos_exibir; ?></span><?php } ?>           
            </a>
            <div class="dropdown-menu dropdown-menu-right navbar-dropdown preview-list" aria-labelledby="notificationDropdown">
              <a class="dropdown-item">
                <p class="mb-0 font-weight-normal float-left"><?php echo $lang['lang_info_pagina_informacoes_tab_avisos']; ?></p>
              </a>
              <div class="dropdown-divider"></div>
              <?php carregar_avisos_streaming($conexao,$dados_stm["porta"],$dados_servidor["codigo"]); ?>
            </div>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="/sair"><i class="mdi mdi-logout f-22 text-icones" data-toggle="tooltip" data-placement="bottom" title="Sair/logout"></i></a>
          </li>
          <li>
            <button type="button" class="btn btn-info" id="status-streaming" onClick="status_streaming('<?php echo $login_code; ?>');" style="margin: 10px;min-width: 150px; min-height: 40px"><i class="fa fa-refresh"></i></button>
          </li>
        </ul>
        <button class="navbar-toggler navbar-toggler-right d-lg-none align-self-center" type="button" data-toggle="offcanvas">
          <span class="mdi mdi-menu text-icones"></span>
        </button>
      </div>
    </nav>
    <div class="container-fluid page-body-wrapper">
      <?php require_once("menu.php"); ?>
      <!-- partial -->
      <div class="main-panel">
        <div class="content-wrapper">
          <div id="local-status-acoes"><?php echo $_SESSION['status_acao'];unset($_SESSION['status_acao']); ?></div>
          <div class="row">            

             <?php if($dados_stm["aplicacao"] == 'live' || $dados_stm["aplicacao"] == 'tvstation') { ?>
                            <div class="<?php if($dados_stm["aplicacao"] == 'tvstation') { echo "col-xl-6 col-md-6"; } else { echo "col-md-12"; } ?>">
                                <div class="card">
                                    <div class="card-header">
                                        <header><?php echo $lang['lang_info_streaming_dados_conexao_aba_streaming']; ?></header>
                                    </div>
                                    <div class="card-body">
                                        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                                          <tr>
                                            <td width="150" height="40" align="left" style="padding-left:5px;"><strong><?php echo $lang['lang_info_streaming_dados_conexao_servidor']; ?></strong></td>
                                            <td align="left" id="dados_url">rtmp://<?php echo dominio_servidor($conexao,$dados_servidor["nome"]); ?>:1935/<?php echo $dados_stm["login"]; ?>&nbsp;&nbsp;<i class="fa fa-copy f-16 text-blue" style="cursor:pointer" title="Copiar/Copy" onClick="copiar_texto('rtmp://<?php echo dominio_servidor($conexao,$dados_servidor["nome"]); ?>:1935/<?php echo $dados_stm["login"]; ?>');"></i></td>
                                          </tr>
                                          <tr>
                                            <td height="40" align="left" style="padding-left:5px;"><strong>Stream</strong></td>
                                            <td align="left" id="dados_chave"><?php if($dados_stm["aplicacao"] == 'tvstation') { echo "live"; } else { echo $dados_stm["login"]; }?>&nbsp;&nbsp;<i class="fa fa-copy f-16 text-blue" style="cursor:pointer" title="Copiar/Copy" onClick="copiar_texto('<?php if($dados_stm["aplicacao"] == 'tvstation') { echo "live"; } else { echo $dados_stm["login"]; }?>');"></i></td>
                                          </tr>
                                          <tr>
                                            <td height="40" align="left" style="padding-left:5px;"><strong>Bitrate</strong></td>
                                            <td align="left"><?php echo $dados_stm["bitrate"]; ?> Kbps (video + audio)</td>
                                          </tr>
                                          <?php if($dados_stm["autenticar_live"] == 'sim') { ?>
                                          <tr>
                                            <td width="150" height="40" align="left" style="padding-left:5px;"><strong><?php echo $lang['lang_info_streaming_dados_conexao_usuario']; ?></strong></td>
                                            <td align="left" id="dados_login"><?php echo $dados_stm["login"]; ?>&nbsp;&nbsp;<i class="fa fa-copy f-16 text-blue" style="cursor:pointer" title="Copiar/Copy" onClick="copiar_texto('<?php echo $dados_stm["login"]; ?>');"></i></td>
                                          </tr>
                                          <tr>
                                            <td height="40" align="left" style="padding-left:5px;"><strong><?php echo $lang['lang_info_streaming_dados_conexao_senha']; ?></strong></td>
                                            <td align="left" id="dados_senha"><?php echo $dados_stm["senha_transmissao"]; ?>&nbsp;&nbsp;<i class="fa fa-copy f-16 text-blue" style="cursor:pointer" title="Copiar/Copy" onClick="copiar_texto('<?php echo $dados_stm["senha_transmissao"]; ?>');"></i></td>
                                          </tr>
                                          <?php } ?>
                                          <tr>
                                            <td height="40" align="left" style="padding-left:5px;"><strong><?php echo $lang['lang_info_streaming_dados_conexao_profile_fmle']; ?></strong></td>
                                            <td align="left"><a href="/dados-conexao/FMLE" data-toggle="tooltip" data-placement="bottom" title="<?php echo $lang['lang_info_streaming_dados_conexao_profile_fmle_info']; ?>">[Download]</a></td>
                                          </tr>
                                        </table>
                                    </div>
                                </div>
                            </div>
                            <?php } ?>
                            <?php if($dados_stm["aplicacao"] == 'tvstation' || $dados_stm["aplicacao"] == 'vod') { ?>
                            <div class="<?php if($dados_stm["aplicacao"] == 'vod') { echo "col-md-12"; } else { echo "col-xl-6 col-md-6"; } ?>">
                                <div class="card">
                                    <div class="card-header">
                                        <header><?php echo $lang['lang_info_streaming_dados_conexao_aba_ftp']; ?></header>
                                    </div>
                                    <div class="card-body">
                                        <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                                          <tr>
                                            <td width="160" height="40" align="left" style="padding-left:5px;"><strong>Servidor/Server/Host</strong></td>
                                            <td align="left" id="dados_ftp_url"><?php echo dominio_servidor($conexao,$dados_servidor["nome"]); ?>&nbsp;&nbsp;<i class="fa fa-copy f-16 text-blue" style="cursor:pointer" title="Copiar/Copy" onClick="copiar_texto('<?php echo dominio_servidor($conexao,$dados_servidor["nome"]); ?>');"></i></td>
                                          </tr>
                                          <tr>
                                            <td height="40" align="left" style="padding-left:5px;"><strong><?php echo $lang['lang_info_streaming_dados_conexao_usuario']; ?></strong></td>
                                            <td align="left" id="dados_ftp_login"><?php echo $dados_stm["login"]; ?>&nbsp;&nbsp;<i class="fa fa-copy f-16 text-blue" style="cursor:pointer" title="Copiar/Copy" onClick="copiar_texto('<?php echo $dados_stm["login"]; ?>');"></i></td>
                                          </tr>
                                          <tr>
                                            <td height="40" align="left" style="padding-left:5px;"><strong><?php echo $lang['lang_info_streaming_dados_conexao_senha']; ?></strong></td>
                                            <td align="left" id="dados_ftp_senha"><?php echo $dados_stm["senha"]; ?>&nbsp;&nbsp;<i class="fa fa-copy f-16 text-blue" style="cursor:pointer" title="Copiar/Copy" onClick="copiar_texto('<?php echo $dados_stm["senha"]; ?>');"></i></td>
                                          </tr>
                                          <tr>
                                            <td height="40" align="left" style="padding-left:5px;"><strong><?php echo $lang['lang_info_streaming_dados_conexao_ftp_porta']; ?></strong></td>
                                            <td align="left">21</td>
                                          </tr>

                                          <tr>
                                            <td height="80" align="left" style="padding-left:5px;"></td>
                                            <td align="left"></td>
                                          </tr>
                                        </table>
                                    </div>
                                </div>
                            </div>
                            <?php } ?>

          </div>
        </div>
      </div>
      <!-- modal -->
      <div class="modal fade" id="avisos" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title"><?php echo $lang['lang_info_pagina_informacoes_tab_avisos']; ?></h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                </div>
                <div class="modal-body" id="avisos-conteudo"><img src="/img/ajax-loader.gif" align="center" /></div>
            </div>
        </div>
        </div>
                
        <div class="modal fade" id="log-sistema" tabindex="-1" role="dialog" aria-hidden="true">
        <div class="modal-dialog modal-dialog-centered" role="document">
            <div class="modal-content">
                <div class="modal-body" id="log-sistema-conteudo" style="text-align:center"><img src="/img/ajax-loader.gif" /></div>
            </div>
        </div>
      </div>
    </div>
  </div>
  <script src="/inc/vendor.bundle.base.js"></script>
  <script src="/inc/vendor.bundle.addons.js"></script>
  <script src="/inc/theme.js"></script>
  <script>
  status_streaming('<?php echo $login_code; ?>');
  setInterval("status_streaming('<?php echo $login_code; ?>')",60000);
  </script>
</body>
</html>