2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
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 #include <Elementary.h>
19 #include <media_content.h>
20 #include <AppCommon.h>
23 #include "mediadata.h"
24 #include "videodata.h"
33 CMediaData::CMediaData(void)
36 media_content_connect();
39 CMediaData::~CMediaData(void)
41 media_content_disconnect();
44 bool CMediaData::sm_GetMediaInfo(media_info_h media_h, void *dt)
48 md = (SMediaData *)dt;
50 media_info_get_display_name(media_h, &md->name);
51 media_info_get_file_path(media_h, &md->path);
52 media_info_get_modified_time(media_h, &md->time);
54 md->video = new CVideoData;
55 md->video->Update(media_h);
60 bool CMediaData::Create(const char *path)
68 r = media_filter_create(&filter);
69 if (r != MEDIA_CONTENT_ERROR_NONE) {
70 _ERR("Media Filter Creation Failed");
74 snprintf(buf, sizeof(buf), "MEDIA_PATH = \"%s\"", path);
76 r = media_filter_set_condition(filter, buf,
77 MEDIA_CONTENT_COLLATE_DEFAULT);
78 if (r != MEDIA_CONTENT_ERROR_NONE) {
79 _ERR("Fail to set filter condition");
80 media_filter_destroy(filter);
86 _ERR("allocation failed");
90 r = media_info_foreach_media_from_db(filter, sm_GetMediaInfo, m);
91 if (r != MEDIA_CONTENT_ERROR_NONE) {
92 _ERR("MEDIA CONTENT ERROR: %d", r);
93 media_filter_destroy(filter);
101 media_filter_destroy(filter);
106 void CMediaData::Destroy(void)
120 const char *CMediaData::GetName(void)
127 const char *CMediaData::GetPath(void)
134 time_t CMediaData::GetTime(void)
141 int CMediaData::GetDuration(void)
145 return m->video->GetDuration();
148 int CMediaData::GetPosition(void)
152 return m->video->GetPosition();
155 int CMediaData::GetWidth(void)
159 return m->video->GetWidth();
162 int CMediaData::GetHeight(void)
166 return m->video->GetHeight();