Commit 4b17a472 authored by Ing. Jiří Fryč's avatar Ing. Jiří Fryč

next version.

parent 967a535c
No preview for this file type
......@@ -8,9 +8,22 @@ namespace KazetaNode
{
abstract class Command
{
public Command()
{
}
public abstract string[] Aliases { get; }
public abstract void Execute(AbstractLibraryInstance instance, CommandInput input);
}
abstract class Command<T> : Command where T:AbstractLibrary
{
protected internal T library;
public Command(T library)
{
this.library = library;
}
}
class CmdTestNetwork : Command
{
......@@ -105,13 +118,13 @@ namespace KazetaNode
if (mode == 5) { input.Arguments.Add(value); value = ""; mode = 0; continue; }
}
if(mode==0) { mode = 4; }
if(mode==0) { mode = 4; value += line[i]; }
else if(mode==1) { name += line[i]; }
else { value += line[i]; }
i++;
}
if (value.Length > 0)
if (mode > 4)
if (mode >= 4)
input.Arguments.Add(value);
else
input.Parameters.Add(name, value);
......
This diff is collapsed.
......@@ -25,6 +25,7 @@
<ItemGroup>
<Folder Include="Libraries\BlackMagicVideoHub\" />
<Folder Include="Libraries\TaskScheduler\" />
<Folder Include="Libraries\Visca\" />
</ItemGroup>
......
......@@ -27,7 +27,8 @@ namespace KazetaNode.Libraries
libraries = new List<AbstractLibrary>
{
new Ffmpeg.Ffmpeg(),
new KosApi.KosApi(libraryConfig?["kosapi"])
new KosApi.KosApi(libraryConfig?["kosapi"]),
new Room.Room()
};
return libraries;
}
......
......@@ -4,8 +4,12 @@ using System.Text;
namespace KazetaNode.Libraries.KosApi
{
class CmdKosApiRoomInfo : Command
class CmdKosApiRoomInfo : Command<KosApi>
{
public CmdKosApiRoomInfo(KosApi library) : base(library)
{
}
public override string[] Aliases => new string[] { "kosapi-info-room" };
public override void Execute(AbstractLibraryInstance instance, CommandInput input)
......@@ -13,13 +17,36 @@ namespace KazetaNode.Libraries.KosApi
throw new NotImplementedException();
}
}
class CmdKosApiCourseInfo : Command
class CmdKosApiCourseInfo : Command<KosApi>
{
public CmdKosApiCourseInfo(KosApi library) : base(library)
{
}
public override string[] Aliases => new string[] { "kosapi-info-course" };
public override void Execute(AbstractLibraryInstance instance, CommandInput input)
{
throw new NotImplementedException();
var res = library.Endpoint.CourseInfoAsync(input.Arguments[0]); // B4M36ESW
res.Wait();
var course=res.Result;
if (course == null)
{
ConsoleP.AppendLine("Course with code '" + input.Arguments[0] + "' not found");
return;
}
ConsoleP.AppendLine("Course '" + course.Code + "'");
ConsoleP.AppendLine("Název: '" + course.NameCs);
ConsoleP.AppendLine("Name: " + course.NameEn);
ConsoleP.AppendLine("Teachers: " + String.Join(", ", course.Teachers));
ConsoleP.AppendDelimeter();
ConsoleP.AppendCols(new int[] { 10, 10, 10, 10, 10 }, "Type","Day","Room","From","To");
ConsoleP.AppendDelimeter();
foreach (var par in course.Parallels)
{
ConsoleP.AppendCols(new int[] { 10,10,10,10,10 },par.Type.ToString(), par.Day.ToString(),Program.GetLibrary<Room.Room>(typeof(Room.Room)).RoomExist(par.RoomId)?"@green": "@red", par.RoomId,"@reset",par.FromHM[0]+":"+par.FromHM[1],par.ToHM[0]+":"+par.ToHM[1]);
}
ConsoleP.AppendDelimeter();
}
}
}
......@@ -13,7 +13,7 @@ namespace KazetaNode.Libraries.KosApi
public override string Version => "1.0";
public override List<Command> Commands => new List<Command>();
public override List<Command> Commands => new List<Command>() { new CmdKosApiCourseInfo(this),new CmdKosApiRoomInfo(this)};
public override Dictionary<string, Tuple<Type, Network.ReceiveMessage>> Messages => throw new NotImplementedException();
......
......@@ -9,7 +9,7 @@ namespace KazetaNode.Libraries.KosApi
public string Code { get; set; }
public string NameCs { get; set; }
public string NameEn { get; set; }
public string[] Teachers { get; set; }
public HashSet<string> Teachers { get; set; } = new HashSet<string>();
public List<KosCourseParallel> Parallels { get; set; } = new List<KosCourseParallel>();
}
enum Parity { ODD,EVEN,BOTH}
......
......@@ -30,7 +30,6 @@ namespace KazetaNode.Libraries.KosApi
Client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/xml"));
GetTokenAsync().Wait();
CourseInfoAsync("B4M36ESW");
}
......@@ -65,10 +64,14 @@ namespace KazetaNode.Libraries.KosApi
var res=await Client.GetAsync("rooms/" + code);
return await Client.GetAsync("rooms/" + code).ContinueWith<bool>(e => e.Result.IsSuccessStatusCode);
}
public async System.Threading.Tasks.Task CourseInfoAsync(string code,string sem="current")
public async System.Threading.Tasks.Task<KosCourse> CourseInfoAsync(string code,string sem="current")
{
KosCourse course = new KosCourse();
try {
XNamespace atom = "http://www.w3.org/2005/Atom";
XNamespace n= "http://kosapi.feld.cvut.cz/schema/3";
XNamespace xlink = "http://www.w3.org/1999/xlink";
XNamespace xml = XNamespace.Xml;
Client.DefaultRequestHeaders.Remove("Authorization");
var t = await GetTokenAsync();
Client.DefaultRequestHeaders.Add("Authorization", "Bearer " + t["access_token"].ToString());
......@@ -76,11 +79,40 @@ namespace KazetaNode.Libraries.KosApi
query["limit"] = "1000";
query["detail"] = "1";
query["sem"] = sem;
var res = await Client.GetAsync("courses/" + code+ "/parallels?"+query.ToString());
var res = await Client.GetAsync("courses/" + code + "?" + query.ToString());
if (!res.IsSuccessStatusCode)
return null;
var body = await res.Content.ReadAsStringAsync();
var doc = XDocument.Parse(body);
course.Code = code;
var names = doc.Root.Element(atom + "content")?.Elements(n + "name");
if (names != null)
foreach (var name in names)
{
if (name.Attribute(xml + "lang").Value.Equals("cs"))
course.NameCs = name.Value;
else if (name.Attribute(xml + "lang").Value.Equals("en"))
course.NameEn = name.Value;
}
foreach (var teacher in doc.Root.Element(atom + "content")?.Element(n + "instance")?.Element(n + "lecturers")?.Elements(n + "teacher"))
{
var val = teacher?.Attribute(xlink + "href")?.Value.Split("/")?[1];
if (val != null)
course.Teachers.Add(val);
}
foreach (var teacher in doc.Root.Element(atom + "content")?.Element(n + "instance")?.Element(n + "instructors")?.Elements(n + "teacher"))
{
var val = teacher?.Attribute(xlink + "href")?.Value.Split("/")?[1];
if (val != null)
course.Teachers.Add(val);
}
res = await Client.GetAsync("courses/" + code+ "/parallels?"+query.ToString());
if (!res.IsSuccessStatusCode)
return null;
body = await res.Content.ReadAsStringAsync();
doc = XDocument.Parse(body);
var elements = doc.Root.Elements(atom + "entry");
KosCourse course = new KosCourse();
foreach(var element in elements)
{
var content = element.Element(atom + "content");
......@@ -114,9 +146,12 @@ namespace KazetaNode.Libraries.KosApi
course.Parallels.Add(p);
}
}
res = await Client.GetAsync("courses/" + code + "?" + query.ToString());
body = await res.Content.ReadAsStringAsync();
doc = XDocument.Parse(body);
}
catch (Exception e)
{
return null;
}
return course;
}
}
}
......@@ -8,13 +8,14 @@ namespace KazetaNode.Models
{
public string Id { get; set; }
public string Ip { get; set; }
public ushort Port { get; set; }
}
class NdiSourceDescriptor
class NdiSourceDescriptor : NdiSource
{
public NdiSource Source { get; set; }
public DateTime Validity { get; set; }
public bool VideoCapture { get; set; }
public bool AudioCapture { get; set; }
public int Priority { get; set; }
public string DisplayName { get; set; }
}
class Room
{
......
......@@ -10,8 +10,32 @@ namespace KazetaNode.Models
public string Name { get; set; }
}
class ProjectFile
{
public string FileName { get; set; }
public int Size { get; set; }
}
class ProjectCapture
{
public string Room { get; set; }
public DateTime From { get; set; }
public DateTime To { get; set; }
public CaptureMode Mode { get; set; } = CaptureMode.SPEAKER_PRESENTATION_BLACKBOARD;
public VideoQuality Quality { get; set; } = VideoQuality.V1080p;
public List<string> Before { get; set; } = new List<string>();
public List<string> After { get; set; } = new List<string>();
}
class ProjectPersist
{
public List<string> At { get; set; }
}
class Project
{
public List<string> Files { get; set; }
public Guid Id { get; set; }
public List<ProjectFile> Files { get; set; } = new List<ProjectFile>();
public ProjectCapture Capture { get; set; }
}
}
......@@ -36,6 +36,11 @@ namespace KazetaNode
public static List<RoomDefinition> LocalRooms { get; set; } = null;
public static Dictionary<string, Command> Commands=new Dictionary<string, Command>();
public static T GetLibrary<T>(Type type) where T: AbstractLibrary
{
return (T)Libraries.FirstOrDefault(lib => lib.GetType().IsEquivalentTo(type));
}
private static void RegisterCommands(params Command[] cmds)
{
......
rooms:
- id: "KN:E-207"
- id: "KN:E-301"
modes:
- SPEAKER_PRESENTATION_BLACKBOARD
- SPEAKER_PRESENTATION
- SPEAKER_BLACKBOARD
- SPEAKER
- BLACKBOARD
- AUDIO
- ALL
- SPEAKER_PRESENTATION
- SPEAKER_BLACKBOARD
- SPEAKER
- BLACKBOARD
- AUDIO
- ALL
initialize:
- only: [SPEAKER_PRESENTATION_BLACKBOARD,SPEAKER_BLACKBOARD,BLACKBOARD]
script:
- dmx turn-off 0x01 0x02 0x03 0x04 0x05
- dmx turn-on 0x06 0x07
- dmx intensity .50 0x06 0x07
script:
- dmx turn-off 0x01 0x02 0x03 0x04 0x05
- dmx turn-on 0x06 0x07
- dmx intensity .50 0x06 0x07
capture:
- only: []
script:
- ffmpeg %%
script:
- ffmpeg %%
terminate:
- only: [SPEAKER_PRESENTATION_BLACKBOARD,SPEAKER_BLACKBOARD,BLACKBOARD]
script:
- dmx turn-on 0x01 0x02 0x03 0x04 0x05
- dmx turn-off 0x06 0x07
script:
- dmx turn-on 0x01 0x02 0x03 0x04 0x05
- dmx turn-off 0x06 0x07
capability: [v480p,v720p,v1080p,v2k,v4k]
sources:
- type: NDI
ip: 10.0.0.0.1
port: 5040
name: test2
displayName: "Speaker camera"
priority: 1000
type: SPEAKER
ip: 10.0.0.0.1
port: 5040
id: primary_camera
display_name: "Speaker camera"
priority: 1000
video_capture: true
audio_capture: false
- type: NDI
ip: 10.0.0.0.1
port: 5041
name: test3
displayName: "Audio in 1"
priority: 1000
type: AUDIO
ip: 10.0.0.0.1
port: 5041
id: primary_microphone
display_name: "Audio in 1"
priority: 1000
video_capture: false
audio_capture: true
- type: NDI
ip: 10.0.0.0.1
port: 5042
name: test4
displayName: "Audio in 1"
priority: 1000
type: AUDIO
\ No newline at end of file
ip: 10.0.0.0.1
port: 5042
id: test4
display_name: "Audio in 1"
priority: 1000
video_capture: false
audio_capture: true
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment