Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Luni-4 committed Mar 5, 2024
1 parent 317df38 commit 35d5a41
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/index.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::collections::HashMap;
use std::fmt;
use std::mem;
use std::panic;
Expand Down Expand Up @@ -235,6 +236,45 @@ impl Indexer {
}
}

pub fn create_indexer_2(
source_file: &Path,
demuxer_options: HashMap<String, String>,
) -> Result<Self> {
let source = CString::new(source_file.to_str().unwrap()).unwrap();
let number_options = demuxer_options.len();
let demuxer_options_cstring = demuxer_options
.into_iter()
.map(|(key, value)| {
(CString::new(key).unwrap(), CString::new(value).unwrap())
})
.collect::<Vec<(CString, CString)>>();

let demuxer_keys_values = demuxer_options_cstring
.iter()
.map(|(key, value)| ffms2_sys::FFMS_KeyValuePair {
Key: key.as_ptr(),
Value: value.as_ptr(),
})
.collect::<Vec<ffms2_sys::FFMS_KeyValuePair>>();

let mut error = InternalError::new();

let indexer = unsafe {
ffms2_sys::FFMS_CreateIndexer2(
source.as_ptr(),
demuxer_keys_values.as_ptr(),
number_options as i32,
error.as_mut_ptr(),
)
};

if indexer.is_null() {
Err(error.into())
} else {
Ok(Indexer { indexer })
}
}

pub fn codec_name(&self, track: usize) -> String {
let c_ptr = unsafe {
ffms2_sys::FFMS_GetCodecNameI(self.indexer, track as i32)
Expand Down

0 comments on commit 35d5a41

Please sign in to comment.