| 1 |
/* gstreamermm - a C++ wrapper for gstreamer |
| 2 |
* |
| 3 |
* Copyright 2008-2016 The gstreamermm Development Team |
| 4 |
* |
| 5 |
* This library is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU Lesser General Public |
| 7 |
* License as published by the Free Software Foundation; either |
| 8 |
* version 2.1 of the License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This library is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* Lesser General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU Lesser General Public |
| 16 |
* License along with this library; if not, write to the Free |
| 17 |
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| 18 |
*/ |
| 19 |
|
| 20 |
namespace Gst |
| 21 |
{ |
| 22 |
|
| 23 |
Fourcc::Fourcc() |
| 24 |
: first(0), second(0), third(0), fourth(0) |
| 25 |
{} |
| 26 |
|
| 27 |
Fourcc& Fourcc::operator=(const Fourcc& src) |
| 28 |
{ |
| 29 |
first = src.first; |
| 30 |
second = src.second; |
| 31 |
third = src.third; |
| 32 |
fourth = src.fourth; |
| 33 |
|
| 34 |
return *this; |
| 35 |
} |
| 36 |
|
| 37 |
Fourcc::Fourcc(char first, char second, char third, char fourth) |
| 38 |
: first(first), second(second), third(third), fourth(fourth) |
| 39 |
{} |
| 40 |
|
| 41 |
Fourcc::Fourcc(const Glib::ustring& s) |
| 42 |
: first(0), second(0), third(0), fourth(0) |
| 43 |
{ |
| 44 |
guint32 fourcc = GST_STR_FOURCC(s.c_str()); |
| 45 |
set_ccs(fourcc); |
| 46 |
|
| 47 |
} |
| 48 |
|
| 49 |
Fourcc::Fourcc(guint32 fourcc) |
| 50 |
: first(0), second(0), third(0), fourth(0) |
| 51 |
{ |
| 52 |
set_ccs(fourcc); |
| 53 |
} |
| 54 |
|
| 55 |
Fourcc::Fourcc(const Fourcc& f) |
| 56 |
: first(f.first), second(f.second), third(f.third), fourth(f.fourth) |
| 57 |
{} |
| 58 |
|
| 59 |
void Fourcc::set_ccs(guint32 fourcc) |
| 60 |
{ |
| 61 |
first = fourcc & 0xff; |
| 62 |
second = (fourcc >> 8) & 0xff; |
| 63 |
third = (fourcc >> 16) & 0xff; |
| 64 |
fourth = (fourcc >> 24) & 0xff; |
| 65 |
} |
| 66 |
|
| 67 |
|
| 68 |
Fraction::Fraction() |
| 69 |
: num(0), denom(1) |
| 70 |
{} |
| 71 |
|
| 72 |
Fraction::Fraction(int num, int denom) |
| 73 |
: num(num), denom(denom) |
| 74 |
{} |
| 75 |
|
| 76 |
Fraction::Fraction(const Fraction& src) |
| 77 |
: num(src.num), denom(src.denom) |
| 78 |
{} |
| 79 |
|
| 80 |
Fraction::Fraction(const Glib::ValueBase& value) |
| 81 |
: num(0), denom(1) |
| 82 |
{ |
| 83 |
if(GST_VALUE_HOLDS_FRACTION(value.gobj())) |
| 84 |
{ |
| 85 |
num = gst_value_get_fraction_numerator(value.gobj()); |
| 86 |
denom = gst_value_get_fraction_denominator(value.gobj()); |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
Fraction::Fraction(const GValue& value) |
| 91 |
: num(0), denom(1) |
| 92 |
{ |
| 93 |
//if(GST_VALUE_HOLDS_FRACTION(&value)) |
| 94 |
{ |
| 95 |
num = gst_value_get_fraction_numerator(&value); |
| 96 |
denom = gst_value_get_fraction_denominator(&value); |
| 97 |
} |
| 98 |
} |
| 99 |
|
| 100 |
Fraction& Fraction::operator=(const Fraction& src) |
| 101 |
{ |
| 102 |
num = src.num; |
| 103 |
denom = src.denom; |
| 104 |
|
| 105 |
return *this; |
| 106 |
} |
| 107 |
|
| 108 |
template <> |
| 109 |
void Range<int>::init_range(const GValue& value) |
| 110 |
{ |
| 111 |
if(G_VALUE_HOLDS(&value, GST_TYPE_INT_RANGE)) |
| 112 |
{ |
| 113 |
min = gst_value_get_int_range_min(&value); |
| 114 |
max = gst_value_get_int_range_max(&value); |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
template <> |
| 119 |
void Range<double>::init_range(const GValue& value) |
| 120 |
{ |
| 121 |
if(G_VALUE_HOLDS(&value, GST_TYPE_DOUBLE_RANGE)) |
| 122 |
{ |
| 123 |
min = gst_value_get_double_range_min(&value); |
| 124 |
max = gst_value_get_double_range_max(&value); |
| 125 |
} |
| 126 |
} |
| 127 |
|
| 128 |
template <> |
| 129 |
void Range<Gst::Fraction>::init_range(const GValue& value) |
| 130 |
{ |
| 131 |
if(G_VALUE_HOLDS(&value, GST_TYPE_FRACTION_RANGE)) |
| 132 |
{ |
| 133 |
const GValue* min = gst_value_get_fraction_range_min(&value); |
| 134 |
const GValue* max = gst_value_get_fraction_range_max(&value); |
| 135 |
|
| 136 |
this->min.num = gst_value_get_fraction_numerator(min); |
| 137 |
this->min.denom = gst_value_get_fraction_denominator(min); |
| 138 |
|
| 139 |
this->max.num = gst_value_get_fraction_numerator(max); |
| 140 |
this->max.denom = gst_value_get_fraction_denominator(max); |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
} //namespace Gst |
| 145 |
|
| 146 |
namespace Glib |
| 147 |
{ |
| 148 |
|
| 149 |
// static |
| 150 |
GType Value<Gst::Range<int>>::value_type() |
| 151 |
{ |
| 152 |
return GST_TYPE_INT_RANGE; |
| 153 |
} |
| 154 |
|
| 155 |
void Value<Gst::Range<int>>::set(const Gst::Range<int>& data) |
| 156 |
{ |
| 157 |
gst_value_set_int_range(&gobject_, data.min, data.max); |
| 158 |
} |
| 159 |
|
| 160 |
Gst::Range<int> Value<Gst::Range<int>>::get() const |
| 161 |
{ |
| 162 |
return Gst::Range<int>(gobject_); |
| 163 |
} |
| 164 |
|
| 165 |
// static |
| 166 |
GType Value<Gst::Range<double>>::value_type() |
| 167 |
{ |
| 168 |
return GST_TYPE_DOUBLE_RANGE; |
| 169 |
} |
| 170 |
|
| 171 |
void Value<Gst::Range<double>>::set(const Gst::Range<double>& data) |
| 172 |
{ |
| 173 |
gst_value_set_double_range(&gobject_, data.min, data.max); |
| 174 |
} |
| 175 |
|
| 176 |
Gst::Range<double> Value<Gst::Range<double>>::get() const |
| 177 |
{ |
| 178 |
return Gst::Range<double>(gobject_); |
| 179 |
} |
| 180 |
|
| 181 |
// static |
| 182 |
GType Value<Gst::Fraction>::value_type() |
| 183 |
{ |
| 184 |
return GST_TYPE_FRACTION; |
| 185 |
} |
| 186 |
|
| 187 |
void Value<Gst::Fraction>::set(const Gst::Fraction& data) |
| 188 |
{ |
| 189 |
gst_value_set_fraction(&gobject_, data.num, data.denom); |
| 190 |
} |
| 191 |
|
| 192 |
Gst::Fraction Value<Gst::Fraction>::get() const |
| 193 |
{ |
| 194 |
return Gst::Fraction(gobject_); |
| 195 |
} |
| 196 |
|
| 197 |
// static |
| 198 |
GType Value<Gst::Range<Gst::Fraction>>::value_type() |
| 199 |
{ |
| 200 |
return GST_TYPE_FRACTION_RANGE; |
| 201 |
} |
| 202 |
|
| 203 |
void Value<Gst::Range<Gst::Fraction>>::set(const Gst::Range<Gst::Fraction>& data) |
| 204 |
{ |
| 205 |
gst_value_set_fraction_range_full(&gobject_, data.min.num, data.min.denom, |
| 206 |
data.max.num, data.max.denom); |
| 207 |
} |
| 208 |
|
| 209 |
Gst::Range<Gst::Fraction> Value<Gst::Range<Gst::Fraction>>::get() const |
| 210 |
{ |
| 211 |
return Gst::Range<Gst::Fraction>(gobject_); |
| 212 |
} |
| 213 |
|
| 214 |
} // namespace Glib |