/
types.go
1888 lines (1434 loc) · 57.9 KB
/
types.go
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 2022 The nagare media authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v2
import (
"encoding/json"
"errors"
"time"
"github.com/nagare-media/models.go/base"
)
const (
// TODO: update this with the new spec
SchemaURI = "urn:mpeg:mpegi:nbmp:2023"
)
const (
WorkflowDescriptionDocumentMIMEType = "application/mpeg-nbmp-wdd+json"
WorkflowDescriptionDocumentExt = "wdd"
TaskDescriptionDocumentMIMEType = "application/mpeg-nbmp-tdd+json"
TaskDescriptionDocumentExt = "tdd"
FunctionDescriptionDocumentMIMEType = "application/mpeg-nbmp-fdd+json"
FunctionDescriptionDocumentExt = "fdd"
)
type Function struct {
// +optional
Scheme *Scheme `json:"scheme,omitempty"`
General General `json:"general"`
Input Input `json:"input"`
Output Output `json:"output"`
// +optional
Processing *Processing `json:"processing,omitempty"`
// +optional
Requirement *Requirement `json:"requirement,omitempty"`
// +optional
Configuration *Configuration `json:"configuration,omitempty"`
// +optional
Step *Step `json:"step,omitempty"`
// +optional
ClientAssistant *ClientAssistant `json:"client-assistant,omitempty"`
// +optional
Assertion *Assertion `json:"assertion,omitempty"`
// +optional
Variables []Variable `json:"variables,omitempty"`
// +optional
Events []Event `json:"events,omitempty"`
// +optional
Security *Security `json:"security,omitempty"`
}
type MediaProcessingEntityCapabilities struct {
// +optional
Scheme *Scheme `json:"scheme,omitempty"`
General General `json:"general"`
// +optional
Capabilities *Capabilities `json:"capabilities,omitempty"`
// +optional
Variables []Variable `json:"variables,omitempty"`
// +optional
Events []Event `json:"events,omitempty"`
// +optional
Monitoring *Monitoring `json:"monitoring,omitempty"`
// +optional
Reporting *Reporting `json:"reporting,omitempty"`
// +optional
Notification *Notification `json:"notification,omitempty"`
}
type Workflow struct {
// +optional
Scheme *Scheme `json:"scheme,omitempty"`
General General `json:"general"`
// +optional
Repository *Repository `json:"repository,omitempty"`
Input Input `json:"input"`
Output Output `json:"output"`
Processing Processing `json:"processing"`
Requirement Requirement `json:"requirement"`
// +optional
Step *Step `json:"step,omitempty"`
// +optional
ClientAssistant *ClientAssistant `json:"client-assistant,omitempty"`
// +optional
Failover *Failover `json:"failover,omitempty"`
// +optional
Monitoring *Monitoring `json:"monitoring,omitempty"`
// +optional
Assertion *Assertion `json:"assertion,omitempty"`
// +optional
Reporting *Reporting `json:"reporting,omitempty"`
// +optional
Notification *Notification `json:"notification,omitempty"`
// +optional
Acknowledge *Acknowledge `json:"acknowledge,omitempty"`
// +optional
Security *Security `json:"security,omitempty"`
// +optional
Scale *Scale `json:"scale,omitempty"`
// +optional
Schedule *Schedule `json:"schedule,omitempty"`
}
type Task struct {
// +optional
Scheme *Scheme `json:"scheme,omitempty"`
General General `json:"general"`
Input Input `json:"input"`
Output Output `json:"output"`
Processing Processing `json:"processing"`
Requirement Requirement `json:"requirement"`
// +optional
Configuration *Configuration `json:"configuration,omitempty"`
// +optional
Step *Step `json:"step,omitempty"`
// +optional
StartupDelay *StartupDelay `json:"startup-delay,omitempty"`
// +optional
ClientAssistant *ClientAssistant `json:"client-assistant,omitempty"`
// +optional
Failover *Failover `json:"failover,omitempty"`
// +optional
Monitoring *Monitoring `json:"monitoring,omitempty"`
// +optional
Assertion *Assertion `json:"assertion,omitempty"`
// +optional
Reporting *Reporting `json:"reporting,omitempty"`
// +optional
Notification *Notification `json:"notification,omitempty"`
// +optional
Acknowledge *Acknowledge `json:"acknowledge,omitempty"`
// +optional
Security *Security `json:"security,omitempty"`
// +optional
Scale *Scale `json:"scale,omitempty"`
// +optional
Schedule *Schedule `json:"schedule,omitempty"`
}
// This descriptor provides a scheme identifier to identify the base scheme used for its descriptors.
type Scheme struct {
// identifies the scheme for this document
// It shall be a valid URI according to IETF RFC 3986.
URI base.URI `json:"uri"`
}
// This descriptor provides general details about the underlying resource.
type General struct {
// unique string in the scope of repository/workflow of the resource
ID string `json:"id"`
// name for identifying the resource
Name string `json:"name"`
// a human-readable description for the resource
Description string `json:"description"`
// rank of function/function group among functions with the same functionality
// A higher number means a higher rank.
// +optional
Rank *uint64 `json:"rank,omitempty"`
// URN must match ^urn:mpeg:mpegi:nbmp:(2([0-9]{3})):([a-zA-Z0-9_]+)$
// TODO: Annex C (informative) describes urn:mpeg:mpegi:nbmp:... as brand name to identify MPEG compatible functions.
// Can this be interpreted that non-compatible custom functions should use a different namespace thus not
// matching the pattern?
// +optional
NBMPBrand *base.URI `json:"nbmp-brand,omitempty"`
// date and time of publication of this resource
// +optional
PublishedTime *time.Time `json:"published-time,omitempty"`
// priority information for the resource
// shall not be present for function description documents
// +optional
Priority *uint64 `json:"priority,omitempty"`
// +optional
Location *string `json:"location,omitempty"`
// +optional
TaskGroup []TaskGroupItem `json:"task-group,omitempty"`
// input-ports and output-ports objects specify the endpoints where the data is communicated from NBMP sources to
// tasks; and between tasks; and from tasks to NBMP sinks.
//
// shall not be present for workflow description documents
// TODO: the JSON schema requires this field; the NBMP specification forbids this field for workflow description
// documents ("shall not"); the NBMP specification requires this parameter for general descriptors. All are
// normative.
InputPorts []Port `json:"input-ports,omitempty"`
// input-ports and output-ports objects specify the endpoints where the data is communicated from NBMP sources to
// tasks; and between tasks; and from tasks to NBMP sinks.
//
// shall not be present for workflow description documents
// TODO: the JSON schema requires this field; the NBMP specification forbids this field for workflow description
// documents ("shall not"); the NBMP specification requires this parameter for general descriptors. All are
// normative.
OutputPorts []Port `json:"output-ports,omitempty"`
// value ‘true’ indicates containing descriptor describes a function group or task workflow
// If the value is ‘true’, a connection-map object shall exist in this description.
// default is false
// this is a pointer as this field should not be present in workflow description documents
// +optional
IsGroup *bool `json:"is-group,omitempty"`
// default is false
// +optional
Nonessential bool `json:"nonessential,omitempty"`
// +optional
State *State `json:"state"`
}
type State string
var (
InstantiatedState State = "instantiated"
IdleState State = "idle"
RunningState State = "running"
InErrorState State = "in-error"
DestroyedState State = "destroyed"
)
type TaskGroupItem struct {
GroupID string `json:"group-id"`
TaskID []string `json:"task-id"`
// default is "distance"
// +optional
GroupType *GroupType `json:"group-type,omitempty"`
// default is "synchronous"
// +optional
GroupMode *GroupMode `json:"group-mode,omitempty"`
// default is false
// +optional
NetZero bool `json:"net-zero"`
}
type GroupType string
var (
DistanceGroupType GroupType = "distance"
SyncGroupType GroupType = "sync"
VirtualGroupType GroupType = "virtual"
)
type GroupMode string
var (
SynchronousGroupMode GroupMode = "synchronous"
AsynchronousGroupMode GroupMode = "asynchronous"
)
type Port struct {
// unique string among all port-names of this resource defining the logic name for input or output
PortName string `json:"port-name"`
// The bind object specifies how to associate a port name to a stream, either input or output. For NBMP functions,
// they provide static information about the port names and their binding data formats and protocols. For NBMP tasks,
// they provide information about the needs for connections between ports and input and output streams by NBMP
// workflow manager.
// TODO: optional due to changes discussed in ISO/IEC JTC 1/SC 29/WG 03 N0951
// +optional
Bind *PortBinding `json:"bind,omitempty"`
}
type PortBinding struct {
StreamID string `json:"stream-id"`
// TODO: optional due to changes discussed in ISO/IEC JTC 1/SC 29/WG 03 N0951
// +optional
Name *string `json:"name,omitempty"`
// +optional
Keywords []string `json:"keywords,omitempty"`
}
// This descriptor provides the parameters of the underlying resource’s inputs. The input descriptor consists of two
// arrays of objects: one for the media inputs and one for metadata inputs.
type Input struct {
// +optional
MediaParameters []MediaParameter `json:"media-parameters,omitempty"`
// +optional
MetadataParameters []MetadataParameter `json:"metadata-parameters,omitempty"`
}
// This descriptor provides the parameters of the underlying resource’s outputs. The output descriptor consists of two
// arrays of objects: one for the media outputs and one for metadata outputs.
type Output struct {
// +optional
MediaParameters []MediaParameter `json:"media-parameters,omitempty"`
// +optional
MetadataParameters []MetadataParameter `json:"metadata-parameters,omitempty"`
}
type MediaParameter struct {
// unique identifier, with the scope of function or task or workflow, to identify the media or metadata stream
//
// For functions, it is defined in the function descriptor. For tasks, it is assigned by the workflow manager. For
// workflows, it is assigned by the NBMP source.
//
// TODO: the JSON schema requires this field; the NBMP specification forbids this field for function description
// documents ("shall not"); the NBMP specification requires this parameter for Input/Output descriptors. All are
// normative.
//
// shall not be present for function description documents
StreamID string `json:"stream-id"`
// string name assigned to this input
//
// For functions, it is defined in the function descriptor. For tasks, it is assigned by the workflow manager. For
// workflows, it is assigned by the NBMP source.
Name string `json:"name"`
// list of keywords describing this input properties
//
// The keyword should be human-readable.
Keywords []string `json:"keywords"`
// MIME media type of media or metadata in IANA registry
MimeType string `json:"mime-type"`
// format of video
//
// The parameter list is defined using generic parameter representation of subclause 9.22.1.
// +optional
VideoFormat []Parameter `json:"video-format,omitempty"`
// format of audio
//
// The parameter list is defined using generic parameter representation of subclause 9.22.1.
// +optional
AudioFormat []Parameter `json:"audio-format,omitempty"`
// format of image
//
// The parameter list is defined using generic parameter representation of subclause 9.22.1.
// +optional
ImageFormat []Parameter `json:"image-format,omitempty"`
// 'codecs' and 'profiles' parameters, as defined in IETF RFC 6381
// +optional
CodecType *string `json:"codec-type,omitempty"`
// protocol for delivery of or access to media including protocol parameters such as port number(s)
//
// Ingest protocol for timed metadata including protocol parameters such as the port number(s). Example: HTTP. When
// the workflow manager receives this information, it takes the responsibility of returning back with the protocol
// endpoint information of the appropriate media processing entity to the media source so the media source can ingest
// metadata using that protocol.
//
// NOTE This is only applicable for media and timed metadata.
Protocol string `json:"protocol"`
// default is "push"
// +optional
Mode *MediaAccessMode `json:"mode,omitempty"`
// maximum accepted throughput by this resource
// +optional
Throughput *uint64 `json:"throughput,omitempty"`
// minimum input buffer size
// +optional
Buffersize *uint64 `json:"buffersize,omitempty"`
// +optional
AvailabilityDuration *uint64 `json:"availability-duration,omitempty"`
// must be >= 1
// +optional
Timeout *uint64 `json:"timeout,omitempty"`
// URL (according to IETF RFC 3986) of the server where the media will be sent to/from or the location to/from where
// the media can be fetched to/from
//
// NOTE When this parameter is missing for a workflow, the workflow manager can assign origination/destination
// information of the appropriate media processing entity to the media source so the media source/sink can ingest
// media using that protocol.
CachingServerURL base.URI `json:"caching-server-url"`
// must not be set for Outputs
// +optional
CompletionTimeout *uint64 `json:"completion-timeout,omitempty"`
}
type MetadataParameter struct {
// unique identifier, with the scope of function or task or workflow, to identify the media or metadata stream
//
// For functions, it is defined in the function descriptor. For tasks, it is assigned by the workflow manager. For
// workflows, it is assigned by the NBMP source.
//
// TODO: the JSON schema requires this field; the NBMP specification forbids this field for function description
// documents ("shall not"); the NBMP specification requires this parameter for Input/Output descriptors. All are
// normative.
//
// shall not be present for function description documents
StreamID string `json:"stream-id"`
// string name assigned to this input
//
// For functions, it is defined in the function descriptor. For tasks, it is assigned by the workflow manager. For
// workflows, it is assigned by the NBMP source.
Name string `json:"name"`
// list of keywords describing this input properties
//
// The keyword should be human-readable.
Keywords []string `json:"keywords"`
// MIME media type of media or metadata in IANA registry
MimeType string `json:"mime-type"`
// 'codecs' and 'profiles' parameters, as defined in IETF RFC 6381
// +optional
CodecType *string `json:"codec-type,omitempty"`
// protocol for delivery of or access to media including protocol parameters such as port number(s)
//
// Ingest protocol for timed metadata including protocol parameters such as the port number(s). Example: HTTP. When
// the workflow manager receives this information, it takes the responsibility of returning back with the protocol
// endpoint information of the appropriate media processing entity to the media source so the media source can ingest
// metadata using that protocol.
//
// NOTE This is only applicable for media and timed metadata.
Protocol string `json:"protocol"`
// default is "push"
// +optional
Mode *MediaAccessMode `json:"mode,omitempty"`
// maximum size of metadata in each fetch or push accepted by this input
// +optional
MaxSize *uint64 `json:"max-size,omitempty"`
// minimum interval between two fetch or push accepted by this input
// +optional
MinInterval *uint64 `json:"min-interval,omitempty"`
// +optional
AvailabilityDuration *uint64 `json:"availability-duration,omitempty"`
// must be >= 1
// +optional
Timeout *uint64 `json:"timeout,omitempty"`
// URL (according to IETF RFC 3986) of the server where the media will be sent from or the location from where the
// media can be fetched from
//
// NOTE When this parameter is missing for a workflow, the workflow manager can assign origination information of the
// appropriate media processing entity to the media source so the media source can ingest media using that protocol.
// +optional
CachingServerURL *base.URI `json:"caching-server-url,omitempty"`
// URL (according to IETF RFC 3986) or scheme identifier of metadata
//
// The schema-uri refers to a metadata-dictionary object that consists of a set of parameter-value pairs. The
// parameters’ names, data types and value ranges are defined by the metadata scheme owner.
//
// +optional
SchemeURI *base.URI `json:"scheme-uri,omitempty"`
// must not be set for Outputs
// +optional
CompletionTimeout *uint64 `json:"completion-timeout,omitempty"`
}
type MediaAccessMode string
var (
PushMediaAccessMode MediaAccessMode = "push"
PullMediaAccessMode MediaAccessMode = "pull"
)
// This descriptor provides high-level details about the requested media processing of a workflow by listing the set of
// tasks to be performed on the input media data.
type Processing struct {
// list of keywords that can be used to execute a search in the function repository
// TODO: the JSON schema requires this field; the NBMP specification forbids this field for task description
// documents ("shall not"); the NBMP specification requires this parameter for processing descriptors. All are
// normative.
Keywords []string `json:"keywords"`
Image []ProcessingImage `json:"image"`
// resource’s start time
// shall not be present for function description documents
// +optional
StartTime *time.Time `json:"start-time,omitempty"`
// The array of connection-map object provides a description of the media workflow DAG, i.e. the connection
// information between different tasks in the graph. Each element in this array represents an edge in the DAG.
//
// shall not be present for task description documents
//
// +optional
ConnectionMap []ConnectionMapping `json:"connection-map,omitempty"`
// shall not be present for task description documents
// +optional
FunctionRestrictions []FunctionRestriction `json:"function-restrictions,omitempty"`
}
type ProcessingImage struct {
// flag indicating whether the image is static or dynamic
//
// A value of ‘true’ indicates the image is built dynamically.
// default is false
// +optional
IsDynamic bool `json:"is-dynamic"`
// pointer to the resource implementation, according to IETF RFC 3986
// TODO: the JSON schema requires this field; the NBMP specification forbids this field for workflow description
// documents ("shall not"); the NBMP specification requires this parameter for processing descriptors. All are
// normative.
URL base.URI `json:"url"`
// +optional
StaticImageInfo *StaticImageInfo `json:"static-image-info,omitempty"`
// +optional
DynamicImageInfo *DynamicImageInfo `json:"dynamic-image-info,omitempty"`
}
type StaticImageInfo struct {
// operation system
OS string `json:"os"`
// version number of operation system
Version string `json:"version"`
// hardware architecture
Architecture string `json:"architecture"`
// environment
Environment string `json:"environment"`
// URL (according to IETF RFC 3986) defining the patching scheme for this image
// +optional
PatchURL *string `json:"patch-url,omitempty"`
// +optional
PatchScript map[string]interface{} `json:"patch-script,omitempty"`
}
type DynamicImageInfo struct {
// URL (according to IETF RFC 3986) defining information object scheme or information needed for dynamic build
Scheme base.URI `json:"scheme"`
Information map[string]interface{} `json:"information"`
}
type ConnectionMapping struct {
ConnectionID string `json:"connection-id"`
From ConnectionMappingPort `json:"from"`
To ConnectionMappingPort `json:"to"`
// +optional
Flowcontrol *FlowcontrolRequirement `json:"flowcontrol,omitempty"`
// specifies the deployment of the 2 connected tasks
//
// When the value is True, the 2 tasks shall be deployed into the same MPE, Otherwise, the deployment is determined by
// the workflow manager based on available resources.
// default is false
// +optional
CoLocated bool `json:"co-located"`
// default is true (TODO)
// +optional
Breakable *bool `json:"breakable,omitempty"`
// +optional
OtherParameters []Parameter `json:"other-parameters,omitempty"`
}
type ConnectionMappingPort struct {
// specifies function’s id
ID string `json:"id"`
// specifies identifier for one instance of a function
//
// An instance of a function shall have unique restrictions in a function group. This identifier shall be unique for
// each instance in the same function group.
//
// NOTE If a function is used more than once in one function group with identical restrictions, these restrictions can
// be defined by one instance of that function.
Instance string `json:"instance"`
// specifies function’s logic port name
PortName string `json:"port-name"`
// restrictions to the input descriptor parameters
// This object shall not be present in “from” objects.
// +optional
InputRestrictions *Input `json:"input-restrictions,omitempty"`
// restrictions to the output descriptor parameters
// This object shall not be present in “to” objects.
// +optional
OutputRestrictions *Output `json:"output-restrictions,omitempty"`
}
type FunctionRestriction struct {
Instance string `json:"instance"`
// +optional
General *General `json:"general,omitempty"`
// +optional
Processing *Processing `json:"processing,omitempty"`
// +optional
Requirements *Requirement `json:"requirements,omitempty"`
// +optional
Configuration *Configuration `json:"configuration,omitempty"`
// +optional
ClientAssistant *ClientAssistant `json:"client-assistant,omitempty"`
// +optional
Failover *Failover `json:"failover,omitempty"`
// +optional
Monitoring *Monitoring `json:"monitoring,omitempty"`
// +optional
Reporting *Reporting `json:"reporting,omitempty"`
// +optional
Notification *Notification `json:"notification,omitempty"`
// +optional
Step *Step `json:"step,omitempty"`
// +optional
Security *Security `json:"security,omitempty"`
// +optional
Blacklist []Blacklist `json:"blacklist,omitempty"`
}
type Blacklist string
var (
RequirementBlacklist Blacklist = "requirement"
ClientAssistantBlacklist Blacklist = "client-assistant"
FailOverBlacklist Blacklist = "fail-over"
MonitoringBlacklist Blacklist = "monitoring"
ReportingBlacklist Blacklist = "reporting"
NotificationBlacklist Blacklist = "notification"
SecurityBlacklist Blacklist = "security"
)
// This descriptor provides requirements parameters that can be configured for the underlying resource.
type Requirement struct {
// +optional
Flowcontrol *FlowcontrolRequirement `json:"flowcontrol,omitempty"`
// +optional
Hardware *HardwareRequirement `json:"hardware,omitempty"`
// +optional
Security *SecurityRequirement `json:"security,omitempty"`
// +optional
WorkflowTask *WorkflowTaskRequirement `json:"workflow-task,omitempty"`
// +optional
ResourceEstimators *ResourceEstimatorsRequirement `json:"resource-estimators,omitempty"`
}
type FlowcontrolRequirement struct {
// typical expected delay for the resource (in millisecond)
// For workflows this specifies the end-to-end delay requirements for the workflow.
// For tasks this specifies the delay requirements for the task.
// +optional
TypicalDelay *uint64 `json:"typical-delay,omitempty"`
// minimum delay (i.e. amount time from input to output sample) adequate for this resource (in millisecond)
// +optional
MinDelay *uint64 `json:"min-delay,omitempty"`
// maximum delay required for this resource (in millisecond)
// +optional
MaxDelay *uint64 `json:"max-delay,omitempty"`
// minimum bandwidth required for this resource (in bits/second)
// +optional
MinThroughput *uint64 `json:"min-throughput,omitempty"`
// maximum bandwidth adequate for this resource (in bits/second)
// +optional
MaxThroughput *uint64 `json:"max-throughput,omitempty"`
// averaging window used to calculate the throughput (in millisecond)
// The default is one second.
// +optional
AveragingWindow *uint64 `json:"averaging-window,omitempty"`
}
type HardwareRequirement struct {
// number of vcpus to be reserved for the execution of a task
// +optional
VCPU *uint64 `json:"vcpu,omitempty"`
// number of vgpus to be reserved for the execution of a task
// +optional
VGPU *uint64 `json:"vgpu,omitempty"`
// memory to be reserved for the execution of a task (in megabytes)
// +optional
RAM *uint64 `json:"ram,omitempty"`
// size of local disk to be used by a workflow or a task (in gigabytes)
// +optional
Disk *uint64 `json:"disk,omitempty"`
// identifier of the geographical location of the data center in which the task is to be executed
//
// The location is represented by a two-letter (alpha2) country code (ISO 3166-1) optionally followed by ‘-‘ and the
// postal code conforming to the country’s postal code standard.
// +optional
Placement *HardwareRequirementPlacement `json:"placement,omitempty"`
}
type HardwareRequirementPlacement string // pattern (^[A-Z]{2}$)|(^[A-Z]{2}-.*)
type SecurityRequirement struct {
// indicates if TLS or DTLS shall be used for the transport of media data
// default is false
// +optional
TLS bool `json:"tls"`
// indicates if IPSec tunnel model shall be used for the transport of media data
// default is false
// +optional
IPsec bool `json:"ipsec"`
// indicates if MPEG common encryption (ISO/IEC 23001-7) shall be used for the exchange of media data
// default is false
// +optional
CENC bool `json:"cenc"`
}
type WorkflowTaskRequirement struct {
// whether functions can be fused or split by the NBMP workflow manager
//
// When fused or enhanced, some system tasks may be added or dropped automatically and dynamically.
// default is false
// +optional
FunctionFusible bool `json:"function-fusible"`
// whether the inputs and outputs of a task can be modified or enhanced with system-provided built-in functions such
// as media transcoding, media transport buffering for synchronization, or transporting media/metadata data between
// tasks/MPEs over networks
// default is false
// +optional
FunctionEnhancable bool `json:"function-enhancable"`
// defines workflow execution modes
// default is "streaming"
// +optional
ExecutionMode *ExecutionMode `json:"execution-mode,omitempty"`
// +optional
Proximity []TaskProximityRequirement `json:"proximity,omitempty"`
// +optional
ProximityEquation *TaskProximityEquation `json:"proximity-equation,omitempty"`
// +optional
SplitEfficiency *TaskSplitEfficiency `json:"split-efficiency,omitempty"`
}
type ExecutionMode string
var (
StreamingExecutionMode ExecutionMode = "streaming"
StepExecutionMode ExecutionMode = "step"
HybridExecutionMode ExecutionMode = "hybrid"
)
type TaskProximityRequirement struct {
OtherTaskID string `json:"other-task-id"`
// must be >= -1
Distance int64 `json:"distance"`
}
type TaskProximityEquation struct {
DistanceParameters []Variable `json:"distance-parameters"`
DistanceEquation string `json:"distance-equation"`
}
type TaskSplitEfficiency struct {
// default is "pnorm"
// +optional
SplitNorm *TaskSplitEfficiencyNorm `json:"split-norm,omitempty"`
// default is "2"
// +optional
SplitEquation *string `json:"split-equation,omitempty"`
// +optional
SplitResult *uint64 `json:"split-result,omitempty"`
}
type TaskSplitEfficiencyNorm string
var (
PnormTaskSplitEfficiencyNorm TaskSplitEfficiencyNorm = "pnorm"
CustomTaskSplitEfficiencyNorm TaskSplitEfficiencyNorm = "custom"
)
type ResourceEstimatorsRequirement struct {
DefaultValues []DefaultValue `json:"default-values"`
// +optional
ComputationalEstimator *string `json:"computational-estimator,omitempty"`
// +optional
MemoryEstimator *string `json:"memory-estimator,omitempty"`
// +optional
BandwidthEstimator *string `json:"bandwidth-estimator,omitempty"`
}
type DefaultValue struct {
// name of the input, output or configuration parameter
Name string `json:"name"`
// default value of the input, output or configuration parameter
Value string `json:"value"`
}
// This descriptor provides configuration information for the underlying resource.
type Configuration struct {
Parameters []Parameter `json:"parameters"`
}
type Parameter struct {
Name string `json:"name"`
ID int64 `json:"id"`
// TODO: spelling
// +optional
Description *string `json:"discription,omitempty"`
Datatype Datatype `json:"datatype"`
// List of ids that shall exist for this parameter to become valid
// +optional
Conditions []int64 `json:"conditions,omitempty"`
// List of configuration ids that shall not exist for this parameter to become valid
// +optional
Exclusions []int64 `json:"exclusions,omitempty"`
// must be set for non-array datatypes
// must be nil for array datatype
// +optional
Values []ParameterValue `json:"values,omitempty"`
// must be nil for non-array datatypes
// must be set for array datatype
// TODO: this is an array in the JSON schema, but must (likely) be an JSON schema object.
// +optional
Schema map[string]interface{} `json:"schema,omitempty"`
}
func (p *Parameter) UnmarshalJSON(data []byte) error {
type PartialParameter struct {
Name string `json:"name"`
ID int64 `json:"id"`
Description *string `json:"discription,omitempty"` // TODO: spelling
Datatype Datatype `json:"datatype"`
Conditions []int64 `json:"conditions,omitempty"`
Exclusions []int64 `json:"exclusions,omitempty"`
Values []json.RawMessage `json:"values,omitempty"`
Schema map[string]interface{} `json:"schema,omitempty"`
}
pp := PartialParameter{}
err := json.Unmarshal(data, &pp)
if err != nil {
return err
}
p.Name = pp.Name
p.ID = pp.ID
p.Description = pp.Description
p.Datatype = pp.Datatype
p.Conditions = pp.Conditions
p.Exclusions = pp.Exclusions
p.Schema = pp.Schema
p.Values = make([]ParameterValue, len(pp.Values))
for i, rawVal := range pp.Values {
var val ParameterValue
switch p.Datatype {
case BooleanDatatype:
val = &BooleanParameterValue{}
case IntegerDatatype:
val = &IntegerParameterValue{}
case NumberDatatype:
val = &NumberParameterValue{}
case StringDatatype:
val = &StringParameterValue{}
case ArrayDatatype:
return errors.New("Parameter.UnmarshalJSON: specifying values is invalid for array datatype")
default:
return errors.New("Parameter.UnmarshalJSON: values datatype unspecified or unknown")
}