1.0.0-rc.107

Former-commit-id: 2a334fbfa4aebe447a24845c134731dd58b95f10
TangShanKaiPing
wanggang 6 years ago
parent 70f95c06a3
commit 0b22a69457

@ -2,19 +2,4 @@
@{
HtmlTitle = Model.Name;
}
<video id="videoElement" controls autoplay style="width:640px;height:480px;background-color:#000;"></video>
@section scripts{
<script src="/lib/flv.js/flv.min.js"></script>
<script>
if (flvjs.isSupported()) {
var videoElement = document.getElementById('videoElement');
var flvPlayer = flvjs.createPlayer({
type: 'flv',
url: 'http://'+location.hostname+ '@Model.Value'
});
flvPlayer.attachMediaElement(videoElement);
flvPlayer.load();
flvPlayer.play();
}
</script>
}
<video id="videoElement" controls autoplay style="width:640px;height:480px;background-color:#000;" src="@Model.Value"></video>

@ -10,6 +10,7 @@ using Microsoft.AspNetCore.SignalR;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Drawing;
@ -469,5 +470,41 @@ namespace IoTCenter.Controllers
}
}
}
#region srs callback
/// <summary>
/// 录制完毕事件响应
///{"action":"on_dvr","client_id":107,"ip":"192.168.3.124","vhost":"__defaultVhost__","app":"live","stream":"main0a5d5deee43011b483884cbd8fd2b3dd","param":"","cwd":"/root/publish/apps/srs","file":"./objs/nginx/html/live.main0a5d5deee43011b483884cbd8fd2b3dd.1574832559180.mp4"}
/// </summary>
/// <returns></returns>
public IActionResult OnDvr()
{
using (var reader = new StreamReader(Request.Body))
{
var json = reader.ReadToEndAsync().Result;
var result = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
if (result["action"] == "on_dvr")
{
var streamId = result["stream"];
var deviceNumber = streamId.StartsWith("main") ? streamId.Substring(4) : streamId.Substring(3);
var device = this._deviceRepo.ReadOnlyTable().FirstOrDefault(o => o.Number == deviceNumber);
if (device != null)
{
this._liveRecordRepo.Add(new LiveRecord
{
DeviceNumber = deviceNumber,
DeviceName = device?.DisplayName,
Name = $"回放{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}",
Value = $"/video{result["file"].Substring(result["file"].LastIndexOf('/'))}"
});
this._liveRecordRepo.SaveChanges();
}
}
}
return Content(string.Empty);
}
#endregion srs callback
}
}

@ -1,52 +0,0 @@
using Application.Domain.Entities;
using Infrastructure.Data;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace IoTCenter.Controllers
{
public class ServiceController : Controller
{
private readonly IRepository<Device> _deviceRepo;
private readonly IRepository<LiveRecord> _liveRecordRepo;
public ServiceController(IRepository<Device> deviceRepo, IRepository<LiveRecord> liveRecordRepo)
{
this._deviceRepo = deviceRepo;
this._liveRecordRepo = liveRecordRepo;
}
/// <summary>
/// 录制完毕事件响应
///{"action":"on_dvr","client_id":128,"ip":"127.0.0.1","vhost":"__defaultVhost__","app":"live","stream":"mainb57e867ae29d11b483864cbd8fd0f747","param":"","cwd":"/root/publish/apps/srs","file":"./objs/nginx/html/live/mainb57e867ae29d11b483864cbd8fd0f747.1565084670048.flv"}
/// </summary>
/// <returns></returns>
public IActionResult OnDvr()
{
using (var reader = new StreamReader(Request.Body))
{
var json = reader.ReadToEndAsync().Result;
var result = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
if (result["action"] == "on_dvr")
{
var streamId = result["stream"];
var deviceNumber = streamId.StartsWith("main") ? streamId.Substring(4) : streamId.Substring(3);
var device = this._deviceRepo.ReadOnlyTable().FirstOrDefault(o => o.Number == deviceNumber);
this._liveRecordRepo.Add(new LiveRecord
{
DeviceNumber = deviceNumber,
DeviceName = device?.DisplayName,
Name = $"回放{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}",
Value = $"/video{result["file"].Substring(result["file"].LastIndexOf('/'))}"
});
this._liveRecordRepo.SaveChanges();
}
}
return Content(string.Empty);
}
}
}

@ -1,5 +1,5 @@
{
"version": "1.0.0-rc.106",
"version": "1.0.0-rc.107",
"Logging": {
"LogLevel": {
"Default": "Warning",

File diff suppressed because it is too large Load Diff

@ -34,15 +34,15 @@ vhost __defaultVhost__ {
hls_ts_file [app]/[stream]-[seq].ts;
}
dvr {
enabled off;
dvr_path ./objs/nginx/html/[app].[stream].[timestamp].flv;
enabled on;
dvr_path ../IoTCenter/wwwroot/video/[app]-[stream]-[timestamp].mp4;
dvr_plan segment;
dvr_duration 600;
dvr_duration 3600;
dvr_wait_keyframe on;
time_jitter full;
}
http_hooks {
enabled on;
on_dvr http://localhost/IoTCenter/Service/OnDvr;
on_dvr http://localhost/IoTCenter/App/OnDvr;
}
}
}

@ -0,0 +1,48 @@
# main config for srs.
# @see full.conf for detail config.
listen 1935;
daemon off;
max_connections 1000;
srs_log_tank file;
srs_log_file ./objs/srs.log;
http_api {
enabled on;
listen 1985;
}
http_server {
enabled on;
listen 8080;
dir ./objs/nginx/html;
}
stats {
network 0;
disk sda sdb xvda xvdb;
}
vhost __defaultVhost__ {
http_remux {
enabled on;
mount [vhost]/[app]/[stream].flv;
hstrs on;
}
hls {
enabled on;
hls_fragment 3;
hls_window 10;
hls_path ./objs/nginx/html;
hls_m3u8_file [app]/[stream].m3u8;
hls_ts_file [app]/[stream]-[seq].ts;
}
dvr {
enabled off;
dvr_path ./objs/nginx/html/[app].[stream].[timestamp].flv;
dvr_plan segment;
dvr_duration 600;
dvr_wait_keyframe on;
time_jitter full;
}
http_hooks {
enabled on;
on_dvr http://localhost/IoTCenter/Service/OnDvr;
}
}
Loading…
Cancel
Save