github.com/boki/go-xmp@v1.0.1/models/xmp_dm/model.go (about) 1 // Copyright (c) 2017-2018 Alexander Eichhorn 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"): you may 4 // not use this file except in compliance with the License. You may obtain 5 // a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12 // License for the specific language governing permissions and limitations 13 // under the License. 14 15 // Package xmpdm implements the XMP Dynamic Media namespace as defined by XMP Specification Part 2. 16 package xmpdm 17 18 import ( 19 "fmt" 20 "trimmer.io/go-xmp/models/xmp_tpg" 21 "trimmer.io/go-xmp/xmp" 22 ) 23 24 var ( 25 NsXmpDM = xmp.NewNamespace("xmpDM", "http://ns.adobe.com/xmp/1.0/DynamicMedia/", NewModel) 26 ) 27 28 func init() { 29 xmp.Register(NsXmpDM, xmp.XmpMetadata) 30 } 31 32 func NewModel(name string) xmp.Model { 33 return &XmpDM{} 34 } 35 36 func MakeModel(d *xmp.Document) (*XmpDM, error) { 37 m, err := d.MakeModel(NsXmpDM) 38 if err != nil { 39 return nil, err 40 } 41 x, _ := m.(*XmpDM) 42 return x, nil 43 } 44 45 func FindModel(d *xmp.Document) *XmpDM { 46 if m := d.FindModel(NsXmpDM); m != nil { 47 return m.(*XmpDM) 48 } 49 return nil 50 } 51 52 type XmpDM struct { 53 AbsPeakAudioFilePath string `xmp:"xmpDM:absPeakAudioFilePath"` 54 Album string `xmp:"xmpDM:album"` 55 AltTapeName string `xmp:"xmpDM:altTapeName"` 56 AltTimecode Timecode `xmp:"xmpDM:altTimecode"` 57 Artist string `xmp:"xmpDM:artist"` 58 AudioChannelType AudioChannelType `xmp:"xmpDM:audioChannelType"` 59 AudioCompressor string `xmp:"xmpDM:audioCompressor"` 60 AudioSampleRate float64 `xmp:"xmpDM:audioSampleRate"` 61 AudioSampleType AudioSampleType `xmp:"xmpDM:audioSampleType"` 62 BeatSpliceParams BeatSpliceStretch `xmp:"xmpDM:beatSpliceParams"` 63 CameraAngle CameraAngle `xmp:"xmpDM:cameraAngle"` 64 CameraLabel string `xmp:"xmpDM:cameraLabel"` 65 CameraModel string `xmp:"xmpDM:cameraModel"` 66 CameraMove CameraMove `xmp:"xmpDM:cameraMove"` 67 Client string `xmp:"xmpDM:client"` 68 Comment string `xmp:"xmpDM:comment"` 69 Composer string `xmp:"xmpDM:composer"` 70 ContributedMedia MediaArray `xmp:"xmpDM:contributedMedia"` 71 Director string `xmp:"xmpDM:director"` 72 DirectorPhotography string `xmp:"xmpDM:directorPhotography"` 73 Duration MediaTime `xmp:"xmpDM:duration"` 74 Engineer string `xmp:"xmpDM:engineer"` 75 FileDataRate xmp.Rational `xmp:"xmpDM:fileDataRate"` 76 Genre string `xmp:"xmpDM:genre"` 77 Good xmp.Bool `xmp:"xmpDM:good"` 78 Instrument string `xmp:"xmpDM:instrument"` 79 IntroTime MediaTime `xmp:"xmpDM:introTime"` 80 Key MusicalKey `xmp:"xmpDM:key"` 81 LogComment string `xmp:"xmpDM:logComment"` 82 Loop xmp.Bool `xmp:"xmpDM:loop"` 83 NumberOfBeats float64 `xmp:"xmpDM:numberOfBeats"` 84 Markers MarkerList `xmp:"xmpDM:markers"` 85 OutCue MediaTime `xmp:"xmpDM:outCue"` 86 ProjectName string `xmp:"xmpDM:projectName"` 87 ProjectRef ProjectLink `xmp:"xmpDM:projectRef"` 88 PullDown PullDown `xmp:"xmpDM:pullDown"` 89 RelativePeakAudioFilePath xmp.Uri `xmp:"xmpDM:relativePeakAudioFilePath"` 90 RelativeTimestamp MediaTime `xmp:"xmpDM:relativeTimestamp"` 91 ReleaseDate xmp.Date `xmp:"xmpDM:releaseDate"` 92 ResampleParams ResampleStretch `xmp:"xmpDM:resampleParams"` 93 ScaleType MusicalScale `xmp:"xmpDM:scaleType"` 94 Scene string `xmp:"xmpDM:scene"` 95 ShotDate xmp.Date `xmp:"xmpDM:shotDate"` 96 ShotDay string `xmp:"xmpDM:shotDay"` 97 ShotLocation string `xmp:"xmpDM:shotLocation"` 98 ShotName string `xmp:"xmpDM:shotName"` 99 ShotNumber string `xmp:"xmpDM:shotNumber"` 100 ShotSize ShotSize `xmp:"xmpDM:shotSize"` 101 SpeakerPlacement string `xmp:"xmpDM:speakerPlacement"` 102 StartTimecode Timecode `xmp:"xmpDM:startTimecode"` 103 StretchMode StretchMode `xmp:"xmpDM:stretchMode"` 104 TakeNumber int `xmp:"xmpDM:takeNumber"` 105 TapeName string `xmp:"xmpDM:tapeName"` 106 Tempo float64 `xmp:"xmpDM:tempo"` 107 TimeScaleParams TimeScaleStretch `xmp:"xmpDM:timeScaleParams"` 108 TimeSignature TimeSignature `xmp:"xmpDM:timeSignature"` 109 TrackNumber int `xmp:"xmpDM:trackNumber"` 110 Tracks TrackArray `xmp:"xmpDM:Tracks"` 111 VideoAlphaMode AlphaMode `xmp:"xmpDM:videoAlphaMode"` 112 VideoAlphaPremultipleColor xmptpg.Colorant `xmp:"xmpDM:videoAlphaPremultipleColor"` 113 VideoAlphaUnityIsTransparent xmp.Bool `xmp:"xmpDM:videoAlphaUnityIsTransparent"` 114 VideoColorSpace ColorSpace `xmp:"xmpDM:videoColorSpace"` 115 VideoCompressor string `xmp:"xmpDM:videoCompressor"` 116 VideoFieldOrder FieldOrder `xmp:"xmpDM:videoFieldOrder"` 117 VideoFrameRate VideoFrameRate `xmp:"xmpDM:videoFrameRate"` 118 VideoFrameSize xmptpg.Dimensions `xmp:"xmpDM:videoFrameSize"` 119 VideoPixelDepth PixelDepth `xmp:"xmpDM:videoPixelDepth"` 120 VideoPixelAspectRatio xmp.Rational `xmp:"xmpDM:videoPixelAspectRatio"` 121 PartOfCompilation xmp.Bool `xmp:"xmpDM:partOfCompilation"` 122 Lyrics string `xmp:"xmpDM:lyrics"` 123 DiscNumber int `xmp:"xmpDM:discNumber"` 124 125 // not found in XMP spec, but in files 126 StartTimeScale int `xmp:"xmpDM:startTimeScale"` // "24" 127 StartTimeSampleSize int `xmp:"xmpDM:startTimeSampleSize"` // "1" 128 } 129 130 func (x XmpDM) Can(nsName string) bool { 131 return NsXmpDM.GetName() == nsName 132 } 133 134 func (x XmpDM) Namespaces() xmp.NamespaceList { 135 return xmp.NamespaceList{NsXmpDM} 136 } 137 138 func (x *XmpDM) SyncModel(d *xmp.Document) error { 139 return nil 140 } 141 142 func (x *XmpDM) SyncFromXMP(d *xmp.Document) error { 143 return nil 144 } 145 146 func (x XmpDM) SyncToXMP(d *xmp.Document) error { 147 return nil 148 } 149 150 func (x *XmpDM) CanTag(tag string) bool { 151 _, err := xmp.GetNativeField(x, tag) 152 return err == nil 153 } 154 155 func (x *XmpDM) GetTag(tag string) (string, error) { 156 if v, err := xmp.GetNativeField(x, tag); err != nil { 157 return "", fmt.Errorf("%s: %v", NsXmpDM.GetName(), err) 158 } else { 159 return v, nil 160 } 161 } 162 163 func (x *XmpDM) SetTag(tag, value string) error { 164 if err := xmp.SetNativeField(x, tag, value); err != nil { 165 return fmt.Errorf("%s: %v", NsXmpDM.GetName(), err) 166 } 167 return nil 168 }