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 FCntVideoContentInfo.cpp
18 * @brief This is the implementation file for the %VideoContentInfo class.
20 * This file contains implementation of the %VideoContentInfo class.
23 #include <FBaseSysLog.h>
24 #include <FCntContentManagerUtil.h>
25 #include <FCntVideoMetadata.h>
27 #include <FIoDirectory.h>
28 #include <FSysEnvironment.h>
29 #include <FIo_FileImpl.h>
30 #include <FApp_AppInfo.h>
31 #include "FCnt_VideoContentInfoImpl.h"
34 using namespace Tizen::App;
35 using namespace Tizen::Base;
36 using namespace Tizen::Io;
37 using namespace Tizen::Locations;
38 using namespace Tizen::System;
40 namespace Tizen { namespace Content
43 _VideoContentInfoImpl::_VideoContentInfoImpl(void)
58 _VideoContentInfoImpl::~_VideoContentInfoImpl(void)
63 _VideoContentInfoImpl*
64 _VideoContentInfoImpl::GetInstance(VideoContentInfo& videoContentInfo)
66 return videoContentInfo.__pVideoContentInfoImpl;
69 const _VideoContentInfoImpl*
70 _VideoContentInfoImpl::GetInstance(const VideoContentInfo& videoContentInfo)
72 return videoContentInfo.__pVideoContentInfoImpl;
76 _VideoContentInfoImpl::Construct(const String& contentPath, const String& thumbnailPath, bool setGps)
79 int contentLength = 0;
80 FileAttributes attribute;
83 contentLength = contentPath.GetLength();
84 SysTryReturnResult(NID_CNT, _FileImpl::IsMediaPath(contentPath), E_INVALID_ARG,
85 "The contentPath should start with /Media or /Storagecard/Media.");
86 SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
87 "The file corresponding to contentPath could not be found.");
89 if (!thumbnailPath.IsEmpty())
92 "The thumbnailPath is not supported but you can get the thumbnail managed by Tizen from ContentInfo::GetThumbnailN().");
97 SysLog(NID_CNT, "The setGps is not supported.");
100 SetContentPath(contentPath);
101 SetContentType(CONTENT_TYPE_VIDEO);
107 _VideoContentInfoImpl::Construct(const String* pContentPath)
109 result r = E_SUCCESS;
111 if (pContentPath != null)
113 String contentPath(*pContentPath);
115 if (!_AppInfo::IsOspCompat())
117 if (!(contentPath.StartsWith(Environment::GetMediaPath(), 0)
118 || contentPath.StartsWith(Environment::GetExternalStoragePath(), 0)))
120 SysLogException(NID_CNT, E_INVALID_ARG, "[E_INVALID_ARG] The path is not supported.");
121 return E_INVALID_ARG;
127 if (contentPath.StartsWith(OSP_MEDIA_PHONE, 0))
129 // Because the content path is saved like /opt/media or /opt/storage/sdcard/ in SLP database,
130 // it should be converted in 2.0.
131 r = contentPath.Replace(OSP_MEDIA_PHONE, Environment::GetMediaPath());
132 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
134 else if (contentPath.StartsWith(OSP_MEDIA_MMC, 0))
136 r = contentPath.Replace(OSP_MEDIA_MMC, Environment::GetExternalStoragePath());
137 SysTryReturnResult(NID_CNT, !IsFailed(r), E_INVALID_ARG, "Construct() failed.");
141 SysLogException(NID_CNT, E_INVALID_ARG,
142 "[E_INVALID_ARG] The contentPath should start with /Media or /Storagecard/Media.");
143 return E_INVALID_ARG;
147 int length = contentPath.GetLength();
148 SysTryReturnResult(NID_CNT, length != 0, E_INVALID_ARG,
149 "The length of pContentPath is 0.");
150 SysTryReturnResult(NID_CNT, File::IsFileExist(contentPath), E_FILE_NOT_FOUND,
151 "The file corresponding to pContentPath could not be found.");
153 SetContentPath(contentPath);
154 SetContentType(CONTENT_TYPE_VIDEO);
158 SetContentType(CONTENT_TYPE_VIDEO);
165 _VideoContentInfoImpl::GetGenre(void) const
167 if (__genre.IsEmpty())
169 SysLog(NID_CNT, "Genre is empty.");
170 return String(L"Unknown");
177 _VideoContentInfoImpl::GetArtist(void) const
179 if (__artist.IsEmpty())
181 SysLog(NID_CNT, "Artist is empty.");
182 return String(L"Unknown");
189 _VideoContentInfoImpl::GetBitrate(void) const
191 return __audioBitrate;
195 _VideoContentInfoImpl::GetAudioBitrate(void) const
197 return __audioBitrate;
201 _VideoContentInfoImpl::GetVideoBitrate(void) const
203 return __videoBitrate;
207 _VideoContentInfoImpl::GetFramerate(void) const
213 _VideoContentInfoImpl::GetWidth(void) const
219 _VideoContentInfoImpl::GetHeight(void) const
225 _VideoContentInfoImpl::GetTitle(void) const
227 if (__title.IsEmpty())
229 SysLog(NID_CNT, "Title is empty.");
230 return String(L"Unknown");
237 _VideoContentInfoImpl::GetAlbumName(void) const
239 if (__albumName.IsEmpty())
241 SysLog(NID_CNT, "AlbumName is empty.");
242 return String(L"Unknown");
249 _VideoContentInfoImpl::GetDuration(void) const
255 _VideoContentInfoImpl::SetGenre(const Tizen::Base::String& genre)
261 _VideoContentInfoImpl::SetArtist(const Tizen::Base::String& artist)
267 _VideoContentInfoImpl::SetBitrate(int bitrate)
269 __audioBitrate = bitrate;
273 _VideoContentInfoImpl::SetAudioBitrate(int audioBitrate)
275 __audioBitrate = audioBitrate;
279 _VideoContentInfoImpl::SetVideoBitrate(int videoBitrate)
281 __videoBitrate = videoBitrate;
285 _VideoContentInfoImpl::SetFramerate(int framerate)
287 __framerate = framerate;
291 _VideoContentInfoImpl::SetWidth(int width)
297 _VideoContentInfoImpl::SetHeight(int height)
303 _VideoContentInfoImpl::SetTitle(const Tizen::Base::String& title)
309 _VideoContentInfoImpl::SetAlbumName(const Tizen::Base::String& albumName)
311 __albumName = albumName;
315 _VideoContentInfoImpl::SetDuration(long duration)
317 __duration = duration;