| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 | 
							- <?php
 
- namespace Live\Lib;
 
- use Dever;
 
- class Handle
 
- {
 
-     public function method($config)
 
-     {
 
-         if ($config['type'] == 1) {
 
-             $method = new Qiniu($config);
 
-         }
 
-         return $method;
 
-     }
 
-     # 启动
 
-     public function start($id)
 
-     {
 
-         $info = Dever::db('live/stream')->one($id);
 
-         $config = Dever::db('live/info')->one($info['live_id']);
 
-         $method = $this->method($config);
 
-         $stream = $method->start($info['key']);
 
-     }
 
-     # 禁播
 
-     public function stop($id)
 
-     {
 
-         $info = Dever::db('live/stream')->one($id);
 
-         $config = Dever::db('live/info')->one($info['live_id']);
 
-         $method = $this->method($config);
 
-         $stream = $method->stop($info['key']);
 
-     }
 
-     # 初始化流
 
-     public function init($id, $name = '')
 
-     {
 
-         $info = Dever::db('live/stream')->one($id);
 
-         if ($info['url_rtmp']) {
 
-             return;
 
-         }
 
-         if ($name) {
 
-             $info['key'] = $name;
 
-         }
 
-         $config = Dever::db('live/info')->one($info['live_id']);
 
-         
 
-         $method = $this->method($config);
 
-         $stream = $method->create($info['key']);
 
-         $rtmp = $method->getRtmp($info['key'], $info['times'] * 3600);
 
-         $url = $method->getPlay($info['key']);
 
-         $data['where_id'] = $id;
 
-         $data['live'] = $rtmp;
 
-         $data['url_rtmp'] = $url['rtmp'];
 
-         $data['url_hls'] = $url['hls'];
 
-         $data['url_hdl'] = $url['hdl'];
 
-         $data['url_pic'] = $url['pic'];
 
-         $live['info'] = $stream;
 
-         $data['info'] = Dever::json_encode($live);
 
-         Dever::db('live/stream')->update($data);
 
-         return $data;
 
-     }
 
-     # 获取流信息 定时跑
 
-     public function get($id)
 
-     {
 
-         $info = Dever::db('live/stream')->one($id);
 
-         $time = time();
 
-         if ($time <= $info['sdate']) {
 
-             return;
 
-         }
 
-         $config = Dever::db('live/info')->one($info['live_id']);
 
-         
 
-         $method = $this->method($config);
 
-         $stream = $method->getInfo($info['key']);
 
-         $live = $method->getLiveStatus($info['key']);
 
-         $hitory = $method->history($info['key']);
 
-         $data['where_id'] = $id;
 
-         $live = Dever::json_decode($info['info']);
 
-         $live['info'] = $stream;
 
-         $live['live'] = $live;
 
-         $live['hitory'] = $history;
 
-         $data['info'] = Dever::json_encode($live);
 
-         Dever::db('live/stream')->update($data);
 
-         return $data;
 
-     }
 
- }
 
 
  |