-
Notifications
You must be signed in to change notification settings - Fork 38
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
AVBitStreamFilter #20
Comments
Awesome! Thanks for contribution! Finally got someone understands how the macro works 😄 . There are several small problems: First, you can use Second, you shouldn't need the Third, you can simply Last but not least, don't forget to implement Looking forward to your Pull Request. |
Thanks!
Ah I should have known better. I already knew that av_bsf_alloc was doing the alloc but for some reason I couldn't wrap my head around it.
Does this mean that the user doesn't know if an OOM error occured? Here it is with the fixes you've suggested. wrap_ref!(AVBitStreamFilterRef: ffi::AVBitStreamFilter);
impl AVBitStreamFilterRef {
/// Find a bitstream filter instance with it's short name.
pub fn find_by_name(name: &CStr) -> Option<AVBitStreamFilterRef> {
unsafe { ffi::av_bsf_get_by_name(name.as_ptr()) }
.upgrade()
.map(|x| unsafe { AVBitStreamFilterRef::from_raw(x) })
}
}
wrap!(AVBSFContext: ffi::AVBSFContext);
impl AVBSFContext {
/// Create a new [`AVBSFContext`] instance, allocate private data and
/// initialize defaults for the given [`AVBitStreamFilterRef`].
pub fn new(filter: &AVBitStreamFilterRef) -> Self {
let bsfc_raw = ptr::null_mut();
unsafe {
let filter_ptr = filter.as_ptr();
ffi::av_bsf_alloc(filter_ptr, bsfc_raw);
AVBSFContext::from_raw((*bsfc_raw).upgrade().unwrap())
}
}
}
impl Drop for AVBSFContext {
fn drop(&mut self) {
unsafe {
ffi::av_bsf_free(&mut self.as_mut_ptr())
}
}
} I'm gonna work a little bit more on it then I'll open a WIP pull request to fix any mistakes I might have made. |
Overall it looks good, here are some more suggestions: You can change this line: Overall it looks good. :-) |
Sorry for clicking the wrong button( |
See #23 for updates. |
I'm trying to implement AVBitStreamFilter in this library. I have a little code so far but I'm not sure if I'm working in the right direction.
AVBitStreamFilter
was easy butAVBSFContext
has a bit of a strange allocation method and I couldn't find another example like it in your code.Would you mind taking a look and letting me know if I'm doing anything wrong? This is what I have so far.
The text was updated successfully, but these errors were encountered: