获取监控设备直播地址
parent
26fba3816b
commit
cd90308c97
|
|
@ -725,4 +725,63 @@ class DeviceController extends Controller
|
|||
|
||||
return WormPhotoResource::collection($wormPhotos);
|
||||
}
|
||||
|
||||
/**
|
||||
* 监控设备直播地址
|
||||
*/
|
||||
public function live(int $id, BiAngDeviceService $biangDeviceService)
|
||||
{
|
||||
$device = Device::where('type', DeviceType::Monitor)->findOrFail($id);
|
||||
|
||||
switch ($device->supplier_key) {
|
||||
case 'device-supplier-biang':
|
||||
$client = $biangDeviceService->buildHttpClient($device);
|
||||
|
||||
// 直播地址
|
||||
$address = $client->getMonitorPalyAddress($device->sn);
|
||||
|
||||
return [
|
||||
'type' => 'm3u8',
|
||||
'address' => (string) $address,
|
||||
];
|
||||
}
|
||||
|
||||
// 直播地址
|
||||
$address = '';
|
||||
|
||||
if ($rtspUrl = data_get($device->extends, 'rtsp_url')) {
|
||||
$value = Setting::where('slug', 'ffmpeg_websocket_ip')->value('value');
|
||||
|
||||
$wsConfig = $value ? json_decode($value, true) : [];
|
||||
if (! is_array($wsConfig)) {
|
||||
$wsConfig = [];
|
||||
}
|
||||
$wsConfig = array_merge([
|
||||
'host' => '',
|
||||
'ip' => '127.0.0.1',
|
||||
'port'=> '80',
|
||||
'ssl' => false,
|
||||
], $wsConfig);
|
||||
|
||||
if ($wsConfig['ssl'] && $wsConfig['host']) {
|
||||
$address = sprintf(
|
||||
'wss://%s/rtsp?url=%s',
|
||||
$wsConfig['host'],
|
||||
base64_encode($rtspUrl),
|
||||
);
|
||||
} else {
|
||||
$address = sprintf(
|
||||
'wss://%s:%s/rtsp?url=%s',
|
||||
$wsConfig['ip'],
|
||||
$wsConfig['port'],
|
||||
base64_encode($rtspUrl),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'type' => 'flv',
|
||||
'address' => $address,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ Route::group([
|
|||
Route::apiResource('devices', DeviceController::class)->names('device');
|
||||
Route::get('devices/{device}/worm-statics', [DeviceController::class, 'wormStatics']);
|
||||
Route::get('devices/{device}/worm-photos', [DeviceController::class, 'wormPhotos']);
|
||||
Route::get('devices/{device}/live', [DeviceController::class, 'live']);
|
||||
Route::put('devices-update-recommend/{device}', [DeviceController::class, 'updateRecommendStatus']);
|
||||
Route::get('devices-num', [DeviceController::class, 'typeStatusNum'])->name('device.type_status_num');
|
||||
Route::get('monitoring-data', [DeviceController::class, 'timeZoneList']);
|
||||
|
|
|
|||
Loading…
Reference in New Issue