-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmissing_reference.go
More file actions
88 lines (74 loc) · 2.35 KB
/
missing_reference.go
File metadata and controls
88 lines (74 loc) · 2.35 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// SPDX-License-Identifier: Apache-2.0
// Copyright Contributors to the OpenTimelineIO project
package gotio
import (
"encoding/json"
"github.com/Avalanche-io/gotio/opentime"
)
// MissingReferenceSchema is the schema for MissingReference.
var MissingReferenceSchema = Schema{Name: "MissingReference", Version: 1}
// MissingReference represents media for which a concrete reference is missing.
type MissingReference struct {
MediaReferenceBase
}
// NewMissingReference creates a new MissingReference.
func NewMissingReference(
name string,
availableRange *opentime.TimeRange,
metadata AnyDictionary,
) *MissingReference {
return &MissingReference{
MediaReferenceBase: NewMediaReferenceBase(name, availableRange, metadata, nil),
}
}
// IsMissingReference returns true for MissingReference.
func (m *MissingReference) IsMissingReference() bool {
return true
}
// SchemaName returns the schema name.
func (m *MissingReference) SchemaName() string {
return MissingReferenceSchema.Name
}
// SchemaVersion returns the schema version.
func (m *MissingReference) SchemaVersion() int {
return MissingReferenceSchema.Version
}
// Clone creates a deep copy.
func (m *MissingReference) Clone() SerializableObject {
return &MissingReference{
MediaReferenceBase: MediaReferenceBase{
SerializableObjectWithMetadataBase: SerializableObjectWithMetadataBase{
name: m.name,
metadata: CloneAnyDictionary(m.metadata),
},
availableRange: cloneAvailableRange(m.availableRange),
availableImageBounds: cloneBox2d(m.availableImageBounds),
},
}
}
// IsEquivalentTo returns true if equivalent.
func (m *MissingReference) IsEquivalentTo(other SerializableObject) bool {
otherM, ok := other.(*MissingReference)
if !ok {
return false
}
return m.name == otherM.name && areMetadataEqual(m.metadata, otherM.metadata)
}
// MarshalJSON implements json.Marshaler.
func (m *MissingReference) MarshalJSON() ([]byte, error) {
return json.Marshal(m.marshalMediaReferenceJSON(MissingReferenceSchema))
}
// UnmarshalJSON implements json.Unmarshaler.
func (m *MissingReference) UnmarshalJSON(data []byte) error {
var j mediaReferenceJSON
if err := json.Unmarshal(data, &j); err != nil {
return err
}
m.unmarshalMediaReferenceJSON(&j)
return nil
}
func init() {
RegisterSchema(MissingReferenceSchema, func() SerializableObject {
return NewMissingReference("", nil, nil)
})
}