Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extradata methods also to cc #59

Closed
wants to merge 6 commits into from

Conversation

Cacsjep
Copy link
Contributor

@Cacsjep Cacsjep commented Apr 1, 2024

No description provided.

Copy link
Owner

@asticode asticode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather create an extra_data.go file (no test file needed) with

func getExtraData(d *C.uint8_t, size C.size_t) []byte {
  // Content of current CodecParameters.ExtraData()
}
func setExtraData(b []byte, d **C.uint8_t, size *C.size_t) error {
  // Content of current CodecParameters.SetExtraData()
} 

and use these 2 new functions in both CodecContext and CodecParameters 🤔

codec_context_test.go Show resolved Hide resolved
@Cacsjep
Copy link
Contributor Author

Cacsjep commented Apr 2, 2024

I'd rather create an extra_data.go file (no test file needed) with

they share many similar fields like framerate, pixfmt etc.., then u have extra file just for these two things i dont know whats better.

@asticode
Copy link
Owner

asticode commented Apr 2, 2024

they share many similar fields like framerate, pixfmt etc.., then u have extra file just for these two things i dont know whats better.

I think creating global unexported functions that take pointers to C fields like I suggest would be best:

func getExtraData(d *C.uint8_t, size C.size_t) []byte {
  // Content of current CodecParameters.ExtraData()
}
func setExtraData(b []byte, d **C.uint8_t, size *C.size_t) error {
  // Content of current CodecParameters.SetExtraData()
} 

No need to create structs or anything else, just helper functions that unify the logic to retrieve and set the extradata. We may use them for other structs in the future.

For instance the content of getExtraData would be:

	return bytesFromC(func(size *C.size_t) *C.uint8_t {
		*size = C.size_t(size)
		return d
	})

@asticode
Copy link
Owner

@Cacsjep do you feel like implementing the requested changes? If not, that's ok, I'll have some time to implement them in the coming days 👍

@Cacsjep
Copy link
Contributor Author

Cacsjep commented Apr 12, 2024

@Cacsjep do you feel like implementing the requested changes? If not, that's ok, I'll have some time to implement them in the coming days 👍

Oh, I'm sorry, I completely forgot, I don't have time at the moment. It would be cool if you make it, if not I can do it next month or so =)

@asticode
Copy link
Owner

No worries, fyi I've merged in master the extra data methods to CodecContext 👍

@asticode asticode closed this Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants