diff options
author | Praveen Gattu <gattu.p@samsung.com> | 2016-05-25 17:53:34 +0530 |
---|---|---|
committer | Praveen Gattu <gattu.p@samsung.com> | 2016-05-30 16:01:36 +0530 |
commit | 2ab06a651a745942dd390f1cb5ac8628dfdf5007 (patch) | |
tree | 53ebc95d2958fd664f148aff62d2ec47a52ef68a | |
parent | 363292b46e40a161720b15c15e29c0f6f7977c10 (diff) | |
download | media-content-2ab06a651a745942dd390f1cb5ac8628dfdf5007.tar.gz media-content-2ab06a651a745942dd390f1cb5ac8628dfdf5007.tar.bz2 media-content-2ab06a651a745942dd390f1cb5ac8628dfdf5007.zip |
Fixed review comments and updated CSProj file.
Changed async apis.Incorporated SE review comments.
Change-Id: I4a7e912839f33a310bc88460c4e9a6b6ee0f0391
Signed-off-by: Praveen Gattu <gattu.p@samsung.com>
25 files changed, 318 insertions, 336 deletions
diff --git a/Tizen.Content/Interop/Interop.AudioInformation.cs b/Tizen.Content/Interop/Interop.AudioInformation.cs index d93120b..3f604bf 100644..100755 --- 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 index a76893a..35afe8d 100644..100755 --- 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 index 24cf383..e4a7a37 100644..100755 --- 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</summary> public class AudioInformation : MediaInformation { - internal new readonly Interop.AudioInformation.SafeAudioInformationHandle _handle; + private readonly Interop.AudioInformation.SafeAudioInformationHandle _handle; /// <summary> /// Gets the tag ID for the media. @@ -386,21 +386,14 @@ namespace Tizen.Content.MediaContent } } - /// <summary> - /// Updates the given audio information in the media database. - /// </summary> - /// <returns> - /// void </returns> - 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; } /// <summary> @@ -43,7 +43,7 @@ namespace Tizen.Content.MediaContent /// <summary> /// The PID which publishes notification /// </summary> - public int PID + public int Pid { get; set; } @@ -75,7 +75,7 @@ namespace Tizen.Content.MediaContent /// <summary> /// The UUID of media or directory, which is updated /// </summary> - public string UUID + public string Uuid { get; set; } @@ -83,7 +83,7 @@ namespace Tizen.Content.MediaContent /// <summary> /// The path of the media or directory /// </summary> - public string Path + public string FilePath { get; set; } @@ -96,18 +96,4 @@ namespace Tizen.Content.MediaContent get; set; } } - - /// <summary> - /// Event arguments passed when the media scanning is finished. - /// </summary> - public class ContentScanCompletedEventArgs : EventArgs - { - /// <summary> - /// The error code - /// </summary> - 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. /// </summary> - 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<ContentUpdatedEventArgs> s_contentUpdated; @@ -104,10 +104,10 @@ namespace Tizen.Content.MediaContent /// <summary> /// Requests to cancel the media folder scanning. /// </summary> - /// <param name="path">The folder path</param> - public static void CancelScanningFolder(string path) + /// <param name="folderPath">The folder path</param> + 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 /// <summary> /// Requests to scan a media file. /// </summary> - /// <param name="path">The file path</param> + /// <param name="filePath">The file path</param> /// <returns>A reference to the MediaInformation object scanned</returns> /// <remarks> /// 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. /// </remarks> - public static Task Scan(string path) + public static void Scan(string filePath) { - var task = new TaskCompletionSource<int>(); - 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; } /// <summary> /// Inserts a media to the media database /// </summary> /// <param name="MediaInformation">Media to be inserted</param> - 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 /// <summary> /// Requests to scan a media folder, asynchronously. /// </summary> - /// <param name="path">The file path</param> + /// <param name="folderPath">The folder path</param> /// <remarks> /// 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. /// </remarks> - public static Task StartScanningFolderAsync(string path, bool recursive = true) + public static Task StartScanningFolderAsync(string folderPath, bool recursive = true) { var task = new TaskCompletionSource<int>(); 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 } /// <summary> - /// Gets the reference to a content collection. + /// Gets the reference to a content store. /// </summary> - /// <param name="type">Allowed types: Folder, Storage, Playlist, Tag</param> + /// <param name="type">Allowed types: MediaFolder, Storage</param> /// <param name="id">The id of the media content</param> - /// <returns>Reference to the ContentCollection</returns> - public static Task<T> GetContentCollectionsAsync<T>(string id) where T : ContentCollection + /// <returns>Reference to the ContentSourceType item</returns> + public static T GetContentCollection<T>(string id) where T : ContentCollection { ConnectToDB(); MediaContentError res = MediaContentError.None; ContentCollection contentCollection = null; IntPtr _handle; - var task = new TaskCompletionSource<T>(); 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; } /// <summary> /// Gets the reference to a content store. /// </summary> - /// <param name="type">Allowed types: MediaBookmark, Album</param> + /// <param name="type">Allowed types: PlayList, Album, Tag</param> /// <param name="id">The id of the media content</param> /// <returns>Reference to the ContentSourceType item</returns> - public static Task<T> GetContentCollectionAsync<T>(int id) where T : ContentCollection + public static T GetContentCollectionAsync<T>(int id) where T : ContentCollection { ConnectToDB(); MediaContentError res = MediaContentError.None; ContentCollection contentCollection = null; IntPtr _handle; - var task = new TaskCompletionSource<T>(); 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<MediaFolder> ForEachFolder(ContentFilter filter) @@ -518,7 +529,7 @@ namespace Tizen.Content.MediaContent /// <param name="type">Allowed types: Album, MediaBookmark, Folder, Storage, Playlist, Tag</param> /// <param name="filter">Filter for content items</param> /// <returns></returns> - public static Task<IEnumerable<T>> GetContentCollectionAsync<T>(ContentFilter filter) where T : ContentCollection + public static Task<IEnumerable<T>> GetContentCollectionsAsync<T>(ContentFilter filter) where T : ContentCollection { ConnectToDB(); var task = new TaskCompletionSource<IEnumerable<T>>(); @@ -558,11 +569,12 @@ namespace Tizen.Content.MediaContent /// <summary> /// Inserts media files into the media database, asynchronously. /// </summary> - /// <param name="paths">The path array to the media files</param> + /// <param name="filePaths">The path array to the media files</param> /// <returns></returns> - public static Task AddBatchMediaInformationAsync(string[] paths) + public static Task AddBatchMediaInformationAsync(IEnumerable<string> filePaths) { ConnectToDB(); + string[] paths = ((List<string>)filePaths).ToArray(); var task = new TaskCompletionSource<int>(); MediaContentError res = MediaContentError.None; Interop.MediaInformation.MediaInsertCompletedCallback callback = (MediaContentError error, IntPtr userData) => @@ -580,12 +592,13 @@ namespace Tizen.Content.MediaContent /// <summary> /// Inserts the burst shot images into the media database, asynchronously. /// </summary> - /// <param name="paths">The path array to the burst shot images</param> + /// <param name="filePaths">The path array to the burst shot images</param> /// <returns></returns> - public static Task AddBurstShotImagesAsync(string[] paths) + public static Task AddBurstShotImagesAsync(IEnumerable<string> filePaths) { ConnectToDB(); var task = new TaskCompletionSource<int>(); + string[] paths = ((List<string>)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 /// </summary> /// <param name="collection">The content collection to be inserted</param> - public static Task InsertToDatabaseAsync(ContentCollection collection) + public static void InsertToDatabase(ContentCollection collection) { ConnectToDB(); - var task = new TaskCompletionSource<int>(); - 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; } /// <summary> /// Deletes a media from the media database /// </summary> /// <param name="MediaInformation">Media to be deleted</param> - public static Task DeleteFromDatabaseAsync(MediaInformation MediaInformation) + public static void DeleteFromDatabase(MediaInformation MediaInformation) { ConnectToDB(); - var task = new TaskCompletionSource<int>(); - 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; } /// <summary> /// Update a media in the media database /// </summary> /// <param name="MediaInformation">Media to be updated</param> - public static Task UpdateToDatabaseAsync(MediaInformation MediaInformation) + public static void UpdateToDatabase(MediaInformation mediaInformation) { ConnectToDB(); - var task = new TaskCompletionSource<int>(); - 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; } /// <summary> /// Inserts a MediaBookmark to the media database /// </summary> /// <param name="bookmark">MediaBookmark to be inserted</param> - public static Task InsertToDatabaseAsync(MediaBookmark bookmark) + public static void InsertToDatabase(MediaBookmark bookmark) { ConnectToDB(); - var task = new TaskCompletionSource<int>(); - 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; } /// <summary> /// Deletes a bookmark from the media database /// </summary> /// <param name="bookmark">MediaBookmark to be deleted</param> - public static Task DeleteFromDatabaseAsync(MediaBookmark bookmark) + public static void DeleteFromDatabase(MediaBookmark bookmark) { ConnectToDB(); - var task = new TaskCompletionSource<int>(); - 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; } /// <summary> /// Deletes a media face from the media database /// </summary> /// <param name="mediaFace">Media face to be deleted</param> - public static Task DeleteFromDatabaseAsync(MediaFace mediaFace) + public static void DeleteFromDatabase(MediaFace mediaFace) { ConnectToDB(); - var task = new TaskCompletionSource<int>(); - 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; } /// <summary> /// Updates a media face in the media database /// </summary> /// <param name="mediaFace">Media face to be updated</param> - public static Task UpdateToDatabaseAsync(MediaFace mediaFace) + public static void UpdateToDatabase(MediaFace mediaFace) { ConnectToDB(); - var task = new TaskCompletionSource<int>(); - 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; } /// <summary> /// Inserts a media face to the media database /// </summary> /// <param name="mediaFace">Media face to be inserted</param> - public static Task InsertToDatabaseAsync(MediaFace mediaFace) + public static void InsertToDatabase(MediaFace mediaFace) { ConnectToDB(); - var task = new TaskCompletionSource<int>(); - 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 /// </summary> /// <value> /// string path of the thumbnail.</value> - 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</summary> public class ImageInformation : MediaInformation { - internal new readonly Interop.ImageInformation.SafeImageInformationHandle _handle; + private readonly Interop.ImageInformation.SafeImageInformationHandle _handle; + /// <summary> /// Gets the tag ID for the image. /// </summary> @@ -233,21 +234,14 @@ namespace Tizen.Content.MediaContent } } - /// <summary> - /// Updates the given image information in the media database. - /// </summary> - /// <returns> - /// void </returns> - 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 /// </summary> /// <param name="timeStamp">The bookmark time offset (in seconds)</param> /// <param name="thumbnailPath">The thumbnail path of video bookmark. If the media type is audio, then thumbnail is null.</param> - 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 /// <summary> /// Ascending order /// </summary> - ASC, + Asc, /// <summary> /// Descending order /// </summary> - DESC + Desc } /// <summary> @@ -36,7 +36,7 @@ namespace Tizen.Content.MediaContent /// <summary> /// Media file path. You can use above define to set the condition of media filter and order keyword. /// </summary> - Path, + FilePath, /// <summary> /// Media base name. You can use above define to set the condition of media filter and order keyword. /// </summary> @@ -453,8 +453,7 @@ namespace Tizen.Content.MediaContent /// <summary> /// Invalid media group ID /// </summary> - Max, - None + Max } /// <summary> /// Enumerations for defining set of conditions in media filer for media folder @@ -546,25 +545,29 @@ namespace Tizen.Content.MediaContent public enum ContentCollectionType { /// <summary> - /// + ///Content Collection type folder /// </summary> Folder, /// <summary> - /// + ///Content Collection type storage /// </summary> Storage, /// <summary> - /// + /// Content Collection type album /// </summary> Album, /// <summary> - /// + ///Content Collection type playlist /// </summary> PlayList, /// <summary> - /// + ///Content Collection type tag + /// </summary> + Tag, + /// <summary> + ///Content Collection type group /// </summary> - Tag + Group } /// <summary> /// Enum to give the type of media information.</summary> @@ -633,4 +636,4 @@ namespace Tizen.Content.MediaContent /// </summary> 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 /// <summary> /// Out of memory. /// </summary> - OotOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, + OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory, /// <summary> /// Invalid Operation. /// </summary> 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 /// <summary> /// The path of the media folder /// </summary> - 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.</remarks> public class MediaInformation { - internal readonly Interop.MediaInformation.SafeMediaInformationHandle _handle; + private readonly Interop.MediaInformation.SafeMediaInformationHandle _handle; /// <summary> /// Gets the count of media tags for the passed filter in the given mediaId from the media database. /// </summary> /// <returns> /// int count</returns> - /// <param name="content"> The content having the Media Id for the Tags</param> /// <param name="filter">The Filter for matching Tags</param> - 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 } /// <summary> - /// Updates the given media info in the media database. - /// </summary> - /// <returns> - /// void </returns> - 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); - } - } - - /// <summary> /// Cancels the creation of image's thumbnail for the given media. /// </summary> /// <returns> @@ -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 /// </remarks> public class PlayList : ContentCollection { + private IDictionary<string, int> dictionary = new Dictionary<string, int>(); 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"); + } + } + /// <summary> /// The ID of the media playlist /// </summary> @@ -103,7 +129,7 @@ namespace Tizen.Content.MediaContent /// <summary> /// The constructor to create a new playlist with the given name in the media database. /// </summary> - /// <param name="playListName">The name of the inserted playlist</param> + /// <param name="name">The name of the inserted playlist</param> 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. /// </summary> /// <param name="mediaContent">The AudioContent object to be removed</param> - 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. /// </summary> /// <param name="name">The name of the playlist to save</param> - /// <param name="path">The path to import the playlist file</param> + /// <param name="filePath">The path to import the playlist file</param> /// <returns>The imported PlayList object</returns> - 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. /// </summary> /// <returns>path The path to export the playlist</returns> - 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); - } - } - - /// <summary> - /// Gets the media content list for the given playlist member id. - /// </summary> - /// <param name="filter">The content filter</param> - /// <returns>Media content list</returns> - public Task<IDictionary<int, MediaInformation>> GetPlayListItemsAsync(ContentFilter filter) + public static void Export(PlayList list, string filePath) { - var tcs = new TaskCompletionSource<IDictionary<int, MediaInformation>>(); - - IDictionary<int, MediaInformation> dictionary = new Dictionary<int, MediaInformation>(); - 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; } /// <summary> 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. /// </summary> - internal class Storage : ContentCollection + public class Storage : ContentCollection { private IntPtr _storageHandle; - internal IntPtr Handle
- {
- get
- {
- return _storageHandle;
- }
+ internal IntPtr Handle + { + get + { + return _storageHandle; + } } /// <summary> /// The storage id of the media storage @@ -48,7 +48,7 @@ namespace Tizen.Content.MediaContent /// <summary> /// The storage path of the media storage /// </summary> - 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; + } } /// <summary> /// 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 } } - /// <summary> - /// Updates the given video information in the media database. - /// </summary> - /// <returns> - /// void </returns> - 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 index 4b9f330..3448ae4 100644..100755 --- a/Tizen.Content/Tizen.Content.csproj +++ b/Tizen.Content/Tizen.Content.csproj @@ -44,55 +44,18 @@ <Reference Include="System.Data" /> <Reference Include="System.Xml" /> <Reference Include="Tizen"> - <HintPath>..\..\..\Desktop\Tizen_dlls\Tizen.dll</HintPath> + <HintPath>..\tct-mediacontent-tizen-tests\lib\Tizen.dll</HintPath> </Reference> <Reference Include="Tizen.Applications"> - <HintPath>..\..\..\Desktop\Tizen_dlls\Tizen.Applications.dll</HintPath> + <HintPath>..\tct-mediacontent-tizen-tests\lib\Tizen.Applications.dll</HintPath> </Reference> <Reference Include="Tizen.Internals"> - <HintPath>..\..\..\Desktop\Tizen_dlls\Tizen.Internals.dll</HintPath> + <HintPath>..\tct-mediacontent-tizen-tests\lib\Tizen.Internals.dll</HintPath> </Reference> </ItemGroup> <ItemGroup> - <Compile Include="Interop\Interop.AudioInformation.cs" /> - <Compile Include="Interop\Interop.Glib.cs" /> - <Compile Include="Interop\Interop.ImageInformation.cs" /> - <Compile Include="Interop\Interop.Libc.cs" /> - <Compile Include="Interop\Interop.Libraries.cs" /> - <Compile Include="Interop\Interop.MediaInformation.cs" /> - <Compile Include="Interop\Interop.media_bookmark.cs" /> - <Compile Include="Interop\Interop.media_content.cs" /> - <Compile Include="Interop\Interop.media_face.cs" /> - <Compile Include="Interop\Interop.media_filter.cs" /> - <Compile Include="Interop\Interop.media_folder.cs" /> - <Compile Include="Interop\Interop.media_group.cs" /> - <Compile Include="Interop\Interop.media_playlist.cs" /> - <Compile Include="Interop\Interop.media_storage.cs" /> - <Compile Include="Interop\Interop.media_tag.cs" /> - <Compile Include="Interop\Interop.VideoInformation.cs" /> - <Compile Include="MediaContent\Album.cs" /> - <Compile Include="MediaContent\AudioInformation.cs" /> - <Compile Include="MediaContent\ContentCollection.cs" /> - <Compile Include="MediaContent\ContentEventArgs.cs" /> - <Compile Include="MediaContent\ContentFilter.cs" /> - <Compile Include="MediaContent\ContentManager.cs" /> - <Compile Include="MediaContent\CreateThumbnailResult.cs" /> - <Compile Include="MediaContent\ExceptionFactory.cs" /> - <Compile Include="MediaContent\FaceRect.cs" /> - <Compile Include="MediaContent\Group.cs" /> - <Compile Include="MediaContent\ImageInformation.cs" /> - <Compile Include="MediaContent\MediaBookmark.cs" /> - <Compile Include="MediaContent\MediaContentEnums.cs" /> - <Compile Include="MediaContent\MediaContentErrorFactory.cs" /> - <Compile Include="MediaContent\MediaContentTypes.cs" /> - <Compile Include="MediaContent\MediaFace.cs" /> - <Compile Include="MediaContent\MediaFolder.cs" /> - <Compile Include="MediaContent\MediaInformation.cs" /> - <Compile Include="MediaContent\PlayList.cs" /> - <Compile Include="MediaContent\Storage.cs" /> - <Compile Include="MediaContent\Tag.cs" /> - <Compile Include="MediaContent\VideoInformation.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="Interop\*.cs" /> + <Compile Include="Tizen.Content.MediaContent\*.cs" /> </ItemGroup> <ItemGroup> <None Include="Tizen.Content.snk" /> @@ -105,4 +68,4 @@ <Target Name="AfterBuild"> </Target> --> -</Project>
\ No newline at end of file +</Project> diff --git a/packaging/csapi-media-content.spec b/packaging/csapi-media-content.spec index 0aa5b21..dc7e678 100644..100755 --- 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 |