-
Notifications
You must be signed in to change notification settings - Fork 2
/
metadata.go
47 lines (35 loc) · 1.09 KB
/
metadata.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package media
import "encoding/json"
////////////////////////////////////////////////////////////////////////////////
// TYPES
type meta struct {
Key string `json:"key" writer:",width:30"`
Value any `json:"value,omitempty" writer:",wrap,width:50"`
}
type metadata struct {
meta
}
const (
MetaArtwork = "artwork" // Metadata key for artwork, sets the value as []byte
MetaDuration = "duration" // Metadata key for duration, sets the value as float64 (seconds)
)
////////////////////////////////////////////////////////////////////////////////
// LIFECYCLE
// Return the metadata for the media stream
func newMetadata(key string, value any) Metadata {
return &metadata{meta{key, value}}
}
////////////////////////////////////////////////////////////////////////////////
// STRINIGY
func (m *metadata) String() string {
data, _ := json.MarshalIndent(m, "", " ")
return string(data)
}
////////////////////////////////////////////////////////////////////////////////
// PUBLIC METHODS
func (m *metadata) Key() string {
return m.meta.Key
}
func (m *metadata) Value() any {
return m.meta.Value
}