Skip to content

Commit 62ad31b

Browse files
committed
EBML: Stub MergeTag impl
1 parent fd28684 commit 62ad31b

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

lofty/src/ebml/tag/generic.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,13 @@ matroska_mapping_tables!(
136136
const TAG_RETAINED: bool = true;
137137
const TAG_CONSUMED: bool = false;
138138

139-
pub(super) fn split_tag(mut ebml_tag: MatroskaTag) -> (MatroskaTag, Tag) {
139+
pub(super) fn split_tag(mut matroska_tag: MatroskaTag) -> (MatroskaTag, Tag) {
140140
let mut tag = Tag::new(TagType::Matroska);
141141

142142
// TODO: Pictures, can they be handled in a generic way?
143143
// What about the uid and referral?
144144

145-
ebml_tag.tags.retain_mut(|t| {
145+
matroska_tag.tags.retain_mut(|t| {
146146
let target_type = match &t.target {
147147
Some(t) if !t.has_uids() => t.target_type,
148148
// We cannot use any tags bound to uids
@@ -159,7 +159,7 @@ pub(super) fn split_tag(mut ebml_tag: MatroskaTag) -> (MatroskaTag, Tag) {
159159
return TAG_RETAINED;
160160
});
161161

162-
(ebml_tag, tag)
162+
(matroska_tag, tag)
163163
}
164164

165165
fn split_simple_tags(
@@ -196,3 +196,7 @@ fn split_simple_tags(
196196

197197
return TAG_CONSUMED;
198198
}
199+
200+
pub(super) fn merge_tag(tag: Tag, matroska_tag: MatroskaTag) -> MatroskaTag {
201+
todo!()
202+
}

lofty/src/ebml/tag/mod.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,8 @@ impl SplitTag for MatroskaTag {
367367
impl MergeTag for SplitTagRemainder {
368368
type Merged = MatroskaTag;
369369

370-
fn merge_tag(self, _tag: crate::tag::Tag) -> Self::Merged {
371-
todo!()
370+
fn merge_tag(self, tag: crate::tag::Tag) -> Self::Merged {
371+
generic::merge_tag(tag, self.0)
372372
}
373373
}
374374

@@ -385,7 +385,13 @@ impl From<MatroskaTag> for crate::tag::Tag {
385385
}
386386

387387
impl From<crate::tag::Tag> for MatroskaTag {
388-
fn from(input: crate::tag::Tag) -> Self {
388+
fn from(mut input: crate::tag::Tag) -> Self {
389+
if unsafe { global_options().preserve_format_specific_items } {
390+
if let Some(companion) = input.companion_tag.take().and_then(CompanionTag::matroska) {
391+
return SplitTagRemainder(companion).merge_tag(input);
392+
}
393+
}
394+
389395
SplitTagRemainder::default().merge_tag(input)
390396
}
391397
}

0 commit comments

Comments
 (0)