2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 * @file FCnt_VideoMetadataImpl.cpp
18 * @brief This is the implementation file for the %_VideoMetadataImpl class.
20 * This file contains implementation of the %_VideoMetadataImpl class.
23 #include <FBaseSysLog.h>
24 #include <FCntVideoMetadata.h>
25 #include <FCnt_VideoMetadataImpl.h>
26 #include <FGrp_BitmapImpl.h>
29 using namespace Tizen::Base;
30 using namespace Tizen::Graphics;
32 namespace Tizen { namespace Content
35 _VideoMetadataImpl::_VideoMetadataImpl(void)
38 unique_ptr<VideoMeta, VideoMetaDeleter> pNewVideoMeta(new (nothrow) VideoMeta());
39 if (pNewVideoMeta != null)
41 __pVideoMeta = move(pNewVideoMeta);
46 SysLog(NID_CNT, "The memory is insufficient.");
50 _VideoMetadataImpl::~_VideoMetadataImpl(void)
56 _VideoMetadataImpl::GetInstance(VideoMetadata& videoMetadata)
58 return videoMetadata.__pImpl;
61 const _VideoMetadataImpl*
62 _VideoMetadataImpl::GetInstance(const VideoMetadata& videoMetadata)
64 return videoMetadata.__pImpl;
68 _VideoMetadataImpl::SetVideoMetadata(const VideoMeta* pVideoMeta)
72 SysTryReturnResult(NID_CNT, pVideoMeta != null, E_INVALID_ARG, "pVideoMeta is null.");
74 __pVideoMeta->width = pVideoMeta->width;
75 __pVideoMeta->height = pVideoMeta->height;
76 __pVideoMeta->framerate = pVideoMeta->framerate;
77 __pVideoMeta->audioBitrate = pVideoMeta->audioBitrate;
78 __pVideoMeta->videoBitrate = pVideoMeta->videoBitrate;
79 __pVideoMeta->duration = pVideoMeta->duration;
80 __pVideoMeta->contentPath = pVideoMeta->contentPath;
82 if (pVideoMeta->pGenre != null)
84 __pVideoMeta->pGenre = new (nothrow) String(*(pVideoMeta->pGenre));
85 SysTryReturnResult(NID_CNT, __pVideoMeta->pGenre != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
87 if (pVideoMeta->pComment != null)
89 __pVideoMeta->pComment = new (nothrow) String(*(pVideoMeta->pComment));
90 SysTryReturnResult(NID_CNT, __pVideoMeta->pComment != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
92 if (pVideoMeta->pDescription != null)
94 __pVideoMeta->pDescription = new (nothrow) String(*(pVideoMeta->pDescription));
95 SysTryReturnResult(NID_CNT, __pVideoMeta->pDescription != null, E_OUT_OF_MEMORY, "The memory is insufficient.");
97 if (pVideoMeta->pAlbumArt != null)
99 __pVideoMeta->pAlbumArt = _BitmapImpl::CloneN(*(pVideoMeta->pAlbumArt));
100 if (__pVideoMeta->pAlbumArt == null)
102 SysLog(NID_CNT, "_BitmapImpl::CloneN failed.");
103 // Because album art is one of the metadata, it is not exception in this function but is exception in _AudioMetadataImpl::GetAlbumArtN().
111 _VideoMetadataImpl::GetVideoMetadata(void) const
113 return __pVideoMeta.get();
116 _VideoMetadataImpl::_VideoMetadataImpl(const _VideoMetadataImpl& rhs)
119 unique_ptr<VideoMeta, VideoMetaDeleter> pNewVideoMeta(new (nothrow) VideoMeta());
120 if (pNewVideoMeta != null)
122 pNewVideoMeta->width = (rhs.__pVideoMeta)->width;
123 pNewVideoMeta->height = (rhs.__pVideoMeta)->height;
124 pNewVideoMeta->framerate = (rhs.__pVideoMeta)->framerate;
125 pNewVideoMeta->audioBitrate = (rhs.__pVideoMeta)->audioBitrate;
126 pNewVideoMeta->videoBitrate = (rhs.__pVideoMeta)->videoBitrate;
127 pNewVideoMeta->duration = (rhs.__pVideoMeta)->duration;
128 pNewVideoMeta->contentPath = (rhs.__pVideoMeta)->contentPath;
131 if ((rhs.__pVideoMeta)->pGenre != null)
133 pNewVideoMeta->pGenre = new (nothrow) String(*((rhs.__pVideoMeta)->pGenre));
134 if (pNewVideoMeta->pGenre == null)
136 SysLog(NID_CNT, "The memory is insufficient.");
141 if ((rhs.__pVideoMeta)->pComment != null)
143 pNewVideoMeta->pComment = new (nothrow) String(*((rhs.__pVideoMeta)->pComment));
144 if (pNewVideoMeta->pComment == null)
146 SysLog(NID_CNT, "The memory is insufficient.");
151 if ((rhs.__pVideoMeta)->pDescription != null)
153 pNewVideoMeta->pDescription = new (nothrow) String(*((rhs.__pVideoMeta)->pDescription));
154 if (pNewVideoMeta->pDescription == null)
156 SysLog(NID_CNT, "The memory is insufficient.");
160 if ((rhs.__pVideoMeta)->pAlbumArt != null)
162 pNewVideoMeta->pAlbumArt = _BitmapImpl::CloneN(*((rhs.__pVideoMeta)->pAlbumArt));
163 if (pNewVideoMeta->pAlbumArt == null)
165 SysLog(NID_CNT, "The memory is insufficient.");
170 __pVideoMeta = move(pNewVideoMeta);
175 SysLog(NID_CNT, "The memory is insufficient.");
180 _VideoMetadataImpl::operator =(const _VideoMetadataImpl& rhs)
182 // check for self-assignment
189 if (__pVideoMeta != null && (rhs.__pVideoMeta) != null)
191 // DeleteMetadata(__pVideoMeta);
192 // __pVideoMeta = new (nothrow) VideoMeta;
194 __pVideoMeta.reset(new (nothrow) VideoMeta);
196 else if (__pVideoMeta != null)
198 //DeleteMetadata(__pVideoMeta);
200 __pVideoMeta.reset(null);
203 else if ((rhs.__pVideoMeta) != null)
205 //__pVideoMeta = new (nothrow) VideoMeta;
207 __pVideoMeta.reset(new (nothrow) VideoMeta);
211 // __pVideoMeta and rhs.__pVideoMeta are null.
215 __pVideoMeta->width = (rhs.__pVideoMeta)->width;
216 __pVideoMeta->height = (rhs.__pVideoMeta)->height;
217 __pVideoMeta->framerate = (rhs.__pVideoMeta)->framerate;
218 __pVideoMeta->audioBitrate = (rhs.__pVideoMeta)->audioBitrate;
219 __pVideoMeta->videoBitrate = (rhs.__pVideoMeta)->videoBitrate;
220 __pVideoMeta->duration = (rhs.__pVideoMeta)->duration;
221 __pVideoMeta->contentPath = (rhs.__pVideoMeta)->contentPath;
224 if (__pVideoMeta->pGenre != null && (rhs.__pVideoMeta)->pGenre != null)
226 // delete previous data
227 delete __pVideoMeta->pGenre;
228 __pVideoMeta->pGenre = null;
230 __pVideoMeta->pGenre = new String(*((rhs.__pVideoMeta)->pGenre));
232 else if (__pVideoMeta->pGenre != null)
234 delete __pVideoMeta->pGenre;
235 __pVideoMeta->pGenre = null;
237 else if ((rhs.__pVideoMeta)->pGenre != null)
239 __pVideoMeta->pGenre = new String(*((rhs.__pVideoMeta)->pGenre));
243 if (__pVideoMeta->pComment != null && (rhs.__pVideoMeta)->pComment != null)
245 // delete previous data
246 delete __pVideoMeta->pComment;
247 __pVideoMeta->pComment = null;
249 __pVideoMeta->pComment = new (nothrow) String(*((rhs.__pVideoMeta)->pComment));
251 else if (__pVideoMeta->pComment != null)
253 delete __pVideoMeta->pComment;
254 __pVideoMeta->pComment = null;
256 else if ((rhs.__pVideoMeta)->pComment != null)
258 __pVideoMeta->pComment = new (nothrow) String(*((rhs.__pVideoMeta)->pComment));
262 if (__pVideoMeta->pDescription != null && (rhs.__pVideoMeta)->pDescription != null)
264 // delete previous data
265 delete __pVideoMeta->pDescription;
266 __pVideoMeta->pDescription = null;
268 __pVideoMeta->pDescription = new (nothrow) String(*((rhs.__pVideoMeta)->pDescription));
270 else if (__pVideoMeta->pDescription != null)
272 delete __pVideoMeta->pDescription;
273 __pVideoMeta->pDescription = null;
275 else if ((rhs.__pVideoMeta)->pDescription != null)
277 __pVideoMeta->pDescription = new (nothrow) String(*((rhs.__pVideoMeta)->pDescription));
281 if (__pVideoMeta->pAlbumArt != null && (rhs.__pVideoMeta)->pAlbumArt != null)
283 // delete previous data
284 delete __pVideoMeta->pAlbumArt;
285 __pVideoMeta->pAlbumArt = null;
287 __pVideoMeta->pAlbumArt = _BitmapImpl::CloneN(*((rhs.__pVideoMeta)->pAlbumArt));
289 else if (__pVideoMeta->pAlbumArt != null)
291 delete __pVideoMeta->pAlbumArt;
292 __pVideoMeta->pAlbumArt = null;
294 else if ((rhs.__pVideoMeta)->pAlbumArt != null)
296 __pVideoMeta->pAlbumArt = _BitmapImpl::CloneN(*((rhs.__pVideoMeta)->pAlbumArt));
299 SysLog(NID_CNT, "_VideoMetadataImpl::operator =(const _VideoMetadataImpl& rhs) is called.");
304 _VideoMetadataImpl::Equals(const Tizen::Base::Object& rhs) const
306 const _VideoMetadataImpl* pRhs = dynamic_cast <const _VideoMetadataImpl*>(&rhs);
312 if (this->GetAudioBitrate() != pRhs->GetAudioBitrate())
316 if (this->GetDuration() != pRhs->GetDuration())
320 if (this->GetFramerate() != pRhs->GetFramerate())
324 if (!((this->GetGenre()).Equals(pRhs->GetGenre())))
328 if (!((this->GetComment()).Equals(pRhs->GetComment())))
332 if (!((this->GetDescription()).Equals(pRhs->GetDescription())))
336 if (this->GetHeight() != pRhs->GetHeight())
340 if (this->GetVideoBitrate() != pRhs->GetVideoBitrate())
344 if (this->GetWidth() != pRhs->GetWidth())
353 _VideoMetadataImpl::GetHashCode(void) const
355 return Integer::GetHashCode(this->GetAudioBitrate())
356 ^ Long::GetHashCode(this->GetDuration())
357 ^ Integer::GetHashCode(this->GetFramerate())
358 ^ (this->GetGenre()).GetHashCode()
359 ^ (this->GetComment()).GetHashCode()
360 ^ (this->GetDescription()).GetHashCode()
361 ^ Integer::GetHashCode(this->GetHeight())
362 ^ Integer::GetHashCode(this->GetVideoBitrate())
363 ^ Integer::GetHashCode(this->GetWidth());
367 _VideoMetadataImpl::GetWidth(void) const
369 if (__pVideoMeta == null)
371 SysLog(NID_CNT, "__pVideoMeta is null.");
374 return __pVideoMeta->width;
378 _VideoMetadataImpl::GetHeight(void) const
380 if (__pVideoMeta == null)
382 SysLog(NID_CNT, "__pVideoMeta is null.");
385 return __pVideoMeta->height;
389 _VideoMetadataImpl::GetDuration(void) const
391 if (__pVideoMeta == null)
393 SysLog(NID_CNT, "__pVideoMeta is null.");
396 return __pVideoMeta->duration;
400 _VideoMetadataImpl::GetFramerate(void) const
402 if (__pVideoMeta == null)
404 SysLog(NID_CNT, "__pVideoMeta is null.");
407 return __pVideoMeta->framerate;
411 _VideoMetadataImpl::GetAudioBitrate(void) const
413 if (__pVideoMeta == null)
415 SysLog(NID_CNT, "__pVideoMeta is null.");
418 return __pVideoMeta->audioBitrate;
422 _VideoMetadataImpl::GetVideoBitrate(void) const
424 if (__pVideoMeta == null)
426 SysLog(NID_CNT, "__pVideoMeta is null.");
429 return __pVideoMeta->videoBitrate;
433 _VideoMetadataImpl::GetGenre(void) const
435 if (__pVideoMeta == null || __pVideoMeta->pGenre == null)
437 SysLog(NID_CNT, "__pVideoMeta or __pVideoMeta->pGenre is null.");
440 return *(__pVideoMeta->pGenre);
444 _VideoMetadataImpl::GetComment(void) const
446 if (__pVideoMeta == null || __pVideoMeta->pComment == null)
448 SysLog(NID_CNT, "__pVideoMeta or __pVideoMeta->pComment is null.");
451 return *(__pVideoMeta->pComment);
455 _VideoMetadataImpl::GetDescription(void) const
457 if (__pVideoMeta == null || __pVideoMeta->pDescription == null)
459 SysLog(NID_CNT, "__pVideoMeta or __pVideoMeta->pDescription is null.");
462 return *(__pVideoMeta->pDescription);
471 _VideoMetadataImpl::GetAlbumArtN(void) const
473 // E_SUCCESS, E_DATA_NOT_FOUND, E_OUT_OF_MEMORY
477 if (__pVideoMeta == null || __pVideoMeta->pAlbumArt == null)
479 SysLogException(NID_CNT, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] __pVideoMeta or __pVideoMeta->pAlbumArt is null.");
483 Bitmap* pBitmap = _BitmapImpl::CloneN(*(__pVideoMeta->pAlbumArt));
484 SysTryReturn(NID_CNT, pBitmap != null, null, E_DATA_NOT_FOUND, "[E_DATA_NOT_FOUND] _BitmapImpl::CloneN failed.");