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

implemented VideoSequenceParser inspired by SDK_Segment_Utils.VideoSequencerParser from original SDK #67

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
6 changes: 6 additions & 0 deletions premiere/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(clippy::all)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

What does this silence? Instead of this, can we fix the clippy lints, or at least silence only specific ones?

#![doc = include_str!(concat!("../", std::env!("CARGO_PKG_README")))]

use premiere_sys as pr_sys;
Expand Down Expand Up @@ -40,6 +41,11 @@ pub mod suites {
pub use crate::pf_suites::transition ::TransitionSuite as Transition;
pub use crate::pf_suites::utility ::UtilitySuite as Utility;
}

pub mod utils {
pub mod video_sequence_parser; pub use video_sequence_parser::VideoSequenceParser;
}

pub use suites::string::PrString;
pub use suites::video_segment_properties::*;
pub use suites::video_segment::VideoSegmentProperties;
Expand Down
79 changes: 79 additions & 0 deletions premiere/src/utils/video_sequence_parser.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
use crate::*;
use pr_sys::*;
use std::collections::HashMap;

#[derive(Debug, Clone)]
pub struct ClipOperator {
pub node_id: i32,
pub node_type: String,
pub hash: prPluginID,
pub flags: i32,
}

pub type ClipOperatorsMap = HashMap<i32, ClipOperator>;

pub struct VideoSequenceParser {
segment_suite: suites::VideoSegment,
}

impl VideoSequenceParser {
pub fn new() -> Result<Self, Error> {
Ok(Self {
segment_suite: suites::VideoSegment::new()?,
})
}

pub fn parse_clip_operators(&self, clip_node_id: i32) -> Result<ClipOperatorsMap, Error> {
let clip_node_operators = self.segment_suite.node_operator_count(clip_node_id)?;
let mut operators_map: ClipOperatorsMap = HashMap::new();

for operator_node_index in 0..clip_node_operators {
let operator_node_id = self
.segment_suite
.acquire_operator_node_id(clip_node_id, operator_node_index)?;

let (operator_node_type, operator_node_hash, operator_node_flags) =
self.segment_suite.node_info(operator_node_id)?;

log::debug!(
"Clip Operator: {:?} {:?} {:?}",
operator_node_type,
operator_node_hash,
operator_node_flags
);
Comment on lines +38 to +43
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of all these log::debug! calls, I think the parse_clip_operators should return a structute which has all these fields you print here, but the struct impls the Debug trait,. The end-user should just dbg!(parse_clip_operators(...) if they desire, or use the values in other way

Copy link
Owner

Choose a reason for hiding this comment

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

Or return a tuple of the current Ok and namely struct, i.e. Result<(ClipOperatorsMap, ParseClipOperatorStatus), Error>


if operator_node_type
== String::from_utf8_lossy(kVideoSegment_NodeType_Effect).to_string()
{
let effect_name = self
.segment_suite
.node_property(operator_node_id, Property::Effect_FilterMatchName)
.unwrap_or_else(|_| PropertyData::String("<Unknown Effect>".to_string()));
log::debug!("\tEffect: {:?}", effect_name);

let effect_instance_id = self
.segment_suite
.node_property(operator_node_id, Property::Effect_RuntimeInstanceID);
log::debug!("\tEffect Instance ID: {:?}", effect_instance_id);

let filter_params = self
.segment_suite
.node_property(operator_node_id, Property::Effect_FilterParams);
log::debug!("\tEffect Params: {filter_params:?}");
}

operators_map.insert(
operator_node_id,
ClipOperator {
node_id: operator_node_id,
node_type: operator_node_type,
hash: operator_node_hash,
flags: operator_node_flags,
},
);
self.segment_suite.release_video_node_id(operator_node_id)?;
}

Ok(operators_map)
}
}