github.com/boki/go-xmp@v1.0.1/models/ixml/enum.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 ixml
    16  
    17  import (
    18  	"fmt"
    19  	"strings"
    20  )
    21  
    22  type TakeType string
    23  
    24  const (
    25  	TakeTypeDefault      TakeType = "DEFAULT"
    26  	TakeTypeNoGood       TakeType = "NO_GOOD"
    27  	TakeTypeFalseStart   TakeType = "FALSE_START"
    28  	TakeTypeWildTrack    TakeType = "WILD_TRACK"
    29  	TakeTypePickup       TakeType = "PICKUP"
    30  	TakeTypeRehearsal    TakeType = "REHEARSAL"
    31  	TakeTypeAnnouncement TakeType = "ANNOUNCEMENT"
    32  	TakeTypeSoundGuide   TakeType = "SOUND_GUIDE"
    33  )
    34  
    35  type TakeTypeList []TakeType
    36  
    37  func (x TakeTypeList) Contains(t TakeType) bool {
    38  	for _, v := range x {
    39  		if v == t {
    40  			return true
    41  		}
    42  	}
    43  	return false
    44  }
    45  
    46  func (x *TakeTypeList) Add(t TakeType) {
    47  	if !x.Contains(t) {
    48  		*x = append(*x, t)
    49  	}
    50  }
    51  
    52  func (x *TakeTypeList) Del(t TakeType) {
    53  	idx := -1
    54  	for i, v := range *x {
    55  		if v == t {
    56  			idx = i
    57  		}
    58  	}
    59  	if idx > -1 {
    60  		*x = append((*x)[:idx], (*x)[idx+1:]...)
    61  	}
    62  }
    63  
    64  func (x TakeTypeList) IsDefault() bool {
    65  	if len(x) == 0 {
    66  		return true
    67  	}
    68  	return x.Contains(TakeTypeDefault)
    69  }
    70  
    71  // allow future extensions
    72  func ParseTakeType(s string) TakeType {
    73  	switch s {
    74  	case "DEFAULT":
    75  		return TakeTypeDefault
    76  	case "NO_GOOD":
    77  		return TakeTypeNoGood
    78  	case "FALSE_START":
    79  		return TakeTypeFalseStart
    80  	case "WILD_TRACK":
    81  		return TakeTypeWildTrack
    82  	case "PICKUP":
    83  		return TakeTypePickup
    84  	case "REHEARSAL":
    85  		return TakeTypeRehearsal
    86  	case "ANNOUNCEMENT":
    87  		return TakeTypeAnnouncement
    88  	case "SOUND_GUIDE":
    89  		return TakeTypeSoundGuide
    90  	default:
    91  		return TakeType(s)
    92  	}
    93  }
    94  
    95  func (x TakeTypeList) MarshalText() ([]byte, error) {
    96  	if len(x) == 0 {
    97  		return nil, nil
    98  	}
    99  	l := make([]string, len(x))
   100  	for i, v := range x {
   101  		l[i] = string(v)
   102  	}
   103  	return []byte(strings.Join(l, ",")), nil
   104  }
   105  
   106  func (x *TakeTypeList) UnmarshalText(data []byte) error {
   107  	fields := strings.Split(string(data), ",")
   108  	if len(fields) == 0 {
   109  		return nil
   110  	}
   111  	ttl := make(TakeTypeList, len(fields))
   112  	for i, v := range fields {
   113  		ttl[i] = ParseTakeType(v)
   114  	}
   115  	*x = ttl
   116  	return nil
   117  }
   118  
   119  // Location Type
   120  //
   121  type LocationType string
   122  
   123  const (
   124  	LocationTypeInterior LocationType = "INT"
   125  	LocationTypeExterior LocationType = "EXT"
   126  )
   127  
   128  type LocationTypeList []LocationType
   129  
   130  // allow future extensions
   131  func ParseLocationType(s string) LocationType {
   132  	switch s {
   133  	case "INT":
   134  		return LocationTypeInterior
   135  	case "EXT":
   136  		return LocationTypeExterior
   137  	default:
   138  		return LocationType(s)
   139  	}
   140  }
   141  
   142  func (x *LocationTypeList) Add(t LocationType) {
   143  	if !x.Contains(t) {
   144  		*x = append(*x, t)
   145  	}
   146  }
   147  
   148  func (x *LocationTypeList) Del(t LocationType) {
   149  	idx := -1
   150  	for i, v := range *x {
   151  		if v == t {
   152  			idx = i
   153  		}
   154  	}
   155  	if idx > -1 {
   156  		*x = append((*x)[:idx], (*x)[idx+1:]...)
   157  	}
   158  }
   159  
   160  func (x LocationTypeList) MarshalText() ([]byte, error) {
   161  	if len(x) == 0 {
   162  		return nil, nil
   163  	}
   164  	l := make([]string, len(x))
   165  	for i, v := range x {
   166  		l[i] = string(v)
   167  	}
   168  	return []byte(strings.Join(l, ",")), nil
   169  }
   170  
   171  func (x *LocationTypeList) UnmarshalText(data []byte) error {
   172  	fields := strings.Split(string(data), ",")
   173  	if len(fields) == 0 {
   174  		return nil
   175  	}
   176  	ttl := make(LocationTypeList, len(fields))
   177  	for i, v := range fields {
   178  		ttl[i] = ParseLocationType(v)
   179  	}
   180  	*x = ttl
   181  	return nil
   182  }
   183  
   184  func (x LocationTypeList) Contains(t LocationType) bool {
   185  	for _, v := range x {
   186  		if v == t {
   187  			return true
   188  		}
   189  	}
   190  	return false
   191  }
   192  
   193  // Location Time
   194  //
   195  type LocationTime string
   196  
   197  const (
   198  	LocationTimeSunrise   LocationTime = "SUNRISE"
   199  	LocationTimeMorning   LocationTime = "MORNING"
   200  	LocationTimeMidday    LocationTime = "MIDDAY"
   201  	LocationTimeDay       LocationTime = "DAY"
   202  	LocationTimeAfternoon LocationTime = "AFTERNOON"
   203  	LocationTimeEvening   LocationTime = "EVENING"
   204  	LocationTimeSunset    LocationTime = "SUNSET"
   205  	LocationTimeNight     LocationTime = "NIGHT"
   206  )
   207  
   208  type LocationTimeList []LocationTime
   209  
   210  // allow future extensions
   211  func ParseLocationTime(s string) LocationTime {
   212  	switch s {
   213  	case "SUNRISE":
   214  		return LocationTimeSunrise
   215  	case "MORNING":
   216  		return LocationTimeMorning
   217  	case "MIDDAY":
   218  		return LocationTimeMidday
   219  	case "DAY":
   220  		return LocationTimeDay
   221  	case "AFTERNOON":
   222  		return LocationTimeAfternoon
   223  	case "EVENING":
   224  		return LocationTimeEvening
   225  	case "SUNSET":
   226  		return LocationTimeSunset
   227  	case "NIGHT":
   228  		return LocationTimeNight
   229  	default:
   230  		return LocationTime(s)
   231  	}
   232  }
   233  
   234  func (x *LocationTimeList) Add(t LocationTime) {
   235  	if !x.Contains(t) {
   236  		*x = append(*x, t)
   237  	}
   238  }
   239  
   240  func (x *LocationTimeList) Del(t LocationTime) {
   241  	idx := -1
   242  	for i, v := range *x {
   243  		if v == t {
   244  			idx = i
   245  		}
   246  	}
   247  	if idx > -1 {
   248  		*x = append((*x)[:idx], (*x)[idx+1:]...)
   249  	}
   250  }
   251  
   252  func (x LocationTimeList) MarshalText() ([]byte, error) {
   253  	if len(x) == 0 {
   254  		return nil, nil
   255  	}
   256  	l := make([]string, len(x))
   257  	for i, v := range x {
   258  		l[i] = string(v)
   259  	}
   260  	return []byte(strings.Join(l, ",")), nil
   261  }
   262  
   263  func (x *LocationTimeList) UnmarshalText(data []byte) error {
   264  	fields := strings.Split(string(data), ",")
   265  	if len(fields) == 0 {
   266  		return nil
   267  	}
   268  	ttl := make(LocationTimeList, len(fields))
   269  	for i, v := range fields {
   270  		ttl[i] = ParseLocationTime(v)
   271  	}
   272  	*x = ttl
   273  	return nil
   274  }
   275  
   276  func (x LocationTimeList) Contains(t LocationTime) bool {
   277  	for _, v := range x {
   278  		if v == t {
   279  			return true
   280  		}
   281  	}
   282  	return false
   283  }
   284  
   285  type FunctionType string
   286  
   287  const (
   288  	FunctionMS_M         FunctionType = "M-MID_SIDE"
   289  	FunctionMS_S         FunctionType = "S-MID_SIDE"
   290  	FunctionXY_X         FunctionType = "X-X_Y "
   291  	FunctionXY_Y         FunctionType = "Y-X_Y"
   292  	FunctionMix_L        FunctionType = "L-MIX"
   293  	FunctionMix_R        FunctionType = "R-MIX"
   294  	FunctionMix          FunctionType = "MIX"
   295  	FunctionLeft         FunctionType = "LEFT"
   296  	FunctionRight        FunctionType = "RIGHT"
   297  	FunctionDMS_F        FunctionType = "F-DMS"
   298  	FunctionDMS_8        FunctionType = "8-DMS"
   299  	FunctionDMS_R        FunctionType = "R-DMS"
   300  	FunctionLCR_L        FunctionType = "L-LCR"
   301  	FunctionLCR_C        FunctionType = "C-LCR"
   302  	FunctionLCR_R        FunctionType = "R-LCR"
   303  	FunctionLCRS_L       FunctionType = "L-LCRS"
   304  	FunctionLCRS_C       FunctionType = "C-LCRS"
   305  	FunctionLCRS_R       FunctionType = "R-LCRS"
   306  	FunctionLCRS_S       FunctionType = "S-LCRS"
   307  	Function51_L         FunctionType = "L-5.1"
   308  	Function51_C         FunctionType = "C-5.1"
   309  	Function51_R         FunctionType = "R-5.1"
   310  	Function51_Ls        FunctionType = "Ls-5.1"
   311  	Function51_Rs        FunctionType = "Rs-5.1"
   312  	Function51_LFE       FunctionType = "LFE-5.1"
   313  	Function71_L         FunctionType = "L-7.1"
   314  	Function71_Lc        FunctionType = "Lc-7.1"
   315  	Function71_C         FunctionType = "C-7.1"
   316  	Function71_Rc        FunctionType = "Rc-7.1"
   317  	Function71_R         FunctionType = "R-7.1"
   318  	Function71_Ls        FunctionType = "Ls-7.1"
   319  	Function71_Rs        FunctionType = "Rs-7.1"
   320  	Function71_LFE       FunctionType = "LFE-7.1"
   321  	FunctionSurroundL    FunctionType = "L-GENERIC"    // Main Layer Front Left
   322  	FunctionSurroundLc   FunctionType = "Lc-GENERIC"   // Main Layer Front Left Center
   323  	FunctionSurroundC    FunctionType = "C-GENERIC"    // Main Layer Front Center
   324  	FunctionSurroundRc   FunctionType = "Rc-GENERIC"   // Main Layer Front Right Center
   325  	FunctionSurroundR    FunctionType = "R-GENERIC"    // Main Layer Front Right
   326  	FunctionSurroundLs   FunctionType = "Ls-GENERIC"   // Main Layer Rear Left
   327  	FunctionSurroundCs   FunctionType = "Cs-GENERIC"   // Main Layer Rear Center
   328  	FunctionSurroundRs   FunctionType = "Rs-GENERIC"   // Main Layer Rear Right
   329  	FunctionSurroundLFE  FunctionType = "LFE-GENERIC"  // LFE
   330  	FunctionSurroundSl   FunctionType = "Sl-GENERIC"   // Main Layer Side Left
   331  	FunctionSurroundSr   FunctionType = "Sr-GENERIC"   // Main Layer Side Right
   332  	FunctionSurroundLcs  FunctionType = "Lcs-GENERIC"  // Main Layer Rear Left Center
   333  	FunctionSurroundRcs  FunctionType = "Rcs-GENERIC"  // Main Layer Rear Right Center
   334  	FunctionSurroundLFE2 FunctionType = "LFE2-GENERIC" // LFE 2
   335  	FunctionSurroundVoG  FunctionType = "VoG-GENERIC"  // Top Layer Voice of God
   336  	FunctionSurroundTl   FunctionType = "Tl-GENERIC"   // Top Layer Front Left
   337  	FunctionSurroundTc   FunctionType = "Tc-GENERIC"   // Top Layer Front Center
   338  	FunctionSurroundTr   FunctionType = "Tr-GENERIC"   // Top Layer Front Right
   339  	FunctionSurroundTrl  FunctionType = "Trl-GENERIC"  // Top Layer Rear Left
   340  	FunctionSurroundTrc  FunctionType = "Trc-GENERIC"  // Top Layer Rear Center
   341  	FunctionSurroundTrr  FunctionType = "Trr-GENERIC"  // Top Layer Rear Right
   342  	FunctionSurroundTsl  FunctionType = "Tsl-GENERIC"  // Top Layer Side Left
   343  	FunctionSurroundTsr  FunctionType = "Tsr-GENERIC"  // Top Layer Side Right
   344  	FunctionSurroundVoD  FunctionType = "VoD-GENERIC"  // Bottom Layer Voice of Devil
   345  	FunctionSurroundBl   FunctionType = "Bl-GENERIC"   // Bottom Layer Front Left
   346  	FunctionSurroundBc   FunctionType = "Bc-GENERIC"   // Bottom Layer Front Center
   347  	FunctionSurroundBr   FunctionType = "Br-GENERIC"   // Bottom Layer Front Right
   348  	FunctionSurroundBrl  FunctionType = "Brl-GENERIC"  // Bottom Layer Rear Left
   349  	FunctionSurroundBrc  FunctionType = "Brc-GENERIC"  // Bottom Layer Rear Center
   350  	FunctionSurroundBrr  FunctionType = "Brr-GENERIC"  // Bottom Layer Rear Right
   351  	FunctionSurroundBsl  FunctionType = "Bsl-GENERIC"  // Bottom Layer Side Left
   352  	FunctionSurroundBsr  FunctionType = "Bsr-GENERIC"  // Bottom Layer Side Right
   353  	FunctionSoundfield_W FunctionType = "W-SOUNDFIELD"
   354  	FunctionSoundfield_X FunctionType = "X-SOUNDFIELD"
   355  	FunctionSoundfield_Y FunctionType = "Y-SOUNDFIELD"
   356  	FunctionSoundfield_Z FunctionType = "Z-SOUNDFIELD"
   357  	FunctionVideo        FunctionType = "VIDEO"
   358  )
   359  
   360  type FunctionSet []FunctionType
   361  
   362  var (
   363  	FunctionSetMS            FunctionSet = FunctionSet{FunctionMS_M, FunctionMS_S}
   364  	FunctionSetXY            FunctionSet = FunctionSet{FunctionXY_X, FunctionXY_Y}
   365  	FunctionSetStereoDownmix FunctionSet = FunctionSet{FunctionMix_L, FunctionMix_R}
   366  	FunctionSetMonoDownmix   FunctionSet = FunctionSet{FunctionMix}
   367  	FunctionSetStereo        FunctionSet = FunctionSet{FunctionLeft, FunctionRight}
   368  	FunctionSetDMS           FunctionSet = FunctionSet{FunctionDMS_F, FunctionDMS_8, FunctionDMS_R}
   369  	FunctionSetLCR           FunctionSet = FunctionSet{FunctionLCR_L, FunctionLCR_C, FunctionLCR_R}
   370  	FunctionSetLCRS          FunctionSet = FunctionSet{FunctionLCRS_L, FunctionLCRS_C, FunctionLCRS_R, FunctionLCRS_S}
   371  	FunctionSet51            FunctionSet = FunctionSet{Function51_L, Function51_C, Function51_R, Function51_Ls, Function51_Rs, Function51_LFE}
   372  	FunctionSet71            FunctionSet = FunctionSet{Function71_L, Function71_Lc, Function71_C, Function71_Rc, Function71_R, Function71_Ls, Function71_Rs, Function71_LFE}
   373  	FunctionSetSoundfiled    FunctionSet = FunctionSet{FunctionSoundfield_W, FunctionSoundfield_X, FunctionSoundfield_Y, FunctionSoundfield_Z}
   374  )
   375  
   376  func (x FunctionSet) Contains(t FunctionType) bool {
   377  	for _, v := range x {
   378  		if v == t {
   379  			return true
   380  		}
   381  	}
   382  	return false
   383  }
   384  
   385  func (x *FunctionSet) Add(t FunctionType) {
   386  	if !x.Contains(t) {
   387  		*x = append(*x, t)
   388  	}
   389  }
   390  
   391  func (x *FunctionSet) Del(t FunctionType) {
   392  	idx := -1
   393  	for i, v := range *x {
   394  		if v == t {
   395  			idx = i
   396  		}
   397  	}
   398  	if idx > -1 {
   399  		*x = append((*x)[:idx], (*x)[idx+1:]...)
   400  	}
   401  }
   402  
   403  func (x *FunctionSet) Merge(s FunctionSet) {
   404  	for _, v := range s {
   405  		x.Add(v)
   406  	}
   407  }
   408  
   409  func (x *FunctionSet) Sub(s FunctionSet) {
   410  	for _, v := range s {
   411  		x.Del(v)
   412  	}
   413  }
   414  
   415  type TimecodeFlag string
   416  
   417  const (
   418  	TimecodeFlagInvalid TimecodeFlag = ""
   419  	TimecodeFlagDF      TimecodeFlag = "DF"
   420  	TimecodeFlagNDF     TimecodeFlag = "NDF"
   421  )
   422  
   423  func ParseTimecodeFlag(s string) TimecodeFlag {
   424  	switch s {
   425  	case "DF":
   426  		return TimecodeFlagDF
   427  	case "NDF":
   428  		return TimecodeFlagNDF
   429  	default:
   430  		return TimecodeFlagInvalid
   431  	}
   432  }
   433  
   434  func (x *TimecodeFlag) UnmarshalText(data []byte) error {
   435  	s := string(data)
   436  	if f := ParseTimecodeFlag(s); f == TimecodeFlagInvalid {
   437  		return fmt.Errorf("ixml: invalid timecode flag '%s'", s)
   438  	} else {
   439  		*x = f
   440  	}
   441  	return nil
   442  }
   443  
   444  type SyncPointType string
   445  
   446  const (
   447  	SyncPointRelative SyncPointType = "RELATIVE"
   448  	SyncPointAbsolute SyncPointType = "ABSOLUTE"
   449  )
   450  
   451  type SyncPointFunctionType string
   452  
   453  const (
   454  	SyncPointPreRecordSamplecount SyncPointFunctionType = "PRE_RECORD_SAMPLECOUNT"
   455  	SyncPointSlateGeneric         SyncPointFunctionType = "SLATE_GENERIC"
   456  	SyncPointHeadSlate            SyncPointFunctionType = "HEAD_SLATE"
   457  	SyncPointTailSlate            SyncPointFunctionType = "TAIL_SLATE"
   458  	SyncPointMarkerGeneric        SyncPointFunctionType = "MARKER_GENERIC"
   459  	SyncPointMarkerAutoplay       SyncPointFunctionType = "MARKER_AUTOPLAY"
   460  	SyncPointMarkerAutoplayStop   SyncPointFunctionType = "MARKER_AUTOPLAYSTOP"
   461  	SyncPointMarkerAutoplayLoop   SyncPointFunctionType = "MARKER_AUTOPLAYLOOP"
   462  	SyncPointGroupOffset          SyncPointFunctionType = "GROUP_OFFSET"
   463  )