From: Praveen Gattu Date: Wed, 25 May 2016 12:23:34 +0000 (+0530) Subject: Fixed review comments and updated CSProj file. X-Git-Tag: accepted/tizen/mobile/20161215.072346~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2ab06a651a745942dd390f1cb5ac8628dfdf5007;p=platform%2Fcore%2Fcsapi%2Fmedia-content.git Fixed review comments and updated CSProj file. Changed async apis.Incorporated SE review comments. Change-Id: I4a7e912839f33a310bc88460c4e9a6b6ee0f0391 Signed-off-by: Praveen Gattu --- diff --git a/Tizen.Content/Interop/Interop.AudioInformation.cs b/Tizen.Content/Interop/Interop.AudioInformation.cs old mode 100644 new mode 100755 index d93120b..3f604bf --- a/Tizen.Content/Interop/Interop.AudioInformation.cs +++ b/Tizen.Content/Interop/Interop.AudioInformation.cs @@ -85,7 +85,7 @@ internal static partial class Interop internal static extern int SetPlayedPosition(SafeAudioInformationHandle audioInformationHandle, int playedPosition); [DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_update_to_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int UpdateToDB(SafeAudioInformationHandle audioInformationHandle); + internal static extern int UpdateToDB(IntPtr audioInformationHandle); internal sealed class SafeAudioInformationHandle : SafeHandle { diff --git a/Tizen.Content/Interop/Interop.MediaBookmark.cs b/Tizen.Content/Interop/Interop.MediaBookmark.cs index 629dcc4..cd67a4b 100644 --- a/Tizen.Content/Interop/Interop.MediaBookmark.cs +++ b/Tizen.Content/Interop/Interop.MediaBookmark.cs @@ -6,7 +6,7 @@ internal partial class Interop internal static partial class MediaBookmark { [DllImport(Libraries.MediaContent, EntryPoint = "media_bookmark_insert_to_db")] - internal static extern int InsertToDb(string media_id, uint time, string thumbnail_path); + internal static extern int InsertToDb(string media_id, DateTime time, string thumbnail_path); [DllImport(Libraries.MediaContent, EntryPoint = "media_bookmark_delete_from_db")] internal static extern int DeleteFromDb(int bookmark_id); @@ -27,6 +27,6 @@ internal partial class Interop internal static extern int GetMarkedTime(IntPtr bookmark, out uint marked_time); [DllImport(Libraries.MediaContent, EntryPoint = "media_bookmark_get_thumbnail_path")] - internal static extern int GetThumbnailPath(IntPtr bookmark, out string path); + internal static extern int GetThumbnailPath(IntPtr bookmark, out string filePath); } } diff --git a/Tizen.Content/Interop/Interop.MediaContent.cs b/Tizen.Content/Interop/Interop.MediaContent.cs index e34eec9..5196198 100644 --- a/Tizen.Content/Interop/Interop.MediaContent.cs +++ b/Tizen.Content/Interop/Interop.MediaContent.cs @@ -14,19 +14,19 @@ internal static partial class Interop internal static extern int Disconnect(); [DllImport(Libraries.MediaContent, EntryPoint = "media_content_scan_file")] - internal static extern int ScanFile(string path); + internal static extern int ScanFile(string filePath); [DllImport(Libraries.MediaContent, EntryPoint = "media_content_cancel_scan_folder")] - internal static extern int CancelScanFolder(string path); + internal static extern int CancelScanFolder(string folderPath); // Callback [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate void MediaScanCompletedCallback(MediaContentError error, IntPtr data); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - internal delegate void MediaContentDBUpdatedCallback(MediaContentError error, int pid, MediaContentUpdateItemType updateItem, MediaContentDBUpdateType updateType, MediaContentType mediaType, string uuid, string path, string mimeType, IntPtr data); + internal delegate void MediaContentDBUpdatedCallback(MediaContentError error, int pid, MediaContentUpdateItemType updateItem, MediaContentDBUpdateType updateType, MediaContentType mediaType, string uuid, string filePath, string mimeType, IntPtr data); [DllImport(Libraries.MediaContent, EntryPoint = "media_content_scan_folder")] - internal static extern int ScanFolder(string path, bool is_recursive, MediaScanCompletedCallback scanCompletedCallback, IntPtr userData); + internal static extern int ScanFolder(string folderPath, bool is_recursive, MediaScanCompletedCallback scanCompletedCallback, IntPtr userData); [DllImport(Libraries.MediaContent, EntryPoint = "media_content_set_db_updated_cb")] internal static extern int SetDbUpdatedCb(MediaContentDBUpdatedCallback mediaContentDBUpdatedCallback, IntPtr userData); diff --git a/Tizen.Content/Interop/Interop.MediaFolder.cs b/Tizen.Content/Interop/Interop.MediaFolder.cs index 7e35b2c..a837138 100644 --- a/Tizen.Content/Interop/Interop.MediaFolder.cs +++ b/Tizen.Content/Interop/Interop.MediaFolder.cs @@ -26,7 +26,7 @@ internal static partial class Interop [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_path")] - internal static extern int GetPath(IntPtr folder, out string path); + internal static extern int GetPath(IntPtr folder, out string folderPath); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_name")] internal static extern int GetName(IntPtr folder, out string folder_name); @@ -65,6 +65,6 @@ internal static partial class Interop internal static extern int ForeachFolderFromDb(IntPtr filter, MediaFolderCallback callback, IntPtr user_data); [DllImport(Libraries.MediaContent, EntryPoint = "media_folder_foreach_media_from_db")] - internal static extern int ForeachMediaFromDb(string folder_id, IntPtr? filter, MediaInfoCallback callback, IntPtr user_data); + internal static extern int ForeachMediaFromDb(string folder_id, IntPtr filter, MediaInfoCallback callback, IntPtr user_data); } -} \ No newline at end of file +} diff --git a/Tizen.Content/Interop/Interop.MediaInformation.cs b/Tizen.Content/Interop/Interop.MediaInformation.cs old mode 100644 new mode 100755 index a76893a..35afe8d --- a/Tizen.Content/Interop/Interop.MediaInformation.cs +++ b/Tizen.Content/Interop/Interop.MediaInformation.cs @@ -16,7 +16,7 @@ internal static partial class Interop internal static partial class MediaInformation { [UnmanagedFunctionPointer(CallingConvention.Cdecl)] - internal delegate void MediaThumbnailCompletedCallback(MediaContentError error, string path, IntPtr UserData); + internal delegate void MediaThumbnailCompletedCallback(MediaContentError error, string filePath, IntPtr UserData); [UnmanagedFunctionPointer(CallingConvention.Cdecl)] internal delegate bool MediaTagCallback(IntPtr tagHandle, IntPtr UserData); @@ -37,19 +37,19 @@ internal static partial class Interop internal delegate bool MediaInformationCallback(IntPtr mediaInformationHandle, IntPtr UserData); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_insert_to_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int Insert(string path, out SafeMediaInformationHandle info); + internal static extern int Insert(string filePath, out SafeMediaInformationHandle info); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_insert_batch_to_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int BatchInsert(string[] pathArray, int arrayLength, MediaInsertCompletedCallback callback, IntPtr userData); + internal static extern int BatchInsert(string[] filePathArray, int arrayLength, MediaInsertCompletedCallback callback, IntPtr userData); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_insert_burst_shot_to_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int BurstShotInsert(string[] pathArray, int arrayLength, MediaInsertBurstShotCompletedCallback callback, IntPtr userData); + internal static extern int BurstShotInsert(string[] filePathArray, int arrayLength, MediaInsertBurstShotCompletedCallback callback, IntPtr userData); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_delete_from_db", CallingConvention = CallingConvention.Cdecl)] internal static extern int Delete(string mediaId); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_delete_batch_from_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int BatchDelete(IntPtr? filter); + internal static extern int BatchDelete(IntPtr filter); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_destroy", CallingConvention = CallingConvention.Cdecl)] internal static extern int Destroy(IntPtr mediaInformationHandle); @@ -61,13 +61,13 @@ internal static partial class Interop internal static extern int GetMediaCount(IntPtr filter, out int mediaCount); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_foreach_media_from_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAllMedia(IntPtr? filter, MediaInformationCallback callback, IntPtr userData); + internal static extern int GetAllMedia(IntPtr filter, MediaInformationCallback callback, IntPtr userData); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_tag_count_from_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetTagCount(string mediaId, IntPtr? filter, out int tagCount); + internal static extern int GetTagCount(string mediaId, IntPtr filter, out int tagCount); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_foreach_tag_from_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAllTags(string mediaId, IntPtr? filter, MediaTagCallback callback, IntPtr userData); + internal static extern int GetAllTags(string mediaId, IntPtr filter, MediaTagCallback callback, IntPtr userData); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_bookmark_count_from_db", CallingConvention = CallingConvention.Cdecl)] internal static extern int GetBookmarkCount(string mediaId, IntPtr filter, out int bookmarkCount); @@ -82,19 +82,19 @@ internal static partial class Interop internal static extern int GetAllFaces(string mediaId, IntPtr filter, MediaFaceCallback callback, IntPtr userData); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_image", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetImage(SafeMediaInformationHandle mediaInformationHandle, out Interop.ImageInformation.SafeImageInformationHandle image); + internal static extern int GetImage(IntPtr mediaInformationHandle, out Interop.ImageInformation.SafeImageInformationHandle image); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_video", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetVideo(SafeMediaInformationHandle mediaInformationHandle, out Interop.VideoInformation.SafeVideoInformationHandle video); + internal static extern int GetVideo(IntPtr mediaInformationHandle, out Interop.VideoInformation.SafeVideoInformationHandle video); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_audio", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetAudio(SafeMediaInformationHandle mediaInformationHandle, out Interop.AudioInformation.SafeAudioInformationHandle audio); + internal static extern int GetAudio(IntPtr mediaInformationHandle, out Interop.AudioInformation.SafeAudioInformationHandle audio); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_media_id", CallingConvention = CallingConvention.Cdecl)] internal static extern int GetMediaId(SafeMediaInformationHandle mediaInformationHandle, out string mediaId); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_file_path", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetFilePath(SafeMediaInformationHandle mediaInformationHandle, out string path); + internal static extern int GetFilePath(SafeMediaInformationHandle mediaInformationHandle, out string filePath); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_display_name", CallingConvention = CallingConvention.Cdecl)] internal static extern int GetDisplayName(SafeMediaInformationHandle mediaInformationHandle, out string name); @@ -118,7 +118,7 @@ internal static partial class Interop internal static extern int GetTimeline(SafeMediaInformationHandle mediaInformationHandle, out int time); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_thumbnail_path", CallingConvention = CallingConvention.Cdecl)] - internal static extern int GetThumbnailPath(SafeMediaInformationHandle mediaInformationHandle, out string path); + internal static extern int GetThumbnailPath(SafeMediaInformationHandle mediaInformationHandle, out string filePath); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_description", CallingConvention = CallingConvention.Cdecl)] internal static extern int GetDescription(SafeMediaInformationHandle mediaInformationHandle, out string description); @@ -235,7 +235,7 @@ internal static partial class Interop internal static extern int SetKeyword(SafeMediaInformationHandle mediaInformationHandle, string keyword); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_update_to_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int UpdateToDB(SafeMediaInformationHandle mediaInformationHandle); + internal static extern int UpdateToDB(IntPtr mediaInformationHandle); [DllImport(Libraries.MediaContent, EntryPoint = "media_info_refresh_metadata_to_db", CallingConvention = CallingConvention.Cdecl)] internal static extern int RefreshMetadataToDB(string mediaId); diff --git a/Tizen.Content/Interop/Interop.MediaPlaylist.cs b/Tizen.Content/Interop/Interop.MediaPlaylist.cs index d599682..2488afc 100644 --- a/Tizen.Content/Interop/Interop.MediaPlaylist.cs +++ b/Tizen.Content/Interop/Interop.MediaPlaylist.cs @@ -37,10 +37,10 @@ internal static partial class Interop internal static extern int SetName(IntPtr playlist, string playlist_name); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_get_thumbnail_path")] - internal static extern int GetThumbnailPath(IntPtr playlist, out string path); + internal static extern int GetThumbnailPath(IntPtr playlist, out string filePath); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_set_thumbnail_path")] - internal static extern int SetThumbnailPath(IntPtr playlist, string path); + internal static extern int SetThumbnailPath(IntPtr playlist, string filePath); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_set_play_order")] internal static extern int SetPlayOrder(IntPtr playlist, int playlist_member_id, int play_order); @@ -58,10 +58,10 @@ internal static partial class Interop internal static extern int UpdateToDb(IntPtr playlist); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_import_from_file")] - internal static extern int ImportFromFile(string playlist_name, string path, out IntPtr playlist); + internal static extern int ImportFromFile(string playlist_name, string filePath, out IntPtr playlist); [DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_export_to_file")] - internal static extern int ExportToFile(IntPtr playlist, string path); + internal static extern int ExportToFile(IntPtr playlist, string filePath); //Callbacks [UnmanagedFunctionPointer(CallingConvention.Cdecl)] diff --git a/Tizen.Content/Interop/Interop.MediaStorage.cs b/Tizen.Content/Interop/Interop.MediaStorage.cs index 11eb6a5..0fe8c68 100644 --- a/Tizen.Content/Interop/Interop.MediaStorage.cs +++ b/Tizen.Content/Interop/Interop.MediaStorage.cs @@ -41,9 +41,9 @@ internal static partial class Interop internal delegate void MediaInfoCallback(Interop.MediaInformation.SafeMediaInformationHandle mediaInformation, IntPtr data); [DllImport(Libraries.MediaContent, EntryPoint = "media_storage_foreach_storage_from_db")] - internal static extern int ForeachStorageFromDb(IntPtr? filter, MediaStorageCallback callback, IntPtr user_data); + internal static extern int ForeachStorageFromDb(IntPtr filter, MediaStorageCallback callback, IntPtr user_data); [DllImport(Libraries.MediaContent, EntryPoint = "media_storage_foreach_media_from_db")] internal static extern int ForeachMediaFromDb(string storage_id, IntPtr filter, MediaInfoCallback callback, IntPtr user_data); } -} \ No newline at end of file +} diff --git a/Tizen.Content/Interop/Interop.VideoInformation.cs b/Tizen.Content/Interop/Interop.VideoInformation.cs old mode 100644 new mode 100755 index 24cf383..e4a7a37 --- a/Tizen.Content/Interop/Interop.VideoInformation.cs +++ b/Tizen.Content/Interop/Interop.VideoInformation.cs @@ -82,7 +82,7 @@ internal static partial class Interop internal static extern int SetPlayedPosition(SafeVideoInformationHandle videoInformationHandle, int playedPosition); [DllImport(Libraries.MediaContent, EntryPoint = "video_meta_update_to_db", CallingConvention = CallingConvention.Cdecl)] - internal static extern int UpdateToDB(SafeVideoInformationHandle videoInformationHandle); + internal static extern int UpdateToDB(IntPtr videoInformationHandle); internal sealed class SafeVideoInformationHandle : SafeHandle { diff --git a/Tizen.Content/Tizen.Content.MediaContent/AudioInformation.cs b/Tizen.Content/Tizen.Content.MediaContent/AudioInformation.cs index 61799ff..11b06a1 100644 --- a/Tizen.Content/Tizen.Content.MediaContent/AudioInformation.cs +++ b/Tizen.Content/Tizen.Content.MediaContent/AudioInformation.cs @@ -22,7 +22,7 @@ namespace Tizen.Content.MediaContent /// AudioContent class API gives the information related to the audio media stored in the device public class AudioInformation : MediaInformation { - internal new readonly Interop.AudioInformation.SafeAudioInformationHandle _handle; + private readonly Interop.AudioInformation.SafeAudioInformationHandle _handle; /// /// Gets the tag ID for the media. @@ -386,21 +386,14 @@ namespace Tizen.Content.MediaContent } } - /// - /// Updates the given audio information in the media database. - /// - /// - /// void - public override void Update() + internal IntPtr AudioHandle { - int result = Interop.AudioInformation.UpdateToDB(_handle); - if ((MediaContentError)result != MediaContentError.None) + get { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); + return _handle.DangerousGetHandle(); } } - internal AudioInformation(Interop.AudioInformation.SafeAudioInformationHandle handle, Interop.MediaInformation.SafeMediaInformationHandle mediaInformationHandle) : base(mediaInformationHandle) { diff --git a/Tizen.Content/Tizen.Content.MediaContent/ContentEventArgs.cs b/Tizen.Content/Tizen.Content.MediaContent/ContentEventArgs.cs index aaa7849..d51dac6 100644 --- a/Tizen.Content/Tizen.Content.MediaContent/ContentEventArgs.cs +++ b/Tizen.Content/Tizen.Content.MediaContent/ContentEventArgs.cs @@ -20,15 +20,15 @@ namespace Tizen.Content.MediaContent public class ContentUpdatedEventArgs : EventArgs { internal ContentUpdatedEventArgs(MediaContentError error, int pid, MediaContentUpdateItemType updateItem, - MediaContentDBUpdateType updateType, MediaContentType mediaType, string uuid, string path, string mimeType) + MediaContentDBUpdateType updateType, MediaContentType mediaType, string uuid, string filePath, string mimeType) { Error = error; - PID = pid; + Pid = pid; UpdateItem = updateItem; UpdateType = updateType; MediaType = mediaType; - UUID = uuid; - Path = path; + Uuid = uuid; + FilePath = filePath; MimeType = mimeType; } /// @@ -43,7 +43,7 @@ namespace Tizen.Content.MediaContent /// /// The PID which publishes notification /// - public int PID + public int Pid { get; set; } @@ -75,7 +75,7 @@ namespace Tizen.Content.MediaContent /// /// The UUID of media or directory, which is updated /// - public string UUID + public string Uuid { get; set; } @@ -83,7 +83,7 @@ namespace Tizen.Content.MediaContent /// /// The path of the media or directory /// - public string Path + public string FilePath { get; set; } @@ -96,18 +96,4 @@ namespace Tizen.Content.MediaContent get; set; } } - - /// - /// Event arguments passed when the media scanning is finished. - /// - public class ContentScanCompletedEventArgs : EventArgs - { - /// - /// The error code - /// - private MediaContentError error - { - get; set; - } - } } diff --git a/Tizen.Content/Tizen.Content.MediaContent/ContentManager.cs b/Tizen.Content/Tizen.Content.MediaContent/ContentManager.cs index 953ff21..66f8492 100644 --- a/Tizen.Content/Tizen.Content.MediaContent/ContentManager.cs +++ b/Tizen.Content/Tizen.Content.MediaContent/ContentManager.cs @@ -33,7 +33,7 @@ namespace Tizen.Content.MediaContent /// ContentManager class is the interface class for accessing the ContentCollection and MediaInformation. /// This class allows usre to create/update db operations for media content. /// - public class ContentManager + public static class ContentManager { private static bool s_isConnected = false; internal static void ConnectToDB() @@ -61,9 +61,9 @@ namespace Tizen.Content.MediaContent } } - private static readonly Interop.Content.MediaContentDBUpdatedCallback s_contentUpdatedCallback = (MediaContentError error, int pid, MediaContentUpdateItemType updateItem, MediaContentDBUpdateType updateType, MediaContentType mediaType, string uuid, string path, string mimeType, IntPtr userData) => + private static readonly Interop.Content.MediaContentDBUpdatedCallback s_contentUpdatedCallback = (MediaContentError error, int pid, MediaContentUpdateItemType updateItem, MediaContentDBUpdateType updateType, MediaContentType mediaType, string uuid, string filePath, string mimeType, IntPtr userData) => { - ContentUpdatedEventArgs eventArgs = new ContentUpdatedEventArgs(error, pid, updateItem, updateType, mediaType, uuid, path, mimeType); + ContentUpdatedEventArgs eventArgs = new ContentUpdatedEventArgs(error, pid, updateItem, updateType, mediaType, uuid, filePath, mimeType); s_contentUpdated?.Invoke(null, eventArgs); }; private static event EventHandler s_contentUpdated; @@ -104,10 +104,10 @@ namespace Tizen.Content.MediaContent /// /// Requests to cancel the media folder scanning. /// - /// The folder path - public static void CancelScanningFolder(string path) + /// The folder path + public static void CancelScanningFolder(string folderPath) { - MediaContentError result = (MediaContentError)Interop.Content.CancelScanFolder(path); + MediaContentError result = (MediaContentError)Interop.Content.CancelScanFolder(folderPath); if (result != MediaContentError.None) { throw MediaContentErrorFactory.CreateException(result, "Failed scan"); @@ -126,6 +126,9 @@ namespace Tizen.Content.MediaContent int count = 0; IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; MediaContentError res = MediaContentError.None; + MediaGroupType groupType = MediaGroupType.DisplayName; + if (handle != IntPtr.Zero) + groupType = filter.GroupType; switch (type) { case ContentCollectionType.Album: @@ -143,6 +146,9 @@ namespace Tizen.Content.MediaContent case ContentCollectionType.PlayList: res = (MediaContentError)Interop.Playlist.GetPlaylistCountFromDb(handle, out count); break; + case ContentCollectionType.Group: + res = (MediaContentError)Interop.Group.GetGroupCountFromDb(handle, groupType, out count); + break; default: res = MediaContentError.InavlidParameter; break; @@ -214,7 +220,7 @@ namespace Tizen.Content.MediaContent /// /// Requests to scan a media file. /// - /// The file path + /// The file path /// A reference to the MediaInformation object scanned /// /// This function requests to scan a media file to the media server. If media file is not registered to DB yet, @@ -222,29 +228,27 @@ namespace Tizen.Content.MediaContent /// then this tries to refresh information. If requested file does not exist on file system, /// information of the media file will be removed from the media DB. /// - public static Task Scan(string path) + public static void Scan(string filePath) { - var task = new TaskCompletionSource(); - MediaContentError result = (MediaContentError)Interop.Content.ScanFile(path); + ConnectToDB(); + MediaContentError result = (MediaContentError)Interop.Content.ScanFile(filePath); if (result != MediaContentError.None) { throw MediaContentErrorFactory.CreateException(result, "Failed scan"); } - task.SetResult(0); - return task.Task; } /// /// Inserts a media to the media database /// /// Media to be inserted - public static MediaInformation AddMediaInformation(string path) + public static MediaInformation AddMediaInformation(string filePath) { MediaInformation mediaInformation = null; ConnectToDB(); Interop.MediaInformation.SafeMediaInformationHandle mediaInformationHandle; //TODO: verify the usage of MediaInformation._handle.DangerousGetHandle() - MediaContentError result = (MediaContentError)Interop.MediaInformation.Insert(path, out mediaInformationHandle); + MediaContentError result = (MediaContentError)Interop.MediaInformation.Insert(filePath, out mediaInformationHandle); if (result != MediaContentError.None) { throw MediaContentErrorFactory.CreateException(result, "Failed to Insert Bookmark to DB"); @@ -256,14 +260,14 @@ namespace Tizen.Content.MediaContent /// /// Requests to scan a media folder, asynchronously. /// - /// The file path + /// The folder path /// /// This function requests to scan a media folder to the media server with given completed callback function. /// ContentScanCompleted event will be truggered when the scanning is finished. /// The sub folders are also scanned,if there are sub folders in that folder. /// If any folder must not be scanned, a blank file ".scan_ignore" has to be created in that folder. /// - public static Task StartScanningFolderAsync(string path, bool recursive = true) + public static Task StartScanningFolderAsync(string folderPath, bool recursive = true) { var task = new TaskCompletionSource(); Interop.Content.MediaScanCompletedCallback scanCompleted = (MediaContentError scanResult, IntPtr data) => @@ -272,7 +276,7 @@ namespace Tizen.Content.MediaContent task.SetResult((int)scanResult); }; - MediaContentError result = (MediaContentError)Interop.Content.ScanFolder(path, recursive, scanCompleted, IntPtr.Zero); + MediaContentError result = (MediaContentError)Interop.Content.ScanFolder(folderPath, recursive, scanCompleted, IntPtr.Zero); if (result != MediaContentError.None) { throw MediaContentErrorFactory.CreateException(result, "Failed scan"); @@ -281,18 +285,17 @@ namespace Tizen.Content.MediaContent } /// - /// Gets the reference to a content collection. + /// Gets the reference to a content store. /// - /// Allowed types: Folder, Storage, Playlist, Tag + /// Allowed types: MediaFolder, Storage /// The id of the media content - /// Reference to the ContentCollection - public static Task GetContentCollectionsAsync(string id) where T : ContentCollection + /// Reference to the ContentSourceType item + public static T GetContentCollection(string id) where T : ContentCollection { ConnectToDB(); MediaContentError res = MediaContentError.None; ContentCollection contentCollection = null; IntPtr _handle; - var task = new TaskCompletionSource(); if (typeof(T) == typeof(MediaFolder)) { res = (MediaContentError)Interop.Folder.GetFolderFromDb(id, out _handle); @@ -301,7 +304,8 @@ namespace Tizen.Content.MediaContent Log.Warn(Globals.LogTag, "Failed to get the content collection"); throw MediaContentErrorFactory.CreateException(res, "Failed to get the content collection"); } - contentCollection = new MediaFolder(_handle); + if (_handle != IntPtr.Zero) + contentCollection = new MediaFolder(_handle); } else if (typeof(T) == typeof(Storage)) { @@ -311,26 +315,32 @@ namespace Tizen.Content.MediaContent Log.Warn(Globals.LogTag, "Failed to get the content collection"); throw MediaContentErrorFactory.CreateException(res, "Failed to get the content collection"); } - contentCollection = new Storage(_handle); + if (_handle != IntPtr.Zero) + { + String path; + Interop.Storage.GetId(_handle, out path); + Console.WriteLine("path from framework : " + path); + contentCollection = new Storage(_handle); + } + else + Console.WriteLine("invalid handle"); } - task.SetResult((T)contentCollection); - return task.Task; + return (T)contentCollection; } /// /// Gets the reference to a content store. /// - /// Allowed types: MediaBookmark, Album + /// Allowed types: PlayList, Album, Tag /// The id of the media content /// Reference to the ContentSourceType item - public static Task GetContentCollectionAsync(int id) where T : ContentCollection + public static T GetContentCollectionAsync(int id) where T : ContentCollection { ConnectToDB(); MediaContentError res = MediaContentError.None; ContentCollection contentCollection = null; IntPtr _handle; - var task = new TaskCompletionSource(); if (typeof(T) == typeof(PlayList)) { res = (MediaContentError)Interop.Playlist.GetPlaylistFromDb(id, out _handle); @@ -339,7 +349,8 @@ namespace Tizen.Content.MediaContent Log.Warn(Globals.LogTag, "Failed to get the content collection"); throw MediaContentErrorFactory.CreateException(res, "Failed to get the content collection"); } - contentCollection = new MediaFolder(_handle); + if (_handle != IntPtr.Zero) + contentCollection = new MediaFolder(_handle); } else if (typeof(T) == typeof(Album)) { @@ -349,7 +360,8 @@ namespace Tizen.Content.MediaContent Log.Warn(Globals.LogTag, "Failed to get the content collection"); throw MediaContentErrorFactory.CreateException(res, "Failed to get the content collection"); } - contentCollection = new Storage(_handle); + if (_handle != IntPtr.Zero) + contentCollection = new Storage(_handle); } else if (typeof(T) == typeof(Tag)) { @@ -359,11 +371,10 @@ namespace Tizen.Content.MediaContent Log.Warn(Globals.LogTag, "Failed to get the content collection"); throw MediaContentErrorFactory.CreateException(res, "Failed to get the content collection"); } - contentCollection = new Storage(_handle); + if (_handle != IntPtr.Zero) + contentCollection = new Storage(_handle); } - - task.SetResult((T)contentCollection); - return task.Task; + return (T)contentCollection; } private static List ForEachFolder(ContentFilter filter) @@ -518,7 +529,7 @@ namespace Tizen.Content.MediaContent /// Allowed types: Album, MediaBookmark, Folder, Storage, Playlist, Tag /// Filter for content items /// - public static Task> GetContentCollectionAsync(ContentFilter filter) where T : ContentCollection + public static Task> GetContentCollectionsAsync(ContentFilter filter) where T : ContentCollection { ConnectToDB(); var task = new TaskCompletionSource>(); @@ -558,11 +569,12 @@ namespace Tizen.Content.MediaContent /// /// Inserts media files into the media database, asynchronously. /// - /// The path array to the media files + /// The path array to the media files /// - public static Task AddBatchMediaInformationAsync(string[] paths) + public static Task AddBatchMediaInformationAsync(IEnumerable filePaths) { ConnectToDB(); + string[] paths = ((List)filePaths).ToArray(); var task = new TaskCompletionSource(); MediaContentError res = MediaContentError.None; Interop.MediaInformation.MediaInsertCompletedCallback callback = (MediaContentError error, IntPtr userData) => @@ -580,12 +592,13 @@ namespace Tizen.Content.MediaContent /// /// Inserts the burst shot images into the media database, asynchronously. /// - /// The path array to the burst shot images + /// The path array to the burst shot images /// - public static Task AddBurstShotImagesAsync(string[] paths) + public static Task AddBurstShotImagesAsync(IEnumerable filePaths) { ConnectToDB(); var task = new TaskCompletionSource(); + string[] paths = ((List)filePaths).ToArray(); MediaContentError res = MediaContentError.None; Interop.MediaInformation.MediaInsertBurstShotCompletedCallback callback = (MediaContentError error, IntPtr userData) => { @@ -643,9 +656,67 @@ namespace Tizen.Content.MediaContent throw MediaContentErrorFactory.CreateException(result, "Failed to clone media"); } - MediaInformation info = new MediaInformation(newHandle); - - mediaInformationList.Add(info); + MediaContentType type; + Interop.MediaInformation.GetMediaType(newHandle, out type); + if (type == MediaContentType.Image) + { + Interop.ImageInformation.SafeImageInformationHandle imageInfo; + result = (MediaContentError)Interop.MediaInformation.GetImage(mediaHandle, out imageInfo); + if (result != MediaContentError.None) + { + Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); + } + if (imageInfo != null) + { + MediaInformation info = new ImageInformation(imageInfo, newHandle); + mediaInformationList.Add(info); + } + else + { + throw MediaContentErrorFactory.CreateException(MediaContentError.InavlidParameter, "Could not find the Image Information"); + } + } + else if ((type == MediaContentType.Music) || (type == MediaContentType.Sound)) + { + Interop.AudioInformation.SafeAudioInformationHandle audioInfo; + result = (MediaContentError)Interop.MediaInformation.GetAudio(mediaHandle, out audioInfo); + if (result != MediaContentError.None) + { + Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); + } + if (audioInfo != null) + { + MediaInformation info = new AudioInformation(audioInfo, newHandle); + mediaInformationList.Add(info); + } + else + { + throw MediaContentErrorFactory.CreateException(MediaContentError.InavlidParameter, "Could not find the Audio Information"); + } + } + else if (type == MediaContentType.Video) + { + Interop.VideoInformation.SafeVideoInformationHandle audioInfo; + result = (MediaContentError)Interop.MediaInformation.GetVideo(mediaHandle, out audioInfo); + if (result != MediaContentError.None) + { + Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); + } + if (audioInfo != null) + { + MediaInformation info = new VideoInformation(audioInfo, newHandle); + mediaInformationList.Add(info); + } + else + { + throw MediaContentErrorFactory.CreateException(MediaContentError.InavlidParameter, "Could not find the Audio Information"); + } + } + else if (type == MediaContentType.Others) + { + MediaInformation info = new MediaInformation(newHandle); + mediaInformationList.Add(info); + } return true; }; result = (MediaContentError)Interop.MediaInformation.GetAllMedia(handle, callback, IntPtr.Zero); @@ -782,11 +853,9 @@ namespace Tizen.Content.MediaContent /// Inserts a content collection to the media database /// /// The content collection to be inserted - public static Task InsertToDatabaseAsync(ContentCollection collection) + public static void InsertToDatabase(ContentCollection collection) { ConnectToDB(); - var task = new TaskCompletionSource(); - task.SetResult(0); Type type = collection.GetType(); if (type == typeof(Tag)) { @@ -794,10 +863,9 @@ namespace Tizen.Content.MediaContent MediaContentError result = (MediaContentError)Interop.Tag.InsertToDb(((Tag)collection).Name, out tagHandle); if (result != MediaContentError.None) { - Log.Error(Globals.LogTag, "Failed to insert collection to the database"); + throw MediaContentErrorFactory.CreateException(result, "Failed to insert collection to the database"); } ((Tag)collection).Handle= tagHandle; - task.SetResult((int)result); } if (type == typeof(PlayList)) { @@ -805,176 +873,166 @@ namespace Tizen.Content.MediaContent MediaContentError result = (MediaContentError)Interop.Playlist.InsertToDb(((PlayList)collection).Name, out playListHandle); if (result != MediaContentError.None) { - Log.Error(Globals.LogTag, "Failed to insert collection to the database"); + throw MediaContentErrorFactory.CreateException(result, "Failed to insert collection to the database"); } ((PlayList)collection).Handle = playListHandle; - task.SetResult((int)result); } if (type == typeof(MediaFolder)) { MediaContentError result = MediaContentError.InvalidOperation; if (result != MediaContentError.None) { - Log.Error(Globals.LogTag, "Failed to insert collection to the database"); + throw MediaContentErrorFactory.CreateException(result, "Failed to insert collection to the database"); } - task.SetResult((int)result); } if (type == typeof(Storage)) { MediaContentError result = MediaContentError.InvalidOperation; if (result != MediaContentError.None) { - Log.Error(Globals.LogTag, "Failed to insert collection to the database"); + throw MediaContentErrorFactory.CreateException(result, "Failed to insert collection to the database"); } - task.SetResult((int)result); } if (type == typeof(Album)) { MediaContentError result = MediaContentError.InvalidOperation; if (result != MediaContentError.None) { - Log.Error(Globals.LogTag, "Failed to insert collection to the database"); + throw MediaContentErrorFactory.CreateException(result, "Failed to insert collection to the database"); } - task.SetResult((int)result); } if (type == typeof(Group)) { MediaContentError result = MediaContentError.InvalidOperation; if (result != MediaContentError.None) { - Log.Error(Globals.LogTag, "Failed to insert collection to the database"); + throw MediaContentErrorFactory.CreateException(result, "Failed to insert collection to the database"); } - task.SetResult((int)result); } - return task.Task; } /// /// Deletes a media from the media database /// /// Media to be deleted - public static Task DeleteFromDatabaseAsync(MediaInformation MediaInformation) + public static void DeleteFromDatabase(MediaInformation MediaInformation) { ConnectToDB(); - var task = new TaskCompletionSource(); - ConnectToDB(); //TODO: verify the usage of MediaInformation._handle.DangerousGetHandle() MediaContentError result = (MediaContentError)Interop.MediaInformation.Delete(MediaInformation.MediaId); if (result != MediaContentError.None) { throw MediaContentErrorFactory.CreateException(result, "Failed to Insert Bookmark to DB"); } - task.SetResult(0); - return task.Task; } /// /// Update a media in the media database /// /// Media to be updated - public static Task UpdateToDatabaseAsync(MediaInformation MediaInformation) + public static void UpdateToDatabase(MediaInformation mediaInformation) { ConnectToDB(); - var task = new TaskCompletionSource(); - ConnectToDB(); - //TODO: verify the usage of MediaInformation._handle.DangerousGetHandle() - MediaContentError result = (MediaContentError)Interop.MediaInformation.UpdateToDB(MediaInformation._handle); + MediaContentError result; + if (mediaInformation is ImageInformation) + { + result = (MediaContentError)Interop.AudioInformation.UpdateToDB(((ImageInformation)mediaInformation).ImageHandle); + if (result != MediaContentError.None) + { + throw MediaContentErrorFactory.CreateException(result, "Failed to Insert Bookmark to DB"); + } + } + else if(mediaInformation is VideoInformation) + { + result = (MediaContentError)Interop.VideoInformation.UpdateToDB(((VideoInformation)mediaInformation).VideoHandle); + if (result != MediaContentError.None) + { + throw MediaContentErrorFactory.CreateException(result, "Failed to Insert Bookmark to DB"); + } + } + else if(mediaInformation is AudioInformation) + { + result = (MediaContentError)Interop.AudioInformation.UpdateToDB(((AudioInformation)mediaInformation).AudioHandle); + if (result != MediaContentError.None) + { + throw MediaContentErrorFactory.CreateException(result, "Failed to Insert Bookmark to DB"); + } + } + result = (MediaContentError)Interop.MediaInformation.UpdateToDB(mediaInformation.MediaHandle); if (result != MediaContentError.None) { throw MediaContentErrorFactory.CreateException(result, "Failed to Insert Bookmark to DB"); } - task.SetResult(0); - return task.Task; } /// /// Inserts a MediaBookmark to the media database /// /// MediaBookmark to be inserted - public static Task InsertToDatabaseAsync(MediaBookmark bookmark) + public static void InsertToDatabase(MediaBookmark bookmark) { ConnectToDB(); - var task = new TaskCompletionSource(); - ConnectToDB(); MediaContentError result = (MediaContentError)Interop.MediaBookmark.InsertToDb(bookmark._mediaId, bookmark._timeStamp, bookmark._thumbnailPath); if (result != MediaContentError.None) { throw MediaContentErrorFactory.CreateException(result, "Failed to Insert Bookmark to DB"); } - task.SetResult(0); - return task.Task; } /// /// Deletes a bookmark from the media database /// /// MediaBookmark to be deleted - public static Task DeleteFromDatabaseAsync(MediaBookmark bookmark) + public static void DeleteFromDatabase(MediaBookmark bookmark) { ConnectToDB(); - var task = new TaskCompletionSource(); - ConnectToDB(); MediaContentError result = (MediaContentError)Interop.MediaBookmark.DeleteFromDb(bookmark.Id); if (result != MediaContentError.None) { throw MediaContentErrorFactory.CreateException(result, "Failed to Delete Bookmark from DB"); } - task.SetResult(0); - return task.Task; } /// /// Deletes a media face from the media database /// /// Media face to be deleted - public static Task DeleteFromDatabaseAsync(MediaFace mediaFace) + public static void DeleteFromDatabase(MediaFace mediaFace) { ConnectToDB(); - var task = new TaskCompletionSource(); - ConnectToDB(); MediaContentError result = (MediaContentError)Interop.Face.DeleteFromDb(mediaFace.Id); if (result != MediaContentError.None) { throw MediaContentErrorFactory.CreateException(result, "Failed to Delete Face from DB"); } - task.SetResult(0); - return task.Task; } /// /// Updates a media face in the media database /// /// Media face to be updated - public static Task UpdateToDatabaseAsync(MediaFace mediaFace) + public static void UpdateToDatabase(MediaFace mediaFace) { ConnectToDB(); - var task = new TaskCompletionSource(); - ConnectToDB(); MediaContentError result = (MediaContentError)Interop.Face.UpdateToDb(mediaFace.Handle); if (result != MediaContentError.None) { throw MediaContentErrorFactory.CreateException(result, "Failed to update Face to DB"); } - task.SetResult(0); - return task.Task; } /// /// Inserts a media face to the media database /// /// Media face to be inserted - public static Task InsertToDatabaseAsync(MediaFace mediaFace) + public static void InsertToDatabase(MediaFace mediaFace) { ConnectToDB(); - var task = new TaskCompletionSource(); - ConnectToDB(); MediaContentError result = (MediaContentError)Interop.Face.InsertToDb(mediaFace.Handle); if (result != MediaContentError.None) { throw MediaContentErrorFactory.CreateException(result, "Failed to add Face to DB"); } - task.SetResult(0); - return task.Task; } } } diff --git a/Tizen.Content/Tizen.Content.MediaContent/CreateThumbnailResult.cs b/Tizen.Content/Tizen.Content.MediaContent/CreateThumbnailResult.cs index e4dd19c..5a76dcf 100644 --- a/Tizen.Content/Tizen.Content.MediaContent/CreateThumbnailResult.cs +++ b/Tizen.Content/Tizen.Content.MediaContent/CreateThumbnailResult.cs @@ -42,7 +42,7 @@ namespace Tizen.Content.MediaContent /// /// /// string path of the thumbnail. - public string Path + public string FilePath { get; internal set; diff --git a/Tizen.Content/Tizen.Content.MediaContent/ImageInformation.cs b/Tizen.Content/Tizen.Content.MediaContent/ImageInformation.cs index 41016d6..7221c03 100644 --- a/Tizen.Content/Tizen.Content.MediaContent/ImageInformation.cs +++ b/Tizen.Content/Tizen.Content.MediaContent/ImageInformation.cs @@ -21,7 +21,8 @@ namespace Tizen.Content.MediaContent /// ImageContent class API gives the information related to the image media stored in the device public class ImageInformation : MediaInformation { - internal new readonly Interop.ImageInformation.SafeImageInformationHandle _handle; + private readonly Interop.ImageInformation.SafeImageInformationHandle _handle; + /// /// Gets the tag ID for the image. /// @@ -233,21 +234,14 @@ namespace Tizen.Content.MediaContent } } - /// - /// Updates the given image information in the media database. - /// - /// - /// void - public override void Update() + internal IntPtr ImageHandle { - int result = Interop.ImageInformation.UpdateToDB(_handle); - if ((MediaContentError)result != MediaContentError.None) + get { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); + return _handle.DangerousGetHandle(); } } - internal ImageInformation(Interop.ImageInformation.SafeImageInformationHandle handle, Interop.MediaInformation.SafeMediaInformationHandle mediaInformationHandle) : base(mediaInformationHandle) { diff --git a/Tizen.Content/Tizen.Content.MediaContent/MediaBookmark.cs b/Tizen.Content/Tizen.Content.MediaContent/MediaBookmark.cs index 400e547..f0d3b70 100644 --- a/Tizen.Content/Tizen.Content.MediaContent/MediaBookmark.cs +++ b/Tizen.Content/Tizen.Content.MediaContent/MediaBookmark.cs @@ -22,7 +22,7 @@ namespace Tizen.Content.MediaContent { private IntPtr _bookmarkHandle; private bool _disposedValue = false; - internal readonly uint _timeStamp; + internal readonly DateTime _timeStamp; internal readonly String _thumbnailPath; internal readonly String _mediaId; internal MediaBookmark(IntPtr handle) @@ -90,7 +90,7 @@ namespace Tizen.Content.MediaContent /// /// The bookmark time offset (in seconds) /// The thumbnail path of video bookmark. If the media type is audio, then thumbnail is null. - public MediaBookmark(MediaInformation content, uint time, string thumbnailPath) + public MediaBookmark(MediaInformation content, DateTime time, string thumbnailPath) { _mediaId = content.MediaId; _timeStamp = time; diff --git a/Tizen.Content/Tizen.Content.MediaContent/MediaContentEnums.cs b/Tizen.Content/Tizen.Content.MediaContent/MediaContentEnums.cs index 56ac1e1..4b5a1a2 100644 --- a/Tizen.Content/Tizen.Content.MediaContent/MediaContentEnums.cs +++ b/Tizen.Content/Tizen.Content.MediaContent/MediaContentEnums.cs @@ -17,11 +17,11 @@ namespace Tizen.Content.MediaContent /// /// Ascending order /// - ASC, + Asc, /// /// Descending order /// - DESC + Desc } /// @@ -36,7 +36,7 @@ namespace Tizen.Content.MediaContent /// /// Media file path. You can use above define to set the condition of media filter and order keyword. /// - Path, + FilePath, /// /// Media base name. You can use above define to set the condition of media filter and order keyword. /// @@ -453,8 +453,7 @@ namespace Tizen.Content.MediaContent /// /// Invalid media group ID /// - Max, - None + Max } /// /// Enumerations for defining set of conditions in media filer for media folder @@ -546,25 +545,29 @@ namespace Tizen.Content.MediaContent public enum ContentCollectionType { /// - /// + ///Content Collection type folder /// Folder, /// - /// + ///Content Collection type storage /// Storage, /// - /// + /// Content Collection type album /// Album, /// - /// + ///Content Collection type playlist /// PlayList, /// - /// + ///Content Collection type tag + /// + Tag, + /// + ///Content Collection type group /// - Tag + Group } /// /// Enum to give the type of media information. @@ -633,4 +636,4 @@ namespace Tizen.Content.MediaContent /// Rot270 = 8 }; -} \ No newline at end of file +} diff --git a/Tizen.Content/Tizen.Content.MediaContent/MediaContentErrorFactory.cs b/Tizen.Content/Tizen.Content.MediaContent/MediaContentErrorFactory.cs index 4e2c2c1..2e8bdf2 100644 --- a/Tizen.Content/Tizen.Content.MediaContent/MediaContentErrorFactory.cs +++ b/Tizen.Content/Tizen.Content.MediaContent/MediaContentErrorFactory.cs @@ -13,52 +13,52 @@ namespace Tizen.Content.MediaContent { case MediaContentError.InavlidParameter: { - exp = new ArgumentException("Invalid Parameters Provided"); + exp = new ArgumentException(msg +" Invalid Parameters Provided"); break; } - case MediaContentError.OotOfMemory: + case MediaContentError.OutOfMemory: { - exp = new InvalidOperationException("Out Of Memory"); + exp = new InvalidOperationException(msg + " Out Of Memory"); break; } case MediaContentError.InavlidOperation: { - exp = new InvalidOperationException("Inavlid operation"); + exp = new InvalidOperationException(msg + " Inavlid operation"); break; } case MediaContentError.NoSpaceOnDevice: { - exp = new InvalidOperationException("No Space Left on Device"); + exp = new InvalidOperationException(msg + " No Space Left on Device"); break; } case MediaContentError.PermissionDenied: { - exp = new InvalidOperationException("Permission Denied"); + exp = new InvalidOperationException(msg + " Permission Denied"); break; } case MediaContentError.DBFailed: { - exp = new InvalidOperationException("DataBase Failed"); + exp = new InvalidOperationException(msg + " DataBase Failed"); break; } case MediaContentError.DBBusy: { - exp = new InvalidOperationException("DataBase Busy"); + exp = new InvalidOperationException(msg + " DataBase Busy"); break; } case MediaContentError.NetworkError: { - exp = new InvalidOperationException("Network Error"); + exp = new InvalidOperationException(msg + " Network Error"); break; } case MediaContentError.UnsupportedContent: { - exp = new ArgumentException("Content Not Supported"); + exp = new ArgumentException(msg + " Content Not Supported"); break; } default: { - exp = new InvalidOperationException(""); + exp = new InvalidOperationException(msg); break; } } diff --git a/Tizen.Content/Tizen.Content.MediaContent/MediaContentTypes.cs b/Tizen.Content/Tizen.Content.MediaContent/MediaContentTypes.cs index 7d4c074..a078b24 100644 --- a/Tizen.Content/Tizen.Content.MediaContent/MediaContentTypes.cs +++ b/Tizen.Content/Tizen.Content.MediaContent/MediaContentTypes.cs @@ -37,7 +37,7 @@ namespace Tizen.Content.MediaContent /// /// Out of memory. /// - OotOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, + OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, /// /// Invalid Operation. /// diff --git a/Tizen.Content/Tizen.Content.MediaContent/MediaFolder.cs b/Tizen.Content/Tizen.Content.MediaContent/MediaFolder.cs index bb91bff..81a024b 100644 --- a/Tizen.Content/Tizen.Content.MediaContent/MediaFolder.cs +++ b/Tizen.Content/Tizen.Content.MediaContent/MediaFolder.cs @@ -70,7 +70,7 @@ namespace Tizen.Content.MediaContent /// /// The path of the media folder /// - public string Path + public string FolderPath { get { diff --git a/Tizen.Content/Tizen.Content.MediaContent/MediaInformation.cs b/Tizen.Content/Tizen.Content.MediaContent/MediaInformation.cs index 71410d2..6e457cb 100644 --- a/Tizen.Content/Tizen.Content.MediaContent/MediaInformation.cs +++ b/Tizen.Content/Tizen.Content.MediaContent/MediaInformation.cs @@ -27,20 +27,19 @@ namespace Tizen.Content.MediaContent /// handling with thumbnail and updating media info to DB. public class MediaInformation { - internal readonly Interop.MediaInformation.SafeMediaInformationHandle _handle; + private readonly Interop.MediaInformation.SafeMediaInformationHandle _handle; /// /// Gets the count of media tags for the passed filter in the given mediaId from the media database. /// /// /// int count - /// The content having the Media Id for the Tags /// The Filter for matching Tags - public int GetTagCount(MediaInformation content, ContentFilter filter) + public int GetTagCount(ContentFilter filter) { int count = 0; IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - int result = Interop.MediaInformation.GetTagCount(content.MediaId, handle, out count); + int result = Interop.MediaInformation.GetTagCount(MediaId, handle, out count); if ((MediaContentError)result != MediaContentError.None) { Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); @@ -114,20 +113,6 @@ namespace Tizen.Content.MediaContent } /// - /// Updates the given media info in the media database. - /// - /// - /// void - public virtual void Update() - { - int result = Interop.MediaInformation.UpdateToDB(_handle); - if ((MediaContentError)result != MediaContentError.None) - { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); - } - } - - /// /// Cancels the creation of image's thumbnail for the given media. /// /// @@ -153,7 +138,7 @@ namespace Tizen.Content.MediaContent { CreateThumbnailResult response = new CreateThumbnailResult(); response.Result = createResult; - response.Path = path; + response.FilePath = path; task.SetResult(response); }; int result = Interop.MediaInformation.CreateThumbnail(_handle, thumbnailResult, IntPtr.Zero); @@ -997,6 +982,13 @@ namespace Tizen.Content.MediaContent } } + internal IntPtr MediaHandle + { + get + { + return _handle.DangerousGetHandle(); + } + } internal MediaInformation(Interop.MediaInformation.SafeMediaInformationHandle handle) { diff --git a/Tizen.Content/Tizen.Content.MediaContent/PlayList.cs b/Tizen.Content/Tizen.Content.MediaContent/PlayList.cs index 8fce886..e3caecd 100644 --- a/Tizen.Content/Tizen.Content.MediaContent/PlayList.cs +++ b/Tizen.Content/Tizen.Content.MediaContent/PlayList.cs @@ -22,6 +22,7 @@ namespace Tizen.Content.MediaContent /// public class PlayList : ContentCollection { + private IDictionary dictionary = new Dictionary(); private IntPtr _playlistHandle; internal IntPtr Handle { @@ -35,6 +36,31 @@ namespace Tizen.Content.MediaContent } } + private void refreshPlaylistDictionary() + { + dictionary.Clear(); + MediaContentError res; + Interop.Playlist.PlaylistMemberCallback callback = (int memberId, IntPtr mediaHandle, IntPtr data) => + { + Interop.MediaInformation.SafeMediaInformationHandle newHandle; + res = (MediaContentError)Interop.MediaInformation.Clone(out newHandle, mediaHandle); + if (res != MediaContentError.None) + { + throw MediaContentErrorFactory.CreateException(res, "Failed to clone media"); + } + + MediaInformation info = new MediaInformation(newHandle); + string mediaId; + Interop.MediaInformation.GetMediaId(newHandle, out mediaId); + dictionary.Add(mediaId, memberId); + }; + res = (MediaContentError)Interop.Playlist.ForeachMediaFromDb(Id, IntPtr.Zero, callback, IntPtr.Zero); + if (res != MediaContentError.None) + { + throw MediaContentErrorFactory.CreateException(res, "Failed to get playlist items"); + } + } + /// /// The ID of the media playlist /// @@ -103,7 +129,7 @@ namespace Tizen.Content.MediaContent /// /// The constructor to create a new playlist with the given name in the media database. /// - /// The name of the inserted playlist + /// The name of the inserted playlist public PlayList(string name) { Name = name; @@ -138,8 +164,14 @@ namespace Tizen.Content.MediaContent /// Removes the playlist members related with the media from the given playlist. /// /// The AudioContent object to be removed - public void RemoveItem(int memberId) + public void RemoveItem(MediaInformation media) { + int memberId = -1; + dictionary.TryGetValue(media.MediaId, out memberId); + if (memberId == -1) { + refreshPlaylistDictionary(); + } + dictionary.TryGetValue(media.MediaId, out memberId); MediaContentError res = (MediaContentError)Interop.Playlist.RemoveMedia(_playlistHandle, memberId); if (res != MediaContentError.None) { @@ -181,17 +213,17 @@ namespace Tizen.Content.MediaContent /// Imports the playlist from m3u playlist file. /// /// The name of the playlist to save - /// The path to import the playlist file + /// The path to import the playlist file /// The imported PlayList object - public static PlayList Import(string name, string path) + public static PlayList Import(string name, string filePath) { PlayList playList = null; IntPtr playlistHandle; - MediaContentError res = (MediaContentError)Interop.Playlist.ImportFromFile(name, path, out playlistHandle); + MediaContentError res = (MediaContentError)Interop.Playlist.ImportFromFile(name, filePath, out playlistHandle); if (res != MediaContentError.None) { - throw MediaContentErrorFactory.CreateException(res, "Failed to import playlist " + name + " from " + path); + throw MediaContentErrorFactory.CreateException(res, "Failed to import playlist " + name + " from " + filePath); } playList = new PlayList(name); playList._playlistHandle = playlistHandle; @@ -202,47 +234,14 @@ namespace Tizen.Content.MediaContent /// Exports the playlist to m3u playlist file. /// /// path The path to export the playlist - public static void Export(PlayList list, string path) - { - - MediaContentError res = (MediaContentError)Interop.Playlist.ExportToFile(list.Handle, path); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to export playlist " + list.Name + " to " + path); - } - } - - /// - /// Gets the media content list for the given playlist member id. - /// - /// The content filter - /// Media content list - public Task> GetPlayListItemsAsync(ContentFilter filter) + public static void Export(PlayList list, string filePath) { - var tcs = new TaskCompletionSource>(); - - IDictionary dictionary = new Dictionary(); - IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero; - MediaContentError res; - Interop.Playlist.PlaylistMemberCallback callback = (int memberId, IntPtr mediaHandle, IntPtr data) => - { - Interop.MediaInformation.SafeMediaInformationHandle newHandle ; - res = (MediaContentError)Interop.MediaInformation.Clone(out newHandle, mediaHandle); - if (res != MediaContentError.None) - { - throw MediaContentErrorFactory.CreateException(res, "Failed to clone media"); - } - MediaInformation info = new MediaInformation(newHandle); - dictionary.Add(memberId, info); - }; - res = (MediaContentError)Interop.Playlist.ForeachMediaFromDb(Id, handle, callback, IntPtr.Zero); + MediaContentError res = (MediaContentError)Interop.Playlist.ExportToFile(list.Handle, filePath); if (res != MediaContentError.None) { - throw MediaContentErrorFactory.CreateException(res, "Failed to get playlist items"); + throw MediaContentErrorFactory.CreateException(res, "Failed to export playlist " + list.Name + " to " + filePath); } - tcs.TrySetResult(dictionary); - return tcs.Task; } /// diff --git a/Tizen.Content/Tizen.Content.MediaContent/Storage.cs b/Tizen.Content/Tizen.Content.MediaContent/Storage.cs index b34e6a1..21ab3d2 100644 --- a/Tizen.Content/Tizen.Content.MediaContent/Storage.cs +++ b/Tizen.Content/Tizen.Content.MediaContent/Storage.cs @@ -18,15 +18,15 @@ namespace Tizen.Content.MediaContent /// The system generates the storage id when the external storage is added.And the system manages the media information in each of the storage by using storage id. /// So you can get the information from the storage that you want to view. /// - internal class Storage : ContentCollection + public class Storage : ContentCollection { private IntPtr _storageHandle; - internal IntPtr Handle - { - get - { - return _storageHandle; - } + internal IntPtr Handle + { + get + { + return _storageHandle; + } } /// /// The storage id of the media storage @@ -48,7 +48,7 @@ namespace Tizen.Content.MediaContent /// /// The storage path of the media storage /// - public string Path + public string StoragePath { get { diff --git a/Tizen.Content/Tizen.Content.MediaContent/Tag.cs b/Tizen.Content/Tizen.Content.MediaContent/Tag.cs index b2721f6..d7b8bec 100644 --- a/Tizen.Content/Tizen.Content.MediaContent/Tag.cs +++ b/Tizen.Content/Tizen.Content.MediaContent/Tag.cs @@ -20,16 +20,16 @@ namespace Tizen.Content.MediaContent public class Tag : ContentCollection { private IntPtr _tagHandle; - internal IntPtr Handle - { - get - { - return _tagHandle; - } - set - { - _tagHandle = value; - } + internal IntPtr Handle + { + get + { + return _tagHandle; + } + set + { + _tagHandle = value; + } } /// /// The ID of the media tag @@ -86,10 +86,10 @@ namespace Tizen.Content.MediaContent Name = tagName; ContentManager.ConnectToDB(); MediaContentError res = (MediaContentError)Interop.Tag.InsertToDb(tagName, out _tagHandle); - if (res != MediaContentError.None) - { - Console.WriteLine("Exception occured "+ res); - throw MediaContentErrorFactory.CreateException(res, "Failed to create playlist"); + if (res != MediaContentError.None) + { + Console.WriteLine("Exception occured "+ res); + throw MediaContentErrorFactory.CreateException(res, "Failed to create playlist"); } string test; Interop.Tag.GetName(_tagHandle, out test); diff --git a/Tizen.Content/Tizen.Content.MediaContent/VideoInformation.cs b/Tizen.Content/Tizen.Content.MediaContent/VideoInformation.cs index e8f5b87..f828975 100644 --- a/Tizen.Content/Tizen.Content.MediaContent/VideoInformation.cs +++ b/Tizen.Content/Tizen.Content.MediaContent/VideoInformation.cs @@ -366,21 +366,15 @@ namespace Tizen.Content.MediaContent } } - /// - /// Updates the given video information in the media database. - /// - /// - /// void - public override void Update() + internal IntPtr VideoHandle { - int result = Interop.VideoInformation.UpdateToDB(_handle); - if ((MediaContentError)result != MediaContentError.None) + get { - Log.Error(Globals.LogTag, "Error Occured with error code: " + (MediaContentError)result); + return _handle.DangerousGetHandle(); } } - internal new readonly Interop.VideoInformation.SafeVideoInformationHandle _handle; + private readonly Interop.VideoInformation.SafeVideoInformationHandle _handle; internal VideoInformation(Interop.VideoInformation.SafeVideoInformationHandle handle, Interop.MediaInformation.SafeMediaInformationHandle mediaInformationHandle) : base(mediaInformationHandle) diff --git a/Tizen.Content/Tizen.Content.csproj b/Tizen.Content/Tizen.Content.csproj old mode 100644 new mode 100755 index 4b9f330..3448ae4 --- a/Tizen.Content/Tizen.Content.csproj +++ b/Tizen.Content/Tizen.Content.csproj @@ -44,55 +44,18 @@ - ..\..\..\Desktop\Tizen_dlls\Tizen.dll + ..\tct-mediacontent-tizen-tests\lib\Tizen.dll - ..\..\..\Desktop\Tizen_dlls\Tizen.Applications.dll + ..\tct-mediacontent-tizen-tests\lib\Tizen.Applications.dll - ..\..\..\Desktop\Tizen_dlls\Tizen.Internals.dll + ..\tct-mediacontent-tizen-tests\lib\Tizen.Internals.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + @@ -105,4 +68,4 @@ --> - \ No newline at end of file + diff --git a/packaging/csapi-media-content.spec b/packaging/csapi-media-content.spec old mode 100644 new mode 100755 index 0aa5b21..dc7e678 --- a/packaging/csapi-media-content.spec +++ b/packaging/csapi-media-content.spec @@ -1,5 +1,5 @@ %define dllpath %{_libdir}/mono/tizen -%define dllname Tizen.Messaging.MediaContent.dll +%define dllname Tizen.Content.MediaContent.dll Name: csapi-media-content Summary: Tizen Media Content API for C# @@ -46,7 +46,7 @@ cp %{SOURCE1} . mcs -target:library -out:%{dllname} -keyfile:Tizen.Content/Tizen.Content.snk -pkg:'csapi-tizen'\ Tizen.Content/Properties/AssemblyInfo.cs \ Tizen.Content/Interop/*.cs \ - Tizen.Content/MediaContent/*.cs + Tizen.Content/Tizen.Content.MediaContent/*.cs # check p/invoke if [ -x %{dllname} ]; then