edusoho阿里云直播php源代码披露

在这里插入图片描述
在这里插入图片描述
AliyunLive.php

<?php
/**
 * 作者:李志华
 * 技术支持QQ:
 * 时间:2020/6/12 - 下午10:29
 */
namespace AliLivePlugin\Controller;
use AppBundle\Controller\BaseController;
use Biz\System\Service\SettingService;
use Topxia\Service\Common\ServiceKernel;

class AliyunLive
{
    public function testAction()
    {
        $AppName = 'edusoho';
        $StreamName = 'test001';
        $timestamp = time() + 1800;
        $privatekey = 'edusoho';
        $yourdomain = 'zb.aliyun.saichinet.com';

        $HashValue = md5("/{$AppName}/{$StreamName}-{$timestamp}-0-0-{$privatekey}");
        echo "url:rtmp://video-center-bj.alivecdn.com/{$AppName}";
        echo "<br/>";
        echo "流密钥:{$StreamName}?vhost={$yourdomain}&auth_key={$timestamp}-0-0-{$HashValue}";
        echo "<br/>";

        $rtmpPlayer = md5("/{$AppName}/{$StreamName}-{$timestamp}-0-0-{$privatekey}");
        $flvPlayer = md5("/{$AppName}/{$StreamName}.flv-{$timestamp}-0-0-{$privatekey}");
        $m3u8Player = md5("/{$AppName}/{$StreamName}.m3u8-{$timestamp}-0-0-{$privatekey}");

        echo "rtmpURL:http://{$yourdomain}/{$AppName}/{$StreamName}?auth_key={$timestamp}-0-0-{$rtmpPlayer}";
        echo "<br/>";
        echo "flvURL:http://{$yourdomain}/{$AppName}/{$StreamName}.flv?auth_key={$timestamp}-0-0-{$flvPlayer} ";
        echo "<br/>";
        echo "m3u8URL:http://{$yourdomain}/{$AppName}/{$StreamName}.m3u8?auth_key={$timestamp}-0-0-{$m3u8Player}";
        echo "<br/>";
        return true;
    }

    public function getRoom(array $arguments)
    {
        $AliyunLive = $this->getSettingService()->get('Plugin_AliLive');
        $AppName = $AliyunLive['AppName'];
        $StreamName = $AliyunLive['StreamName'].$arguments['roomid'];
        $timestamp = time() + 1800;
        $pushkey = $AliyunLive['pushkey'];
        $pushdomain = $AliyunLive['pushdomain'];

        $HashValue = md5("/{$AppName}/{$StreamName}-{$timestamp}-0-0-{$pushkey}");
        $data['url'] = "rtmp://{$pushdomain}/{$AppName}";
        // $data['liu'] = "{$StreamName}?vhost={$yourdomain}&auth_key={$timestamp}-0-0-{$HashValue}";
        $data['liu'] = "{$StreamName}?auth_key={$timestamp}-0-0-{$HashValue}";

        return $data;
    }

    public function getLive(array $arguments)
    {
        $AliyunLive = $this->getSettingService()->get('Plugin_AliLive');
        $AppName = $AliyunLive['AppName'];
        $StreamName = $AliyunLive['StreamName'].$arguments['roomid'];
        $timestamp = time() + 1800;
        $privatekey = $AliyunLive['privatekey'];
        $yourdomain = $AliyunLive['yourdomain'];

        $rtmpPlayer = md5("/{$AppName}/{$StreamName}-{$timestamp}-0-0-{$privatekey}");
        $flvPlayer = md5("/{$AppName}/{$StreamName}.flv-{$timestamp}-0-0-{$privatekey}");
        $m3u8Player = md5("/{$AppName}/{$StreamName}.m3u8-{$timestamp}-0-0-{$privatekey}");

        $data['rtmp'] = "rtmp://{$yourdomain}/{$AppName}/{$StreamName}?auth_key={$timestamp}-0-0-{$rtmpPlayer}";
        $data['flv'] = "http://{$yourdomain}/{$AppName}/{$StreamName}.flv?auth_key={$timestamp}-0-0-{$flvPlayer}";
        $data['m3u8'] = "http://{$yourdomain}/{$AppName}/{$StreamName}.m3u8?auth_key={$timestamp}-0-0-{$m3u8Player}";

        return $data;
    }

    /**
     * @return SettingService
     */
    protected function getSettingService()
    {
        return ServiceKernel::instance()->createService('System:SettingService');
    }
}
?>

AliLivePlugin.php

<?php
namespace AliLivePlugin;
use Codeages\PluginBundle\System\PluginBase;
use AliLivePlugin\Biz\AliLiveServiceProvider;
class AliLivePlugin extends PluginBase
{
    public function boot()
    {
        parent::boot();
        $biz = $this->container->get('biz');
        $biz->register(new AliLiveServiceProvider());
    }

    public function getEnabledExtensions()
    {
        return array('DataTag');
    }
}

LiveroomController.php

<?php
namespace AliLivePlugin\Controller;
use Biz\Accessor\AccessorInterface;
use Biz\Activity\Service\ActivityService;
use Biz\Task\Service\TaskService;
use Biz\Course\Service\CourseService;
use Biz\CloudPlatform\CloudAPIFactory;
use Biz\Course\Service\LiveReplayService;
use Biz\OpenCourse\Service\OpenCourseService;
use Symfony\Component\HttpFoundation\Request;
use AppBundle\Controller\LiveroomController as BaseController;

class LiveroomController extends BaseController
{

    public function ticketAction(Request $request, $roomId)
    {
        $ticketNo = $request->query->get('ticket');
//        $ticket = CloudAPIFactory::create('leaf')->get("/liverooms/{$roomId}/tickets/{$ticketNo}");
        //  阿里云直播  
        $ticket['roomUrl'] = $this->generateUrl('aliyun_live_play', array('roomid' => $roomId));

        return $this->createJsonResponse($ticket);
    }
}

AliyunLiveController.php

<?php

namespace AliLivePlugin\Controller;

use AppBundle\Controller\BaseController;
use Biz\Activity\Service\ActivityService;
use Biz\Course\Service\CourseSetService;
use Biz\System\Service\SettingService;
use Biz\Task\Service\TaskService;
use Symfony\Component\HttpFoundation\Request;
use AliLivePlugin\Controller\AliyunLive;

class AliyunLiveController extends BaseController
{
    public function liveAction(Request $request)
    {
        $files =  $request->query->all();
        $AliyunLive = new AliyunLive();
        $live = $AliyunLive->getLive($files);
        $courseTask = $this->getTaskService()->getTask($files['roomid']);
        $courseSet = $this->getCourseSetService()->getCourseSet($courseTask['courseId']);
        $activity =  $this->getActivityService()->getActivity($files['roomid']);

        return $this->render('AliLivePlugin:AliyunLive:live.html.twig', array(
            'live' => $live,
            'courseSet' => $courseSet,
            'courseTask' => $courseTask,
            'activity' => $activity,
        ));
    }

    /**
     * @return ActivityService
     */
    protected function getActivityService()
    {
        return $this->createService('Activity:ActivityService');
    }

    /**
     * @return SettingService
     */
    protected function getSettingService()
    {
        return $this->createService('System:SettingService');
    }

    /**
     * @return TaskService
     */
    protected function getTaskService()
    {
        return $this->getBiz()->service('Task:TaskService');
    }

    /**
     * @return CourseSetService
     */
    protected function getCourseSetService()
    {
        return $this->createService('Course:CourseSetService');
    }
}

技术交流 QQ扫一扫:

在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

linlinlove2

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值