Video.cpp 6.25 KB
Newer Older
atraczyk's avatar
atraczyk committed
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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
/**************************************************************************
* Copyright (C) 2016 by Savoir-faire Linux                                *
* Author: Jger Nicolas <nicolas.jager@savoirfairelinux.com>              *
* Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com>          *
*                                                                         *
* This program is free software; you can redistribute it and/or modify    *
* it under the terms of the GNU General Public License as published by    *
* the Free Software Foundation; either version 3 of the License, or       *
* (at your option) any later version.                                     *
*                                                                         *
* This program is distributed in the hope that it will be useful,         *
* but WITHOUT ANY WARRANTY; without even the implied warranty of          *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
* GNU General Public License for more details.                            *
*                                                                         *
* You should have received a copy of the GNU General Public License       *
* along with this program.  If not, see <http://www.gnu.org/licenses/>.   *
**************************************************************************/

#include "pch.h"

#include "Video.h"

using namespace RingClientUWP;
using namespace Video;

using namespace Platform;

/************************************************************
 *                                                          *
 *                         Size                             *
 *                                                          *
 ***********************************************************/

unsigned int
Video::Size::width()
{
    return m_Width;
}

unsigned int
Video::Size::height()
{
    return m_Height;
}

void
Video::Size::setWidth(unsigned int width)
{
    m_Width = width;
}

void
Video::Size::setHeight(unsigned int height)
{
    m_Height = height;
}

/************************************************************
 *                                                          *
 *                         Rate                             *
 *                                                          *
 ***********************************************************/

String^
Rate::name()
{
    return m_name;
}

unsigned int
Rate::value()
{
    return m_value;
}

void
Rate::setName(String^ name)
{
    m_name = name;
}

void
Rate::setValue(unsigned int value)
{
    m_value = value;
}

/************************************************************
 *                                                          *
 *                         Channel                          *
 *                                                          *
 ***********************************************************/
Channel::Channel()
{
    m_validResolutions = ref new Vector<Resolution^>();
}

String^
Channel::name()
{
    return m_name;
}

Resolution^
Channel::currentResolution()
{
    return m_currentResolution;
}

void
Channel::setName(String^ name)
{
    m_name = name;
}

void
Channel::setCurrentResolution(Resolution^ currentResolution)
{
    m_currentResolution = currentResolution;
}

Vector<Resolution^>^
Channel::resolutionList()
{
    return m_validResolutions;
}

/************************************************************
 *                                                          *
 *                         Resolution                       *
 *                                                          *
 ***********************************************************/

Resolution::Resolution()
{
    m_size = ref new Size();
    m_validRates = ref new Vector<Rate^>();
}

Resolution::Resolution(Video::Size^ size):
    m_size(size)
{ }

String^
Resolution::name()
{
148
    return size()->width().ToString() + "x" + size()->height().ToString();
atraczyk's avatar
atraczyk committed
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
}

Rate^
Resolution::activeRate()
{
    return m_currentRate;
}

Vector<Rate^>^
Resolution::rateList()
{
    return m_validRates;
}

Video::Size^
Resolution::size()
{
    return m_size;
}

String^
Resolution::format()
{
    return m_format;
}

void
Resolution::setWidth(int width)
{
    m_size->setWidth(width);
}

void
Resolution::setHeight(int height)
{
    m_size->setHeight(height);
}

void
Resolution::setFormat(String^ format)
{
    m_format = format;
}

bool
Resolution::setActiveRate(Rate^ rate)
{
196 197
    if (m_currentRate == rate)
        return false;
atraczyk's avatar
atraczyk committed
198

199 200 201
    m_currentRate = rate;
    // set camera device rate here
    return true;
atraczyk's avatar
atraczyk committed
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224
}

/************************************************************
 *                                                          *
 *                         Device                           *
 *                                                          *
 ***********************************************************/

Device::Device(String^ id)
{
    m_deviceId = id;
    m_channels = ref new Vector<Channel^>();
}

String^
Device::id()
{
    return m_deviceId;
}

Vector<Channel^>^
Device::channelList()
{
225
    return m_channels;
atraczyk's avatar
atraczyk committed
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
}

String^
Device::name()
{
    return m_name;
}

Channel^
Device::channel()
{
    return m_currentChannel;
}

bool
Device::setCurrentChannel(Channel^ channel)
{
    if (m_currentChannel == channel)
        return false;
    m_currentChannel = channel;
    return true;
}

void
Device::setName(String^ name)
{
    m_name = name;
}

void
Device::save()
{
}

bool
Device::isActive()
{
    return false;
264
    //return Video::DeviceModel::instance().activeDevice() == this;
atraczyk's avatar
atraczyk committed
265 266 267 268 269 270 271 272
}

void
Device::SetDeviceProperties(String^ format, int width, int height, int rate)
{
    auto rl = m_currentChannel->resolutionList();
    for (auto res : rl) {
        if (res->format() == format &&
273 274 275
                res->size()->width() == width &&
                res->size()->height() == height &&
                res->activeRate()->value() == rate)
atraczyk's avatar
atraczyk committed
276 277
        {
            m_currentChannel->setCurrentResolution(res);
278
            RingDebug::instance->WriteLine("SetDeviceProperties");
atraczyk's avatar
atraczyk committed
279 280 281 282
            return;
        }
    }
}