#ifndef __MEDIADATA_H__
#define __MEDIADATA_H__
-#include <media_content.h>
-#include "videodata.h"
-
-struct mediadata;
-
-int mediadata_init();
-int mediadata_fini();
-
-struct mediadata *mediadata_create(const char *path);
-void mediadata_destroy(struct mediadata *md);
-
-const char *mediadata_get_displayname(struct mediadata *md);
-const char *mediadata_get_filepath(struct mediadata *md);
-time_t mediadata_get_modifiedtime(struct mediadata *md);
-
-const struct videodata *mediadata_get_video_info(struct mediadata *md);
+struct SMediaData;
+
+class CMediaData {
+private:
+ SMediaData *m;
+
+private:
+ static bool sm_GetMediaInfo(media_info_h media_h, void *dt);
+
+public:
+ CMediaData(void);
+ virtual ~CMediaData(void);
+
+ bool Create(const char *path);
+ void Destroy(void);
+
+ const char *GetName(void);
+ const char *GetPath(void);
+ time_t GetTime(void);
+ int GetDuration(void);
+ int GetPosition(void);
+ int GetWidth(void);
+ int GetHeight(void);
+};
#endif
#ifndef __VIDEODATA_H__
#define __VIDEODATA_H__
-#include <media_content.h>
-
-struct videodata;
-
-struct videodata *videodata_create(media_info_h media_h);
-
-void videodata_destroy(struct videodata *video_info);
-
-int videodata_get_duration(const struct videodata *video_info);
-int videodata_get_played_position(const struct videodata *video_info);
-
-int videodata_get_width(const struct videodata *video_info);
-int videodata_get_height(const struct videodata *video_info);
+class CVideoData {
+private:
+ int duration;
+ int position;
+ int width;
+ int height;
+
+public:
+ CVideoData(void);
+ virtual ~CVideoData(void) {}
+
+ bool Update(media_info_h media_h);
+
+ int GetDuration(void);
+ int GetPosition(void);
+ int GetWidth(void);
+ int GetHeight(void);
+};
#endif
bool m_UiInit(void);
bool m_AddControls(void);
void m_UpdateInfoBar(void);
- void m_UpdateInfoBar(struct mediadata *md);
bool m_PlayerInit(void);
void m_ShowBar(void);
void m_HideBar(void);
#include <Elementary.h>
#include <Eina.h>
+#include <media_content.h>
+#include <AppCommon.h>
#include <dbg.h>
#include "define.h"
#include "mediadata.h"
+#include "videodata.h"
-struct mediadata {
+struct SMediaData {
char *name;
char *path;
- time_t modified;
- struct videodata *video_info;
+ time_t time;
+ CVideoData *video;
};
-static int g_ref_count;
-
-int mediadata_init(void)
-{
- int r;
-
- if (g_ref_count > 0) {
- g_ref_count++;
- return -1;
- }
-
- r = media_content_connect();
- if (r != MEDIA_CONTENT_ERROR_NONE) {
- _ERR("Media Content Connect Failed");
- return -1;
- }
- g_ref_count++;
-
- return 0;
-}
-
-int mediadata_fini(void)
+CMediaData::CMediaData(void)
{
- int r;
-
- if (g_ref_count <= 0)
- return -1;
-
- g_ref_count--;
-
- if (g_ref_count == 0) {
- r = media_content_disconnect();
- if (r != MEDIA_CONTENT_ERROR_NONE) {
- _ERR("Media Content Connect Failed");
- return -1;
- }
- }
-
- return 0;
+ m = NULL;
+ media_content_connect();
}
-static void _free_mediadata_item(struct mediadata *md)
+CMediaData::~CMediaData(void)
{
- free(md->name);
- free(md->path);
-
- videodata_destroy(md->video_info);
-
- free(md);
+ media_content_disconnect();
}
-static bool _get_each_media_info(media_info_h media_h, void *dt)
+bool CMediaData::sm_GetMediaInfo(media_info_h media_h, void *dt)
{
- struct mediadata *md;
- int r;
+ SMediaData *md;
- md = *((struct mediadata **)dt);
+ md = (SMediaData *)dt;
- r = media_info_get_display_name(media_h, &(md->name));
- if (r != MEDIA_CONTENT_ERROR_NONE)
- goto error;
+ media_info_get_display_name(media_h, &md->name);
+ media_info_get_file_path(media_h, &md->path);
+ media_info_get_modified_time(media_h, &md->time);
- r = media_info_get_file_path(media_h, &(md->path));
- if (r != MEDIA_CONTENT_ERROR_NONE)
- goto error;
-
- r = media_info_get_modified_time(media_h, &(md->modified));
- if (r != MEDIA_CONTENT_ERROR_NONE)
- goto error;
-
- md->video_info = videodata_create(media_h);
- if (!md->video_info)
- goto error;
+ md->video = new CVideoData;
+ md->video->Update(media_h);
return true;
-
-error:
- _free_mediadata_item(md);
- return false;
}
-struct mediadata *mediadata_create(const char *path)
+bool CMediaData::Create(const char *path)
{
+ ASSERT(!m);
+
filter_h filter;
- struct mediadata *md;
char buf[1024];
int r;
r = media_filter_create(&filter);
if (r != MEDIA_CONTENT_ERROR_NONE) {
_ERR("Media Filter Creation Failed");
- return NULL;
+ return false;
}
snprintf(buf, sizeof(buf), "MEDIA_PATH = \"%s\"", path);
if (r != MEDIA_CONTENT_ERROR_NONE) {
_ERR("Fail to set filter condition");
media_filter_destroy(filter);
- return NULL;
+ return false;
}
- md = (mediadata *)calloc(1, sizeof(*md));
- if (!md) {
+ m = new SMediaData;
+ if (!m) {
_ERR("allocation failed");
- return NULL;
+ return false;
}
- r = media_info_foreach_media_from_db(filter,
- _get_each_media_info, &md);
+ r = media_info_foreach_media_from_db(filter, sm_GetMediaInfo, m);
if (r != MEDIA_CONTENT_ERROR_NONE) {
if (r == MEDIA_CONTENT_ERROR_DB_FAILED)
_ERR("MEDIA CONTENT ERROR DB FAILED");
else
_ERR("MEDIA CONTENT ERROR");
- free(md);
media_filter_destroy(filter);
- return NULL;
+ delete m;
+ m = NULL;
+
+ return false;
}
media_filter_destroy(filter);
- return md;
+ return true;
+}
+
+void CMediaData::Destroy(void)
+{
+ ASSERT(m);
+
+ free(m->name);
+ free(m->path);
+
+ delete m->video;
+ m->video = NULL;
+
+ delete m;
+ m = NULL;
+}
+
+const char *CMediaData::GetName(void)
+{
+ ASSERT(m);
+
+ return m->name;
+}
+
+const char *CMediaData::GetPath(void)
+{
+ ASSERT(m);
+
+ return m->path;
}
-void mediadata_destroy(struct mediadata *md)
+time_t CMediaData::GetTime(void)
{
- if (!md)
- return;
+ ASSERT(m);
- _free_mediadata_item(md);
+ return m->time;
}
-const char *mediadata_get_displayname(struct mediadata *md)
+int CMediaData::GetDuration(void)
{
- if (!md)
- return NULL;
+ ASSERT(m);
- return md->name;
+ return m->video->GetDuration();
}
-const char *mediadata_get_filepath(struct mediadata *md)
+int CMediaData::GetPosition(void)
{
- if (!md)
- return NULL;
+ ASSERT(m);
- return md->path;
+ return m->video->GetPosition();
}
-time_t mediadata_get_modifiedtime(struct mediadata *md)
+int CMediaData::GetWidth(void)
{
- if (!md)
- return -1;
+ ASSERT(m);
- return md->modified;
+ return m->video->GetWidth();
}
-const struct videodata *mediadata_get_video_info(struct mediadata *md)
+int CMediaData::GetHeight(void)
{
- if (!md)
- return NULL;
+ ASSERT(m);
- return md->video_info;
+ return m->video->GetHeight();
}
#include <Elementary.h>
#include <Eina.h>
+#include <media_content.h>
#include <dbg.h>
#include "define.h"
#include "videodata.h"
-struct videodata {
- int duration;
- int position;
- int width;
- int height;
-};
-
-void videodata_destroy(struct videodata *video_info)
+CVideoData::CVideoData(void)
{
- free(video_info);
- video_info = NULL;
+ duration = 0;
+ position = 0;
+ width = 0;
+ height = 0;
}
-struct videodata *videodata_create(media_info_h media_h)
+bool CVideoData::Update(media_info_h media_h)
{
int r;
- struct videodata *video_info;
video_meta_h video_h;
if (!media_h)
- return NULL;
+ return false;
r = media_info_get_video(media_h, &video_h);
if (r != MEDIA_CONTENT_ERROR_NONE || !video_h) {
_ERR("Media video handle fetch error");
- return NULL;
+ return false;
}
- video_info = (videodata *)calloc(1, sizeof(*video_info));
- if (!video_info)
- goto error;
-
- r = video_meta_get_duration(video_h, &video_info->duration);
+ r = video_meta_get_duration(video_h, &duration);
if (r != MEDIA_CONTENT_ERROR_NONE) {
_ERR("video meta get duration error");
- goto error;
+ video_meta_destroy(video_h);
+ return false;
}
- r = video_meta_get_width(video_h, &video_info->width);
+ r = video_meta_get_width(video_h, &width);
if (r != MEDIA_CONTENT_ERROR_NONE) {
_ERR("video meta get width error");
- goto error;
+ video_meta_destroy(video_h);
+ return false;
}
- r = video_meta_get_height(video_h, &video_info->height);
+ r = video_meta_get_height(video_h, &height);
if (r != MEDIA_CONTENT_ERROR_NONE) {
_ERR("video meta get width error");
- goto error;
+ video_meta_destroy(video_h);
+ return false;
}
- r = video_meta_get_played_position(video_h, &video_info->position);
+ r = video_meta_get_played_position(video_h, &position);
if (r != MEDIA_CONTENT_ERROR_NONE) {
_ERR("video meta get played position error");
- goto error;
+ video_meta_destroy(video_h);
+ return false;
}
video_meta_destroy(video_h);
- return video_info;
-
-error:
- video_meta_destroy(video_h);
- videodata_destroy(video_info);
-
- return NULL;
+ return true;
}
-int videodata_get_duration(const struct videodata *video_info)
+int CVideoData::GetDuration(void)
{
- if (!video_info)
- return -1;
-
- return video_info->duration;
+ return duration;
}
-int videodata_get_played_position(const struct videodata *video_info)
+int CVideoData::GetPosition(void)
{
- if (!video_info)
- return -1;
-
- return video_info->position;
+ return position;
}
-int videodata_get_width(const struct videodata *video_info)
+int CVideoData::GetWidth(void)
{
- if (!video_info)
- return -1;
-
- return video_info->width;
+ return width;
}
-int videodata_get_height(const struct videodata *video_info)
+int CVideoData::GetHeight(void)
{
- if (!video_info)
- return -1;
-
- return video_info->height;
+ return width;
}
#include <ViewMgr.h>
#include <BaseView.h>
#include <InputHandler.h>
+#include <media_content.h>
#include <dbg.h>
#include "define.h"
#include "i18n.h"
Evas_Object *base;
char *id;
- struct playermgr *player;
+ playermgr *player;
CVolume *volume;
CVideoController *control;
CVideoSlider *slider;
+ CMediaData *mediadata;
- struct timeout_handler *timeout_handle;
+ timeout_handler *timeout_handle;
bool bar_hidden;
- bool error;
Ecore_Timer *drawanim_timer;
int duration;
void CPlayerView::m_UpdateInfoBar(void)
{
- Evas_Object *obj;
-
- obj = m->base;
-
- /* Title */
- elm_object_part_text_set(obj, PART_TITLETEXT, _(TEXT_NOVIDEO));
-
- /* Created Time */
- elm_object_part_text_set(obj, PART_DATETEXT, _(TEXT_NODATE));
-
- /* Source */
- elm_object_part_text_set(obj, PART_SOURCETEXT, _(TEXT_NOSOURCE));
-
- /* Resolution */
- elm_object_part_text_set(obj, PART_RESOLUTIONTEXT, _(TEXT_NORES));
-}
-
-void CPlayerView::m_UpdateInfoBar(struct mediadata *md)
-{
const char *name;
char buf[32];
time_t video_time;
struct tm tm;
- const struct videodata *vd;
/* Title */
- name = mediadata_get_displayname(md);
+ name = m->mediadata->GetName();
if (name)
elm_object_part_text_set(m->base, PART_TITLETEXT, name);
/* Created Time */
- video_time = mediadata_get_modifiedtime(md);
+ video_time = m->mediadata->GetTime();
if (video_time > 0) {
localtime_r(&video_time, &tm);
elm_object_part_text_set(m->base, PART_CURRENTTEXT, buf);
/* Resolution */
- vd = mediadata_get_video_info(md);
- if (vd) {
- snprintf(buf, sizeof(buf), "%dx%d",
- videodata_get_width(vd),
- videodata_get_height(vd));
+ snprintf(buf, sizeof(buf), "%dx%d", m->mediadata->GetWidth(),
+ m->mediadata->GetHeight());
- m->duration = videodata_get_duration(vd);
- } else {
- snprintf(buf, sizeof(buf), "%s", _(TEXT_NORES));
- m->duration = 0;
- }
+ m->duration = m->mediadata->GetDuration();
elm_object_part_text_set(m->base, PART_RESOLUTIONTEXT, buf);
}
bool CPlayerView::m_PlayerInit(void)
{
- struct mediadata *md;
const char *path;
int r;
path = playermgr_get_video_path(m->player);
- md = mediadata_create(path);
- if (md) {
- m_UpdateInfoBar(md);
- mediadata_destroy(md);
- }
+ m->mediadata->Create(path);
+ m_UpdateInfoBar();
+ m->mediadata->Destroy();
m->slider->Reset(m->duration);
m->control->Signal(E_PLAYPAUSE_BTN, SIG_SET_PAUSE, "");
void CPlayerView::sm_CbTimeoutEvent(void *dt, int type, void *ev)
{
SPlayerView *data;
+ update_action action;
if (!dt)
return;
data = (SPlayerView *)dt;
- if (!data->error) {
- update_action action;
-
- action = ACTION_HIDE;
- CViewMgr::GetInstance()->UpdateView(data->id, (void *)&action);
- }
+ action = ACTION_HIDE;
+ CViewMgr::GetInstance()->UpdateView(data->id, (void *)&action);
}
void CPlayerView::sm_EvtBack(void *dt, Evas_Object *obj, void *ev)
void CPlayerView::m_ControlInit(SPlayerParam *param)
{
- int r;
-
- r = mediadata_init();
- if (r < 0)
+ m->mediadata = new CMediaData;
+ if (!m->mediadata)
_ERR("mediadata init failed");
if (param->id)
}
m->win = win;
- m->error = false;
m_ControlInit((SPlayerParam *)data);
if (!m_PlayerInit()) {
_ERR("failed to play video");
- m->error = true;
-
- m_UpdateInfoBar();
- m->control->Hide();
- elm_object_signal_emit(m->base, SIG_SHOW_VIEW, "");
-
- CBaseView::Create(NULL);
- return true;
+ return false;
}
playermgr_set_completed_cb(m->player, sm_CbPlayComplete, m);
if (m->drawanim_timer)
ecore_timer_del(m->drawanim_timer);
- mediadata_fini();
+ delete m->mediadata;
+ m->mediadata = NULL;
playermgr_fini(m->player);