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 bool CMediaData::sm_GetMediaInfo(media_info_h media_h, void *dt)
39 md = (SMediaData *)dt;
41 media_info_get_display_name(media_h, &md->name);
42 media_info_get_file_path(media_h, &md->path);
43 media_info_get_modified_time(media_h, &md->time);
45 md->video = new CVideoData;
47 md->video->Update(media_h);
52 bool CMediaData::Create(const char *path)
60 r = media_filter_create(&filter);
61 if (r != MEDIA_CONTENT_ERROR_NONE) {
62 _ERR("Media Filter Creation Failed");
66 snprintf(buf, sizeof(buf), "MEDIA_PATH = \"%s\"", path);
68 r = media_filter_set_condition(filter, buf,
69 MEDIA_CONTENT_COLLATE_DEFAULT);
70 if (r != MEDIA_CONTENT_ERROR_NONE) {
71 _ERR("Fail to set filter condition");
72 media_filter_destroy(filter);
78 _ERR("allocation failed");
79 media_filter_destroy(filter);
87 media_content_connect();
89 r = media_info_foreach_media_from_db(filter, sm_GetMediaInfo, m);
90 if (r != MEDIA_CONTENT_ERROR_NONE) {
91 _ERR("MEDIA CONTENT ERROR: %d", r);
92 media_filter_destroy(filter);
93 media_content_disconnect();
101 media_filter_destroy(filter);
106 void CMediaData::Destroy(void)
110 media_content_disconnect();
121 const char *CMediaData::GetName(void)
128 const char *CMediaData::GetPath(void)
135 time_t CMediaData::GetTime(void)
142 int CMediaData::GetDuration(void)
146 return m->video->GetDuration();
149 int CMediaData::GetPosition(void)
153 return m->video->GetPosition();
156 int CMediaData::GetWidth(void)
160 return m->video->GetWidth();
163 int CMediaData::GetHeight(void)
167 return m->video->GetHeight();