|
| 1 | +package openrtb |
| 2 | + |
| 3 | +// The "video" object must be included directly in the impression object if the impression offered |
| 4 | +// for auction is an in-stream video ad opportunity. |
| 5 | +type NativeVideo struct { |
| 6 | + Mimes []string `json:"mimes"` // Content MIME types supported. |
| 7 | + Minduration *int `json:"minduration"` // Minimum video ad duration in seconds |
| 8 | + Maxduration *int `json:"maxduration"` // Maximum video ad duration in seconds |
| 9 | + Protocol *int `json:"protocol,omitempty"` // Video bid response protocols |
| 10 | + Protocols []int `json:"protocols"` // Video bid response protocols |
| 11 | + W *int `json:"w,omitempty"` // Width of the player in pixels |
| 12 | + H *int `json:"h,omitempty"` // Height of the player in pixels |
| 13 | + Startdelay *int `json:"startdelay,omitempty"` // Indicates the start delay in seconds |
| 14 | + Linearity *int `json:"linearity,omitempty"` // Indicates whether the ad impression is linear or non-linear |
| 15 | + Sequence *int `json:"sequence,omitempty"` // Default: 1 |
| 16 | + Battr []int `json:"battr,omitempty"` // Blocked creative attributes |
| 17 | + Maxextended *int `json:"maxextended,omitempty"` // Maximum extended video ad duration |
| 18 | + Minbitrate *int `json:"minbitrate,omitempty"` // Minimum bit rate in Kbps |
| 19 | + Maxbitrate *int `json:"maxbitrate,omitempty"` // Maximum bit rate in Kbps |
| 20 | + Boxingallowed *int `json:"boxingallowed,omitempty"` // If exchange publisher has rules preventing letter boxing |
| 21 | + Playbackmethod []int `json:"playbackmethod,omitempty"` // List of allowed playback methods |
| 22 | + Delivery []int `json:"delivery,omitempty"` // List of supported delivery methods |
| 23 | + Pos *int `json:"pos,omitempty"` // Ad Position |
| 24 | + Companionad []Banner `json:"companionad,omitempty"` |
| 25 | + Api []int `json:"api,omitempty"` // List of supported API frameworks |
| 26 | + Companiontype []int `json:"companiontype,omitempty"` |
| 27 | + Ext Extensions `json:"ext,omitempty"` |
| 28 | +} |
| 29 | + |
| 30 | +// Returns the sequence number, with default fallback |
| 31 | +func (v *NativeVideo) Seq() int { |
| 32 | + if v.Sequence != nil { |
| 33 | + return *v.Sequence |
| 34 | + } |
| 35 | + return 1 |
| 36 | +} |
| 37 | + |
| 38 | +// Returns the boxing permission status, with default fallback |
| 39 | +func (v *NativeVideo) IsBoxingAllowed() bool { |
| 40 | + if v.Boxingallowed != nil { |
| 41 | + return *v.Boxingallowed == 1 |
| 42 | + } |
| 43 | + return true |
| 44 | +} |
| 45 | + |
| 46 | +// Returns the position, with default fallback |
| 47 | +func (v *NativeVideo) Position() int { |
| 48 | + if v.Pos != nil { |
| 49 | + return *v.Pos |
| 50 | + } |
| 51 | + return AD_POS_UNKNOWN |
| 52 | +} |
| 53 | + |
| 54 | +// Validates the object |
| 55 | +func (v *NativeVideo) Valid() (bool, error) { |
| 56 | + if len(v.Mimes) == 0 { |
| 57 | + return false, ErrInvalidVideoMimes |
| 58 | + } else if v.Linearity == nil { |
| 59 | + return false, ErrInvalidVideoLinearity |
| 60 | + } else if v.Minduration == nil { |
| 61 | + return false, ErrInvalidVideoMinduration |
| 62 | + } else if v.Maxduration == nil { |
| 63 | + return false, ErrInvalidVideoMaxduration |
| 64 | + } else if v.Protocol == nil { |
| 65 | + return false, ErrInvalidVideoProtocol |
| 66 | + } |
| 67 | + return true, nil |
| 68 | +} |
| 69 | + |
| 70 | +// Applies defaults |
| 71 | +func (v *NativeVideo) WithDefaults() *NativeVideo { |
| 72 | + if v.Sequence == nil { |
| 73 | + v.Sequence = new(int) |
| 74 | + *v.Sequence = 1 |
| 75 | + } |
| 76 | + if v.Boxingallowed == nil { |
| 77 | + v.Boxingallowed = new(int) |
| 78 | + *v.Boxingallowed = 1 |
| 79 | + } |
| 80 | + if v.Pos == nil { |
| 81 | + v.Pos = new(int) |
| 82 | + *v.Pos = AD_POS_UNKNOWN |
| 83 | + } |
| 84 | + return v |
| 85 | +} |
| 86 | + |
| 87 | +// Set the Linearity |
| 88 | +func (v *NativeVideo) SetLinearity(lin int) *NativeVideo { |
| 89 | + if v.Linearity == nil { |
| 90 | + v.Linearity = new(int) |
| 91 | + } |
| 92 | + *v.Linearity = lin |
| 93 | + return v |
| 94 | +} |
| 95 | + |
| 96 | +// Set the Minduration |
| 97 | +func (v *NativeVideo) SetMinduration(mdur int) *NativeVideo { |
| 98 | + if v.Minduration == nil { |
| 99 | + v.Minduration = new(int) |
| 100 | + } |
| 101 | + *v.Minduration = mdur |
| 102 | + return v |
| 103 | +} |
| 104 | + |
| 105 | +// Set the Maxduration |
| 106 | +func (v *NativeVideo) SetMaxduration(mdur int) *NativeVideo { |
| 107 | + if v.Maxduration == nil { |
| 108 | + v.Maxduration = new(int) |
| 109 | + } |
| 110 | + *v.Maxduration = mdur |
| 111 | + return v |
| 112 | +} |
| 113 | + |
| 114 | +// Set the Protocol |
| 115 | +func (v *NativeVideo) SetProtocol(p int) *NativeVideo { |
| 116 | + if v.Protocol == nil { |
| 117 | + v.Protocol = new(int) |
| 118 | + } |
| 119 | + *v.Protocol = p |
| 120 | + return v |
| 121 | +} |
0 commit comments