diff --git a/.gitignore b/.gitignore index ee79665..5ac245f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_STORE -coverage.out \ No newline at end of file +coverage.out +.idea \ No newline at end of file diff --git a/discard.go b/discard.go new file mode 100644 index 0000000..e5b930a --- /dev/null +++ b/discard.go @@ -0,0 +1,17 @@ +package astiav + +//#include +import "C" + +// https://ffmpeg.org/doxygen/7.0/group__lavc__decoding.html#ga352363bce7d3ed82c101b3bc001d1c16 +type Discard C.enum_AVDiscard + +const ( + DiscardNone = Discard(C.AVDISCARD_NONE) + DiscardDefault = Discard(C.AVDISCARD_DEFAULT) + DiscardNonRef = Discard(C.AVDISCARD_NONREF) + DiscardBidirectional = Discard(C.AVDISCARD_BIDIR) + DiscardNonIntra = Discard(C.AVDISCARD_NONINTRA) + DiscardNonKey = Discard(C.AVDISCARD_NONKEY) + DiscardAll = Discard(C.AVDISCARD_ALL) +) diff --git a/program.go b/program.go index 76863bf..e8ff9c4 100644 --- a/program.go +++ b/program.go @@ -55,3 +55,89 @@ func (p *Program) Streams() (ss []*Stream) { } return } + +// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a9c7a07c08a1f960aaa49f3f47633af5c +func (p *Program) Discard() Discard { + return Discard(p.c.discard) +} + +// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a9c7a07c08a1f960aaa49f3f47633af5c +func (p *Program) SetDiscard(d Discard) { + p.c.discard = int32(d) +} + +// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a7967d41af4812ed61a28762e988c7a02 +func (p *Program) StreamIndex() *uint { + if p.c.stream_index == nil { + return nil + } + u := uint(C.uint(*p.c.stream_index)) + return &u +} + +// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a7967d41af4812ed61a28762e988c7a02 +func (p *Program) SetStreamIndex(n uint) { + if p.c.stream_index != nil { + *p.c.stream_index = C.uint(n) + } +} + +// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#ae9dab38d4694e3da9cba0f882f4e43d3 +func (p *Program) Metadata() *Dictionary { + return newDictionaryFromC(p.c.metadata) +} + +// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#ae9dab38d4694e3da9cba0f882f4e43d3 +func (p *Program) SetMetadata(d *Dictionary) { + p.c.metadata = d.c +} + +// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a4c1539ea3c98da979b95a59a3ea163cb +func (p *Program) ProgramNumber() int { + return int(p.c.program_num) +} + +// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a4c1539ea3c98da979b95a59a3ea163cb +func (p *Program) SetProgramNumber(n int) { + p.c.program_num = C.int(n) +} + +// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a02011963a63c291c6dc6d4eefa56cd69 +func (p *Program) PmtPid() int { + return int(p.c.pmt_pid) +} + +// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a02011963a63c291c6dc6d4eefa56cd69 +func (p *Program) SetPmtPid(n int) { + p.c.pmt_pid = C.int(n) +} + +// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a7e026323df87e84a72ec5e5c8ce341a5 +func (p *Program) PcrPid() int { + return int(p.c.pcr_pid) +} + +// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a7e026323df87e84a72ec5e5c8ce341a5 +func (p *Program) SetPcrPid(n int) { + p.c.pcr_pid = C.int(n) +} + +// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a2276db4d51695120664d527f20b7c532 +func (p *Program) StartTime() int64 { + return int64(p.c.start_time) +} + +// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a5a7795c918153d0f64d68a838e172db4 +func (p *Program) EndTime() int64 { + return int64(p.c.end_time) +} + +// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a7e539e286876577e158039f6e7678452 +func (p *Program) PtsWrapReference() int64 { + return int64(p.c.pts_wrap_reference) +} + +// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#aa3f8af78093a910ff766ac5af381758b +func (p *Program) PtsWrapBehavior() int { + return int(p.c.pts_wrap_behavior) +} diff --git a/program_test.go b/program_test.go index 6c15724..db8ede3 100644 --- a/program_test.go +++ b/program_test.go @@ -14,11 +14,33 @@ func TestProgram(t *testing.T) { require.Equal(t, 1, p.ID()) p.SetID(2) require.Equal(t, 2, p.ID()) + p.SetDiscard(DiscardAll) + require.Equal(t, DiscardAll, p.Discard()) + d := NewDictionary() + require.NoError(t, d.Set("service_name", "test_service_name", 0)) + p.SetMetadata(d) + require.Equal(t, p.Metadata().Get("service_name", nil, 0).Value(), "test_service_name") + p.SetProgramNumber(101) + require.Equal(t, 101, p.ProgramNumber()) + p.SetPmtPid(201) + require.Equal(t, 201, p.PmtPid()) + p.SetPcrPid(301) + require.Equal(t, 301, p.PcrPid()) + require.Equal(t, p.StartTime(), NoPtsValue) + require.Equal(t, p.EndTime(), NoPtsValue) + require.Equal(t, p.PtsWrapReference(), NoPtsValue) + require.Equal(t, p.PtsWrapBehavior(), 0) s := fc.NewStream(nil) s.SetID(2) require.Equal(t, 0, p.NbStreams()) + require.Nil(t, p.StreamIndex(), nil) p.AddStream(s) require.Equal(t, 1, p.NbStreams()) + require.Equal(t, uint(0), *p.StreamIndex()) + var streamIndex uint = 1 + p.SetStreamIndex(streamIndex) + require.Equal(t, streamIndex, *p.StreamIndex()) + s.SetIndex(int(streamIndex)) ss := p.Streams() require.Equal(t, 1, len(ss)) require.Equal(t, s.ID(), ss[0].ID())