From 1034f4d97732e3788dc67edae97ca6030b2934c8 Mon Sep 17 00:00:00 2001 From: Onur Gündüz Date: Mon, 16 Feb 2026 06:56:58 +0100 Subject: Improve documentation --- scanner.go | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'scanner.go') diff --git a/scanner.go b/scanner.go index 30c3098..4169f1f 100644 --- a/scanner.go +++ b/scanner.go @@ -1,4 +1,4 @@ -package bmff +package mp4 import "io" @@ -15,21 +15,26 @@ func (e ScanEntry) DataSize() int64 { return e.Size - int64(e.HeaderSize) } -// Scanner reads top-level box headers from an io.ReadSeeker without -// loading box contents into memory. This lets callers discover box -// positions and sizes, then selectively read only the boxes they need -// (e.g. moov) into a buffer for parsing with NewReader. +// DataOffset returns the byte offset where the box data begins (after the header). +// Use it with [io.ReaderAt.ReadAt] to read box data without seeking. +func (e ScanEntry) DataOffset() int64 { + return e.Offset + int64(e.HeaderSize) +} + +// Scanner reads top-level box headers from an [io.ReadSeeker] without loading +// box contents into memory. Use it to discover box positions and sizes, then +// selectively read only the boxes you need. // // Typical usage: // // f, _ := os.Open("video.mp4") -// sc := bmff.NewScanner(f) +// sc := mp4.NewScanner(f) // for sc.Next() { // e := sc.Entry() -// if e.Type == bmff.TypeMoov { +// if e.Type == mp4.TypeMoov { // buf := make([]byte, e.DataSize()) // sc.ReadBody(buf) -// r := bmff.NewReader(buf) +// r := mp4.NewReader(buf) // // parse moov contents... // } // } -- cgit v1.3.1