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

First implementation of chapter TOC #72

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

crra
Copy link
Contributor

@crra crra commented Jan 29, 2022

Hello Albert,

it seams like that some mp3 players need chapter TOCs in addition to chapter frames to function properly. I've introduced AddChapterTocFrame according to https://id3.org/id3v2-chapters-1.0. I kept the spirit of a 'low-level' API without renaming the boolean values in reverse to support default values (values must be explicitly set). The fields are also named according to the specification to avoid confusion.

@crra
Copy link
Contributor Author

crra commented Jan 31, 2022

Hello @BoGeM,

did you find the chance to look at the pull request? If it's not to your liking, please help me to improve it. I want to get rid of my fork.

@n10v
Copy link
Owner

n10v commented Feb 1, 2022

Hi @crra,
thanks for your PR! It's great addition. I need some time to review the PR :)

@crra
Copy link
Contributor Author

crra commented Feb 1, 2022

Sure, take your time. You can check the live application of the chapters TOCs with mp3binder. The chapters are enabled by default.

Copy link
Owner

@n10v n10v left a comment

Choose a reason for hiding this comment

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

Awesome work, @crra! Really like it 🚀
I wrote some points, but in general it looks great 👍

// AddChapterFrame adds the chapter frame to tag.
func (tag *Tag) AddChapterFrame(cf ChapterFrame) {
tag.AddFrame(tag.CommonID("Chapters"), cf)
}
Copy link
Owner

Choose a reason for hiding this comment

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

As far as I see this change is in the v1 file, but actually all changes should go to v2 folder and you already made them in v2/tag.go, so please delete it :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

However, AddChapterFrame is used in V1:chapter_frame_test.go. Either remove the test or the implementation.


type ChapterTocFrame struct {
ElementID string
// This frame is the root of the Table of Contents tree and is not a child of any other "CTOC" frame.
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
// This frame is the root of the Table of Contents tree and is not a child of any other "CTOC" frame.
// TopLevel defines if a frame is the root of the Table of Contents tree and is not a child of any other "CTOC" frame.

ElementID string
// This frame is the root of the Table of Contents tree and is not a child of any other "CTOC" frame.
TopLevel bool
// This provides a hint as to whether the elements should be played as a continuous ordered sequence or played individually.
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
// This provides a hint as to whether the elements should be played as a continuous ordered sequence or played individually.
// Ordered defines if the entries in the Chapters IDs are ordered.

TopLevel bool
// This provides a hint as to whether the elements should be played as a continuous ordered sequence or played individually.
Ordered bool
ChapterIds []string
Copy link
Owner

Choose a reason for hiding this comment

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

IMO it's better to name properties the same as they named in the spec. Also good idea to provide comment for it:

Suggested change
ChapterIds []string
// Zero or more CHAP/CTOC Child element IDs.
ChildElementIds []string

// This provides a hint as to whether the elements should be played as a continuous ordered sequence or played individually.
Ordered bool
ChapterIds []string
Description *TextFrame
Copy link
Owner

Choose a reason for hiding this comment

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

I think it should be named as DescriptiveData like in spec:

Suggested change
Description *TextFrame
DescriptiveData *TextFrame

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think my implementation is wrong. After reading the spec again: TIT2 and TIT3 can be added, so it's a collection of text frames rather than one single text frame.

buf := getByteSlice(32 * 1024)
defer putByteSlice(buf)

for {
Copy link
Owner

Choose a reason for hiding this comment

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

As far as I understand, you're parsing DescriptiveData here. You're using for-loop, but AFAIU there can be only one DescriptiveData, so you don't need loop, right?

Description: &TextFrame{
Encoding: EncodingUTF8,
Text: testChapterTocSampleTitle,
},
Copy link
Owner

Choose a reason for hiding this comment

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

Nice!
Can you please add a test for ChapterTocFrame without Description? 🙂

@crra
Copy link
Contributor Author

crra commented Feb 3, 2022

Hello @BoGeM,

How do you read?

[...] followed by a sequence of optional frames that are embedded within the "CTOC" frame and which describe this element of the table of contents (e.g. a "TIT2" frame representing the name of the element) or provide related material such as URLs and images. These sub-frames are contained within the bounds of the "CTOC" frame as signalled by the size field in the "CTOC" frame header.

Does this mean any frame can be embedded? So it's like a new container for any id3v2 tags listed in common_ids.go? Even if they don't make sense like UFID? What do you think?

@n10v
Copy link
Owner

n10v commented Feb 18, 2022

Hey @crra,
sorry for not answering for a long time, had a lot of stuff to do.

That's good point actually, but it's so confusing (as a lot of places in id3v2 spec). When I read this, I also have the same understanding as you because of the sentence such as URLs and images. It seems that it should be a part of CTOC Descriptive Data and not only the text frame can be stored there. The Figure 2 only shows an example with TIT2 frame as descriptive data, but AFAIU everything can be there. And I have the same understanding as you that it's basically a new container for any id3v2 tags.

IMO it's a rare edge case that will require a lot of work and code to implement. IMO for now we can skip the whole descriptive data

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.

None yet

2 participants