-
Notifications
You must be signed in to change notification settings - Fork 0
/
CasparCG.vb
3875 lines (3188 loc) · 149 KB
/
CasparCG.vb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'Copyright by Media Support - Didi Kunz didi@mediasupport.ch
'The same license conditions apply as CasparCG server has.
'
Imports System.Net.Sockets
Imports System.Net.NetworkInformation
Imports System.IO
Imports System.Text
Imports System.Xml
Imports System.Xml.Serialization
Imports System.Diagnostics
Imports System.ComponentModel
Imports System.Threading
Imports System.Globalization
''' <summary>
''' CasparCG connection object
''' </summary>
''' <remarks>Wrapper around a System.Net.Sockets.Socket object</remarks>
<Serializable()> _
Public Class CasparCG
Implements ICloneable
#Region "Enums and local classes"
''' <summary>
''' Media clip types
''' </summary>
''' <remarks>Used for GetMediaClipsNames function</remarks>
Public Enum MediaTypes
''' <summary>
''' All media types
''' </summary>
All
''' <summary>
''' Only videos
''' </summary>
Movie
''' <summary>
''' Only still pictures
''' </summary>
Still
''' <summary>
''' Only audio clips
''' </summary>
Audio
End Enum
''' <summary>
''' Return Value of the Connect function
''' </summary>
Public Enum enumConnectResult
''' <summary>
''' Succesfully connected to CasparCG
''' </summary>
crSuccessfull
''' <summary>
''' The machine could not be pinged, network error or machine is not running
''' </summary>
crMachineNotAvailable
''' <summary>
''' CasparCG does not respond, it is not started on the machine
''' </summary>
crCasparCGNotStarted
''' <summary>
''' A local CasprCG server could not be loaded using the CasparExePath property
''' </summary>
crLocalCasparCGCouldNotBeStarted
''' <summary>
''' This is not a local CasparCG and could not be started using the CasparExePath argument
''' </summary>
crIsNotLocal
End Enum
''' <summary>
''' The way channel and layer informations get added to template data.
''' </summary>
Public Enum enumAddInfoFieldsType
''' <summary>
''' No channel and layer informations were added.
''' </summary>
itNone
''' <summary>
''' The standard "channel" and "layer" variable names are used.
''' </summary>
itStandard
''' <summary>
''' The Aveco automation specific variable names "astra_output" and "astra_layer" are used.
''' </summary>
itAveco
End Enum
''' <summary>
''' Class for use with delayed execution.
''' </summary>
Public Class Retard
Public Property Amount As Integer
Public Sub New()
Me.Amount = 0
End Sub
Public Sub New(ByVal Retard As Integer)
Me.Amount = Retard
End Sub
End Class
Public Class ChannelInfo
Public Property Width As Integer
Public Property Height As Integer
Public Property Framerate As Single
Public Property IsInterlaced As Boolean
Public Sub New()
Me.Width = 1920
Me.Height = 1080
Me.Framerate = 50
Me.IsInterlaced = True
End Sub
Public Sub New(text As String)
text = text.Replace("dci", "")
Dim i As Integer = text.IndexOfAny("ip".ToCharArray)
If i = -1 Then
Select Case text
Case "PAL"
Me.Height = 576
Me.Framerate = 50
Me.IsInterlaced = True
Case "NTSC"
Me.Height = 486
Me.Framerate = 59.94
Me.IsInterlaced = True
End Select
Else
Me.Height = Integer.Parse(text.Substring(0, i))
Me.Framerate = Single.Parse(text.Substring(i + 1)) / 100
Me.IsInterlaced = (text.Substring(i, 1) = "i")
End If
Me.Width = CInt(Me.Height * 1.7778)
End Sub
Public Sub New(ByVal Width As Integer, ByVal Height As Integer, ByVal Framerate As Integer, ByVal IsInterlaced As Boolean)
Me.Width = Width
Me.Height = Height
Me.Framerate = Framerate
Me.IsInterlaced = IsInterlaced
End Sub
End Class
#End Region
#Region "Vars"
<NonSerialized()> Private _Caspar As Socket
<NonSerialized()> Private _CasparProc As Process
<NonSerialized()> Private _Scanner As Process
<NonSerialized()> Private _Version As VersionInfo = New VersionInfo
<NonSerialized()> Private _ServerPaths As Paths
<NonSerialized()> Private _ChannelInfos As List(Of ChannelInfo) = Nothing
<NonSerialized()> Private _DelayQueue As DelayQueue = New DelayQueue(Me)
Private _ServerAdress As String = "localhost"
Private _IsLocal As Boolean = True
#End Region
#Region "Properties"
''' <summary>
''' The name of the CasparCG Server instance
''' </summary>
Public Property Name As String = "Local"
''' <summary>
''' The port number to connect to
''' </summary>
''' <remarks>Defaults to 5250</remarks>
Public Property Port As Integer = 5250
''' <summary>
''' The default channel to output in
''' </summary>
''' <remarks>Defaults to 1</remarks>
Public Property DefaultChannel As Integer = 1
''' <summary>
''' The default layer to output on
''' </summary>
''' <remarks>Defaults to 5</remarks>
Public Property DefaultLayer As Integer = 5
''' <summary>
''' Inhibits exeptions on connection errors
''' </summary>
''' <remarks>Used in combination with CasparExePath</remarks>
Public Property KeepQuiet As Boolean
''' <summary>
''' Full qualified path to Caspar's exe file. Must be local to the client.
''' </summary>
''' <remarks>Used in combination with Retries</remarks>
Public Property CasparExePath As String = ""
''' <summary>
''' Number of retries for a connection, before giving up.
''' </summary>
''' <remarks>Used in combination with CasparExePath</remarks>
Public Property Retries As Integer = 1
''' <summary>
''' IP-Address or computer name to connect to Caspar
''' </summary>
Public Property ServerAdress As String
Get
Return _ServerAdress
End Get
Set(ByVal value As String)
_ServerAdress = value.Trim
_IsLocal = (_ServerAdress.ToLower = "localhost" Or _ServerAdress = "127.0.0.1")
End Set
End Property
Public Property AddInfoFields As enumAddInfoFieldsType = enumAddInfoFieldsType.itStandard
Public Property OverwriteInfoFields As Boolean = False
''' <summary>
''' True to replace backslashes, single and double quotes for HTML.
''' </summary>
Public Property FormatTextsForHTML As Boolean = False
''' <summary>
''' If Caspar is on the local machine
''' </summary>
''' <returns>True if local, false if remote</returns>
ReadOnly Property IsLocal As Boolean
Get
Return _IsLocal
End Get
End Property
''' <summary>
''' Points to a folder were pictres are stored
''' </summary>
''' <remarks>The path is local to the server</remarks>
Public Property LocalPictureFolder As String
''' <summary>
''' Points to a folder were pictres are stored
''' </summary>
''' <remarks>The path is a network share seen from the client</remarks>
Public Property RemotePictureFolder As String
''' <summary>
''' Set Channel-filter for the ExecuteFiltered function
''' </summary>
''' <remarks>A space separated list of allowed channels</remarks>
Public Property ChannelFilterList As String
''' <summary>
''' Indicate connection status
''' </summary>
''' <remarks>True if connected, false otherwise</remarks>
Public ReadOnly Property Connected As Boolean
Get
Return _Caspar.Connected
End Get
End Property
Public Class VersionInfo
Public Property Major As Integer
Public Property Minor As Integer
Public Property Revision As Integer
End Class
''' <summary>
''' Query the version of CasparCG server as a VersionInfo object
''' </summary>
''' <returns></returns>
Public ReadOnly Property Version As VersionInfo
Get
If _Version Is Nothing OrElse _Version.Major = 0 Then
Dim s As String = Execute("VERSION SERVER").Data
If s <> "" Then
Dim parts() As String = s.Split(CChar("."))
If parts.Length >= 3 Then
_Version.Major = CInt(parts(0))
_Version.Minor = CInt(parts(1))
Dim inte As Integer = 0
If Integer.TryParse(parts(2), inte) Then
_Version.Revision = inte
Else
Dim subParts() As String = parts(2).Split(CChar(" "))
If Integer.TryParse(subParts(0), inte) Then
_Version.Revision = inte
Else
_Version.Revision = 0
End If
End If
End If
End If
End If
Return _Version
End Get
End Property
''' <summary>
''' Query the version of CasparCG server as a serialized integer:
''' Version.Major * 1000000 +
''' Version.Minor * 10000 +
''' Version.Revision
''' </summary>
Public ReadOnly Property VersionSerialized As Integer
Get
Return (Version.Major * 1000000) + (Version.Minor * 10000) + Version.Revision
End Get
End Property
Public ReadOnly Property IsPsdSupported As Boolean
Get
Return (Version.Major >= 2 And Version.Minor >= 1 And Version.Minor <> 2)
End Get
End Property
''' <summary>
''' Paths object
''' </summary>
''' <remarks>Used for the ServerPaths property</remarks>
<XmlRoot("paths")>
Public Class Paths
''' <summary>
''' Path to the media files (video, audio and stills)
''' </summary>
<XmlElement(ElementName:="media-path")>
Public Property MediaPath As String = "media\"
''' <summary>
''' Path to the log files
''' </summary>
<XmlElement(ElementName:="log-path")>
Public Property LogPath As String = "log\"
''' <summary>
''' Path to the data files
''' </summary>
''' <remarks>Data files are managed using the DATA commands</remarks>
<XmlElement(ElementName:="data-path")>
Public Property DataPath As String = "data\"
''' <summary>
''' Path to the templates
''' </summary>
<XmlElement(ElementName:="template-path")>
Public Property TemplatePath As String = "templates\"
''' <summary>
''' Path to the thumbnails
''' </summary>
<XmlElement(ElementName:="thumbnail-path")>
Public Property ThumbnailPath As String = ""
''' <summary>
''' Path to the fonts
''' </summary>
<XmlElement(ElementName:="font-path")>
Public Property FontPath As String = ""
''' <summary>
''' Initial path
''' </summary>
''' <value></value>
<XmlElement(ElementName:="initial-path")>
Public Property InitialPath As String = ""
End Class
''' <summary>
''' Gets the paths settings of Caspar
''' </summary>
''' <remarks>Does not make sense for remote Caspar Servers</remarks>
Public ReadOnly Property ServerPaths() As Paths
Get
If _ServerPaths Is Nothing OrElse _ServerPaths.InitialPath = "" Then
Try
Dim s As String = Execute("INFO PATHS").Data
Dim b As Byte() = Encoding.UTF8.GetBytes(Left(s, InStrRev(s, "</paths>") + 7))
Dim ser As XmlSerializer = New XmlSerializer(GetType(Paths))
_ServerPaths = CType(ser.Deserialize(New System.IO.MemoryStream(b)), Paths)
Catch ex As Exception
_ServerPaths = New Paths
End Try
End If
Return _ServerPaths
End Get
End Property
Public ReadOnly Property NumberOfChannels As Integer
Get
If _ChannelInfos Is Nothing Then
GetChannelInfos()
End If
Return _ChannelInfos.Count
End Get
End Property
''' <summary>
''' Sets the first layer, that will be cleared by Clearlayers
''' </summary>
<XmlIgnore()>
Public Property FirstClearlayer As Integer
''' <summary>
''' Sets the last layer, that will be cleared by Clearlayers
''' </summary>
<XmlIgnore()>
Public Property LastClearlayer As Integer
''' <summary>
''' Sets the path to write metadata files into.
''' </summary>
<XmlIgnore()>
Public Property MetaDataPath As String
#End Region
#Region "Template Commands"
''' <summary>
''' Adds the template in Caspar
''' </summary>
''' <param name="TemplateData">The Template object to get fields from</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Uses the template name inside the Template object. Defaults to DefaultChannel DefaultLayer and plays the template after loading</remarks>
Public Function CG_Add(ByVal TemplateData As Template) As ReturnInfo
Return CG_Add(DefaultChannel, DefaultLayer, TemplateData.Name, TemplateData, True)
End Function
''' <summary>
''' Adds the template in Caspar
''' </summary>
''' <param name="TemplateData">The Template object to get fields from</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Uses the template name inside the Template object. Defaults to DefaultChannel DefaultLayer and plays the template after loading</remarks>
Public Function CG_Add(ByVal TemplateData As Template, ByVal Retard As Retard) As ReturnInfo
Return CG_Add(DefaultChannel, DefaultLayer, TemplateData.Name, TemplateData, True, Retard)
End Function
''' <summary>
''' Adds the template in Caspar
''' </summary>
''' <param name="TemplateName">The name of the template</param>
''' <param name="TemplateData">The Template object to get fields from</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel DefaultLayer and plays the template after loading</remarks>
Public Function CG_Add(ByVal TemplateName As String, ByVal TemplateData As Template) As ReturnInfo
Return CG_Add(DefaultChannel, DefaultLayer, TemplateName, TemplateData, True)
End Function
''' <summary>
''' Adds the template in Caspar
''' </summary>
''' <param name="TemplateName">The name of the template</param>
''' <param name="TemplateData">The Template object to get fields from</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel DefaultLayer and plays the template after loading</remarks>
Public Function CG_Add(ByVal TemplateName As String, ByVal TemplateData As Template, ByVal Retard As Retard) As ReturnInfo
Return CG_Add(DefaultChannel, DefaultLayer, TemplateName, TemplateData, True, Retard)
End Function
''' <summary>
''' Adds the template in Caspar
''' </summary>
''' <param name="Layer">The layer number</param>
''' <param name="TemplateName">The name of the template</param>
''' <param name="TemplateData">The Template object to get fields from</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel and plays the template after loading</remarks>
Public Function CG_Add(ByVal Layer As Integer, ByVal TemplateName As String, ByVal TemplateData As Template) As ReturnInfo
Return CG_Add(DefaultChannel, Layer, TemplateName, TemplateData, True)
End Function
''' <summary>
''' Adds the template in Caspar
''' </summary>
''' <param name="Layer">The layer number</param>
''' <param name="TemplateName">The name of the template</param>
''' <param name="TemplateData">The Template object to get fields from</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel and plays the template after loading</remarks>
Public Function CG_Add(ByVal Layer As Integer, ByVal TemplateName As String, ByVal TemplateData As Template, ByVal Retard As Retard) As ReturnInfo
Return CG_Add(DefaultChannel, Layer, TemplateName, TemplateData, True, Retard)
End Function
''' <summary>
''' Adds the template in Caspar
''' </summary>
''' <param name="Layer">The layer number</param>
''' <param name="TemplateName">The name of the template</param>
''' <param name="TemplateData">The Template object to get fields from</param>
''' <param name="AutoPlay">Plays the template after loading if set to true</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel</remarks>
Public Function CG_Add(ByVal Layer As Integer, ByVal TemplateName As String, ByVal TemplateData As Template, ByVal AutoPlay As Boolean) As ReturnInfo
Return CG_Add(DefaultChannel, Layer, TemplateName, TemplateData, AutoPlay)
End Function
''' <summary>
''' Adds the template in Caspar
''' </summary>
''' <param name="Layer">The layer number</param>
''' <param name="TemplateName">The name of the template</param>
''' <param name="TemplateData">The Template object to get fields from</param>
''' <param name="AutoPlay">Plays the template after loading if set to true</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel</remarks>
Public Function CG_Add(ByVal Layer As Integer, ByVal TemplateName As String, ByVal TemplateData As Template, ByVal AutoPlay As Boolean, ByVal Retard As Retard) As ReturnInfo
Return CG_Add(DefaultChannel, Layer, TemplateName, TemplateData, AutoPlay, Retard)
End Function
''' <summary>
''' Adds the template in Caspar
''' </summary>
''' <param name="Channel">The channel in Caspar</param>
''' <param name="Layer">The layer number</param>
''' <param name="TemplateName">The name of the template</param>
''' <param name="TemplateData">The Template object to get fields from</param>
''' <param name="AutoPlay">Plays the template after loading if set to true</param>
''' <param name="FlashLayer">Optional, use only when absolutely needed</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel</remarks>
Public Function CG_Add(ByVal Channel As Integer, ByVal Layer As Integer, ByVal TemplateName As String, ByVal TemplateData As Template, ByVal AutoPlay As Boolean, ByVal Optional FlashLayer As Integer = 1) As ReturnInfo
If TemplateData IsNot Nothing Then
If Not TemplateData.InfoFieldsAdded Or OverwriteInfoFields Then
Select Case Me.AddInfoFields
Case enumAddInfoFieldsType.itStandard
TemplateData.AddField("channel", Channel.ToString)
TemplateData.AddField("layer", Layer.ToString)
Case enumAddInfoFieldsType.itAveco
TemplateData.AddField("astra_output", Channel.ToString)
TemplateData.AddField("astra_layer", Layer.ToString)
End Select
TemplateData.InfoFieldsAdded = True
End If
''ToDo: Comment out for production
'Data_Store("CasparData", TemplateData)
Return Execute(String.Format("CG {1}-{2} ADD {6} {0}{4}{0} {5} {0}{3}{0}", ChrW(&H22), Channel, Layer, TemplateData.TemplateDataText(FormatTextsForHTML), TemplateName, IIf(AutoPlay, "1", "0"), FlashLayer))
Else
Return New ReturnInfo()
End If
End Function
''' <summary>
''' Adds the template in Caspar
''' </summary>
''' <param name="Channel">The channel in Caspar</param>
''' <param name="Layer">The layer number</param>
''' <param name="TemplateName">The name of the template</param>
''' <param name="TemplateData">The Template object to get fields from</param>
''' <param name="AutoPlay">Plays the template after loading if set to true</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <param name="FlashLayer">Optional, use only when absolutely needed</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>The main CG_Add Function. Adds a channel and a layer TemplateField to the Fields collection. This is usefull to call back the server via TCP/IP.</remarks>
Public Function CG_Add(ByVal Channel As Integer, ByVal Layer As Integer, ByVal TemplateName As String, ByVal TemplateData As Template, ByVal AutoPlay As Boolean, ByVal Retard As Retard, ByVal Optional FlashLayer As Integer = 1) As ReturnInfo
If TemplateData IsNot Nothing Then
If Not TemplateData.InfoFieldsAdded Or OverwriteInfoFields Then
Select Case Me.AddInfoFields
Case enumAddInfoFieldsType.itStandard
TemplateData.AddField("channel", Channel.ToString)
TemplateData.AddField("layer", Layer.ToString)
Case enumAddInfoFieldsType.itAveco
TemplateData.AddField("astra_output", Channel.ToString)
TemplateData.AddField("astra_layer", Layer.ToString)
End Select
TemplateData.InfoFieldsAdded = True
End If
''ToDo: Comment out for production
'Data_Store("CasparData", TemplateData)
Return Execute(String.Format("CG {1}-{2} ADD {6} {0}{4}{0} {5} {0}{3}{0}", ChrW(&H22), Channel, Layer, TemplateData.TemplateDataText(FormatTextsForHTML), TemplateName, IIf(AutoPlay, "1", "0"), FlashLayer), Retard)
Else
Return New ReturnInfo()
End If
End Function
''' <summary>
''' Adds the template in Caspar, using a Dataset
''' </summary>
''' <param name="Channel">The channel in Caspar</param>
''' <param name="Layer">The layer number</param>
''' <param name="TemplateName">The name of the template</param>
''' <param name="DataSetName">The name of the DataSet already stored on the server</param>
''' <param name="AutoPlay">Plays the template after loading if set to true</param>
''' <param name="FlashLayer">Optional, use only when absolutely needed</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>The CG_Add Function witch uses a DataSet insted on a Template object.</remarks>
Public Function CG_Add(ByVal Channel As Integer, ByVal Layer As Integer, ByVal TemplateName As String, ByVal DataSetName As String, ByVal AutoPlay As Boolean, ByVal Optional FlashLayer As Integer = 1) As ReturnInfo
Return Execute(String.Format("CG {1}-{2} ADD {6} {0}{4}{0} {5} {0}{3}{0}", ChrW(&H22), Channel, Layer, DataSetName, TemplateName, IIf(AutoPlay, "1", "0"), FlashLayer))
End Function
''' <summary>
''' Adds the template in Caspar, using a Dataset
''' </summary>
''' <param name="Channel">The channel in Caspar</param>
''' <param name="Layer">The layer number</param>
''' <param name="TemplateName">The name of the template</param>
''' <param name="DataSetName">The name of the DataSet already stored on the server</param>
''' <param name="AutoPlay">Plays the template after loading if set to true</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <param name="FlashLayer">Optional, use only when absolutely needed</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>The CG_Add Function witch uses a DataSet insted on a Template object.</remarks>
Public Function CG_Add(ByVal Channel As Integer, ByVal Layer As Integer, ByVal TemplateName As String, ByVal DataSetName As String, ByVal AutoPlay As Boolean, ByVal Retard As Retard, ByVal Optional FlashLayer As Integer = 1) As ReturnInfo
Return Execute(String.Format("CG {1}-{2} ADD {6} {0}{4}{0} {5} {0}{3}{0}", ChrW(&H22), Channel, Layer, DataSetName, TemplateName, IIf(AutoPlay, "1", "0"), FlashLayer), Retard)
End Function
''' <summary>
''' Plays the template in Caspar
''' </summary>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel DefaultLayer</remarks>
Public Function CG_Play() As ReturnInfo
Return CG_Play(DefaultChannel, DefaultLayer)
End Function
''' <summary>
''' Plays the template in Caspar
''' </summary>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel DefaultLayer</remarks>
Public Function CG_Play(ByVal Retard As Retard) As ReturnInfo
Return CG_Play(DefaultChannel, DefaultLayer, Retard)
End Function
''' <summary>
''' Plays the template in Caspar
''' </summary>
''' <param name="Layer">The layer number</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel</remarks>
Public Function CG_Play(ByVal Layer As Integer) As ReturnInfo
Return CG_Play(DefaultChannel, Layer)
End Function
''' <summary>
''' Plays the template in Caspar
''' </summary>
''' <param name="Layer">The layer number</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel</remarks>
Public Function CG_Play(ByVal Layer As Integer, ByVal Retard As Retard) As ReturnInfo
Return CG_Play(DefaultChannel, Layer, Retard)
End Function
''' <summary>
''' Plays the template in Caspar
''' </summary>
''' <param name="Channel">The channel in Caspar</param>
''' <param name="Layer">The layer number</param>
''' <param name="FlashLayer">Optional, use only when absolutely needed</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>The main CG_Play function.</remarks>
Public Function CG_Play(ByVal Channel As Integer, ByVal Layer As Integer, ByVal Optional FlashLayer As Integer = 1) As ReturnInfo
Return Execute(String.Format("CG {0}-{1} PLAY {2}", Channel, Layer, FlashLayer))
End Function
''' <summary>
''' Plays the template in Caspar
''' </summary>
''' <param name="Channel">The channel in Caspar</param>
''' <param name="Layer">The layer number</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <param name="FlashLayer">Optional, use only when absolutely needed</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>The main CG_Play function.</remarks>
Public Function CG_Play(ByVal Channel As Integer, ByVal Layer As Integer, ByVal Retard As Retard, ByVal Optional FlashLayer As Integer = 1) As ReturnInfo
Return Execute(String.Format("CG {0}-{1} PLAY {2}", Channel, Layer, FlashLayer), Retard)
End Function
''' <summary>
''' Updates the datafields of a template
''' </summary>
''' <param name="TemplateData">The Template object to get fields from</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel DefaultLayer</remarks>
Public Function CG_Update(ByVal TemplateData As Template) As ReturnInfo
Return CG_Update(DefaultChannel, DefaultLayer, TemplateData)
End Function
''' <summary>
''' Updates the datafields of a template
''' </summary>
''' <param name="TemplateData">The Template object to get fields from</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel DefaultLayer</remarks>
Public Function CG_Update(ByVal TemplateData As Template, ByVal Retard As Retard) As ReturnInfo
Return CG_Update(DefaultChannel, DefaultLayer, TemplateData, Retard)
End Function
''' <summary>
''' Updates the datafields of a template
''' </summary>
''' <param name="Layer">The layer number</param>
''' <param name="TemplateData">The Template object to get fields from</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel</remarks>
Public Function CG_Update(ByVal Layer As Integer, ByVal TemplateData As Template) As ReturnInfo
Return CG_Update(DefaultChannel, Layer, TemplateData)
End Function
''' <summary>
''' Updates the datafields of a template
''' </summary>
''' <param name="Layer">The layer number</param>
''' <param name="TemplateData">The Template object to get fields from</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel</remarks>
Public Function CG_Update(ByVal Layer As Integer, ByVal TemplateData As Template, ByVal Retard As Retard) As ReturnInfo
Return CG_Update(DefaultChannel, Layer, TemplateData, Retard)
End Function
''' <summary>
''' Updates the datafields of a template
''' </summary>
''' <param name="Channel">The channel in Caspar</param>
''' <param name="Layer">The layer number</param>
''' <param name="TemplateData">The Template object to get fields from</param>
''' <param name="FlashLayer">Optional, use only when absolutely needed</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>The main CG_Play function.</remarks>
Public Function CG_Update(ByVal Channel As Integer, ByVal Layer As Integer, ByVal TemplateData As Template, ByVal Optional FlashLayer As Integer = 1) As ReturnInfo
Return Execute(String.Format("CG {1}-{2} UPDATE {4} {0}{3}{0}", ChrW(&H22), Channel, Layer, TemplateData.TemplateDataText(FormatTextsForHTML), FlashLayer))
End Function
''' <summary>
''' Updates the datafields of a template
''' </summary>
''' <param name="Channel">The channel in Caspar</param>
''' <param name="Layer">The layer number</param>
''' <param name="TemplateData">The Template object to get fields from</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <param name="FlashLayer">Optional, use only when absolutely needed</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>The main CG_Play function.</remarks>
Public Function CG_Update(ByVal Channel As Integer, ByVal Layer As Integer, ByVal TemplateData As Template, ByVal Retard As Retard, ByVal Optional FlashLayer As Integer = 1) As ReturnInfo
Return Execute(String.Format("CG {1}-{2} UPDATE {4} {0}{3}{0}", ChrW(&H22), Channel, Layer, TemplateData.TemplateDataText(FormatTextsForHTML), FlashLayer), Retard)
End Function
''' <summary>
''' Updates the datafields of a template from a Dataset
''' </summary>
''' <param name="Channel">The channel in Caspar</param>
''' <param name="Layer">The layer number</param>
''' <param name="DataSetName">The name of the DataSet already stored on the server</param>
''' <param name="FlashLayer">Optional, use only when absolutely needed</param>
''' <returns>A ReturnInfo object</returns>
Public Function CG_Update(ByVal Channel As Integer, ByVal Layer As Integer, ByVal DataSetName As String, ByVal Optional FlashLayer As Integer = 1) As ReturnInfo
Return Execute(String.Format("CG {1}-{2} UPDATE {4} {0}{3}{0}", ChrW(&H22), Channel, Layer, DataSetName, FlashLayer))
End Function
''' <summary>
''' Updates the datafields of a template from a Dataset
''' </summary>
''' <param name="Channel">The channel in Caspar</param>
''' <param name="Layer">The layer number</param>
''' <param name="DataSetName">The name of the DataSet already stored on the server</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <param name="FlashLayer">Optional, use only when absolutely needed</param>
''' <returns>A ReturnInfo object</returns>
Public Function CG_Update(ByVal Channel As Integer, ByVal Layer As Integer, ByVal DataSetName As String, ByVal Retard As Retard, ByVal Optional FlashLayer As Integer = 1) As ReturnInfo
Return Execute(String.Format("CG {1}-{2} UPDATE {4} {0}{3}{0}", ChrW(&H22), Channel, Layer, DataSetName, FlashLayer), Retard)
End Function
''' <summary>
''' Stops the display of a template
''' </summary>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel DefaultLayer</remarks>
Public Function CG_Stop() As ReturnInfo
Return CG_Stop(DefaultChannel, DefaultLayer)
End Function
''' <summary>
''' Stops the display of a template
''' </summary>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel DefaultLayer</remarks>
Public Function CG_Stop(ByVal Retard As Retard) As ReturnInfo
Return CG_Stop(DefaultChannel, DefaultLayer, Retard)
End Function
''' <summary>
''' Stops the display of a template
''' </summary>
''' <param name="Layer">The layer number</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel</remarks>
Public Function CG_Stop(ByVal Layer As Integer) As ReturnInfo
Return CG_Stop(DefaultChannel, Layer, New Retard)
End Function
''' <summary>
''' Stops the display of a template
''' </summary>
''' <param name="Layer">The layer number</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel</remarks>
Public Function CG_Stop(ByVal Layer As Integer, ByVal Retard As Retard) As ReturnInfo
Return CG_Stop(DefaultChannel, Layer, Retard)
End Function
''' <summary>
''' Stops the display of a template
''' </summary>
''' <param name="Channel">The channel in Caspar</param>
''' <param name="Layer">The layer number</param>
''' <param name="FlashLayer">Optional, use only when absolutely needed</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>The main CG_Stop function.</remarks>
Public Function CG_Stop(ByVal Channel As Integer, ByVal Layer As Integer, ByVal Optional FlashLayer As Integer = 1) As ReturnInfo
Return Execute(String.Format("CG {0}-{1} STOP {2}", Channel, Layer, FlashLayer))
End Function
''' <summary>
''' Stops the display of a template
''' </summary>
''' <param name="Channel">The channel in Caspar</param>
''' <param name="Layer">The layer number</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <param name="FlashLayer">Optional, use only when absolutely needed</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>The main CG_Stop function.</remarks>
Public Function CG_Stop(ByVal Channel As Integer, ByVal Layer As Integer, ByVal Retard As Retard, ByVal Optional FlashLayer As Integer = 1) As ReturnInfo
Return Execute(String.Format("CG {0}-{1} STOP {2}", Channel, Layer, FlashLayer), Retard)
End Function
''' <summary>
''' Calls the next step inside a template
''' </summary>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel DefaultLayer</remarks>
Public Function CG_Next() As ReturnInfo
Return CG_Next(DefaultChannel, DefaultLayer, New Retard)
End Function
''' <summary>
''' Calls the next step inside a template
''' </summary>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel DefaultLayer</remarks>
Public Function CG_Next(ByVal Retard As Retard) As ReturnInfo
Return CG_Next(DefaultChannel, DefaultLayer, Retard)
End Function
''' <summary>
''' Calls the next step inside a template
''' </summary>
''' <param name="Layer">The layer number</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel</remarks>
Public Function CG_Next(ByVal Layer As Integer) As ReturnInfo
Return CG_Next(DefaultChannel, Layer)
End Function
''' <summary>
''' Calls the next step inside a template
''' </summary>
''' <param name="Layer">The layer number</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>Defaults to DefaultChannel</remarks>
Public Function CG_Next(ByVal Layer As Integer, ByVal Retard As Retard) As ReturnInfo
Return CG_Next(DefaultChannel, Layer, Retard)
End Function
''' <summary>
''' Calls the next step inside a template
''' </summary>
''' <param name="Channel">The channel in Caspar</param>
''' <param name="Layer">The layer number</param>
''' <param name="FlashLayer">Optional, use only when absolutely needed</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>The main CG_Next function.</remarks>
Public Function CG_Next(ByVal Channel As Integer, ByVal Layer As Integer, ByVal Optional FlashLayer As Integer = 1) As ReturnInfo
Return Execute(String.Format("CG {0}-{1} NEXT {2}", Channel, Layer, FlashLayer))
End Function
''' <summary>
''' Calls the next step inside a template
''' </summary>
''' <param name="Channel">The channel in Caspar</param>
''' <param name="Layer">The layer number</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <param name="FlashLayer">Optional, use only when absolutely needed</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>The main CG_Next function.</remarks>
Public Function CG_Next(ByVal Channel As Integer, ByVal Layer As Integer, ByVal Retard As Retard, ByVal Optional FlashLayer As Integer = 1) As ReturnInfo
Return Execute(String.Format("CG {0}-{1} NEXT {2}", Channel, Layer, FlashLayer), Retard)
End Function
''' <summary>
''' Invokes a parameterless procedure inside the template
''' </summary>
''' <param name="Func">The function to be executed</param>
''' <returns>A ReturnInfo object</returns>
Public Function CG_Invoke(ByVal Func As String) As ReturnInfo
Return CG_Invoke(DefaultChannel, DefaultLayer, Func)
End Function
''' <summary>
''' Invokes a parameterless procedure inside the template
''' </summary>
''' <param name="Func">The function to be executed</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <returns>A ReturnInfo object</returns>
Public Function CG_Invoke(ByVal Func As String, ByVal Retard As Retard) As ReturnInfo
Return CG_Invoke(DefaultChannel, DefaultLayer, Func, Retard)
End Function
''' <summary>
''' Invokes a parameterless procedure inside the template
''' </summary>
''' <param name="Layer">The layer number</param>
''' <param name="Func">The function to be executed</param>
''' <returns>A ReturnInfo object</returns>
Public Function CG_Invoke(ByVal Layer As Integer, ByVal Func As String) As ReturnInfo
Return CG_Invoke(DefaultChannel, Layer, Func)
End Function
''' <summary>
''' Invokes a parameterless procedure inside the template
''' </summary>
''' <param name="Layer">The layer number</param>
''' <param name="Func">The function to be executed</param>
''' <param name="Retard">Delay the execution for this amount of milliseconds</param>
''' <returns>A ReturnInfo object</returns>
Public Function CG_Invoke(ByVal Layer As Integer, ByVal Func As String, ByVal Retard As Retard) As ReturnInfo
Return CG_Invoke(DefaultChannel, Layer, Func, Retard)
End Function
''' <summary>
''' Invokes a parameterless procedure inside the template
''' </summary>
''' <param name="Channel">The channel in Caspar</param>
''' <param name="Layer">The layer number</param>
''' <param name="Func">The function to be executed</param>
''' <param name="FlashLayer">Optional, use only when absolutely needed</param>
''' <returns>A ReturnInfo object</returns>
''' <remarks>The main CG_Invoke function.</remarks>
Public Function CG_Invoke(ByVal Channel As Integer, ByVal Layer As Integer, ByVal Func As String, ByVal Optional FlashLayer As Integer = 1) As ReturnInfo
Return Execute(String.Format("CG {1}-{2} INVOKE {4} {0}{3}{0}", ChrW(&H22), Channel, Layer, Func, FlashLayer))