2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
21 #include <media_content.h>
22 #include <Commons/Regex.h>
23 #include <Commons/StringUtils.h>
24 #include <CommonsJavaScript/Converter.h>
26 #include "ContentManager.h"
27 #include "ContentFilterValidator.h"
28 #include "ContentUtility.h"
31 using namespace WrtDeviceApis::Commons;
38 int MediacontentManager::m_instanceCount = 0;
40 MediacontentManager::MediacontentManager()
42 //protect for pararel execution
43 DPL::Mutex::ScopedLock mx(&m_constructorMutex);
44 if (m_instanceCount == 0)
46 //when it is first instance then connect to media content service.
47 if( MEDIA_CONTENT_ERROR_NONE != media_content_connect())
49 LoggerD("Media Content Service Connect Fail...");
53 //increase counter of instances
57 MediacontentManager::~MediacontentManager()
59 DPL::Mutex::ScopedLock mx(&m_constructorMutex);
60 //decrease counter of instances
62 if (m_instanceCount == 0)
64 //when it is last instance then clse connection to database
65 if ( MEDIA_CONTENT_ERROR_NONE != media_content_disconnect())
67 LoggerD("Media Content Service Disconnect Fail...");
72 tm* MediacontentManager::toDateTm(time_t date)
74 tm *tm_date = (struct tm *)calloc(1, sizeof(struct tm));
76 localtime_r(&date, tm_date);
81 media_content_orientation_e MediacontentManager::convertToOrientation(string orientation)
83 media_content_orientation_e ret = MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE;
85 if ( orientation.compare("NORMAL")==0)
87 ret = MEDIA_CONTENT_ORIENTATION_NORMAL;
89 else if (orientation.compare("FLIP_HORIZONTAL")==0)
91 ret = MEDIA_CONTENT_ORIENTATION_HFLIP;
93 else if (orientation.compare("ROTATE_180")==0)
95 ret = MEDIA_CONTENT_ORIENTATION_ROT_180;
97 else if (orientation.compare("FLIP_VERTICAL")==0)
99 ret = MEDIA_CONTENT_ORIENTATION_VFLIP;
101 else if (orientation.compare("TRANSPOSE")==0)
103 ret = MEDIA_CONTENT_ORIENTATION_TRANSPOSE;
105 else if (orientation.compare("ROTATE_90")==0)
107 ret = MEDIA_CONTENT_ORIENTATION_ROT_90;
109 else if (orientation.compare("TRANSVERSE")==0)
111 ret =MEDIA_CONTENT_ORIENTATION_TRANSVERSE;
113 else if (orientation.compare("ROTATE_270")==0)
115 ret =MEDIA_CONTENT_ORIENTATION_ROT_270;
119 LoggerD("wrong value.");
120 ret = MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE;
126 void MediacontentManager::convertToPlatformFolder(media_folder_h media_folder, MediacontentFolderPtr& newFolder)
130 media_content_storage_e storageType;
132 if (MEDIA_CONTENT_ERROR_NONE == media_folder_get_folder_id(media_folder, &tmpStr))
136 newFolder->setFolderUUID(tmpStr);
142 if (MEDIA_CONTENT_ERROR_NONE == media_folder_get_path(media_folder, &tmpStr))
146 newFolder->setFolderPath(ContentUtility::convertPathToUri(tmpStr));
152 if (MEDIA_CONTENT_ERROR_NONE == media_folder_get_name(media_folder, &tmpStr))
156 newFolder->setFolderName(tmpStr);
162 if (MEDIA_CONTENT_ERROR_NONE == media_folder_get_modified_time(media_folder, &date))
164 newFolder->setFolderModifiedDate(toDateTm(date));
167 if (MEDIA_CONTENT_ERROR_NONE == media_folder_get_storage_type(media_folder, &storageType))
170 if(storageType == MEDIA_CONTENT_STORAGE_INTERNAL )
174 else if( storageType == MEDIA_CONTENT_STORAGE_EXTERNAL)
182 newFolder->setFolderStorageType(type);
188 void MediacontentManager::readCommonDataFromMediaInfo(media_info_h info, MediacontentMedia* newMedia)
194 unsigned long long tmpLongLong = 0;
197 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_media_id(info, &tmpStr) )
201 newMedia->setMediaUUID(tmpStr);
207 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_mime_type(info, &tmpStr) )
211 newMedia->setMimeType(tmpStr);
217 if (MEDIA_CONTENT_ERROR_NONE == media_info_get_display_name(info, &tmpStr) )
221 newMedia->setDisplayName(tmpStr);
227 if (MEDIA_CONTENT_ERROR_NONE == media_info_get_title(info, &tmpStr) )
231 newMedia->setTitle(tmpStr);
237 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_file_path(info, &tmpStr) )
241 newMedia->setFilePath(ContentUtility::convertPathToUri(tmpStr));
247 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_thumbnail_path (info, &tmpStr) )
251 newMedia->setThumbnailPath(ContentUtility::convertPathToUri(tmpStr));
257 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_description(info, &tmpStr) )
261 newMedia->setDescription(tmpStr);
267 //newImage->setReleasedDate(toDateTm(sqlite3_column_int(pStmt,7)));
268 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_modified_time (info, &tmpDate) )
272 newMedia->setModifiedDate(toDateTm(tmpDate));
276 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_favorite (info, &tmpBool) )
278 newMedia->setFavorite(tmpBool);
281 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_rating (info, &tmpInt) )
283 newMedia->setRating(tmpInt);
286 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_size(info, &tmpLongLong) )
288 newMedia->setSize(tmpLongLong);
293 void MediacontentManager::readImageFromMediaInfo( media_info_h info, MediacontentImage* newImage)
301 newImage->setMediaType("IMAGE");
303 readCommonDataFromMediaInfo(info, newImage);
307 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_image(info, &img))
310 if ( MEDIA_CONTENT_ERROR_NONE == image_meta_get_date_taken (img, &tmpStr) )
314 struct tm *result = (struct tm *)calloc(1, sizeof(struct tm));
315 if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", result) == NULL) {
316 LoggerE( "Couldn't convert supplied date.");
319 newImage->setReleasedDate(result);
324 if ( MEDIA_CONTENT_ERROR_NONE == image_meta_get_width(img, &tmpInt) )
326 newImage->setImageWidth(tmpInt);
329 if ( MEDIA_CONTENT_ERROR_NONE == image_meta_get_height(img, &tmpInt) )
331 newImage->setImageHeight(tmpInt);
334 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_latitude(info, &tmpDouble) )
336 newImage->setImageLatitude(tmpDouble);
339 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_longitude(info, &tmpDouble) )
341 newImage->setImageLongitude(tmpDouble);
344 media_content_orientation_e orientation;
346 if ( MEDIA_CONTENT_ERROR_NONE == image_meta_get_orientation(img, &orientation) )
349 string orientationStr;
354 orientationStr = "NORMAL";
357 orientationStr = "FLIP_HORIZONTAL";
360 orientationStr = "ROTATE_180";
363 orientationStr = "FLIP_VERTICAL";
366 orientationStr = "TRANSPOSE";
369 orientationStr = "ROTATE_90";
372 orientationStr = "TRANSVERSE";
375 orientationStr = "ROTATE_270";
379 newImage->setImageOrientation(orientationStr);
384 if ( METADATA_EXTRACTOR_ERROR_NONE != image_meta_destroy(img))
386 LoggerD(" image_meta_destroy is fail... ");
391 LoggerD("fetch Image Info failed..");
397 LoggerD("media info is NULL");
401 void MediacontentManager::readVideoFromMediaInfo( media_info_h info, MediacontentVideo* newVideo)
409 newVideo->setMediaType("VIDEO");
411 readCommonDataFromMediaInfo(info, newVideo); //set common media infomation
415 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_video(info, &video))
418 if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_recorded_date(video, &tmpStr) )
422 struct tm *result=(struct tm *)calloc(1, sizeof(struct tm));
423 if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", result) == NULL) {
424 LoggerE( "Couldn't convert supplied date.");
426 newVideo->setReleasedDate(result);
433 if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_album(video, &tmpStr) )
437 newVideo->setVideoAlbum(tmpStr);
443 if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_artist(video, &tmpStr) )
447 std::vector<std::string> artists = String::split(tmpStr, TAG_DELIMETER);
448 for( unsigned int i=0; i < artists.size(); i++)
450 string artist = artists.at(i);
451 newVideo->appendVideoArtist(artist);
460 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_longitude(info, &tmpDouble) )
462 newVideo->setVideoLongitude(tmpDouble);
465 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_latitude(info, &tmpDouble) )
467 newVideo->setVideoLatitude(tmpDouble);
470 if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_width(video, &tmpInt) )
472 newVideo->setVideoWidth(tmpInt);
475 if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_height(video, &tmpInt) )
477 newVideo->setVideoHeight(tmpInt);
480 if ( MEDIA_CONTENT_ERROR_NONE == video_meta_get_duration(video, &tmpInt) )
482 newVideo->setVideoDuration(tmpInt);
485 if ( METADATA_EXTRACTOR_ERROR_NONE != video_meta_destroy(video))
487 LoggerD(" video_meta_destroy is fail... ");
493 LoggerD("fetch Video info fail...");
498 LoggerD("media info is NULL");
503 void MediacontentManager::readMusicFromMediaInfo( media_info_h info, MediacontentAudio* newAudio)
507 unsigned long long tmpLongLong = 0;
511 newAudio->setMediaType("AUDIO");
513 readCommonDataFromMediaInfo(info, newAudio); //set common media infomation
517 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_audio(info, &audio))
519 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_recorded_date(audio, &tmpStr) )
523 struct tm *result = (struct tm *)calloc(1, sizeof(struct tm));
524 if (strptime(tmpStr, "%Y:%m:%d %H:%M:%S", result) == NULL) {
525 LoggerE( "Couldn't convert supplied date.");
527 newAudio->setReleasedDate(result);
534 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_album(audio, &tmpStr) )
538 newAudio->setAudioAlbum(tmpStr);
544 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_artist(audio, &tmpStr) )
548 std::vector<std::string> artists = String::split(tmpStr, TAG_DELIMETER);
549 for( unsigned int i=0; i < artists.size(); i++)
551 string artist = artists.at(i);
552 newAudio->appendAudioArtist(artist);
560 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_composer(audio, &tmpStr) )
564 std::vector<std::string> composers = String::split(tmpStr, TAG_DELIMETER);
565 for( unsigned int i=0; i < composers.size(); i++)
567 string composer = composers.at(i);
568 newAudio->appendAudioComposer(composer);
576 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_duration(audio, &tmpInt) )
578 newAudio->setAudioDuration(tmpInt);
581 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_copyright(audio, &tmpStr) )
585 newAudio->setAudioCopyright(tmpStr);
591 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_track_num(audio, &tmpStr) )
597 istringstream(tmpStr) >> trackNum;
599 LoggerD("Track Number type is wrong. (track number:" << tmpStr << ")");
602 newAudio->setAudioTrackNum(trackNum);
608 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_size(info, &tmpLongLong) )
610 newAudio->setAudioSize(tmpLongLong);
613 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_bit_rate(audio, &tmpInt) )
615 newAudio->setAudioBitrate(tmpInt);
618 if ( MEDIA_CONTENT_ERROR_NONE == audio_meta_get_genre(audio, &tmpStr) )
622 std::vector<std::string> genres = String::split(tmpStr, TAG_DELIMETER);
624 for( unsigned int i=0; i < genres.size(); i++)
626 string genre = genres.at(i);
627 newAudio->appendAudioGenre(genre);
635 if ( METADATA_EXTRACTOR_ERROR_NONE != audio_meta_destroy(audio))
637 LoggerD(" audio_meta_destroy is fail... ");
644 LoggerD("fetch Music Info fail...");
651 LoggerD("media info is NULL");
658 bool MediacontentManager::mediaFolderCallback(media_folder_h folder, void *user_data)
660 if (user_data != NULL){
661 IEventFindFolder* event = (IEventFindFolder*)user_data;
664 MediacontentFolderPtr newFolder(new MediacontentFolder());
665 convertToPlatformFolder(folder, newFolder);
667 event->addFolder(newFolder);
672 LoggerD("user data is NULL");
678 bool MediacontentManager::mediaItemCallback(media_info_h info, void* user_data)
680 if (user_data != NULL){
681 IEventBrowseFolder* event = (IEventBrowseFolder*)user_data;
683 media_content_type_e type;
685 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_media_type( info, &type) )
687 if ( type == MEDIA_CONTENT_TYPE_IMAGE)
689 MediacontentImage *newImage(new MediacontentImage());
690 readImageFromMediaInfo(info, newImage);
691 event->addMedia(newImage);
693 else if ( type == MEDIA_CONTENT_TYPE_VIDEO)
695 MediacontentVideo *newVideo(new MediacontentVideo());
696 readVideoFromMediaInfo(info, newVideo);
697 event->addMedia(newVideo);
699 else if ( type == MEDIA_CONTENT_TYPE_MUSIC)
701 MediacontentAudio *newVAudio(new MediacontentAudio());
702 readMusicFromMediaInfo(info, newVAudio);
703 event->addMedia(newVAudio);
705 else if( type == MEDIA_CONTENT_TYPE_OTHERS)
707 MediacontentMedia *newMedia(new MediacontentMedia());
709 newMedia->setMediaType("OTHER");
710 readCommonDataFromMediaInfo(info, newMedia);
711 event->addMedia(newMedia);
718 LoggerD("event is NULL");
724 void MediacontentManager::OnRequestReceived(const IEventFindFolderPtr &eFolder)
726 filter_h filter = NULL;
728 if ( MEDIA_CONTENT_ERROR_NONE == media_filter_create(&filter))
730 string condition="(FOLDER_STORAGE_TYPE = 0 OR FOLDER_STORAGE_TYPE = 1)";
732 media_filter_set_condition(filter, condition.c_str(), MEDIA_CONTENT_COLLATE_DEFAULT ); //set condition
733 if ( MEDIA_CONTENT_ERROR_NONE !=
734 media_folder_foreach_folder_from_db (filter, mediaFolderCallback, eFolder.Get()))
736 LoggerE("A platform error occurs in media_folder_foreach_folder_from_db");
737 eFolder->setResult(false);
740 eFolder->setResult(true);
742 if ( MEDIA_CONTENT_ERROR_NONE != media_filter_destroy(filter))
744 LoggerE("A platform error occurs in media_filter_destroy");
749 void MediacontentManager::OnRequestReceived(const IEventBrowseFolderPtr &eBrowse)
751 MediaSearchVisitorPtr visitor(new MediaSearchVisitor());
752 visitor->setQueryType(MediaSearchVisitor::QUERY_MEDIA);
756 filter_h filter = NULL;
759 if ( MEDIA_CONTENT_ERROR_NONE == media_filter_create(&filter))
761 string condition = "(MEDIA_STORAGE_TYPE = 0 OR MEDIA_STORAGE_TYPE = 1)";;
762 if (eBrowse->getFilterIsSet())
764 FilterPtr jsFilter = eBrowse->getFilter();
765 FilterValidatorPtr validator = MediaFilterValidatorFactory::getMediaFilterValidator(MediaFilterValidatorFactory::QUERY_MEDIA);
766 bool success = jsFilter->validate(validator);
769 eBrowse->setExceptionCode(ExceptionCodes::InvalidArgumentException);
770 ThrowMsg(InvalidArgumentException, "Invalid attirbutes.");
773 IFilterVisitorPtr IVisitor = DPL::StaticPointerCast<IFilterVisitor>(visitor);
774 jsFilter->travel(IVisitor);
775 condition += " AND ";
776 condition += visitor->getResult();
779 //LoggerI("condition:" << condition);
781 media_filter_set_condition(filter, condition.c_str(), MEDIA_CONTENT_COLLATE_DEFAULT ); //set condition
783 if(eBrowse->getSortModesIsSet())
785 media_content_order_e order;
786 SortModePtr attr = eBrowse->getSortMode();
790 string attriName = attr->getAttributeName();
791 attriName = visitor->getPlatformAttr(attriName);
793 if (attriName.compare("") != 0)
795 if (attr->getOrder() == DeviceAPI::Tizen::ASCENDING_SORT_ORDER)
797 order = MEDIA_CONTENT_ORDER_ASC;
801 order = MEDIA_CONTENT_ORDER_DESC;
804 if ( MEDIA_CONTENT_ERROR_NONE !=
805 media_filter_set_order(filter, order, attriName.c_str(), MEDIA_CONTENT_COLLATE_DEFAULT )) //set order
807 LoggerE("A platform error occurs in media_filter_set_order");
814 if (eBrowse->getLimitIsSet() ||eBrowse->getOffsetIsSet() )
819 if ( eBrowse->getLimitIsSet() )
821 count = eBrowse->getLimit();
824 if ( eBrowse->getOffsetIsSet() )
826 offset = eBrowse->getOffset();
829 if ( MEDIA_CONTENT_ERROR_NONE != media_filter_set_offset(filter, offset, count))
831 LoggerE("A platform error occurs in media_filter_set_offset");
837 LoggerE("A platform error occurs in media_filter_create");
838 eBrowse->setResult(false);
841 if ( eBrowse->getFolderIdIsSet())
843 string folderID = eBrowse->getFolderID();
845 if ( MEDIA_CONTENT_ERROR_NONE !=
846 media_folder_foreach_media_from_db (folderID.c_str(), filter, mediaItemCallback, eBrowse.Get()))
848 LoggerE("A platform error occurs in media_folder_foreach_media_from_db");
849 eBrowse->setResult(false);
853 eBrowse->setResult(true);
858 if ( MEDIA_CONTENT_ERROR_NONE !=
859 media_info_foreach_media_from_db (filter, mediaItemCallback, eBrowse.Get()))
861 LoggerE("A platform error occurs in media_info_foreach_media_from_db");
862 eBrowse->setResult(false);
866 eBrowse->setResult(true);
873 if ( MEDIA_CONTENT_ERROR_NONE != media_filter_destroy(filter))
875 LoggerE("A platform error occurs in media_filter_destroy");
879 catch(const Exception &ex)
881 LoggerE("Exception: " << ex.DumpToString());
882 eBrowse->setResult(false);
887 bool MediacontentManager::updateMediaToDB(MediacontentMediaPtr mediaPtr)
889 string type = mediaPtr->getMediaType(); //media type.
890 string mediaId = mediaPtr->getMediaUUID();
892 media_info_h media = NULL;
896 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_media_from_db(mediaId.c_str(), &media))
898 if ( mediaPtr->isChangedRating())
900 if ( MEDIA_CONTENT_ERROR_NONE
901 != media_info_set_rating(media, mediaPtr->getRating()))
903 LoggerD("Error: set rating");
906 if ( mediaPtr->isChangedDescription() )
908 if ( MEDIA_CONTENT_ERROR_NONE
909 != media_info_set_description (media, mediaPtr->getDescription().c_str()))
911 LoggerD("Error: set description");
914 if( mediaPtr->isChangedDisplayName())
916 if ( MEDIA_CONTENT_ERROR_NONE
917 != media_info_set_display_name (media, mediaPtr->getDisplayName().c_str()))
919 LoggerD("Error: set displayname");
923 if(type.compare("IMAGE") ==0 )
925 MediacontentImagePtr imagePtr = DPL::DynamicPointerCast<MediacontentImage>(mediaPtr);
929 image_meta_h img=NULL;
930 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_image(media, &img))
932 if(imagePtr->isChangedOrientaion())
934 if ( MEDIA_CONTENT_ERROR_NONE !=
935 image_meta_set_orientation (img, convertToOrientation(imagePtr->getImageOrientation())))
937 LoggerD("Error: set orientation");
942 if ( MEDIA_CONTENT_ERROR_NONE !=
943 media_info_set_latitude(media, imagePtr->getImageLatitude())
946 LoggerD("Error: set Latitude");
950 if ( MEDIA_CONTENT_ERROR_NONE !=
951 media_info_set_longitude(media, imagePtr->getImageLongitude())
954 LoggerD("Error: set Longitude");
958 if ( MEDIA_CONTENT_ERROR_NONE != image_meta_update_to_db (img) )
960 LoggerD("Error: update db");
964 if ( MEDIA_CONTENT_ERROR_NONE != image_meta_destroy(img))
966 LoggerD("Error: destroy media info");
975 LoggerD("Error: get Image from DB");
982 if(type.compare("VIDEO") ==0 )
984 MediacontentVideoPtr videoPtr = DPL::DynamicPointerCast<MediacontentVideo>(mediaPtr);
988 video_meta_h video = NULL;
989 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_video(media, &video))
991 if ( MEDIA_CONTENT_ERROR_NONE !=
992 media_info_set_latitude(media, videoPtr->getVideoLatitude())
995 LoggerD("Error: set Latitude");
999 if ( MEDIA_CONTENT_ERROR_NONE !=
1000 media_info_set_longitude(media, videoPtr->getVideoLongitude())
1003 LoggerD("Error: set Latitude");
1008 if ( MEDIA_CONTENT_ERROR_NONE != video_meta_update_to_db (video) )
1010 LoggerD("Error: update db");
1014 if ( MEDIA_CONTENT_ERROR_NONE != video_meta_destroy(video))
1016 LoggerD("Error: destroy video meta");
1029 if(type.compare("AUDIO") ==0 )
1032 MediacontentAudioPtr audioPtr = DPL::DynamicPointerCast<MediacontentAudio>(mediaPtr);
1033 if (audioPtr && ( audioPtr->isChangedAudioArtist () || audioPtr->isChangedAudioAlbum()
1034 || audioPtr->isChangedAudioGenre() ||audioPtr->isChangedAudioComposer()
1035 || audioPtr->isChangedAudioTrackNumber()) )
1038 audio_meta_h audio=NULL;
1039 if ( MEDIA_CONTENT_ERROR_NONE == media_info_get_audio(media, &audio))
1041 if ( MEDIA_CONTENT_ERROR_NONE != audio_meta_update_to_db (audio) )
1043 LoggerD("Error: update db");
1047 if ( MEDIA_CONTENT_ERROR_NONE != audio_meta_destroy(audio))
1049 LoggerD("Error: destroy audio meta");
1061 if ( MEDIA_CONTENT_ERROR_NONE != media_info_update_to_db(media))
1063 LoggerD("Error: update to DB");
1070 if ( MEDIA_CONTENT_ERROR_NONE !=media_info_destroy(media))
1072 LoggerD("Error: destroy media info");
1080 void MediacontentManager::OnRequestReceived(const IEventUpdateMediaPtr &eMedia)
1084 MediacontentMediaPtr mediaPtr = eMedia->getMediaItem();
1086 if(updateMediaToDB(mediaPtr))
1088 eMedia->setResult(true);
1092 eMedia->setResult(false);
1093 ThrowMsg(PlatformException, "DB operation is failed");
1096 catch (const Exception &ex)
1098 LoggerE("Exception: " << ex.DumpToString());
1099 eMedia->setResult(false);
1104 void MediacontentManager::OnRequestReceived(const IEventUpdateMediaItemsPtr &eItems)
1108 MediacontentMediaListPtr mediaListPtr = eItems->getMediaItems();
1109 if (mediaListPtr->empty())
1111 LoggerD("Item vector is empty");
1115 for(unsigned int i=0; i<mediaListPtr->size(); i++)
1118 MediacontentMediaPtr mediaPtr = mediaListPtr->at(i);
1119 if(updateMediaToDB(mediaPtr))
1121 eItems->setResult(true);
1122 LoggerD("update success");
1126 eItems->setResult(false);
1127 ThrowMsg(PlatformException, "DB operation is failed");
1133 catch (const Exception &ex)
1135 LoggerE("Exception: " << ex.DumpToString());
1136 eItems->setResult(false);