30
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: VideoCollectionUtils class definition*
|
|
15 |
*/
|
|
16 |
|
|
17 |
#ifndef __VIDEOCOLLECTIONUTILS_H__
|
|
18 |
#define __VIDEOCOLLECTIONUTILS_H__
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDES
|
|
22 |
#include <QObject>
|
|
23 |
#include <QString>
|
|
24 |
#include <mpxmedia.h>
|
|
25 |
|
|
26 |
class VideoCollectionUtils
|
|
27 |
{
|
|
28 |
|
|
29 |
/**
|
|
30 |
* disable copy-constructor and assignment operator
|
|
31 |
*/
|
|
32 |
Q_DISABLE_COPY(VideoCollectionUtils)
|
|
33 |
|
|
34 |
public:
|
|
35 |
|
|
36 |
|
|
37 |
/**
|
|
38 |
* Returns singleton instance for this class.
|
|
39 |
*
|
|
40 |
* @return The singleton instance.
|
|
41 |
*/
|
|
42 |
static VideoCollectionUtils& instance();
|
|
43 |
|
|
44 |
/**
|
|
45 |
* Gets QString value from provided media -object based on attribute provided
|
|
46 |
*
|
|
47 |
* @param CMPXMedia* pointer to media object from where to get data
|
|
48 |
* @param TMPXAttributeData& attribute to look for
|
|
49 |
* @param QString& wanted value
|
|
50 |
*
|
|
51 |
* @return bool true data value gotten ok
|
|
52 |
*/
|
|
53 |
template<class T>
|
|
54 |
bool mediaValue(const CMPXMedia *media, const TMPXAttributeData& attribute, QString& result)
|
|
55 |
{
|
|
56 |
bool status = false;
|
|
57 |
if( media && media->IsSupported(attribute))
|
|
58 |
{
|
|
59 |
HBufC* valueText = NULL;
|
|
60 |
valueText = media->ValueText( attribute ).Alloc();
|
|
61 |
if (valueText && valueText->Length() > 0)
|
|
62 |
{
|
|
63 |
// temp QString needed to make sure string is initialized correctly (Error #424)
|
|
64 |
QString text((QChar*)valueText->Des().Ptr(),valueText->Length());
|
|
65 |
result = text;
|
|
66 |
status = true;
|
|
67 |
}
|
|
68 |
delete valueText;
|
|
69 |
}
|
|
70 |
return status;
|
|
71 |
}
|
|
72 |
|
|
73 |
/**
|
|
74 |
* Gets typed value from provided media -object based on attribute provided
|
|
75 |
*
|
|
76 |
* @param CMPXMedia* pointer to media object from where to get data
|
|
77 |
* @param TMPXAttributeData& attribute to look for
|
|
78 |
* @param T& wanted value
|
|
79 |
*
|
|
80 |
* @return bool true data value gotten ok
|
|
81 |
*/
|
|
82 |
template<class T>
|
|
83 |
bool mediaValue(const CMPXMedia *media, const TMPXAttributeData& attribute, T& result)
|
|
84 |
{
|
|
85 |
bool status = false;
|
|
86 |
if(media && media->IsSupported(attribute))
|
|
87 |
{
|
|
88 |
T *pointer = 0;
|
|
89 |
pointer = media->Value<T>(attribute);
|
|
90 |
if(pointer)
|
|
91 |
{
|
|
92 |
result = *pointer;
|
|
93 |
status = true;
|
|
94 |
}
|
|
95 |
}
|
|
96 |
return status;
|
|
97 |
}
|
|
98 |
|
|
99 |
/**
|
|
100 |
* Gets typed pointer from provided media -object based on attribute provided
|
|
101 |
*
|
|
102 |
* @param CMPXMedia* pointer to media object from where to get data
|
|
103 |
* @param TMPXAttributeData& attribute to look for
|
|
104 |
*
|
|
105 |
* @return T* pointer to wanted data (NULL if does not succeed)
|
|
106 |
*/
|
|
107 |
template<class T>
|
|
108 |
T* mediaValuePtr(const CMPXMedia *media, const TMPXAttributeData& attribute)
|
|
109 |
{
|
|
110 |
T *pointer = 0;
|
|
111 |
if(media && media->IsSupported(attribute))
|
|
112 |
{
|
|
113 |
pointer = media->Value<T>(attribute);
|
|
114 |
}
|
|
115 |
return pointer;
|
|
116 |
}
|
|
117 |
|
|
118 |
/**
|
|
119 |
* Prepares length string from given value.
|
|
120 |
*
|
|
121 |
* @param length Length value in seconds.
|
|
122 |
* @return Length as string (for example "1min 45sec").
|
|
123 |
*/
|
|
124 |
QString prepareLengthString(quint32 length);
|
|
125 |
|
|
126 |
/**
|
|
127 |
* Prepares size string from the given value.
|
|
128 |
*
|
|
129 |
* @param size Size value in bytes
|
|
130 |
* @return Size as string (for example "450 kB").
|
|
131 |
*/
|
|
132 |
QString prepareSizeString(quint32 size);
|
|
133 |
|
|
134 |
|
|
135 |
private:
|
|
136 |
|
|
137 |
/**
|
|
138 |
* Default constructor
|
|
139 |
*/
|
|
140 |
VideoCollectionUtils();
|
|
141 |
|
|
142 |
/**
|
|
143 |
* Destructor
|
|
144 |
*/
|
|
145 |
~VideoCollectionUtils();
|
|
146 |
|
|
147 |
|
|
148 |
|
|
149 |
};
|
|
150 |
#endif // __VIDEOCOLLECTIONUTILS_H__
|
|
151 |
|
|
152 |
// End of file
|
|
153 |
|
|
154 |
|
|
155 |
|