Changed async apis.Incorporated SE review comments.
Change-Id: I4a7e912839f33a310bc88460c4e9a6b6ee0f0391
Signed-off-by: Praveen Gattu <gattu.p@samsung.com>
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
{
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);
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);
}
}
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);
[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);
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
+}
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);
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);
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);
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);
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);
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);
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);
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)]
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
+}
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
{
/// 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.
}
}
- /// <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)
{
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>
/// <summary>
/// The PID which publishes notification
/// </summary>
- public int PID
+ public int Pid
{
get; set;
}
/// <summary>
/// The UUID of media or directory, which is updated
/// </summary>
- public string UUID
+ public string Uuid
{
get; set;
}
/// <summary>
/// The path of the media or directory
/// </summary>
- public string Path
+ public string FilePath
{
get; set;
}
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;
- }
- }
}
/// 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()
}
}
- 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;
/// <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");
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:
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;
/// <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,
/// 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");
/// <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) =>
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");
}
/// <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);
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))
{
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);
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))
{
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))
{
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)
/// <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>>();
/// <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) =>
/// <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) =>
{
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);
/// 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))
{
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))
{
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;
}
}
}
/// </summary>
/// <value>
/// string path of the thumbnail.</value>
- public string Path
+ public string FilePath
{
get;
internal set;
/// 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>
}
}
- /// <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)
{
{
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)
/// </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;
/// <summary>
/// Ascending order
/// </summary>
- ASC,
+ Asc,
/// <summary>
/// Descending order
/// </summary>
- DESC
+ Desc
}
/// <summary>
/// <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>
/// <summary>
/// Invalid media group ID
/// </summary>
- Max,
- None
+ Max
}
/// <summary>
/// Enumerations for defining set of conditions in media filer for media folder
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>
/// </summary>
Rot270 = 8
};
-}
\ No newline at end of file
+}
{
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;
}
}
/// <summary>
/// Out of memory.
/// </summary>
- OotOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
+ OutOfMemory = Tizen.Internals.Errors.ErrorCode.OutOfMemory,
/// <summary>
/// Invalid Operation.
/// </summary>
/// <summary>
/// The path of the media folder
/// </summary>
- public string Path
+ public string FolderPath
{
get
{
/// 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);
}
/// <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>
{
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);
}
}
+ internal IntPtr MediaHandle
+ {
+ get
+ {
+ return _handle.DangerousGetHandle();
+ }
+ }
internal MediaInformation(Interop.MediaInformation.SafeMediaInformationHandle handle)
{
/// </remarks>
public class PlayList : ContentCollection
{
+ private IDictionary<string, int> dictionary = new Dictionary<string, int>();
private IntPtr _playlistHandle;
internal IntPtr Handle
{
}
}
+ 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>
/// <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;
/// 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)
{
/// 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;
/// 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>
/// 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\r
- {\r
- get\r
- {\r
- return _storageHandle;\r
- }\r
+ internal IntPtr Handle
+ {
+ get
+ {
+ return _storageHandle;
+ }
}
/// <summary>
/// The storage id of the media storage
/// <summary>
/// The storage path of the media storage
/// </summary>
- public string Path
+ public string StoragePath
{
get
{
public class Tag : ContentCollection
{
private IntPtr _tagHandle;
- internal IntPtr Handle\r
- {\r
- get\r
- {\r
- return _tagHandle;\r
- }\r
- set\r
- {\r
- _tagHandle = value;\r
- }\r
+ internal IntPtr Handle
+ {
+ get
+ {
+ return _tagHandle;
+ }
+ set
+ {
+ _tagHandle = value;
+ }
}
/// <summary>
/// The ID of the media tag
Name = tagName;
ContentManager.ConnectToDB();
MediaContentError res = (MediaContentError)Interop.Tag.InsertToDb(tagName, out _tagHandle);
- if (res != MediaContentError.None)\r
- {\r
- Console.WriteLine("Exception occured "+ res);\r
- throw MediaContentErrorFactory.CreateException(res, "Failed to create playlist");\r
+ 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);
}
}
- /// <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)
<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" />
<Target Name="AfterBuild">
</Target>
-->
-</Project>
\ No newline at end of file
+</Project>
%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#
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