v210A flowdef
This commit is contained in:
@@ -12,6 +12,7 @@ const (
|
||||
FormatVideo = "urn:x-nmos:format:video"
|
||||
FormatAudio = "urn:x-nmos:format:audio"
|
||||
MediaTypeV210 = "video/v210"
|
||||
MediaTypeV210A = "video/v210a"
|
||||
MediaTypeFloat32 = "audio/float32"
|
||||
|
||||
InterlaceProgressive = "progressive"
|
||||
@@ -75,7 +76,12 @@ type VideoComponent struct {
|
||||
BitDepth uint `json:"bit_depth"`
|
||||
}
|
||||
|
||||
func NewV210Video(id string, width, height uint, rate Rational) (Video, error) {
|
||||
func newVideo(
|
||||
id string,
|
||||
width, height uint,
|
||||
rate Rational,
|
||||
mediaType string,
|
||||
) (Video, error) {
|
||||
definition := Video{
|
||||
Common: Common{
|
||||
Description: "go-mxl-pattern-gen generated video",
|
||||
@@ -86,7 +92,7 @@ func NewV210Video(id string, width, height uint, rate Rational) (Video, error) {
|
||||
Format: FormatVideo,
|
||||
Label: "go-mxl-pattern-gen generated video",
|
||||
Parents: []string{},
|
||||
MediaType: MediaTypeV210,
|
||||
MediaType: mediaType,
|
||||
},
|
||||
GrainRate: rate,
|
||||
FrameWidth: width,
|
||||
@@ -105,7 +111,15 @@ func NewV210Video(id string, width, height uint, rate Rational) (Video, error) {
|
||||
return definition, nil
|
||||
}
|
||||
|
||||
func ParseV210Video(data []byte) (Video, error) {
|
||||
func NewV210Video(id string, width, height uint, rate Rational) (Video, error) {
|
||||
return newVideo(id, width, height, rate, MediaTypeV210)
|
||||
}
|
||||
|
||||
func NewV210AVideo(id string, width, height uint, rate Rational) (Video, error) {
|
||||
return newVideo(id, width, height, rate, MediaTypeV210A)
|
||||
}
|
||||
|
||||
func ParseVideo(data []byte) (Video, error) {
|
||||
var definition Video
|
||||
if err := json.Unmarshal(data, &definition); err != nil {
|
||||
return Video{}, fmt.Errorf("decode video flow definition: %w", err)
|
||||
@@ -123,8 +137,10 @@ func (v Video) Validate() error {
|
||||
if v.Format != FormatVideo {
|
||||
return fmt.Errorf("format must be %q, got %q", FormatVideo, v.Format)
|
||||
}
|
||||
if v.MediaType != MediaTypeV210 {
|
||||
return fmt.Errorf("media_type must be %q, got %q", MediaTypeV210, v.MediaType)
|
||||
switch v.MediaType {
|
||||
case MediaTypeV210, MediaTypeV210A:
|
||||
default:
|
||||
return fmt.Errorf("media_type must be %q or %q, got %q", MediaTypeV210, MediaTypeV210A, v.MediaType)
|
||||
}
|
||||
if v.InterlaceMode != InterlaceProgressive {
|
||||
return fmt.Errorf("interlace_mode must be %q, got %q", InterlaceProgressive, v.InterlaceMode)
|
||||
|
||||
Reference in New Issue
Block a user