QtFit  0.1
Internal library development documentation
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
videomessage.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2021 Paul Colby
3 
4  This file is part of QtFit.
5 
6  QtFit is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  QtFit is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with QtFit. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 /*!
21  * \file
22  * \note This file is automatcially generated. Any changes here are likely to be overwritten.
23  */
24 
25 /*!
26  * \file
27  * Defines the VideoMessage, and VideoMessagePrivate classes.
28  */
29 
30 #include "videomessage.h"
31 #include "videomessage_p.h"
32 
33 #include <QDebug>
34 #include <QtEndian>
35 
37 
38 /*!
39  * \class VideoMessage
40  *
41  * The VideoMessage class represents a FIT VideoMessage data message.
42  *
43  * \sa DataMessage
44  */
45 
46 /*!
47  * Constructs a VideoMessage object.
48  *
49  * Typically, instances of this class will be returned by FitStreamReader::readNext, but this
50  * constructor may be used, along with the relevant setter methods, to create a valid message.
51  */
53 {
54 
55 }
56 
57 /*!
58  * \internal
59  *
60  * Constructs a VideoMessage object with private implementation \a d.
61  *
62  * \param d Pointer to private implementation.
63  */
65 {
66 
67 }
68 
69 /*!
70  * Returns the VideoMessage data message's \c url field's current value.
71  *
72  * \return the \c url field value.
73  */
74 QString VideoMessage::url() const
75 {
76  Q_D(const VideoMessage);
77  return d->url;
78 }
79 
80 /*!
81  * Returns the VideoMessage data message's \c hostingProvider field's current value.
82  *
83  * \return the \c hostingProvider field value.
84  */
86 {
87  Q_D(const VideoMessage);
88  return d->hostingProvider;
89 }
90 
91 /*!
92  * Returns the VideoMessage data message's \c duration field's current value.
93  *
94  * Playback time of video
95  *
96  * \return the \c duration field value.
97  */
98 quint32 VideoMessage::duration() const
99 {
100  Q_D(const VideoMessage);
101  return d->duration;
102 }
103 
104 /*!
105  * Sets the \c url field to \a url.
106  *
107  * \param url The field value to set.
108  */
109 void VideoMessage::setUrl(const QString url)
110 {
111  Q_D(VideoMessage);
112  d->url = url;
113 }
114 /*!
115  * Sets the \c hostingProvider field to \a hostingProvider.
116  *
117  * \param hostingProvider The field value to set.
118  */
119 void VideoMessage::setHostingProvider(const QString hostingProvider)
120 {
121  Q_D(VideoMessage);
122  d->hostingProvider = hostingProvider;
123 }
124 /*!
125  * Sets the \c duration field to \a duration.
126  *
127  * \param duration The field value to set.
128  */
129 void VideoMessage::setDuration(const quint32 duration)
130 {
131  Q_D(VideoMessage);
132  d->duration = duration;
133 }
134 
135 /// \cond internal
136 
137 /*!
138  * \internal
139  *
140  * \class VideoMessagePrivate
141  *
142  * The VideoMessagePrivate class provides private implementation for the VideoMessage.
143  *
144  * \sa VideoMessage
145  */
146 
147 /*!
148  * \internal
149  *
150  * Constructs a VideoMessagePrivate object with public implementation \a q.
151  *
152  * \param q Pointer to public implementaton.
153  */
154 VideoMessagePrivate::VideoMessagePrivate(VideoMessage * const q)
156  , duration(0xFFFFFFFF)
157 {
158  globalMessageNumber = MesgNum::Video;
159 }
160 
161 /*!
162  * \internal
163  *
164  * Destroys the VideoMessagePrivate object.
165  */
167 {
168 
169 }
170 
172  const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian)
173 {
174  switch (fieldId) {
175  case 0: // See Profile.xlsx::Messages:video.url
176  if (!verify(data, baseType, 1, FitBaseType::String, "video.url")) return false;
177  this->url = QString::fromUtf8(data);
178  break;
179  case 1: // See Profile.xlsx::Messages:video.hostingProvider
180  if (!verify(data, baseType, 1, FitBaseType::String, "video.hostingProvider")) return false;
181  this->hostingProvider = QString::fromUtf8(data);
182  break;
183  case 2: // See Profile.xlsx::Messages:video.duration
184  if (!verify(data, baseType, 4, FitBaseType::Uint32, "video.duration")) return false;
185  this->duration = static_cast<quint32>(bigEndian ? qFromBigEndian<quint32>(data) : qFromLittleEndian<quint32>(data));
186  break;
187  default:
188  qWarning() << "ignoring unknown video message field number" << fieldId << bigEndian;
189  // Fall through to return true, as its still 'safe' to continue parsing data messages.
190  }
191  return true;
192 }
193 
194 /// \endcond
195 
#define QTFIT_END_NAMESPACE
Macro for ending the QtFit library's top-most namespace (if one is defined).
Definition: QtFit_global.h:78
#define QTFIT_BEGIN_NAMESPACE
Macro for starting the QtFit library's top-most namespace (if one is defined).
Definition: QtFit_global.h:77
MesgNum globalMessageNumber
FIT Globla Message Number for this FIT Data Message.
bool verify(const QByteArray &data, const FitBaseType actualType, const int expectedSize, const FitBaseType expectedType, const char *messageFieldName)
The AbstractDataMessage class is the polymorphic base class for all FIT Data Message classes.
bool setField(const int fieldId, const QByteArray &data, const FitBaseType baseType, const bool bigEndian) override
QString hostingProvider
The VideoMessage FIT message's hostingProvider field.
virtual ~VideoMessagePrivate()
QString url
The VideoMessage FIT message's url field.
quint32 duration
The VideoMessage FIT message's duration field.
The VideoMessage class represents a FIT VideoMessage data message.
Definition: videomessage.h:39
void setUrl(const QString url)
Sets the url field to url.
QString url() const
Returns the VideoMessage data message's url field's current value.
QString hostingProvider() const
Returns the VideoMessage data message's hostingProvider field's current value.
void setHostingProvider(const QString hostingProvider)
Sets the hostingProvider field to hostingProvider.
VideoMessage()
Constructs a VideoMessage object.
void setDuration(const quint32 duration)
Sets the duration field to duration.
quint32 duration() const
Returns the VideoMessage data message's duration field's current value.
FitBaseType
Garmin FIT FitBaseType type.
Definition: types.h:3388
Declares the VideoMessage class.
Declares the VideoMessagePrivate class.