2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 * @file FCnt_VideoMetadataImpl.cpp
19 * @brief This is the implementation file for the %_VideoMetadataImpl class.
21 * This file contains implementation of the %_VideoMetadataImpl class.
24 #include <FBaseSysLog.h>
25 #include <FCntVideoMetadata.h>
26 #include <FCnt_VideoMetadataImpl.h>
27 #include <FGrp_BitmapImpl.h>
30 using namespace Tizen::Base;
31 using namespace Tizen::Graphics;
33 namespace Tizen { namespace Content
36 _VideoMetadataImpl::_VideoMetadataImpl(void)
39 unique_ptr<VideoMeta, VideoMetaDeleter> pNewVideoMeta(new (nothrow) VideoMeta());
40 if (pNewVideoMeta != null)
42 __pVideoMeta = move(pNewVideoMeta);
47 SysLog(NID_CNT, "The memory is insufficient.");
51 _VideoMetadataImpl::~_VideoMetadataImpl(void)
57 _VideoMetadataImpl::GetInstance(VideoMetadata& videoMetadata)
59 return videoMetadata.__pImpl;
62 const _VideoMetadataImpl*
63 _VideoMetadataImpl::GetInstance(const VideoMetadata& videoMetadata)
65 return videoMetadata.__pImpl;
69 _VideoMetadataImpl::SetVideoMetadata(const VideoMeta* pVideoMeta)
73 SysTryReturnResult(NID_CNT, pVideoMeta != null, E_INVALID_ARG, "pVideoMeta is null.");
75 __pVideoMeta->width = pVideoMeta->width;
76 __pVideoMeta->height = pVideoMeta->height;
77 __pVideoMeta->framerate = pVideoMeta->framerate;
78 __pVideoMeta->audioBitrate = pVideoMeta->audioBitrate;
79 __pVideoMeta->videoBitrate = pVideoMeta->videoBitrate;
80 __pVideoMeta->duration = pVideoMeta->duration;
81 __pVideoMeta->contentPath = pVideoMeta->contentPath;
83 if (pVideoMeta->pGenre != null)
85 __pVideoMeta->pGenre = new (nothrow) String(*(pVideoMeta->pGenre));
86 SysTryReturnResult(NID_CNT, __pVideoMeta->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
88 if (pVideoMeta->pComment != null)
90 __pVideoMeta->pComment = new (nothrow) String(*(pVideoMeta->pComment));
91 SysTryReturnResult(NID_CNT, __pVideoMeta->pComment != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
93 if (pVideoMeta->pDescription != null)
95 __pVideoMeta->pDescription = new (nothrow) String(*(pVideoMeta->pDescription));
96 SysTryReturnResult(NID_CNT, __pVideoMeta->pDescription != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
98 if (pVideoMeta->pAlbumArt != null)
100 __pVideoMeta->pAlbumArt = _BitmapImpl::CloneN(*(pVideoMeta->pAlbumArt));
101 if (__pVideoMeta->pAlbumArt == null)
103 SysLog(NID_CNT, "_BitmapImpl::CloneN failed.");
104 // Because album art is one of the metadata, it is not exception in this function but is exception in _AudioMetadataImpl::GetAlbumArtN().
112 _VideoMetadataImpl::GetVideoMetadata(void) const
114 return __pVideoMeta.get();
117 _VideoMetadataImpl::_VideoMetadataImpl(const _VideoMetadataImpl& rhs)
120 unique_ptr<VideoMeta, VideoMetaDeleter> pNewVideoMeta(new (nothrow) VideoMeta());
121 if (pNewVideoMeta != null)
123 pNewVideoMeta->width = (rhs.__pVideoMeta)->width;
124 pNewVideoMeta->height = (rhs.__pVideoMeta)->height;
125 pNewVideoMeta->framerate = (rhs.__pVideoMeta)->framerate;
126 pNewVideoMeta->audioBitrate = (rhs.__pVideoMeta)->audioBitrate;
127 pNewVideoMeta->videoBitrate = (rhs.__pVideoMeta)->videoBitrate;
128 pNewVideoMeta->duration = (rhs.__pVideoMeta)->duration;
129 pNewVideoMeta->contentPath = (rhs.__pVideoMeta)->contentPath;
132 if ((rhs.__pVideoMeta)->pGenre != null)
134 pNewVideoMeta->pGenre = new (nothrow) String(*((rhs.__pVideoMeta)->pGenre));
135 if (pNewVideoMeta->pGenre == null)
137 SysLog(NID_CNT, "The memory is insufficient.");
142 if ((rhs.__pVideoMeta)->pComment != null)
144 pNewVideoMeta->pComment = new (nothrow) String(*((rhs.__pVideoMeta)->pComment));
145 if (pNewVideoMeta->pComment == null)
147 SysLog(NID_CNT, "The memory is insufficient.");
152 if ((rhs.__pVideoMeta)->pDescription != null)
154 pNewVideoMeta->pDescription = new (nothrow) String(*((rhs.__pVideoMeta)->pDescription));
155 if (pNewVideoMeta->pDescription == null)
157 SysLog(NID_CNT, "The memory is insufficient.");
161 if ((rhs.__pVideoMeta)->pAlbumArt != null)
163 pNewVideoMeta->pAlbumArt = _BitmapImpl::CloneN(*((rhs.__pVideoMeta)->pAlbumArt));
164 if (pNewVideoMeta->pAlbumArt == null)
166 SysLog(NID_CNT, "The memory is insufficient.");
171 __pVideoMeta = move(pNewVideoMeta);
176 SysLog(NID_CNT, "The memory is insufficient.");
181 _VideoMetadataImpl::operator =(const _VideoMetadataImpl& rhs)
183 // check for self-assignment
190 if (__pVideoMeta != null && (rhs.__pVideoMeta) != null)
192 // DeleteMetadata(__pVideoMeta);
193 // __pVideoMeta = new (nothrow) VideoMeta;
195 __pVideoMeta.reset(new (nothrow) VideoMeta);
197 else if (__pVideoMeta != null)
199 //DeleteMetadata(__pVideoMeta);
201 __pVideoMeta.reset(null);
204 else if ((rhs.__pVideoMeta) != null)
206 //__pVideoMeta = new (nothrow) VideoMeta;
208 __pVideoMeta.reset(new (nothrow) VideoMeta);
212 // __pVideoMeta and rhs.__pVideoMeta are null.
216 __pVideoMeta->width = (rhs.__pVideoMeta)->width;
217 __pVideoMeta->height = (rhs.__pVideoMeta)->height;
218 __pVideoMeta->framerate = (rhs.__pVideoMeta)->framerate;
219 __pVideoMeta->audioBitrate = (rhs.__pVideoMeta)->audioBitrate;
220 __pVideoMeta->videoBitrate = (rhs.__pVideoMeta)->videoBitrate;
221 __pVideoMeta->duration = (rhs.__pVideoMeta)->duration;
222 __pVideoMeta->contentPath = (rhs.__pVideoMeta)->contentPath;
225 if (__pVideoMeta->pGenre != null && (rhs.__pVideoMeta)->pGenre != null)
227 // delete previous data
228 delete __pVideoMeta->pGenre;
229 __pVideoMeta->pGenre = null;
231 __pVideoMeta->pGenre = new String(*((rhs.__pVideoMeta)->pGenre));
233 else if (__pVideoMeta->pGenre != null)
235 delete __pVideoMeta->pGenre;
236 __pVideoMeta->pGenre = null;
238 else if ((rhs.__pVideoMeta)->pGenre != null)
240 __pVideoMeta->pGenre = new String(*((rhs.__pVideoMeta)->pGenre));
244 if (__pVideoMeta->pComment != null && (rhs.__pVideoMeta)->pComment != null)
246 // delete previous data
247 delete __pVideoMeta->pComment;
248 __pVideoMeta->pComment = null;
250 __pVideoMeta->pComment = new (nothrow) String(*((rhs.__pVideoMeta)->pComment));
252 else if (__pVideoMeta->pComment != null)
254 delete __pVideoMeta->pComment;
255 __pVideoMeta->pComment = null;
257 else if ((rhs.__pVideoMeta)->pComment != null)
259 __pVideoMeta->pComment = new (nothrow) String(*((rhs.__pVideoMeta)->pComment));
263 if (__pVideoMeta->pDescription != null && (rhs.__pVideoMeta)->pDescription != null)
265 // delete previous data
266 delete __pVideoMeta->pDescription;
267 __pVideoMeta->pDescription = null;
269 __pVideoMeta->pDescription = new (nothrow) String(*((rhs.__pVideoMeta)->pDescription));
271 else if (__pVideoMeta->pDescription != null)
273 delete __pVideoMeta->pDescription;
274 __pVideoMeta->pDescription = null;
276 else if ((rhs.__pVideoMeta)->pDescription != null)
278 __pVideoMeta->pDescription = new (nothrow) String(*((rhs.__pVideoMeta)->pDescription));
282 if (__pVideoMeta->pAlbumArt != null && (rhs.__pVideoMeta)->pAlbumArt != null)
284 // delete previous data
285 delete __pVideoMeta->pAlbumArt;
286 __pVideoMeta->pAlbumArt = null;
288 __pVideoMeta->pAlbumArt = _BitmapImpl::CloneN(*((rhs.__pVideoMeta)->pAlbumArt));
290 else if (__pVideoMeta->pAlbumArt != null)
292 delete __pVideoMeta->pAlbumArt;
293 __pVideoMeta->pAlbumArt = null;
295 else if ((rhs.__pVideoMeta)->pAlbumArt != null)
297 __pVideoMeta->pAlbumArt = _BitmapImpl::CloneN(*((rhs.__pVideoMeta)->pAlbumArt));
300 SysLog(NID_CNT, "_VideoMetadataImpl::operator =(const _VideoMetadataImpl& rhs) is called.");
305 _VideoMetadataImpl::Equals(const Tizen::Base::Object& rhs) const
307 const _VideoMetadataImpl* pRhs = dynamic_cast <const _VideoMetadataImpl*>(&rhs);
313 if (this->GetAudioBitrate() != pRhs->GetAudioBitrate())
317 if (this->GetDuration() != pRhs->GetDuration())
321 if (this->GetFramerate() != pRhs->GetFramerate())
325 if (!((this->GetGenre()).Equals(pRhs->GetGenre())))
329 if (!((this->GetComment()).Equals(pRhs->GetComment())))
333 if (!((this->GetDescription()).Equals(pRhs->GetDescription())))
337 if (this->GetHeight() != pRhs->GetHeight())
341 if (this->GetVideoBitrate() != pRhs->GetVideoBitrate())
345 if (this->GetWidth() != pRhs->GetWidth())
354 _VideoMetadataImpl::GetHashCode(void) const
356 return Integer::GetHashCode(this->GetAudioBitrate())
357 ^ Long::GetHashCode(this->GetDuration())
358 ^ Integer::GetHashCode(this->GetFramerate())
359 ^ (this->GetGenre()).GetHashCode()
360 ^ (this->GetComment()).GetHashCode()
361 ^ (this->GetDescription()).GetHashCode()
362 ^ Integer::GetHashCode(this->GetHeight())
363 ^ Integer::GetHashCode(this->GetVideoBitrate())
364 ^ Integer::GetHashCode(this->GetWidth());
368 _VideoMetadataImpl::GetWidth(void) const
370 if (__pVideoMeta == null)
372 SysLog(NID_CNT, "__pVideoMeta is null.");
375 return __pVideoMeta->width;
379 _VideoMetadataImpl::GetHeight(void) const
381 if (__pVideoMeta == null)
383 SysLog(NID_CNT, "__pVideoMeta is null.");
386 return __pVideoMeta->height;
390 _VideoMetadataImpl::GetDuration(void) const
392 if (__pVideoMeta == null)
394 SysLog(NID_CNT, "__pVideoMeta is null.");
397 return __pVideoMeta->duration;
401 _VideoMetadataImpl::GetFramerate(void) const
403 if (__pVideoMeta == null)
405 SysLog(NID_CNT, "__pVideoMeta is null.");
408 return __pVideoMeta->framerate;
412 _VideoMetadataImpl::GetAudioBitrate(void) const
414 if (__pVideoMeta == null)
416 SysLog(NID_CNT, "__pVideoMeta is null.");
419 return __pVideoMeta->audioBitrate;
423 _VideoMetadataImpl::GetVideoBitrate(void) const
425 if (__pVideoMeta == null)
427 SysLog(NID_CNT, "__pVideoMeta is null.");
430 return __pVideoMeta->videoBitrate;
434 _VideoMetadataImpl::GetGenre(void) const
436 if (__pVideoMeta == null || __pVideoMeta->pGenre == null)
438 SysLog(NID_CNT, "__pVideoMeta or __pVideoMeta->pGenre is null.");
441 return *(__pVideoMeta->pGenre);
445 _VideoMetadataImpl::GetComment(void) const
447 if (__pVideoMeta == null || __pVideoMeta->pComment == null)
449 SysLog(NID_CNT, "__pVideoMeta or __pVideoMeta->pComment is null.");
452 return *(__pVideoMeta->pComment);
456 _VideoMetadataImpl::GetDescription(void) const
458 if (__pVideoMeta == null || __pVideoMeta->pDescription == null)
460 SysLog(NID_CNT, "__pVideoMeta or __pVideoMeta->pDescription is null.");
463 return *(__pVideoMeta->pDescription);
472 _VideoMetadataImpl::GetAlbumArtN(void) const
474 // E_SUCCESS, E_DATA_NOT_FOUND, E_OUT_OF_MEMORY
478 if (__pVideoMeta == null || __pVideoMeta->pAlbumArt == null)
480 SysLogException(NID_CNT, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] __pVideoMeta or __pVideoMeta->pAlbumArt is null.");
484 Bitmap* pBitmap = _BitmapImpl::CloneN(*(__pVideoMeta->pAlbumArt));
485 SysTryReturn(NID_CNT, pBitmap != null, null, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] _BitmapImpl::CloneN failed.");