~ubuntu-branches/ubuntu/trusty/digikam/trusty

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
148
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
/*
 *  Copyright (C) 2011 Tuomo Penttinen, all rights reserved.
 *
 *  Author: Tuomo Penttinen <tp@herqq.org>
 *
 *  This file is part of Herqq UPnP Av (HUPnPAv) library.
 *
 *  Herqq UPnP Av 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.
 *
 *  Herqq UPnP Av 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 Herqq UPnP Av. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef HSEEKINFO_H_
#define HSEEKINFO_H_

#include <HUpnpAv/HUpnpAv>

#include <QtCore/QString>
#include <QtCore/QSharedDataPointer>

namespace Herqq
{

namespace Upnp
{

namespace Av
{

/*!
 * \brief This is a convenience class for working with Seek Modes defined in the
 * AVTransport:2 specification.
 *
 * \headerfile hseekinfo.h HSeekMode
 *
 * \ingroup hupnp_av_avt
 *
 * \remarks This class is not thread-safe.
 */
class H_UPNP_AV_EXPORT HSeekMode
{

public:

    /*!
     * \brief This enumeration specifies the Seek Modes defined in the
     * AVTransport:2 specification.
     *
     * \remarks Many of the descriptions here are more or less direct quotes
     * from the AV Transport:2 specification, section 2.4.13.
     */
    enum Type
    {
        /*!
         * The seek mode is undefined.
         */
        Unknown = -1,

        /*!
         * Track number.
         *
         * Seeks to the beginning of a particular track number.
         *
         * For track-unaware media, special track number "0" is used to indicate
         * the end of the media and thus it is equivalent to the common
         * \e FastReverse VCR functionality. Similarly, track number "1" is
         * equivalent to the common \e FastForward functionality.
         */
        TrackNr = 0,

        /*!
         * Absolute time.
         *
         * The range is from "00:00:00" to the duration of the current media.
         */
        AbsTime,

        /*!
         * Relative time.
         *
         * Seeks within the current track on the current media. The range is
         * from "00:00:00" to the duration of the current track.
         */
        RelTime,

        /*!
         * Absolute count.
         *
         * The range is from 0 to 2147483646, where 0 corresponds to the beginning
         * of the media.
         */
        AbsCount,

        /*!
         * Relative count.
         *
         * Seeks within the current track on the current media. The range is
         * from 0 to the vendor-defined value that corresponds to the end
         * of the current track.
         */
        RelCount,

        /*!
         * Channel frequency.
         *
         * Seeks to the specified channel frequency.
         */
        ChannelFreq,

        /*!
         * Seeks to the pre-defined index at the current media, measured
         * from the beginning of the media.
         *
         * This value applies only track-unaware media and it assumes that the
         * media contains a set of subsequent "marks" that indicate some
         * relevant position on the media.
         *
         * For more information, see the AV Transport:2 specification, section
         * 2.4.13.
         */
        TapeIndex,

        /*!
         * Seeks to the pre-defined index at the current media, measured
         * from the current position on the media.
         *
         * This value applies only track-unaware media and it assumes that the
         * media contains a set of subsequent "marks" that indicate some
         * relevant position on the media.
         *
         * For more information, see the AV Transport:2 specification, section
         * 2.4.13.
         */
        RelTapeIndex,

        /*!
         * Seeks to the desired position, in terms of frames, measured
         * from the beginning of the media. The range of the target value
         * is from "0" to the total duration of the current media, expressed
         * in frames. The value has to be positive.
         */
        Frame,

        /*!
         * For track-aware media, seeks to the desired position in the current
         * track, in terms of frames, measured from the
         * beginning of the current track. The range for the target value
         * is from "0" to the duration of the current track,
         * measured in number of frames. For track-aware media, the target value
         * has to be positive.
         *
         * For track-unaware media (e.g. a single tape), the target value
         * contains the desired position, in terms of frames, measured from a
         * zero reference point on the media. The range for the Target
         * argument is from the beginning of the media, measured from the zero
         * reference point to the end of the media, also measured from the
         * zero reference point. For track-unaware media, the target value
         * can be negative. Indeed, when the zero reference point
         * does not coincide with the beginning of the media, all positions
         * before the zero reference point are expressed as negative
         * values.
         */
        RelFrame,

        /*!
         * Vendor-defined.
         */
        VendorDefined
    };

    Type m_type;
    QString m_typeAsString;

public:

    /*!
     * Creates a new, invalid instance.
     *
     * \sa isValid()
     */
    HSeekMode();

    /*!
     * \brief Creates a new instance.
     *
     * \param type specifies the seek mode.
     *
     * \sa isValid()
     */
    HSeekMode(Type type);

    /*!
     * Creates a new instance from the specified string.
     *
     * \param arg specifies the record quality mode. If the specified string does not
     * correspond to any Type value and the string is not empty, the type() is set to
     * HSeekMode::VendorDefined.
     *
     * \sa isValid()
     */
    HSeekMode(const QString&);

    /*!
     * \brief Indicates if the object is valid.
     *
     * \return \e true in case the object is valid, i.e. the type() is
     * not HSeekMode::Undefined.
     */
    inline bool isValid() const { return m_type != Unknown; }

    /*!
     * \brief Returns a string representation of the object.
     *
     * \return a string representation of the object.
     */
    QString toString() const;

    /*!
     * \brief Returns the Type value.
     *
     * \return The Type value.
     */
    inline Type type() const { return m_type; }

    /*!
     * Converts the specified Type value to string.
     *
     * \param type specifies the Type value to be converted to string.
     *
     * \return a string representation of the specified Type value.
     */
    static QString toString(Type type);

    /*!
     * \brief Returns a Type value corresponding to the specified string, if any.
     *
     * \param type specifies the Type as string.
     *
     * \return a Type value corresponding to the specified string, if any.
     */
    static Type fromString(const QString& type);
};

/*!
 * Compares the two objects for equality.
 *
 * \return \e true in case the objects are logically equivalent.
 *
 * \relates HSeekMode
 */
H_UPNP_AV_EXPORT bool operator==(const HSeekMode& obj1, const HSeekMode& obj2);

/*!
 * Compares the two objects for inequality.
 *
 * \return \e true in case the objects are not logically equivalent.
 *
 * \relates HSeekMode
 */
inline bool operator!=(const HSeekMode& obj1, const HSeekMode& obj2)
{
    return !(obj1 == obj2);
}

class HSeekInfoPrivate;

/*!
 * \brief This class is used to contain information that is required to run a
 * AVTransport seek() operation.
 *
 * \headerfile hseekinfo.h HSeekInfo
 *
 * \ingroup hupnp_av_avt
 *
 * \remarks This class is not thread-safe.
 *
 * \sa HAbstractTransportService::seek(), HAvTransportAdapter::seek()
 */
class H_UPNP_AV_EXPORT HSeekInfo
{

private:

    QSharedDataPointer<HSeekInfoPrivate> h_ptr;

public:

    /*!
     * Creates a new, invalid instance.
     *
     * \sa isValid()
     */
    HSeekInfo();

    /*!
     * \brief Creates a new instance.
     *
     * \param unit specifies how the \a target value should be interpreted.
     *
     * \param target specifies the value that indicates the target position.
     *
     * \sa isValid()
     */
    HSeekInfo(const HSeekMode& unit, const QString& target);

    /*!
     * \brief Copy constructor.
     *
     * Creates a copy of \c other.
     */
    HSeekInfo(const HSeekInfo&);

    /*!
     * \brief Assignment operator.
     *
     * Copies the contents of \c other to this.
     *
     * \return a reference to this.
     */
    HSeekInfo& operator=(const HSeekInfo&);

    /*!
     * \brief Destroys the instance.
     */
    ~HSeekInfo();

    /*!
     * \brief Indicates if the object is valid.
     *
     * \return \e true in case the object is valid, i.e. unit() is
     * not valid.
     */
    bool isValid() const;

    /*!
     * \brief Returns the seek mode, which indicates how the target() value should be
     * interpreted.
     *
     * \return The seek mode, which indicates how the target() value should be
     * interpreted.
     */
    HSeekMode unit() const;

    /*!
     * \brief Returns the value that indicates the target position.
     *
     * \return The value that indicates the target position.
     */
    QString target() const;
};

/*!
 * Compares the two objects for equality.
 *
 * \return \e true in case the objects are logically equivalent.
 *
 * \relates HSeekInfo
 */
H_UPNP_AV_EXPORT bool operator==(const HSeekInfo& obj1, const HSeekInfo& obj2);

/*!
 * Compares the two objects for inequality.
 *
 * \return \e true in case the objects are not logically equivalent.
 *
 * \relates HSeekInfo
 */
inline bool operator!=(const HSeekInfo& obj1, const HSeekInfo& obj2)
{
    return !(obj1 == obj2);
}

}
}
}

#endif /* HSEEKINFO_H_ */