Cron.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Live\Lib;
  3. use Dever;
  4. class Cron
  5. {
  6. public function getStream_api()
  7. {
  8. }
  9. public function getUrl_api()
  10. {
  11. }
  12. # 定时获取 所有流的状态 获取推流地址、拉流地址、推流历史等
  13. public function getStream()
  14. {
  15. $data = Dever::db('live/stream')->state();
  16. if ($data) {
  17. foreach ($data as $k => $v) {
  18. $handle = new Handle();
  19. $data = $handle->get($v['id']);
  20. }
  21. }
  22. return 'yes';
  23. }
  24. # 定时获取 所有的直播视频的回放地址
  25. public function getUrl()
  26. {
  27. $video = Dever::config('base', 'live')->video;
  28. $data = Dever::db($video['table'])->state();
  29. if ($data) {
  30. $time = time();
  31. foreach ($data as $k => $v) {
  32. if ($v[$video['stream_id']] > 0 && !$v[$video['url_m3u8']] && $v[$video['sdate']] > 0 && $v[$video['edate']] > 0 && $time >= $v[$video['edate']]) {
  33. $info = Dever::db('live/stream')->one($v[$video['stream_id']]);
  34. $config = Dever::db('live/info')->one($info['live_id']);
  35. $handle = new Handle();
  36. $method = $handle->method($config);
  37. $handle->createUrlOne($v, $video, $method, $config, $info);
  38. }
  39. }
  40. }
  41. return 'yes';
  42. }
  43. }