v210A flowdef
This commit is contained in:
@@ -28,6 +28,29 @@ func TestNewV210Video(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewV210AVideo(t *testing.T) {
|
||||
definition, err := NewV210AVideo(testVideoID, 1280, 720, Rational{Numerator: 50, Denominator: 1})
|
||||
if err != nil {
|
||||
t.Fatalf("NewV210AVideo: %v", err)
|
||||
}
|
||||
if definition.MediaType != MediaTypeV210A {
|
||||
t.Fatalf("media type = %q, want %q", definition.MediaType, MediaTypeV210A)
|
||||
}
|
||||
wantComponents := []VideoComponent{
|
||||
{Name: "Y", Width: 1280, Height: 720, BitDepth: 10},
|
||||
{Name: "Cb", Width: 640, Height: 720, BitDepth: 10},
|
||||
{Name: "Cr", Width: 640, Height: 720, BitDepth: 10},
|
||||
}
|
||||
if len(definition.Components) != len(wantComponents) {
|
||||
t.Fatalf("component count = %d, want %d", len(definition.Components), len(wantComponents))
|
||||
}
|
||||
for i, want := range wantComponents {
|
||||
if definition.Components[i] != want {
|
||||
t.Fatalf("component %d = %+v, want %+v", i, definition.Components[i], want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewV210VideoRejectsOddWidth(t *testing.T) {
|
||||
_, err := NewV210Video(testVideoID, 1919, 1080, Rational{Numerator: 25, Denominator: 1})
|
||||
if err == nil || !strings.Contains(err.Error(), "even") {
|
||||
@@ -35,7 +58,7 @@ func TestNewV210VideoRejectsOddWidth(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseV210Video(t *testing.T) {
|
||||
func TestParseVideo(t *testing.T) {
|
||||
want, err := NewV210Video(testVideoID, 1920, 1080, Rational{Numerator: 25, Denominator: 1})
|
||||
if err != nil {
|
||||
t.Fatalf("NewV210Video: %v", err)
|
||||
@@ -45,28 +68,58 @@ func TestParseV210Video(t *testing.T) {
|
||||
t.Fatalf("json.Marshal: %v", err)
|
||||
}
|
||||
|
||||
got, err := ParseV210Video(data)
|
||||
got, err := ParseVideo(data)
|
||||
if err != nil {
|
||||
t.Fatalf("ParseV210Video: %v", err)
|
||||
t.Fatalf("ParseVideo: %v", err)
|
||||
}
|
||||
if got.ID != want.ID || got.FrameWidth != want.FrameWidth || got.GrainRate != want.GrainRate {
|
||||
t.Fatalf("parsed definition = %+v, want %+v", got, want)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseV210VideoRejectsAudio(t *testing.T) {
|
||||
func TestParseVideoAcceptsV210A(t *testing.T) {
|
||||
want, err := NewV210AVideo(testVideoID, 1920, 1080, Rational{Numerator: 25, Denominator: 1})
|
||||
if err != nil {
|
||||
t.Fatalf("NewV210AVideo: %v", err)
|
||||
}
|
||||
data, err := json.Marshal(want)
|
||||
if err != nil {
|
||||
t.Fatalf("json.Marshal: %v", err)
|
||||
}
|
||||
|
||||
got, err := ParseVideo(data)
|
||||
if err != nil {
|
||||
t.Fatalf("ParseVideo: %v", err)
|
||||
}
|
||||
if got.MediaType != MediaTypeV210A {
|
||||
t.Fatalf("media type = %q, want %q", got.MediaType, MediaTypeV210A)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseVideoRejectsAudio(t *testing.T) {
|
||||
data := []byte(`{
|
||||
"id":"5fbec3b1-1b0f-417d-9059-8b94a47197ed",
|
||||
"format":"urn:x-nmos:format:audio",
|
||||
"media_type":"audio/float32"
|
||||
}`)
|
||||
|
||||
_, err := ParseV210Video(data)
|
||||
_, err := ParseVideo(data)
|
||||
if err == nil || !strings.Contains(err.Error(), "format must be") {
|
||||
t.Fatalf("error = %v, want video format error", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVideoRejectsUnknownMediaType(t *testing.T) {
|
||||
definition, err := NewV210Video(testVideoID, 1920, 1080, Rational{Numerator: 25, Denominator: 1})
|
||||
if err != nil {
|
||||
t.Fatalf("NewV210Video: %v", err)
|
||||
}
|
||||
definition.MediaType = "video/unknown"
|
||||
if err := definition.Validate(); err == nil || !strings.Contains(err.Error(), "media_type") {
|
||||
t.Fatalf("error = %v, want media_type error", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewFloat32Audio(t *testing.T) {
|
||||
definition, err := NewFloat32Audio(testAudioID, 2, Rational{Numerator: 48000, Denominator: 1})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user