#include <media_info_private.h>
-#define media_content_retv_free_audio_if(expr, val, p_str) do { \
- if (expr) { \
- LOGE(FONT_COLOR_RED"Memory allocation failure"FONT_COLOR_RESET); \
- audio_meta_destroy(p_str); \
- return (val); \
- } \
- } while (0)
-
int audio_meta_destroy(audio_meta_h audio)
{
audio_meta_s *_audio = (audio_meta_s*)audio;
- media_content_retvm_if(_audio == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Audio handle is null");
-
- SAFE_FREE(_audio->media_id);
- SAFE_FREE(_audio->album);
- SAFE_FREE(_audio->artist);
- SAFE_FREE(_audio->album_artist);
- SAFE_FREE(_audio->genre);
- SAFE_FREE(_audio->composer);
- SAFE_FREE(_audio->year);
- SAFE_FREE(_audio->recorded_date);
- SAFE_FREE(_audio->copyright);
- SAFE_FREE(_audio->track_num);
- SAFE_FREE(_audio);
+
+ content_retip_if_fail(audio);
+
+ g_free(_audio->media_id);
+ g_free(_audio->album);
+ g_free(_audio->artist);
+ g_free(_audio->album_artist);
+ g_free(_audio->genre);
+ g_free(_audio->composer);
+ g_free(_audio->year);
+ g_free(_audio->recorded_date);
+ g_free(_audio->copyright);
+ g_free(_audio->track_num);
+ g_free(_audio);
return MEDIA_CONTENT_ERROR_NONE;
}
int audio_meta_clone(audio_meta_h *dst, audio_meta_h src)
{
audio_meta_s *_src = (audio_meta_s*)src;
- media_content_retvm_if(_src == NULL, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Source handle is null");
-
- audio_meta_s *_dst = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
- media_content_retvm_if(_dst == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
-
- if (_src->media_id != NULL) {
- _dst->media_id = g_strdup(_src->media_id);
- media_content_retv_free_audio_if(_dst->media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst);
- }
-
- if (_src->album != NULL) {
- _dst->album = g_strdup(_src->album);
- media_content_retv_free_audio_if(_dst->album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst);
- }
-
- if (_src->artist != NULL) {
- _dst->artist = g_strdup(_src->artist);
- media_content_retv_free_audio_if(_dst->artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst);
- }
-
- if (_src->album_artist != NULL) {
- _dst->album_artist = g_strdup(_src->album_artist);
- media_content_retv_free_audio_if(_dst->album_artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst);
- }
-
- if (_src->genre != NULL) {
- _dst->genre = g_strdup(_src->genre);
- media_content_retv_free_audio_if(_dst->genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst);
- }
-
- if (_src->composer != NULL) {
- _dst->composer = g_strdup(_src->composer);
- media_content_retv_free_audio_if(_dst->composer == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst);
- }
-
- if (_src->year != NULL) {
- _dst->year = g_strdup(_src->year);
- media_content_retv_free_audio_if(_dst->year == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst);
- }
-
- if (_src->recorded_date != NULL) {
- _dst->recorded_date = g_strdup(_src->recorded_date);
- media_content_retv_free_audio_if(_dst->recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst);
- }
-
- if (_src->copyright != NULL) {
- _dst->copyright = g_strdup(_src->copyright);
- media_content_retv_free_audio_if(_dst->copyright == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst);
- }
-
- if (_src->track_num != NULL) {
- _dst->track_num = g_strdup(_src->track_num);
- media_content_retv_free_audio_if(_dst->track_num == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, (audio_meta_h)_dst);
- }
+ content_retip_if_fail(dst);
+ content_retip_if_fail(src);
+
+ audio_meta_s *_dst = g_new0(audio_meta_s, 1);
+
+ _dst->media_id = g_strdup(_src->media_id);
+ _dst->album = g_strdup(_src->album);
+ _dst->artist = g_strdup(_src->artist);
+ _dst->album_artist = g_strdup(_src->album_artist);
+ _dst->genre = g_strdup(_src->genre);
+ _dst->composer = g_strdup(_src->composer);
+ _dst->year = g_strdup(_src->year);
+ _dst->recorded_date = g_strdup(_src->recorded_date);
+ _dst->copyright = g_strdup(_src->copyright);
+ _dst->track_num = g_strdup(_src->track_num);
_dst->bitrate = _src->bitrate;
_dst->bitpersample = _src->bitpersample;
_dst->samplerate = _src->samplerate;
int audio_meta_get_media_id(audio_meta_h audio, char **media_id)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
audio_meta_s *_audio = (audio_meta_s*)audio;
- if (_audio) {
- if (STRING_VALID(_audio->media_id)) {
- *media_id = strdup(_audio->media_id);
- media_content_retvm_if(*media_id == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *media_id = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
+
+ content_retip_if_fail(audio);
+ content_retip_if_fail(media_id);
+
+ *media_id = g_strdup(_audio->media_id);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int audio_meta_get_album(audio_meta_h audio, char **album)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
audio_meta_s *_audio = (audio_meta_s*)audio;
- if (_audio) {
- if (_audio->album != NULL) {
- *album = g_strdup(_audio->album); /*album can be empty string*/
- media_content_retvm_if(*album == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *album = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
+
+ content_retip_if_fail(audio);
+ content_retip_if_fail(album);
+
+ /*album can be empty string*/
+ *album = g_strdup(_audio->album);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int audio_meta_get_artist(audio_meta_h audio, char **artist)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
audio_meta_s *_audio = (audio_meta_s*)audio;
- if (_audio) {
- if (_audio->artist != NULL) {
- *artist = g_strdup(_audio->artist); /*artist can be empty string*/
- media_content_retvm_if(*artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *artist = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
+ content_retip_if_fail(audio);
+ content_retip_if_fail(artist);
+
+ /*artist can be empty string*/
+ *artist = g_strdup(_audio->artist);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int audio_meta_get_album_artist(audio_meta_h audio, char **album_artist)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
audio_meta_s *_audio = (audio_meta_s*)audio;
- if (_audio) {
- if (_audio->album_artist != NULL) {
- *album_artist = g_strdup(_audio->album_artist); /*album_artist can be empty string*/
- media_content_retvm_if(*album_artist == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *album_artist = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
+ content_retip_if_fail(audio);
+ content_retip_if_fail(album_artist);
+
+ /*album_artist can be empty string*/
+ *album_artist = g_strdup(_audio->album_artist);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int audio_meta_get_genre(audio_meta_h audio, char **genre)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
audio_meta_s *_audio = (audio_meta_s*)audio;
- if (_audio) {
- if (_audio->genre != NULL) {
- *genre = g_strdup(_audio->genre); /*genre can be empty string*/
- media_content_retvm_if(*genre == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *genre = NULL;
- }
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
+ content_retip_if_fail(audio);
+ content_retip_if_fail(genre);
+
+ /*genre can be empty string*/
+ *genre = g_strdup(_audio->genre);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int audio_meta_get_composer(audio_meta_h audio, char **composer)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
audio_meta_s *_audio = (audio_meta_s*)audio;
- if (_audio) {
- if (_audio->composer != NULL) {
- *composer = g_strdup(_audio->composer); /*composer can be empty string*/
- media_content_retvm_if(*composer == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *composer = NULL;
- }
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
+ content_retip_if_fail(audio);
+ content_retip_if_fail(composer);
+
+ /*composer can be empty string*/
+ *composer = g_strdup(_audio->composer);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int audio_meta_get_year(audio_meta_h audio, char **year)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
audio_meta_s *_audio = (audio_meta_s*)audio;
- if (_audio) {
- if (_audio->year != NULL) {
- *year = g_strdup(_audio->year); /*year can be empty string*/
- media_content_retvm_if(*year == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *year = NULL;
- }
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
+ content_retip_if_fail(audio);
+ content_retip_if_fail(year);
+
+ /*year can be empty string*/
+ *year = g_strdup(_audio->year);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int audio_meta_get_recorded_date(audio_meta_h audio, char **recorded_date)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
audio_meta_s *_audio = (audio_meta_s*)audio;
- if (_audio) {
- if (_audio->recorded_date != NULL) {
- *recorded_date = g_strdup(_audio->recorded_date);
- media_content_retvm_if(*recorded_date == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *recorded_date = NULL;
- }
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
+ content_retip_if_fail(audio);
+ content_retip_if_fail(recorded_date);
+
+ *recorded_date = g_strdup(_audio->recorded_date);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int audio_meta_get_copyright(audio_meta_h audio, char **copyright)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
audio_meta_s *_audio = (audio_meta_s*)audio;
- if (_audio) {
- if (_audio->copyright != NULL) {
- *copyright = g_strdup(_audio->copyright); /*copyright can be empty string*/
- media_content_retvm_if(*copyright == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *copyright = NULL;
- }
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
+ content_retip_if_fail(audio);
+ content_retip_if_fail(copyright);
+
+ /*copyright can be empty string*/
+ *copyright = g_strdup(_audio->copyright);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int audio_meta_get_track_num(audio_meta_h audio, char **track_num)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
audio_meta_s *_audio = (audio_meta_s*)audio;
- if (_audio) {
- if (_audio->track_num != NULL) {
- *track_num = g_strdup(_audio->track_num); /*track_num can be empty string*/
- media_content_retvm_if(*track_num == NULL, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY, "OUT_OF_MEMORY");
- } else {
- *track_num = NULL;
- }
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
+ content_retip_if_fail(audio);
+ content_retip_if_fail(track_num);
+
+ /*track_num can be empty string*/
+ *track_num = g_strdup(_audio->track_num);
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int audio_meta_get_bit_rate(audio_meta_h audio, int *bit_rate)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
audio_meta_s *_audio = (audio_meta_s*)audio;
- if (_audio && bit_rate) {
- *bit_rate = _audio->bitrate;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(audio);
+ content_retip_if_fail(bit_rate);
- return ret;
+ *bit_rate = _audio->bitrate;
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
int audio_meta_get_bitpersample(audio_meta_h audio, int *bitpersample)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
audio_meta_s *_audio = (audio_meta_s*)audio;
- if (_audio && bitpersample) {
- *bitpersample = _audio->bitpersample;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(audio);
+ content_retip_if_fail(bitpersample);
+
+ *bitpersample = _audio->bitpersample;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int audio_meta_get_sample_rate(audio_meta_h audio, int *sample_rate)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
audio_meta_s *_audio = (audio_meta_s*)audio;
- if (_audio && sample_rate) {
- *sample_rate = _audio->samplerate;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(audio);
+ content_retip_if_fail(sample_rate);
+
+ *sample_rate = _audio->samplerate;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int audio_meta_get_channel(audio_meta_h audio, int *channel)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
audio_meta_s *_audio = (audio_meta_s*)audio;
- if (_audio && channel) {
- *channel = _audio->channel;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(audio);
+ content_retip_if_fail(channel);
+
+ *channel = _audio->channel;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
}
int audio_meta_get_duration(audio_meta_h audio, int *duration)
{
- int ret = MEDIA_CONTENT_ERROR_NONE;
audio_meta_s *_audio = (audio_meta_s*)audio;
- if (_audio) {
- *duration = _audio->duration;
- ret = MEDIA_CONTENT_ERROR_NONE;
- } else {
- media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
+ content_retip_if_fail(audio);
+ content_retip_if_fail(duration);
+
+ *duration = _audio->duration;
- return ret;
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+#ifdef TIZEN_FEATURE_COMPATIBILITY
+int audio_meta_get_played_time(audio_meta_h audio, time_t* played_time)
+{
+ content_warn("DEPRECATION WARNING: audio_meta_get_played_time() is removed from 5.5.");
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int audio_meta_get_played_count(audio_meta_h audio, int *played_count)
+{
+ content_warn("DEPRECATION WARNING: audio_meta_get_played_count() is removed from 5.5.");
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int audio_meta_set_played_count(audio_meta_h audio, int played_count)
+{
+ content_warn("DEPRECATION WARNING: audio_meta_set_played_count() is removed from 5.5.");
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int audio_meta_set_played_time(audio_meta_h audio, time_t played_time)
+{
+ content_warn("DEPRECATION WARNING: audio_meta_set_played_time() is removed from 5.5.");
+
+ return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int audio_meta_update_to_db(audio_meta_h audio)
+{
+ content_warn("DEPRECATION WARNING: audio_meta_update_to_db() is removed from 5.5.");
+
+ return MEDIA_CONTENT_ERROR_NONE;
}
+#endif