Authored by wuxiao

Merge branch 'develop' of http://git.yoho.cn/web/yoho-live into develop

@@ -298,19 +298,60 @@ class RoomController extends BaseController @@ -298,19 +298,60 @@ class RoomController extends BaseController
298 $this->renderJson(Yii::$app->params['success_code'],'',$list); 298 $this->renderJson(Yii::$app->params['success_code'],'',$list);
299 } 299 }
300 300
301 - public function actionLog(){  
302 - $message = "test";  
303 - $level = "";  
304 - Yii::$app->log->getLogger()->log($message, $level); 301 + /**
  302 + * 获取推流房间
  303 + * -二期推流需求
  304 + * @return [type] [description]
  305 + */
  306 + public function actionGetpushroom()
  307 + {
  308 + $requests = $this->requests();
  309 + $secret = $requests['secret'];
  310 + do{
  311 + if(empty(trim($requests['secret']))){
  312 + $retArr = [
  313 + 'code' => Yii::$app->params['failed_code'],
  314 + 'messsage' => '缺少密钥'
  315 + ];
  316 + break;
305 } 317 }
  318 + if($model = Room::findOne(['secret'=>$secret])){
  319 + if($model->living==1){
  320 + $retArr = [
  321 + 'code' => Yii::$app->params['failed_code'],
  322 + 'messsage' => '该房间正在直播中'
  323 + ];
  324 + break;
  325 + }
  326 + $channel_id = $upstream_address = '';
  327 + if($model->roomQchannel){
  328 + $channel_id = $model->roomQchannel->channel_id;
  329 + $upstream_address = $model->roomQchannel->upstream_address;
  330 + }
  331 + $retArr = [
  332 + 'code' => Yii::$app->params['success_code'],
  333 + 'messsage' => '',
  334 + 'data' => [
  335 + 'url' => $upstream_address.'&record=flv',
  336 + 'name' => $model->title,
  337 + 'channel_id' => $channel_id,
  338 + 'secret' => $model->secret,
  339 + 'cid' => '',
  340 + 'app' => '1',
  341 + 'id' => $model->room_id,
  342 + 'type' => $model->living,
  343 + ]
  344 + ];
  345 + }else{
  346 + $retArr = [
  347 + 'code' => Yii::$app->params['failed_code'],
  348 + 'messsage' => '房间不存在'
  349 + ];
  350 + }
  351 + break;
  352 + }while (true);
306 353
307 - public function actionTest(){  
308 -// $re = \common\lib\QcloudApi\Client::self()->CreateRecord("16093425727657864680", date('Y-m-d H:i:s',time()+120), '');  
309 - $re = \common\lib\QcloudApi\Client::self()->DescribeRecordList("16093425727657864680",1,10);  
310 -  
311 -// $re = \common\lib\QcloudApi\Client::self()->StopRecord("16093425727657524184", "131525");  
312 - var_dump($re);  
313 - //http://200013340.vod.myqcloud.com/200013340_6e79da1e65d140d887cdbb7f3ebadf79.f20.mp4 354 + $this->renderJson($retArr['code'], $retArr['messsage'], isset($retArr['data']) ? $retArr['data']:'');
314 } 355 }
315 356
316 /** 357 /**