123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <?php
- namespace app\common\model;
- use think\facade\Db;
- class LiveApply extends BaseModel {
- public $page_info;
- public function getLiveApplyList($condition, $field = '*', $pagesize=10, $order = 'live_apply_id desc') {
- if ($pagesize) {
- $result = Db::name('live_apply')->field($field)->where($condition)->order($order)->paginate(['list_rows' => $pagesize, 'query' => request()->param()], false);
- $this->page_info = $result;
- return $result->items();
- } else {
- $result = Db::name('live_apply')->field($field)->where($condition)->order($order)->select()->toArray();
- return $result;
- }
- }
-
- public function getLiveApplyInfo($condition) {
- $result = Db::name('live_apply')->where($condition)->find();
- return $result;
- }
-
- public function addLiveApply($data) {
- $result = Db::name('live_apply')->insertGetId($data);
- return $result;
- }
-
- public function getLiveApplyGoodsList($condition) {
- $result = Db::name('live_apply_goods')->where($condition)->select()->toArray();
- return $result;
- }
-
- public function addLiveApplyGoodsAll($data) {
- $result = Db::name('live_apply_goods')->insertAll($data);
- return $result;
- }
-
- public function editLiveApply($data, $condition) {
- $result = Db::name('live_apply')->where($condition)->update($data);
- return $result;
- }
-
- public function delLiveApply($condition) {
- return Db::name('live_apply')->where($condition)->delete();
- }
- function getPushUrl($streamName, $time) {
- if (config('ds_config.video_type') == 'aliyun') {
- $domain=config('ds_config.aliyun_live_push_domain');
- $key=config('ds_config.aliyun_live_push_key');
- $rand=rand(10000,99999);
- $ext_str='?auth_key='.$time.'-'.$rand.'-0-'.md5('/live/'.$streamName.'-'.$time.'-'.$rand.'-0-'.$key);
- } else {
- $domain=config('ds_config.live_push_domain');
- $key=config('ds_config.live_push_key');
- $txTime = strtoupper(base_convert($time, 10, 16));
- $txSecret = md5($key . $streamName . $txTime);
- $ext_str = "?" . http_build_query(array(
- "txSecret" => $txSecret,
- "txTime" => $txTime
- ));
- }
- return "rtmp://" . $domain . "/live/" . $streamName . (isset($ext_str) ? $ext_str : "");
- }
- function getPlayUrl($streamName, $time,$rtmp=false){
- if (config('ds_config.video_type') == 'aliyun') {
- $domain=config('ds_config.aliyun_live_play_domain');
- $key=config('ds_config.aliyun_live_play_key');
- $rand=rand(10000,99999);
- $ext_str='?auth_key='.$time.'-'.$rand.'-0-'.md5('/live/'.$streamName.'.m3u8'.'-'.$time.'-'.$rand.'-0-'.$key);
- }else{
- $domain=config('ds_config.live_play_domain');
- }
- if($rtmp){
- return 'rtmp://'.$domain.'/live/'.$streamName . (isset($ext_str) ? $ext_str : "");
- }else{
- return HTTP_TYPE.$domain.'/live/'.$streamName.'.m3u8' . (isset($ext_str) ? $ext_str : "");
- }
-
- }
- }
|