|
@@ -6,13 +6,20 @@ use Dever;
|
|
|
|
|
|
class Api
|
|
|
{
|
|
|
+ private $key = 'signature_dever_2018_jm';
|
|
|
+
|
|
|
+ private function check()
|
|
|
+ {
|
|
|
+ $signature = Dever::input('signature');
|
|
|
+ if ($signature != md5($this->key)) {
|
|
|
+ Dever::alert('signature error');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
# 获取直播地址
|
|
|
public function get()
|
|
|
{
|
|
|
- $signature = Dever::input('signature');
|
|
|
- if ($signature != md5('signature_dever_2018_jm')) {
|
|
|
- Dever::alert('signature error');
|
|
|
- }
|
|
|
+ $this->check();
|
|
|
|
|
|
$data = Dever::db('live/active')->getAll(array('status' => 2));
|
|
|
|
|
@@ -26,24 +33,25 @@ class Api
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- # 获取回放地址
|
|
|
- public function getMp4()
|
|
|
+ # 开始推流
|
|
|
+ public function start()
|
|
|
{
|
|
|
- $signature = Dever::input('signature');
|
|
|
- if ($signature != md5('signature_dever_2018_jm')) {
|
|
|
- Dever::alert('signature error');
|
|
|
- }
|
|
|
+ $this->check();
|
|
|
+ $id = Dever::input('id');
|
|
|
+ $handle = new Handle();
|
|
|
+ $handle->startLive($id);
|
|
|
+
|
|
|
+ return 'ok';
|
|
|
+ }
|
|
|
|
|
|
+ # 获取回放地址
|
|
|
+ public function getVod()
|
|
|
+ {
|
|
|
+ $this->check();
|
|
|
$id = Dever::input('id');
|
|
|
- $data = Dever::db('live/stream')->one($id);
|
|
|
+ $handle = new Handle();
|
|
|
+ $handle->save($id);
|
|
|
|
|
|
- if ($data) {
|
|
|
- foreach ($data as $k => $v) {
|
|
|
- $data[$k]['stream'] = Dever::db('live/stream')->getAll();
|
|
|
- }
|
|
|
- return array('active' => $data);
|
|
|
- } else {
|
|
|
- return array('active' => (object) array());
|
|
|
- }
|
|
|
+ return 'ok';
|
|
|
}
|
|
|
}
|