-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
203 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package mp4 | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/Eyevinn/mp4ff/av1" | ||
) | ||
|
||
func TestEncodeDecodeAvc1(t *testing.T) { | ||
adc := Av1CBox{ | ||
CodecConfRec: av1.CodecConfRec{ | ||
Version: 1, | ||
}, | ||
} | ||
|
||
boxDiffAfterEncodeAndDecode(t, &adc) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package mp4 | ||
|
||
import "testing" | ||
|
||
func TestEncodeDecodeCdat(t *testing.T) { | ||
|
||
cdat := CdatBox{ | ||
Data: []byte{0x01, 0x02, 0x03, 0x04}, | ||
} | ||
boxDiffAfterEncodeAndDecode(t, &cdat) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package mp4 | ||
|
||
import "testing" | ||
|
||
func TestEncodeDecodeMfhd(t *testing.T) { | ||
mfhd := &MfhdBox{ | ||
Version: 0, | ||
Flags: 0, | ||
SequenceNumber: 1, | ||
} | ||
boxDiffAfterEncodeAndDecode(t, mfhd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package mp4 | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestSample(t *testing.T) { | ||
s := NewSample(SyncSampleFlags, 1000, 100, -1001) | ||
fs := FullSample{ | ||
Sample: s, | ||
DecodeTime: 1000, | ||
Data: []byte{0x01, 0x02, 0x03, 0x04}, | ||
} | ||
if !s.IsSync() { | ||
t.Error("Expected sync sample") | ||
} | ||
if fs.PresentationTime() != 0 { | ||
t.Error("Expected presentation time 0") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package mp4 | ||
|
||
import ( | ||
"bytes" | ||
"testing" | ||
|
||
"github.com/Eyevinn/mp4ff/aac" | ||
) | ||
|
||
func TestStsd(t *testing.T) { | ||
stsd := StsdBox{} | ||
samplingFrequency := 48000 | ||
asc := &aac.AudioSpecificConfig{ | ||
ObjectType: 2, | ||
ChannelConfiguration: 2, | ||
SamplingFrequency: samplingFrequency, | ||
ExtensionFrequency: 0, | ||
SBRPresentFlag: false, | ||
PSPresentFlag: false, | ||
} | ||
buf := &bytes.Buffer{} | ||
err := asc.Encode(buf) | ||
if err != nil { | ||
t.Error(err) | ||
} | ||
ascBytes := buf.Bytes() | ||
esds := CreateEsdsBox(ascBytes) | ||
mp4a := CreateAudioSampleEntryBox("mp4a", | ||
uint16(asc.ChannelConfiguration), | ||
16, uint16(samplingFrequency), esds) | ||
btrt := BtrtBox{ | ||
BufferSizeDB: 1536, | ||
MaxBitrate: 96000, | ||
AvgBitrate: 96000, | ||
} | ||
mp4a.AddChild(&btrt) | ||
stsd.AddChild(mp4a) | ||
if len(stsd.Children) != 1 { | ||
t.Error("Expected one child") | ||
} | ||
if stsd.Mp4a == nil { | ||
t.Error("Expected mp4a child") | ||
} | ||
gb := stsd.GetBtrt() | ||
if gb == nil { | ||
t.Error("Expected btrt") | ||
} else { | ||
if *gb != btrt { | ||
t.Errorf("Got btrt %v, expected %v", *gb, btrt) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package mp4 | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestTrakSampleFunctions(t *testing.T) { | ||
testFile := "testdata/bbb_prog_10s.mp4" | ||
f, err := os.Open(testFile) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer f.Close() | ||
mf, err := DecodeFile(f) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
moov := mf.Moov | ||
traks := moov.Traks | ||
if len(traks) != 2 { | ||
t.Fatalf("expected 2 tracks, got %d", len(traks)) | ||
} | ||
trak := traks[0] | ||
if trak.Tkhd.TrackID != 1 { | ||
t.Fatalf("expected trackID 1, got %d", trak.Tkhd.TrackID) | ||
} | ||
first2Samples, err := trak.GetSampleData(1, 2) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if len(first2Samples) != 2 { | ||
t.Fatalf("expected 2 samples, got %d", len(first2Samples)) | ||
} | ||
ranges, err := trak.GetRangesForSampleInterval(1, 2) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if len(ranges) != 1 { | ||
t.Fatalf("expected 1 range, got %d", len(ranges)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package mp4 | ||
|
||
import "fmt" | ||
|
||
func ExampleGetVersion() { | ||
fmt.Println(GetVersion()) | ||
// Output: v0.46, date: 2024-08-08 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package sei | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestSEI5_UnregisteredType(t *testing.T) { | ||
raw := []byte{0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, | ||
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, | ||
0x40, 0x40, 0x40, 0x40} | ||
|
||
us, err := DecodeUserDataUnregisteredSEI(&SEIData{payloadType: SEIUserDataUnregisteredType, | ||
payload: raw}) | ||
if err != nil { | ||
t.Error("Error decoding SEIUserDataUnregisteredType") | ||
} | ||
if us.Type() != SEIUserDataUnregisteredType { | ||
t.Error("Expected SEIUserDataUnregisteredType") | ||
} | ||
if us.Size() != 20 { | ||
t.Errorf("Expected size 20, got %d", us.Size()) | ||
} | ||
if string(us.Payload()) != string(raw) { | ||
t.Errorf("Unexpected payload %v, expected %v", us.Payload(), raw) | ||
} | ||
wantedString := "SEI type 5, size=20, uuid=\"000102030405060708090a0b0c0d0e0f\", payload=\"@@@@\"" | ||
if wantedString != us.String() { | ||
t.Errorf("Unexpected string %q, expected %q", us.String(), wantedString) | ||
} | ||
|
||
} |