Skip to content

Commit

Permalink
Add setters for profile and level to cc and cp
Browse files Browse the repository at this point in the history
  • Loading branch information
Cacsjep committed Mar 31, 2024
1 parent d119d15 commit 5db1573
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions codec_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ func (cc *CodecContext) Level() Level {
return Level(cc.c.level)
}

func (cc *CodecContext) SetLevel(l Level) {
cc.c.level = C.int(l)
}

func (cc *CodecContext) MediaType() MediaType {
return MediaType(cc.c.codec_type)
}
Expand All @@ -192,6 +196,10 @@ func (cc *CodecContext) Profile() Profile {
return Profile(cc.c.profile)
}

func (cc *CodecContext) SetProfile(p Profile) {
cc.c.profile = C.int(p)
}

func (cc *CodecContext) Qmin() int {
return int(cc.c.qmin)
}
Expand Down
4 changes: 4 additions & 0 deletions codec_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ func TestCodecContext(t *testing.T) {
cc4.SetFramerate(NewRational(6, 1))
cc4.SetGopSize(7)
cc4.SetHeight(8)
cc4.SetLevel(16)
cc4.SetProfile(ProfileH264Extended)
cc4.SetPixelFormat(PixelFormat0Bgr)
cc4.SetQmin(5)
cc4.SetSampleAspectRatio(NewRational(10, 1))
Expand All @@ -106,6 +108,8 @@ func TestCodecContext(t *testing.T) {
require.Equal(t, NewRational(6, 1), cc4.Framerate())
require.Equal(t, 7, cc4.GopSize())
require.Equal(t, 8, cc4.Height())
require.Equal(t, Level(16), cc4.Level())
require.Equal(t, ProfileH264Extended, cc4.Profile())
require.Equal(t, PixelFormat0Bgr, cc4.PixelFormat())
require.Equal(t, 5, cc4.Qmin())
require.Equal(t, NewRational(10, 1), cc4.SampleAspectRatio())
Expand Down
8 changes: 8 additions & 0 deletions codec_parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ func (cp *CodecParameters) Level() Level {
return Level(cp.c.level)
}

func (cp *CodecParameters) SetLevel(l Level) {
cp.c.level = C.int(l)
}

func (cp *CodecParameters) MediaType() MediaType {
return MediaType(cp.c.codec_type)
}
Expand All @@ -137,6 +141,10 @@ func (cp *CodecParameters) Profile() Profile {
return Profile(cp.c.profile)
}

func (cp *CodecParameters) SetProfile(p Profile) {
cp.c.profile = C.int(p)
}

func (cp *CodecParameters) SampleAspectRatio() Rational {
return newRationalFromC(cp.c.sample_aspect_ratio)
}
Expand Down
4 changes: 4 additions & 0 deletions codec_parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,12 @@ func TestCodecParameters(t *testing.T) {
require.Equal(t, 1, cp6.FrameSize())
cp6.SetHeight(1)
require.Equal(t, 1, cp6.Height())
cp1.SetLevel(16)
require.Equal(t, Level(16), cp1.Level())
cp6.SetMediaType(MediaTypeAudio)
require.Equal(t, MediaTypeAudio, cp6.MediaType())
cp1.SetProfile(ProfileH264Extended)
require.Equal(t, ProfileH264Extended, cp1.Profile())
cp6.SetPixelFormat(PixelFormat0Bgr)
require.Equal(t, PixelFormat0Bgr, cp6.PixelFormat())
cp6.SetSampleAspectRatio(NewRational(1, 2))
Expand Down

0 comments on commit 5db1573

Please sign in to comment.