internal static extern MediaContentError Clone(out SafeAudioInformationHandle dst, SafeAudioInformationHandle src);
[DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_media_id", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetMediaId(SafeAudioInformationHandle audioInformationHandle, out string mediaId);
+ internal static extern MediaContentError GetMediaId(SafeAudioInformationHandle audioInformationHandle, out IntPtr mediaId);
[DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_album", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetAlbum(SafeAudioInformationHandle audioInformationHandle, out string albumName);
+ internal static extern MediaContentError GetAlbum(SafeAudioInformationHandle audioInformationHandle, out IntPtr albumName);
[DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_artist", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetArtist(SafeAudioInformationHandle audioInformationHandle, out string artistName);
+ internal static extern MediaContentError GetArtist(SafeAudioInformationHandle audioInformationHandle, out IntPtr artistName);
[DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_album_artist", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetAlbumArtist(SafeAudioInformationHandle audioInformationHandle, out string albumArtistName);
+ internal static extern MediaContentError GetAlbumArtist(SafeAudioInformationHandle audioInformationHandle, out IntPtr albumArtistName);
[DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_genre", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetGenre(SafeAudioInformationHandle audioInformationHandle, out string genreName);
+ internal static extern MediaContentError GetGenre(SafeAudioInformationHandle audioInformationHandle, out IntPtr genreName);
[DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_composer", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetComposer(SafeAudioInformationHandle audioInformationHandle, out string composerName);
+ internal static extern MediaContentError GetComposer(SafeAudioInformationHandle audioInformationHandle, out IntPtr composerName);
[DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_year", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetYear(SafeAudioInformationHandle audioInformationHandle, out string year);
+ internal static extern MediaContentError GetYear(SafeAudioInformationHandle audioInformationHandle, out IntPtr year);
[DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_recorded_date", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetRecordedDate(SafeAudioInformationHandle audioInformationHandle, out string recordedDate);
+ internal static extern MediaContentError GetRecordedDate(SafeAudioInformationHandle audioInformationHandle, out IntPtr recordedDate);
[DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_copyright", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetCopyright(SafeAudioInformationHandle audioInformationHandle, out string copyright);
+ internal static extern MediaContentError GetCopyright(SafeAudioInformationHandle audioInformationHandle, out IntPtr copyright);
[DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_track_num", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetTrackNum(SafeAudioInformationHandle audioInformationHandle, out string trackNum);
+ internal static extern MediaContentError GetTrackNum(SafeAudioInformationHandle audioInformationHandle, out IntPtr trackNum);
[DllImport(Libraries.MediaContent, EntryPoint = "audio_meta_get_bit_rate", CallingConvention = CallingConvention.Cdecl)]
internal static extern MediaContentError GetBitRate(SafeAudioInformationHandle audioInformationHandle, out int bitRate);
internal static extern MediaContentError GetOrientation(SafeImageInformationHandle imageInformationHandle, out MediaContentOrientation orientation);
[DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_date_taken", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetDateTaken(SafeImageInformationHandle imageInformationHandle, out string dateTaken);
+ internal static extern MediaContentError GetDateTaken(SafeImageInformationHandle imageInformationHandle, out IntPtr dateTaken);
[DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_burst_id", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetBurstId(SafeImageInformationHandle imageInformationHandle, out string burstId);
+ internal static extern MediaContentError GetBurstId(SafeImageInformationHandle imageInformationHandle, out IntPtr burstId);
[DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_exposure_time", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetExposureTime(SafeImageInformationHandle imageInformationHandle, out string exposureTime);
+ internal static extern MediaContentError GetExposureTime(SafeImageInformationHandle imageInformationHandle, out IntPtr exposureTime);
[DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_fnumber", CallingConvention = CallingConvention.Cdecl)]
internal static extern MediaContentError GetFNumber(SafeImageInformationHandle imageInformationHandle, out double fNumber);
internal static extern MediaContentError GetISO(SafeImageInformationHandle imageInformationHandle, out int iso);
[DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_model", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetModel(SafeImageInformationHandle imageInformationHandle, out string model);
+ internal static extern MediaContentError GetModel(SafeImageInformationHandle imageInformationHandle, out IntPtr model);
[DllImport(Libraries.MediaContent, EntryPoint = "image_meta_is_burst_shot", CallingConvention = CallingConvention.Cdecl)]
internal static extern MediaContentError IsBurstShot(SafeImageInformationHandle imageInformationHandle, out bool isBurstShot);
internal static extern MediaContentError SetOrientation(SafeImageInformationHandle imageInformationHandle, MediaContentOrientation orientation);
[DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_media_id", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetMediaId(SafeImageInformationHandle imageInformationHandle, out string mediaId);
+ internal static extern MediaContentError GetMediaId(SafeImageInformationHandle imageInformationHandle, out IntPtr mediaId);
[DllImport(Libraries.MediaContent, EntryPoint = "image_meta_get_width", CallingConvention = CallingConvention.Cdecl)]
internal static extern MediaContentError GetWidth(SafeImageInformationHandle imageInformationHandle, out int width);
internal static extern MediaContentError GetMarkedTime(IntPtr bookmark, out uint marked_time);
[DllImport(Libraries.MediaContent, EntryPoint = "media_bookmark_get_thumbnail_path")]
- internal static extern MediaContentError GetThumbnailPath(IntPtr bookmark, out string filePath);
+ internal static extern MediaContentError GetThumbnailPath(IntPtr bookmark, out IntPtr filePath);
}
}
internal static extern MediaContentError Destroy(IntPtr face);
[DllImport(Libraries.MediaContent, EntryPoint = "media_face_get_face_id")]
- internal static extern MediaContentError GetFaceId(IntPtr face, out string face_id);
+ internal static extern MediaContentError GetFaceId(IntPtr face, out IntPtr face_id);
[DllImport(Libraries.MediaContent, EntryPoint = "media_face_get_media_id")]
- internal static extern MediaContentError GetMediaId(IntPtr face, out string media_id);
+ internal static extern MediaContentError GetMediaId(IntPtr face, out IntPtr media_id);
[DllImport(Libraries.MediaContent, EntryPoint = "media_face_get_face_rect")]
internal static extern MediaContentError GetFaceRect(IntPtr face, out int rect_x, out int rect_y, out int rect_w, out int IntPtr);
internal static extern MediaContentError GetOrientation(IntPtr face, out int orientation);
[DllImport(Libraries.MediaContent, EntryPoint = "media_face_get_tag")]
- internal static extern MediaContentError GetTag(IntPtr face, out string tag);
+ internal static extern MediaContentError GetTag(IntPtr face, out IntPtr tag);
[DllImport(Libraries.MediaContent, EntryPoint = "media_face_create")]
internal static extern MediaContentError Create(string media_id, out IntPtr face);
internal static extern MediaContentError SetOffset(IntPtr filter, int offset, int count);
[DllImport(Libraries.MediaContent, EntryPoint = "media_filter_set_condition")]
- internal static extern MediaContentError SetCondition(IntPtr filter, string condition, int collate_type);
+ internal static extern MediaContentError SetCondition(IntPtr filter, string condition, ContentCollation type);
[DllImport(Libraries.MediaContent, EntryPoint = "media_filter_set_order")]
- internal static extern MediaContentError SetOrder(IntPtr filter, ContentOrder order_type, string order_keyword, ContentCollation collate_type);
+ internal static extern MediaContentError SetOrder(IntPtr filter, ContentOrder order, string keyword, ContentCollation type);
[DllImport(Libraries.MediaContent, EntryPoint = "media_filter_set_storage")]
- internal static extern MediaContentError SetStorage(IntPtr filter, string storage_id);
+ internal static extern MediaContentError SetStorage(IntPtr filter, string storageId);
[DllImport(Libraries.MediaContent, EntryPoint = "media_filter_get_offset")]
internal static extern MediaContentError GetOffset(IntPtr filter, out int offset, out int count);
[DllImport(Libraries.MediaContent, EntryPoint = "media_filter_get_condition")]
- internal static extern MediaContentError GetCondition(IntPtr filter, out string condition, out int collate_type);
+ internal static extern MediaContentError GetCondition(IntPtr filter, out IntPtr condition, out ContentCollation type);
[DllImport(Libraries.MediaContent, EntryPoint = "media_filter_get_order")]
- internal static extern MediaContentError GetOrder(IntPtr filter, out int order_type, out string order_keyword, out int collate_type);
+ internal static extern MediaContentError GetOrder(IntPtr filter, out ContentOrder order, out IntPtr keyword, out ContentCollation type);
[DllImport(Libraries.MediaContent, EntryPoint = "media_filter_get_storage")]
- internal static extern MediaContentError GetStorage(IntPtr filter, out string storage_id);
+ internal static extern MediaContentError GetStorage(IntPtr filter, out IntPtr storageId);
}
}
\ No newline at end of file
internal static extern MediaContentError Destroy(IntPtr folder);
[DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_folder_id")]
- internal static extern MediaContentError GetFolderId(IntPtr folder, out string folder_id);
+ internal static extern MediaContentError GetFolderId(IntPtr folder, out IntPtr folder_id);
[DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_parent_folder_id")]
- internal static extern MediaContentError GetParentFolderId(IntPtr folder, out string parent_folder_id);
+ internal static extern MediaContentError GetParentFolderId(IntPtr folder, out IntPtr parent_folder_id);
[DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_path")]
- internal static extern MediaContentError GetPath(IntPtr folder, out string folderPath);
+ internal static extern MediaContentError GetPath(IntPtr folder, out IntPtr folderPath);
[DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_name")]
- internal static extern MediaContentError GetName(IntPtr folder, out string folder_name);
+ internal static extern MediaContentError GetName(IntPtr folder, out IntPtr folder_name);
[DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_modified_time")]
internal static extern MediaContentError GetModifiedTime(IntPtr folder, out DateTime date);
[DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_storage_type")]
- internal static extern MediaContentError GetStorageType(IntPtr folder, out int storage_type);
+ internal static extern MediaContentError GetStorageType(IntPtr folder, out ContentStorageType storage_type);
[DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_storage_id")]
- internal static extern MediaContentError GetStorageId(IntPtr folder, out string storage_id);
+ internal static extern MediaContentError GetStorageId(IntPtr folder, out IntPtr storage_id);
[DllImport(Libraries.MediaContent, EntryPoint = "media_folder_get_order")]
internal static extern MediaContentError GetOrder(IntPtr folder, out int order);
internal static extern MediaContentError MediaAlbumGetAlbumId(IntPtr album, out int album_id);
[DllImport(Libraries.MediaContent, EntryPoint = "media_album_get_name")]
- internal static extern MediaContentError MediaAlbumGetName(IntPtr album, out string album_name);
+ internal static extern MediaContentError MediaAlbumGetName(IntPtr album, out IntPtr album_name);
[DllImport(Libraries.MediaContent, EntryPoint = "media_album_get_artist")]
- internal static extern MediaContentError MediaAlbumGetArtist(IntPtr album, out string artist);
+ internal static extern MediaContentError MediaAlbumGetArtist(IntPtr album, out IntPtr artist);
[DllImport(Libraries.MediaContent, EntryPoint = "media_album_get_album_art")]
- internal static extern MediaContentError MediaAlbumGetAlbumArt(IntPtr album, out string album_art);
+ internal static extern MediaContentError MediaAlbumGetAlbumArt(IntPtr album, out IntPtr album_art);
[DllImport(Libraries.MediaContent, EntryPoint = "media_album_get_album_from_db")]
internal static extern MediaContentError MediaAlbumGetAlbumFromDb(int album_id, out IntPtr album);
internal static extern MediaContentError GetAudio(IntPtr mediaInformationHandle, out Interop.AudioInformation.SafeAudioInformationHandle audio);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_media_id", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetMediaId(SafeMediaInformationHandle mediaInformationHandle, out string mediaId);
+ internal static extern MediaContentError GetMediaId(SafeMediaInformationHandle mediaInformationHandle, out IntPtr mediaId);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_file_path", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetFilePath(SafeMediaInformationHandle mediaInformationHandle, out string filePath);
+ internal static extern MediaContentError GetFilePath(SafeMediaInformationHandle mediaInformationHandle, out IntPtr filePath);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_display_name", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetDisplayName(SafeMediaInformationHandle mediaInformationHandle, out string name);
+ internal static extern MediaContentError GetDisplayName(SafeMediaInformationHandle mediaInformationHandle, out IntPtr name);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_media_type", CallingConvention = CallingConvention.Cdecl)]
internal static extern MediaContentError GetMediaType(SafeMediaInformationHandle mediaInformationHandle, out MediaContentType type);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_mime_type", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetMimeType(SafeMediaInformationHandle mediaInformationHandle, out string mimeType);
+ internal static extern MediaContentError GetMimeType(SafeMediaInformationHandle mediaInformationHandle, out IntPtr mimeType);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_size", CallingConvention = CallingConvention.Cdecl)]
internal static extern MediaContentError GetSize(SafeMediaInformationHandle mediaInformationHandle, out long size);
internal static extern MediaContentError GetTimeline(SafeMediaInformationHandle mediaInformationHandle, out int time);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_thumbnail_path", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetThumbnailPath(SafeMediaInformationHandle mediaInformationHandle, out string filePath);
+ internal static extern MediaContentError GetThumbnailPath(SafeMediaInformationHandle mediaInformationHandle, out IntPtr filePath);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_description", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetDescription(SafeMediaInformationHandle mediaInformationHandle, out string description);
+ internal static extern MediaContentError GetDescription(SafeMediaInformationHandle mediaInformationHandle, out IntPtr description);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_longitude", CallingConvention = CallingConvention.Cdecl)]
internal static extern MediaContentError GetLongitude(SafeMediaInformationHandle mediaInformationHandle, out double longitude);
internal static extern MediaContentError GetAltitude(SafeMediaInformationHandle mediaInformationHandle, out double altitude);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_weather", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetWeather(SafeMediaInformationHandle mediaInformationHandle, out string weather);
+ internal static extern MediaContentError GetWeather(SafeMediaInformationHandle mediaInformationHandle, out IntPtr weather);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_rating", CallingConvention = CallingConvention.Cdecl)]
internal static extern MediaContentError GetRating(SafeMediaInformationHandle mediaInformationHandle, out int rating);
internal static extern MediaContentError GetFavorite(SafeMediaInformationHandle mediaInformationHandle, out bool favorite);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_author", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetAuthor(SafeMediaInformationHandle mediaInformationHandle, out string author);
+ internal static extern MediaContentError GetAuthor(SafeMediaInformationHandle mediaInformationHandle, out IntPtr author);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_provider", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetProvider(SafeMediaInformationHandle mediaInformationHandle, out string provider);
+ internal static extern MediaContentError GetProvider(SafeMediaInformationHandle mediaInformationHandle, out IntPtr provider);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_content_name", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetContentName(SafeMediaInformationHandle mediaInformationHandle, out string contentName);
+ internal static extern MediaContentError GetContentName(SafeMediaInformationHandle mediaInformationHandle, out IntPtr contentName);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_title", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetTitle(SafeMediaInformationHandle mediaInformationHandle, out string title);
+ internal static extern MediaContentError GetTitle(SafeMediaInformationHandle mediaInformationHandle, out IntPtr title);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_category", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetCategory(SafeMediaInformationHandle mediaInformationHandle, out string category);
+ internal static extern MediaContentError GetCategory(SafeMediaInformationHandle mediaInformationHandle, out IntPtr category);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_location_tag", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetLocationTag(SafeMediaInformationHandle mediaInformationHandle, out string locationTag);
+ internal static extern MediaContentError GetLocationTag(SafeMediaInformationHandle mediaInformationHandle, out IntPtr locationTag);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_age_rating", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetAgeRating(SafeMediaInformationHandle mediaInformationHandle, out string ageRating);
+ internal static extern MediaContentError GetAgeRating(SafeMediaInformationHandle mediaInformationHandle, out IntPtr ageRating);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_keyword", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetKeyword(SafeMediaInformationHandle mediaInformationHandle, out string keyword);
+ internal static extern MediaContentError GetKeyword(SafeMediaInformationHandle mediaInformationHandle, out IntPtr keyword);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_get_storage_id", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetStorageId(SafeMediaInformationHandle mediaInformationHandle, out string storageId);
+ internal static extern MediaContentError GetStorageId(SafeMediaInformationHandle mediaInformationHandle, out IntPtr storageId);
[DllImport(Libraries.MediaContent, EntryPoint = "media_info_is_drm", CallingConvention = CallingConvention.Cdecl)]
internal static extern MediaContentError IsDrm(SafeMediaInformationHandle mediaInformationHandle, out bool isDrm);
internal static extern MediaContentError GetPlaylistId(IntPtr playlist, out int playlist_id);
[DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_get_name")]
- internal static extern MediaContentError GetName(IntPtr playlist, out string playlist_name);
+ internal static extern MediaContentError GetName(IntPtr playlist, out IntPtr playlist_name);
[DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_set_name")]
internal static extern MediaContentError SetName(IntPtr playlist, string playlist_name);
[DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_get_thumbnail_path")]
- internal static extern MediaContentError GetThumbnailPath(IntPtr playlist, out string filePath);
+ internal static extern MediaContentError GetThumbnailPath(IntPtr playlist, out IntPtr filePath);
[DllImport(Libraries.MediaContent, EntryPoint = "media_playlist_set_thumbnail_path")]
internal static extern MediaContentError SetThumbnailPath(IntPtr playlist, string filePath);
internal static extern MediaContentError Clone(out IntPtr dst, IntPtr src);
[DllImport(Libraries.MediaContent, EntryPoint = "media_storage_get_id")]
- internal static extern MediaContentError GetId(IntPtr storage, out string storage_id);
+ internal static extern MediaContentError GetId(IntPtr storage, out IntPtr storage_id);
[DllImport(Libraries.MediaContent, EntryPoint = "media_storage_get_name")]
- internal static extern MediaContentError GetName(IntPtr storage, out string storage_name);
+ internal static extern MediaContentError GetName(IntPtr storage, out IntPtr storage_name);
[DllImport(Libraries.MediaContent, EntryPoint = "media_storage_get_path")]
- internal static extern MediaContentError GetPath(IntPtr storage, out string storage_path);
+ internal static extern MediaContentError GetPath(IntPtr storage, out IntPtr storage_path);
[DllImport(Libraries.MediaContent, EntryPoint = "media_storage_get_type")]
- internal static extern MediaContentError GetType(IntPtr storage, out int storage_type);
+ internal static extern MediaContentError GetType(IntPtr storage, out ContentStorageType storage_type);
//Callbacks
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal static extern MediaContentError GetTagId(IntPtr tag, out int tag_id);
[DllImport(Libraries.MediaContent, EntryPoint = "media_tag_get_name")]
- internal static extern MediaContentError GetName(IntPtr tag, out string tag_name);
+ internal static extern MediaContentError GetName(IntPtr tag, out IntPtr tag_name);
[DllImport(Libraries.MediaContent, EntryPoint = "media_tag_get_tag_from_db")]
internal static extern MediaContentError GetTagFromDb(int tag_id, out IntPtr tag);
//Callbacks
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
- internal delegate void MediaInfoCallback(IntPtr mediaInformation, IntPtr data);
+ internal delegate bool MediaInfoCallback(IntPtr mediaInformation, IntPtr data);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate bool MediaTagCallback(IntPtr tag, IntPtr data);
internal static extern MediaContentError Clone(out SafeVideoInformationHandle dst, SafeVideoInformationHandle src);
[DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_media_id", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetMediaId(SafeVideoInformationHandle videoInformationHandle, out string mediaId);
+ internal static extern MediaContentError GetMediaId(SafeVideoInformationHandle videoInformationHandle, out IntPtr mediaId);
[DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_album", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetAlbum(SafeVideoInformationHandle videoInformationHandle, out string albumName);
+ internal static extern MediaContentError GetAlbum(SafeVideoInformationHandle videoInformationHandle, out IntPtr albumName);
[DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_artist", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetArtist(SafeVideoInformationHandle videoInformationHandle, out string artistName);
+ internal static extern MediaContentError GetArtist(SafeVideoInformationHandle videoInformationHandle, out IntPtr artistName);
[DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_album_artist", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetAlbumArtist(SafeVideoInformationHandle videoInformationHandle, out string albumArtistName);
+ internal static extern MediaContentError GetAlbumArtist(SafeVideoInformationHandle videoInformationHandle, out IntPtr albumArtistName);
[DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_genre", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetGenre(SafeVideoInformationHandle videoInformationHandle, out string genreName);
+ internal static extern MediaContentError GetGenre(SafeVideoInformationHandle videoInformationHandle, out IntPtr genreName);
[DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_composer", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetComposer(SafeVideoInformationHandle videoInformationHandle, out string composerName);
+ internal static extern MediaContentError GetComposer(SafeVideoInformationHandle videoInformationHandle, out IntPtr composerName);
[DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_year", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetYear(SafeVideoInformationHandle videoInformationHandle, out string year);
+ internal static extern MediaContentError GetYear(SafeVideoInformationHandle videoInformationHandle, out IntPtr year);
[DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_recorded_date", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetRecordedDate(SafeVideoInformationHandle videoInformationHandle, out string recordedDate);
+ internal static extern MediaContentError GetRecordedDate(SafeVideoInformationHandle videoInformationHandle, out IntPtr recordedDate);
[DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_copyright", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetCopyright(SafeVideoInformationHandle videoInformationHandle, out string copyright);
+ internal static extern MediaContentError GetCopyright(SafeVideoInformationHandle videoInformationHandle, out IntPtr copyright);
[DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_track_num", CallingConvention = CallingConvention.Cdecl)]
- internal static extern MediaContentError GetTrackNum(SafeVideoInformationHandle videoInformationHandle, out string trackNum);
+ internal static extern MediaContentError GetTrackNum(SafeVideoInformationHandle videoInformationHandle, out IntPtr trackNum);
[DllImport(Libraries.MediaContent, EntryPoint = "video_meta_get_bit_rate", CallingConvention = CallingConvention.Cdecl)]
internal static extern MediaContentError GetBitRate(SafeVideoInformationHandle videoInformationHandle, out int bitRate);
using System;
using System.Collections.Generic;
+using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace Tizen.Content.MediaContent
get
{
int id = 0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Group.MediaAlbumGetAlbumId(_albumHandle, out id), "Failed to get value");
return id;
{
get
{
- string artist = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.Group.MediaAlbumGetArtist(_albumHandle, out artist), "Failed to get value");
-
- return artist;
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Group.MediaAlbumGetArtist(_albumHandle, out val), "Failed to get value");
+
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
}
{
get
{
- string art = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.Group.MediaAlbumGetAlbumArt(_albumHandle, out art), "Failed to get value");
-
- return art;
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Group.MediaAlbumGetAlbumArt(_albumHandle, out val), "Failed to get value");
+
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
}
{
get
{
- string name = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.Group.MediaAlbumGetArtist(_albumHandle, out name), "Failed to get value");
-
- return name;
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Group.MediaAlbumGetName(_albumHandle, out val), "Failed to get value");
+
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
}
int mediaCount = 0;
IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Group.MediaAlbumGetMediaCountFromDb(Id, handle, out mediaCount), "Failed to get count");
return mediaCount;
Interop.Group.MediaInfoCallback callback = (IntPtr mediaHandle, IntPtr data) =>
{
Interop.MediaInformation.SafeMediaInformationHandle newHandle;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone");
mediaContents.Add(new MediaInformation(newHandle));
return true;
};
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Group.MediaAlbumForeachMediaFromDb(Id, handle, callback, IntPtr.Zero), "Failed to get information");
tcs.TrySetResult(mediaContents);
{
get
{
- string mediaId = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.AudioInformation.GetMediaId(_handle, out mediaId), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.AudioInformation.GetMediaId(_handle, out val), "Failed to get value");
- if (mediaId == null)
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
{
- mediaId = "";
+ Interop.Libc.Free(val);
}
- return mediaId;
}
}
{
get
{
- string album = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.AudioInformation.GetAlbum(_handle, out album), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.AudioInformation.GetAlbum(_handle, out val), "Failed to get value");
- if (album == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- album = "";
+ Interop.Libc.Free(val);
}
- return album;
}
}
{
get
{
- string artist = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.AudioInformation.GetArtist(_handle, out artist), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.AudioInformation.GetArtist(_handle, out val), "Failed to get value");
- if (artist == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- artist = "";
+ Interop.Libc.Free(val);
}
- return artist;
}
}
{
get
{
- string albumArtist = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.AudioInformation.GetAlbumArtist(_handle, out albumArtist), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.AudioInformation.GetAlbumArtist(_handle, out val), "Failed to get value");
- if (albumArtist == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- albumArtist = "";
+ Interop.Libc.Free(val);
}
- return albumArtist;
}
}
{
get
{
- string genre = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.AudioInformation.GetGenre(_handle, out genre), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.AudioInformation.GetGenre(_handle, out val), "Failed to get value");
- if (genre == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- genre = "";
+ Interop.Libc.Free(val);
}
- return genre;
}
}
{
get
{
- string composer = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.AudioInformation.GetComposer(_handle, out composer), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.AudioInformation.GetComposer(_handle, out val), "Failed to get value");
- if (composer == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- composer = "";
+ Interop.Libc.Free(val);
}
- return composer;
}
}
{
get
{
- string year = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.AudioInformation.GetYear(_handle, out year), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.AudioInformation.GetYear(_handle, out val), "Failed to get value");
- if (year == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- year = "";
+ Interop.Libc.Free(val);
}
- return year;
}
}
{
get
{
- string recordedDate = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.AudioInformation.GetRecordedDate(_handle, out recordedDate), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.AudioInformation.GetRecordedDate(_handle, out val), "Failed to get value");
- if (recordedDate == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- recordedDate = "";
+ Interop.Libc.Free(val);
}
- return recordedDate;
}
}
{
get
{
- string copyright = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.AudioInformation.GetCopyright(_handle, out copyright), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.AudioInformation.GetCopyright(_handle, out val), "Failed to get value");
- if (copyright == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- copyright = "";
+ Interop.Libc.Free(val);
}
- return copyright;
}
}
{
get
{
- string trackNumber = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.AudioInformation.GetTrackNum(_handle, out trackNumber), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.AudioInformation.GetTrackNum(_handle, out val), "Failed to get value");
- if (trackNumber == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- trackNumber = "";
+ Interop.Libc.Free(val);
}
- return trackNumber;
}
}
get
{
int bitrate = 0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.AudioInformation.GetBitRate(_handle, out bitrate), "Failed to get value");
return bitrate;
get
{
int bitPerSample = 0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.AudioInformation.GetBitPerSample(_handle, out bitPerSample), "Failed to get value");
return bitPerSample;
get
{
int sampleRate = 0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.AudioInformation.GetSampleRate(_handle, out sampleRate), "Failed to get value");
return sampleRate;
get
{
int channel = 0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.AudioInformation.GetChannel(_handle, out channel), "Failed to get value");
return channel;
get
{
int duration = 0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.AudioInformation.GetDuration(_handle, out duration), "Failed to get value");
return duration;
{
int count = 0;
IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetBookmarkCount(MediaId, handle, out count), "Failed to get count");
return count;
IntPtr filterHandle = (filter != null) ? filter.Handle : IntPtr.Zero;
Interop.MediaInformation.MediaBookmarkCallback callback = (IntPtr handle, IntPtr userData) =>
{
- IntPtr newHandle;
- MediaContentRetValidator.ThrowIfError(
+ IntPtr newHandle = IntPtr.Zero;
+ MediaContentValidator.ThrowIfError(
Interop.MediaBookmark.Clone(out newHandle, handle), "Failed to clone");
coll.Add(new MediaBookmark(newHandle));
return true;
};
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetAllBookmarks(MediaId, filterHandle, callback, IntPtr.Zero), "Failed to get value");
task.SetResult(coll);
using System;
using System.Collections.Generic;
+using System.Runtime.InteropServices;
using System.Threading.Tasks;
/// <summary>
/// The Media Content API provides functions, enumerations used in the entire Content Service.
{
if (!_isConnected)
{
- MediaContentRetValidator.ThrowIfError(Interop.Content.Connect(), "Connect failed");
+ MediaContentValidator.ThrowIfError(Interop.Content.Connect(), "Connect failed");
_isConnected = true;
}
{
if (_isConnected)
{
- MediaContentRetValidator.ThrowIfError(Interop.Content.Disconnect(), "Disconnect failed");
+ MediaContentValidator.ThrowIfError(Interop.Content.Disconnect(), "Disconnect failed");
_isConnected = false;
}
}
- 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) =>
+ 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, filePath, mimeType);
- s_contentUpdated?.Invoke(null, eventArgs);
+ s_contentUpdated?.Invoke(
+ null, new ContentUpdatedEventArgs(error, pid, updateItem, updateType, mediaType, uuid, filePath, mimeType));
};
+
private static event EventHandler<ContentUpdatedEventArgs> s_contentUpdated;
/// <summary>
/// ContentUpdated event is triggered when the media DB changes.
{
if (s_contentUpdated == null)
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Content.SetDbUpdatedCb(s_contentUpdatedCallback, IntPtr.Zero), "Failed to set callback");
}
s_contentUpdated += value;
s_contentUpdated -= value;
if (s_contentUpdated == null)
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Content.UnsetDbUpdatedCb(), "Failed to unset callback");
}
}
{
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;
+ }
ConnectToDB();
if (typeof(T) == typeof(MediaInformation))
{
- res = (MediaContentError)Interop.MediaInformation.GetMediaCount(handle, out count);
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetMediaCount(handle, out count), "Failed to get count");
}
else if (typeof(T) == typeof(MediaBookmark))
{
- res = (MediaContentError)Interop.MediaBookmark.GetBookmarkCountFromDb(handle, out count);
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaBookmark.GetBookmarkCountFromDb(handle, out count), "Failed to get count");
}
else if (typeof(T) == typeof(Album))
{
- res = (MediaContentError)Interop.Group.MediaAlbumGetAlbumCountFromDb(handle, out count);
+ MediaContentValidator.ThrowIfError(
+ Interop.Group.MediaAlbumGetAlbumCountFromDb(handle, out count), "Failed to get count");
}
else if (typeof(T) == typeof(MediaFolder))
{
- res = (MediaContentError)Interop.Folder.GetFolderCountFromDb(handle, out count);
+ MediaContentValidator.ThrowIfError(
+ Interop.Folder.GetFolderCountFromDb(handle, out count), "Failed to get count");
}
else if (typeof(T) == typeof(Storage))
{
- res = (MediaContentError)Interop.Storage.GetStorageCountFromDb(handle, out count);
+ MediaContentValidator.ThrowIfError(
+ Interop.Storage.GetStorageCountFromDb(handle, out count), "Failed to get count");
}
else if (typeof(T) == typeof(Tag))
{
- res = (MediaContentError)Interop.Tag.GetTagCountFromDb(handle, out count);
+ MediaContentValidator.ThrowIfError(
+ Interop.Tag.GetTagCountFromDb(handle, out count), "Failed to get count");
}
else if (typeof(T) == typeof(PlayList))
{
- res = (MediaContentError)Interop.Playlist.GetPlaylistCountFromDb(handle, out count);
+ MediaContentValidator.ThrowIfError(
+ Interop.Playlist.GetPlaylistCountFromDb(handle, out count), "Failed to get count");
}
else if (typeof(T) == typeof(Group))
{
- res = (MediaContentError)Interop.Group.GetGroupCountFromDb(handle, groupType, out count);
+ MediaContentValidator.ThrowIfError(
+ Interop.Group.GetGroupCountFromDb(handle, groupType, out count), "Failed to get count");
}
else
{
- res = MediaContentError.InvalidParameter;
+ throw new ArgumentException("Wrong type");
}
- MediaContentRetValidator.ThrowIfError(res, "Failed to get count for the content");
-
return count;
}
public MediaInformation Select(string id)
{
ConnectToDB();
- MediaInformation result;
Interop.MediaInformation.SafeMediaInformationHandle mediaHandle;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetMediaFromDB(id, out mediaHandle), "Failed to get information");
- result = new MediaInformation(mediaHandle);
- return result;
+ return new MediaInformation(mediaHandle);
}
/// <summary>
{
ConnectToDB();
ContentCollection result = null;
+ IntPtr handle = IntPtr.Zero;
+
if (typeof(T) == typeof(MediaFolder))
{
- IntPtr handle = IntPtr.Zero;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Folder.GetFolderFromDb(id, out handle), "Failed to get information");
- if (handle != IntPtr.Zero)
- result = new MediaFolder(handle);
+ result = new MediaFolder(handle);
+
+ return (T)result;
}
else if (typeof(T) == typeof(Storage))
{
- IntPtr handle = IntPtr.Zero;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Storage.GetStorageInfoFromDb(id, out handle), "Failed to get information");
- if (handle != IntPtr.Zero)
- {
- result = new Storage(handle);
- }
+ result = new Storage(handle);
+
+ return (T)result;
}
- return (result != null) ? (T)result : null;
+
+ return null;
}
public T Select<T>(int id) where T : ContentCollection
{
ConnectToDB();
- ContentCollection contentCollection = null;
- IntPtr _handle;
+ ContentCollection result = null;
+ IntPtr handle = IntPtr.Zero;
+
if (typeof(T) == typeof(PlayList))
{
- MediaContentRetValidator.ThrowIfError(
- Interop.Playlist.GetPlaylistFromDb(id, out _handle), "Failed to get information");
+ MediaContentValidator.ThrowIfError(
+ Interop.Playlist.GetPlaylistFromDb(id, out handle), "Failed to get information");
- if (_handle != IntPtr.Zero)
- contentCollection = new PlayList(_handle);
+ result = new PlayList(handle);
+
+ return (T)result;
}
else if (typeof(T) == typeof(Album))
{
- MediaContentRetValidator.ThrowIfError(
- Interop.Group.MediaAlbumGetAlbumFromDb(id, out _handle), "Failed to get information");
+ MediaContentValidator.ThrowIfError(
+ Interop.Group.MediaAlbumGetAlbumFromDb(id, out handle), "Failed to get information");
+
+ result = new Album(handle);
- if (_handle != IntPtr.Zero)
- contentCollection = new Album(_handle);
+ return (T)result;
}
else if (typeof(T) == typeof(Tag))
{
- MediaContentRetValidator.ThrowIfError(
- Interop.Tag.GetTagFromDb(id, out _handle), "Failed to get information");
+ MediaContentValidator.ThrowIfError(
+ Interop.Tag.GetTagFromDb(id, out handle), "Failed to get information");
- if (_handle != IntPtr.Zero)
- contentCollection = new Tag(_handle);
+ result = new Tag(handle);
+
+ return (T)result;
}
- return (contentCollection != null) ? (T)contentCollection : null;
+ return null;
}
private static IEnumerable<MediaFolder> ForEachFolder(ContentFilter filter)
{
- List<MediaFolder> folderCollections = new List<MediaFolder>();
- Interop.Folder.MediaFolderCallback folderCallback = (IntPtr folderHandle, IntPtr data) =>
+ List<MediaFolder> result = new List<MediaFolder>();
+ Interop.Folder.MediaFolderCallback callback = (IntPtr handle, IntPtr data) =>
{
- IntPtr newHandle;
- MediaContentRetValidator.ThrowIfError(
- Interop.Folder.Clone(out newHandle, folderHandle), "Failed to clone");
+ IntPtr newHandle = IntPtr.Zero;
+ MediaContentValidator.ThrowIfError(
+ Interop.Folder.Clone(out newHandle, handle), "Failed to clone");
- folderCollections.Add(new MediaFolder(newHandle));
+ result.Add(new MediaFolder(newHandle));
return true;
};
IntPtr filterHandle = filter != null ? filter.Handle : IntPtr.Zero;
- MediaContentRetValidator.ThrowIfError(
- Interop.Folder.ForeachFolderFromDb(filterHandle, folderCallback, IntPtr.Zero), "Failed to get information");
+ MediaContentValidator.ThrowIfError(
+ Interop.Folder.ForeachFolderFromDb(filterHandle, callback, IntPtr.Zero), "Failed to get information");
- return folderCollections;
+ return result;
}
private static IEnumerable<Album> ForEachAlbum(ContentFilter filter)
{
- List<Album> albumCollections = new List<Album>();
- Interop.Group.MediaAlbumCallback albumCallback = (IntPtr albumHandle, IntPtr data) =>
+ List<Album> result = new List<Album>();
+ Interop.Group.MediaAlbumCallback callback = (IntPtr handle, IntPtr data) =>
{
IntPtr newHandle = IntPtr.Zero;
- MediaContentRetValidator.ThrowIfError(
- Interop.Group.MediaAlbumClone(out newHandle, albumHandle), "Failed to clone");
+ MediaContentValidator.ThrowIfError(
+ Interop.Group.MediaAlbumClone(out newHandle, handle), "Failed to clone");
- albumCollections.Add(new Album(newHandle));
+ result.Add(new Album(newHandle));
return true;
};
- IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
- MediaContentRetValidator.ThrowIfError(
- Interop.Group.MediaAlbumForeachAlbumFromDb(handle, albumCallback, IntPtr.Zero), "Failed to get information");
+ IntPtr filterHandle = (filter != null) ? filter.Handle : IntPtr.Zero;
+ MediaContentValidator.ThrowIfError(
+ Interop.Group.MediaAlbumForeachAlbumFromDb(filterHandle, callback, IntPtr.Zero), "Failed to get information");
- return albumCollections;
+ return result;
}
private static IEnumerable<Group> ForEachGroup(ContentFilter filter)
groupType = filter.GroupType;
}
- List<Group> groupCollections = new List<Group>();
- Interop.Group.MediaGroupCallback groupCallback = (string groupName, IntPtr data) =>
+ List<Group> result = new List<Group>();
+ Interop.Group.MediaGroupCallback callback = (string groupName, IntPtr data) =>
{
- groupCollections.Add(new Group(groupName, groupType));
+ result.Add(new Group(groupName, groupType));
return true;
};
- MediaContentRetValidator.ThrowIfError(
- Interop.Group.ForeachGroupFromDb(handle, groupType, groupCallback, IntPtr.Zero), "Failed to get information");
+ MediaContentValidator.ThrowIfError(
+ Interop.Group.ForeachGroupFromDb(handle, groupType, callback, IntPtr.Zero), "Failed to get information");
- return groupCollections;
+ return result;
}
private static IEnumerable<Storage> ForEachStorage(ContentFilter filter)
{
IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
- List<Storage> storageCollections = new List<Storage>();
- Interop.Storage.MediaStorageCallback storageCallback = (IntPtr storageHandle, IntPtr data) =>
+ List<Storage> result = new List<Storage>();
+ Interop.Storage.MediaStorageCallback callback = (IntPtr storageHandle, IntPtr data) =>
{
- IntPtr newHandle;
- MediaContentRetValidator.ThrowIfError(
+ IntPtr newHandle = IntPtr.Zero;
+ MediaContentValidator.ThrowIfError(
Interop.Storage.Clone(out newHandle, storageHandle), "Failed to clone");
- storageCollections.Add(new Storage(newHandle));
+ result.Add(new Storage(newHandle));
return true;
};
- MediaContentRetValidator.ThrowIfError(
- Interop.Storage.ForeachStorageFromDb(handle, storageCallback, IntPtr.Zero), "Failed to get information");
+ MediaContentValidator.ThrowIfError(
+ Interop.Storage.ForeachStorageFromDb(handle, callback, IntPtr.Zero), "Failed to get information");
- return storageCollections;
+ return result;
}
private static IEnumerable<Tag> ForEachTag(ContentFilter filter)
{
IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
- List<Tag> tagCollections = new List<Tag>();
- Interop.Tag.MediaTagCallback tagCallback = (IntPtr tagHandle, IntPtr data) =>
+ List<Tag> result = new List<Tag>();
+ Interop.Tag.MediaTagCallback callback = (IntPtr tagHandle, IntPtr data) =>
{
- IntPtr newHandle;
- MediaContentRetValidator.ThrowIfError(
+ IntPtr newHandle = IntPtr.Zero;
+ MediaContentValidator.ThrowIfError(
Interop.Tag.Clone(out newHandle, tagHandle), "Failed to clone");
- tagCollections.Add(new Tag(newHandle));
+ result.Add(new Tag(newHandle));
return true;
};
- MediaContentRetValidator.ThrowIfError(
- Interop.Tag.ForeachTagFromDb(handle, tagCallback, IntPtr.Zero), "Failed to get information");
+ MediaContentValidator.ThrowIfError(
+ Interop.Tag.ForeachTagFromDb(handle, callback, IntPtr.Zero), "Failed to get information");
- return tagCollections;
+ return result;
}
private static IEnumerable<PlayList> ForEachPlayList(ContentFilter filter)
{
IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
- List<PlayList> playListCollections = new List<PlayList>();
- Interop.Playlist.MediaPlaylistCallback playListCallback = (IntPtr playListHandle, IntPtr data) =>
+ List<PlayList> result = new List<PlayList>();
+ Interop.Playlist.MediaPlaylistCallback callback = (IntPtr playListHandle, IntPtr data) =>
{
- IntPtr newHandle;
- MediaContentRetValidator.ThrowIfError(
- Interop.Tag.Clone(out newHandle, playListHandle), "Failed to clone");
+ IntPtr newHandle = IntPtr.Zero;
+ MediaContentValidator.ThrowIfError(
+ Interop.Playlist.Clone(out newHandle, playListHandle), "Failed to clone");
- playListCollections.Add(new PlayList(newHandle));
+ result.Add(new PlayList(newHandle));
return true;
};
- MediaContentRetValidator.ThrowIfError(
- Interop.Playlist.ForeachPlaylistFromDb(handle, playListCallback, IntPtr.Zero), "Failed to get information");
+ MediaContentValidator.ThrowIfError(
+ Interop.Playlist.ForeachPlaylistFromDb(handle, callback, IntPtr.Zero), "Failed to get information");
- return playListCollections;
+ return result;
}
/// <summary>
Interop.MediaInformation.MediaInformationCallback callback = (IntPtr mediaHandle, IntPtr userData) =>
{
Interop.MediaInformation.SafeMediaInformationHandle newHandle;
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone");
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone");
MediaContentType type;
Interop.MediaInformation.GetMediaType(newHandle, out type);
if (type == MediaContentType.Image)
{
Interop.ImageInformation.SafeImageInformationHandle imageInfo;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetImage(mediaHandle, out imageInfo), "Failed to get image information");
mediaInformationList.Add(new ImageInformation(imageInfo, newHandle));
else if ((type == MediaContentType.Music) || (type == MediaContentType.Sound))
{
Interop.AudioInformation.SafeAudioInformationHandle audioInfo;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetAudio(mediaHandle, out audioInfo), "Failed to get audio information");
mediaInformationList.Add(new AudioInformation(audioInfo, newHandle));
else if (type == MediaContentType.Video)
{
Interop.VideoInformation.SafeVideoInformationHandle videoInfo;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetVideo(mediaHandle, out videoInfo), "Failed to get video information");
mediaInformationList.Add(new VideoInformation(videoInfo, newHandle));
{
mediaInformationList.Add(new MediaInformation(newHandle));
}
+
return true;
};
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetAllMedia(handle, callback, IntPtr.Zero), "Failed to get media information");
return mediaInformationList;
public void Delete(MediaInformation mediaInfo)
{
ConnectToDB();
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.Delete(mediaInfo.MediaId), "Failed to remove information");
}
if (type == typeof(Tag))
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Tag.DeleteFromDb(((Tag)contentcollection).Id), "Failed to remove information");
}
else if (type == typeof(PlayList))
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Playlist.DeleteFromDb(((PlayList)contentcollection).Id), "Failed to remove information");
}
else
internal void Delete(MediaBookmark bookmark)
{
ConnectToDB();
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaBookmark.DeleteFromDb(bookmark.Id), "Failed to remove information");
}
internal void Delete(MediaFace face)
{
ConnectToDB();
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Face.DeleteFromDb(face.Id), "Failed to remove face information");
}
{
ConnectToDB();
Type type = contentCollection.GetType();
- MediaContentError result = MediaContentError.None;
if (type == typeof(Tag))
{
- result = (MediaContentError)Interop.Tag.UpdateToDb(((Tag)contentCollection).Handle);
+ MediaContentValidator.ThrowIfError(
+ Interop.Tag.UpdateToDb(((Tag)contentCollection).Handle), "Failed to update DB");
}
else if (type == typeof(PlayList))
{
- result = (MediaContentError)Interop.Playlist.UpdateToDb(((PlayList)contentCollection).Handle);
+ MediaContentValidator.ThrowIfError(
+ Interop.Playlist.UpdateToDb(((PlayList)contentCollection).Handle), "Failed to update DB");
}
else if (type == typeof(MediaFolder))
{
- result = (MediaContentError)Interop.Folder.UpdateToDb(((MediaFolder)contentCollection).Handle);
+ MediaContentValidator.ThrowIfError(
+ Interop.Folder.UpdateToDb(((MediaFolder)contentCollection).Handle), "Failed to update DB");
}
else
{
- result = MediaContentError.InvalidParameter;
+ throw new ArgumentException("The type of content collection is wrong");
}
-
- MediaContentRetValidator.ThrowIfError(result, "Failed to update DB");
}
/// <summary>
{
ConnectToDB();
Type type = mediaInfo.GetType();
- MediaContentError result = MediaContentError.None;
if (type == typeof(ImageInformation))
{
- result = (MediaContentError)Interop.ImageInformation.UpdateToDB(((ImageInformation)mediaInfo).ImageHandle);
+ MediaContentValidator.ThrowIfError(
+ Interop.ImageInformation.UpdateToDB(((ImageInformation)mediaInfo).ImageHandle), "Failed to update DB");
}
else if (type == typeof(AudioInformation))
{
- result = (MediaContentError)Interop.AudioInformation.UpdateToDB(((AudioInformation)mediaInfo).AudioHandle);
+ MediaContentValidator.ThrowIfError(
+ Interop.AudioInformation.UpdateToDB(((AudioInformation)mediaInfo).AudioHandle), "Failed to update DB");
}
else if (type == typeof(VideoInformation))
{
- result = (MediaContentError)Interop.VideoInformation.UpdateToDB(((VideoInformation)mediaInfo).VideoHandle);
+ MediaContentValidator.ThrowIfError(
+ Interop.VideoInformation.UpdateToDB(((VideoInformation)mediaInfo).VideoHandle), "Failed to update DB");
}
else if (type == typeof(MediaInformation))
{
- result = (MediaContentError)Interop.MediaInformation.UpdateToDB(((MediaInformation)mediaInfo).MediaHandle);
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.UpdateToDB(((MediaInformation)mediaInfo).MediaHandle), "Failed to update DB");
}
else
{
- result = MediaContentError.InvalidOperation;
+ throw new ArgumentException("Invalid information type");
}
-
- MediaContentRetValidator.ThrowIfError(result, "Failed to update DB");
}
internal void Update(MediaFace face)
{
ConnectToDB();
-
- MediaContentRetValidator.ThrowIfError(Interop.Face.UpdateToDb(face.Handle), "Failed to update DB");
+ MediaContentValidator.ThrowIfError(Interop.Face.UpdateToDb(face.Handle), "Failed to update DB");
}
/// <summary>
{
ConnectToDB();
Type type = contentCollection.GetType();
- MediaContentError result = MediaContentError.None;
IntPtr handle = IntPtr.Zero;
if (type == typeof(Tag))
{
- result = (MediaContentError)Interop.Tag.InsertToDb(((Tag)contentCollection).Name, out handle);
+ MediaContentValidator.ThrowIfError(
+ Interop.Tag.InsertToDb(((Tag)contentCollection).Name, out handle), "Failed to insert collection");
((Tag)contentCollection).Handle = handle;
}
else if (type == typeof(PlayList))
{
- Console.WriteLine("Playlist insert");
- result = (MediaContentError)Interop.Playlist.InsertToDb(((PlayList)contentCollection).Name, out handle);
+ MediaContentValidator.ThrowIfError(
+ Interop.Playlist.InsertToDb(((PlayList)contentCollection).Name, out handle), "Failed to insert collection");
((PlayList)contentCollection).Handle = handle;
}
else
{
- Console.WriteLine("Inalid insert");
- result = MediaContentError.InvalidParameter;
+ throw new ArgumentException("collection type is wrong");
}
- MediaContentRetValidator.ThrowIfError(result, "Failed to insert collection to the database");
}
internal void Insert(string mediaId, uint offset, string thumbnailPath)
{
ConnectToDB();
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaBookmark.InsertToDb(mediaId, offset, thumbnailPath), "Failed to insert information");
}
internal void Insert(MediaFace face)
{
ConnectToDB();
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Face.InsertToDb(((MediaFace)face).Handle), "Failed to insert information");
}
}
using System;
+using System.Runtime.InteropServices;
namespace Tizen.Content.MediaContent
{
{
private IntPtr _filterHandle = IntPtr.Zero;
private bool _disposedValue = false;
- //private ContentOrder _order = ContentOrder.Asc;
- //private string _orderKey = "MEDIA_ID";
- private ContentCollation _collationType = ContentCollation.Default;
+
internal IntPtr Handle
{
get
{
int offset;
int count;
- MediaContentRetValidator.ThrowIfError(
- Interop.Filter.GetOffset(_filterHandle, out offset, out count), "Failed to Get offset");
+ MediaContentValidator.ThrowIfError(
+ Interop.Filter.GetOffset(_filterHandle, out offset, out count), "Failed to get offset");
return offset;
}
set
{
- MediaContentRetValidator.ThrowIfError(
- Interop.Filter.SetOffset(_filterHandle, value, this.Count), "Failed to Set offset");
+ MediaContentValidator.ThrowIfError(
+ Interop.Filter.SetOffset(_filterHandle, value, this.Count), "Failed to set offset");
}
}
public ContentFilter()
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Filter.Create(out _filterHandle), "Failed to Create Filter handle.");
}
/// <summary>
{
int offset;
int count;
- MediaContentRetValidator.ThrowIfError(
- Interop.Filter.GetOffset(_filterHandle, out offset, out count), "Failed to Getoffset/count");
+ MediaContentValidator.ThrowIfError(
+ Interop.Filter.GetOffset(_filterHandle, out offset, out count), "Failed to get count");
return count;
}
set
{
- MediaContentRetValidator.ThrowIfError(
- Interop.Filter.SetOffset(_filterHandle, this.Offset, value), "Failed to Setoffset/Count");
+ MediaContentValidator.ThrowIfError(
+ Interop.Filter.SetOffset(_filterHandle, this.Offset, value), "Failed to set count");
}
}
/// <summary>
{
get
{
- int orderType;
- string orderKey;
- int collatetType;
- MediaContentRetValidator.ThrowIfError(
- Interop.Filter.GetOrder(_filterHandle, out orderType, out orderKey, out collatetType), "Failed to GetOrder");
+ ContentOrder order;
+ IntPtr val = IntPtr.Zero;
+ ContentCollation collate;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Filter.GetOrder(_filterHandle, out order, out val, out collate), "Failed to get order");
- return (ContentOrder)orderType;
+ return order;
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
}
/// <summary>
{
get
{
- string condition;
- int collatetType;
- MediaContentRetValidator.ThrowIfError(
- Interop.Filter.GetCondition(_filterHandle, out condition, out collatetType), "Failed to GetCondition for CollationType");
+ IntPtr val = IntPtr.Zero;
+ ContentCollation type;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Filter.GetCondition(_filterHandle, out val, out type), "Failed to get collation");
- return (ContentCollation)collatetType;
+ return type;
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
set
{
- _collationType = value;
- MediaContentRetValidator.ThrowIfError(
- Interop.Filter.SetCondition(_filterHandle, this.Condition, (int)value), "Failed to SetCondition for CollationType");
+ MediaContentValidator.ThrowIfError(
+ Interop.Filter.SetCondition(_filterHandle, this.Condition, value), "Failed to set collation");
}
}
/// <summary>
{
get
{
- string conditionVal = "";
- int collatetType;
- MediaContentRetValidator.ThrowIfError(
- Interop.Filter.GetCondition(_filterHandle, out conditionVal, out collatetType), "Failed to GetCondition");
+ IntPtr val = IntPtr.Zero;
+ ContentCollation type;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Filter.GetCondition(_filterHandle, out val, out type), "Failed to get condition");
- return conditionVal;
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
set
{
- MediaContentRetValidator.ThrowIfError(
- Interop.Filter.SetCondition(_filterHandle, value, (int)_collationType), "Failed to SetCondition");
+ MediaContentValidator.ThrowIfError(
+ Interop.Filter.SetCondition(_filterHandle, value, this.CollationType), "Failed to set condition");
}
}
/// <summary>
{
get
{
- string storageId;
- MediaContentRetValidator.ThrowIfError(
- Interop.Filter.GetStorage(_filterHandle, out storageId), "Failed to GetCondition");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Filter.GetStorage(_filterHandle, out val), "Failed to get condition");
- return storageId;
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
set
{
- MediaContentRetValidator.ThrowIfError(
- Interop.Filter.SetStorage(_filterHandle, value), "Failed to SetCondition");
+ MediaContentValidator.ThrowIfError(
+ Interop.Filter.SetStorage(_filterHandle, value), "Failed to set condition");
}
}
/// <summary>
{
get
{
- int orderType;
- string orderKey;
- int collatetType;
- MediaContentRetValidator.ThrowIfError(
- Interop.Filter.GetOrder(_filterHandle, out orderType, out orderKey, out collatetType), "Failed to GetOrder for OrderKey");
+ ContentOrder order;
+ IntPtr val = IntPtr.Zero;
+ ContentCollation type;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Filter.GetOrder(_filterHandle, out order, out val, out type), "Failed to GetOrder for OrderKey");
- return orderKey;
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
}
+
/// <summary>
/// The type of the media group
/// </summary>
- public MediaGroupType GroupType
- {
- get; set;
- }
+ public MediaGroupType GroupType { get; set; }
+
/// <summary>
/// SetOrderProperties like OrderType and OrderKey.
/// </summary>
public void SetOrderProperties(ContentOrder order, string oderKey)
{
- MediaContentRetValidator.ThrowIfError(
- Interop.Filter.SetOrder(_filterHandle, order, oderKey, CollationType), "Failed to SetOrder");
+ MediaContentValidator.ThrowIfError(
+ Interop.Filter.SetOrder(_filterHandle, order, oderKey, CollationType), "Failed to set order");
}
{
if (_filterHandle != IntPtr.Zero)
{
- Interop.Filter.Destroy(_filterHandle); //destroy filterHandle
-
+ Interop.Filter.Destroy(_filterHandle);
_filterHandle = IntPtr.Zero;
}
_disposedValue = true;
public static void Scan(string filePath)
{
Database.ConnectToDB();
- MediaContentRetValidator.ThrowIfError(
- Interop.Content.ScanFile(filePath), "Failed scan");
+ MediaContentValidator.ThrowIfError(Interop.Content.ScanFile(filePath), "Failed scan");
}
/// <summary>
{
Database.ConnectToDB();
Interop.MediaInformation.SafeMediaInformationHandle mediaInformationHandle;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.Insert(filePath, out mediaInformationHandle), "Failed to Insert MediaInformation to DB");
return new MediaInformation(mediaInformationHandle);
Interop.Content.MediaScanCompletedCallback scanCompleted = (MediaContentError scanResult, IntPtr data) =>
{
- MediaContentRetValidator.ThrowIfError(scanResult, "Failed to scan");
+ MediaContentValidator.ThrowIfError(scanResult, "Failed to scan");
task.SetResult((int)scanResult);
};
- MediaContentRetValidator.ThrowIfError(Interop.Content.ScanFolder(folderPath, recursive, scanCompleted, IntPtr.Zero), "Failed to scan");
+
+ MediaContentValidator.ThrowIfError(
+ Interop.Content.ScanFolder(folderPath, recursive, scanCompleted, IntPtr.Zero), "Failed to scan");
return task.Task;
}
if (!taskCompleted)
{
taskCompleted = true;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Content.CancelScanFolder(folderPath), "Failed CancelScanFolder");
task.SetCanceled();
if (!taskCompleted)
{
taskCompleted = true;
- MediaContentRetValidator.ThrowIfError(scanResult, "Failed scan");
+ MediaContentValidator.ThrowIfError(scanResult, "Failed scan");
task.SetResult((int)scanResult);
}
}
};
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Content.ScanFolder(folderPath, recursive, scanCompletedWithToken, IntPtr.Zero), "Failed to scan");
return task.Task;
string[] paths = ((List<string>)filePaths).ToArray();
Interop.MediaInformation.MediaInsertCompletedCallback callback = (MediaContentError error, IntPtr userData) =>
{
- MediaContentRetValidator.ThrowIfError(error, "Failed to batch insert");
+ MediaContentValidator.ThrowIfError(error, "Failed to batch insert");
task.SetResult((int)error);
};
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.BatchInsert(paths, paths.Length, callback, IntPtr.Zero), "Failed to add batch media");
return task.Task;
string[] paths = ((List<string>)filePaths).ToArray();
Interop.MediaInformation.MediaInsertBurstShotCompletedCallback callback = (MediaContentError error, IntPtr userData) =>
{
- MediaContentRetValidator.ThrowIfError(error, "Failed to add burstshot");
+ MediaContentValidator.ThrowIfError(error, "Failed to add burstshot");
task.SetResult((int)error);
};
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.BurstShotInsert(paths, paths.Length, callback, IntPtr.Zero), "Failed to add burst shots to db");
return task.Task;
using System;
using System.Collections.Generic;
+using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace Tizen.Content.MediaContent
{
int mediaCount = 0;
IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Group.GetMediaCountFromDb(Name, _groupType, handle, out mediaCount), "Failed to GetMediaCountFromDb");
return mediaCount;
Interop.Group.MediaInfoCallback callback = (IntPtr mediaHandle, IntPtr data) =>
{
Interop.MediaInformation.SafeMediaInformationHandle newHandle;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone MediaInformation instance");
mediaContents.Add(new MediaInformation(newHandle));
return true;
};
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Group.ForeachMediaFromDb(Name, _groupType, handle, callback, IntPtr.Zero), "Failed to get media information for the group");
tcs.TrySetResult(mediaContents);
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
+using System.Runtime.InteropServices;
namespace Tizen.Content.MediaContent
{
{
get
{
- string mediaId = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.ImageInformation.GetMediaId(_handle, out mediaId), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.ImageInformation.GetMediaId(_handle, out val), "Failed to get value");
- if (mediaId == null)
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
{
- mediaId = "";
+ Interop.Libc.Free(val);
}
- return mediaId;
}
}
get
{
int width = 0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.ImageInformation.GetWidth(_handle, out width), "Failed to get value");
return width;
get
{
int height = 0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.ImageInformation.GetHeight(_handle, out height), "Failed to get value");
return height;
get
{
MediaContentOrientation orientation = MediaContentOrientation.NotAvailable;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.ImageInformation.GetOrientation(_handle, out orientation), "Failed to get value");
return orientation;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.ImageInformation.SetOrientation(_handle, value), "Failed to set value");
}
}
{
get
{
- string takenDate = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.ImageInformation.GetDateTaken(_handle, out takenDate), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.ImageInformation.GetDateTaken(_handle, out val), "Failed to get value");
- if (takenDate == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- takenDate = "";
+ Interop.Libc.Free(val);
}
- return takenDate;
}
}
{
get
{
- string burstId = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.ImageInformation.GetBurstId(_handle, out burstId), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.ImageInformation.GetBurstId(_handle, out val), "Failed to get value");
- if (burstId == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- burstId = "";
+ Interop.Libc.Free(val);
}
- return burstId;
}
}
{
get
{
- string exposureTime = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.ImageInformation.GetExposureTime(_handle, out exposureTime), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.ImageInformation.GetExposureTime(_handle, out val), "Failed to get value");
- if (exposureTime == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- exposureTime = "";
+ Interop.Libc.Free(val);
}
- return exposureTime;
}
}
get
{
double fNumber = 0.0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.ImageInformation.GetFNumber(_handle, out fNumber), "Failed to get value");
return fNumber;
get
{
int iso = 0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.ImageInformation.GetISO(_handle, out iso), "Failed to get value");
return iso;
{
get
{
- string model = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.ImageInformation.GetModel(_handle, out model), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.ImageInformation.GetModel(_handle, out val), "Failed to get value");
- if (model == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- model = "";
+ Interop.Libc.Free(val);
}
- return model;
}
}
get
{
bool isBurst = false;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.ImageInformation.IsBurstShot(_handle, out isBurst), "Failed to get value");
return isBurst;
var task = new TaskCompletionSource<IEnumerable<MediaFace>>();
Collection<MediaFace> coll = new Collection<MediaFace>();
- Interop.MediaInformation.MediaFaceCallback faceCallback = (IntPtr facehandle, IntPtr userData) =>
+ Interop.MediaInformation.MediaFaceCallback callback = (IntPtr faceHandle, IntPtr userData) =>
{
IntPtr newHandle = IntPtr.Zero;
- MediaContentRetValidator.ThrowIfError(
- Interop.Face.Clone(out newHandle, facehandle), "Failed to clone Tag");
+ MediaContentValidator.ThrowIfError(
+ Interop.Face.Clone(out newHandle, faceHandle), "Failed to clone Tag");
coll.Add(new MediaFace(newHandle));
return true;
};
IntPtr filterHandle = (filter != null) ? filter.Handle : IntPtr.Zero;
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetAllFaces(MediaId, filterHandle, faceCallback, IntPtr.Zero), "Failed to get value");
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetAllFaces(MediaId, filterHandle, callback, IntPtr.Zero), "Failed to get value");
task.SetResult(coll);
return task.Task;
}
{
int count = 0;
IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetFaceCount(MediaId, handle, out count), "Failed to get value");
return count;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Runtime.InteropServices;
using System.Text;
namespace Tizen.Content.MediaContent
internal MediaBookmark(IntPtr handle)
{
_bookmarkHandle = handle;
- MediaContentRetValidator.ThrowIfError(
+ IntPtr val = IntPtr.Zero;
+ MediaContentValidator.ThrowIfError(
Interop.MediaBookmark.GetMarkedTime(_bookmarkHandle, out _offset), "Failed to Get Offset");
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaBookmark.GetThumbnailPath(_bookmarkHandle, out _thumbnailPath), "Failed to Get Thumbnail Path");
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaBookmark.GetThumbnailPath(_bookmarkHandle, out val), "Failed to Get Thumbnail Path");
+
+ _thumbnailPath = Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
~MediaBookmark()
get
{
int id;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaBookmark.GetBookmarkId(_bookmarkHandle, out id), "Failed to get bookmark id");
return id;
UnsupportedContent = TizenMediaContentError | 0x04,
NotSupported = ErrorCode.NotSupported,
}
- internal class MediaContentRetValidator
+ internal class MediaContentValidator
{
internal const string LogTag = "Tizen.Content.MediaContent";
throw new PlatformNotSupportedException(msg);
}
}
+
+ internal static string CheckString(string value)
+ {
+ return (value != null) ? value : "";
+ }
}
}
using System;
+using System.Runtime.InteropServices;
namespace Tizen.Content.MediaContent
{
///</param>
internal MediaFace(MediaInformation image, FaceRect rect)
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Face.Create(image.MediaId, out _faceHandle), "Failed to create MediaFace");
- MediaContentRetValidator.ThrowIfError(
- Interop.Face.SetFaceRect(_faceHandle, rect.X, rect.Y, rect.Width, rect.Height), "Failed to set Rect to MediaFace");
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Face.SetFaceRect(_faceHandle, rect.X, rect.Y, rect.Width, rect.Height), "Failed to set Rect to MediaFace");
+ }
+ catch (Exception)
+ {
+ Interop.Face.Destroy(_faceHandle);
+ throw;
+ }
}
~MediaFace()
int y;
int width;
int height;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Face.GetFaceRect(_faceHandle, out x, out y, out width, out height), "Failed to get Rect for the Face");
return new FaceRect(x, y, width, height);
set
{
FaceRect rect = (FaceRect)value;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Face.SetFaceRect(_faceHandle, rect.X, rect.Y, rect.Width, rect.Height), "Failed to set Rect for the Face");
}
}
{
get
{
- string id;
- MediaContentRetValidator.ThrowIfError(
- Interop.Face.GetFaceId(_faceHandle, out id), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Face.GetFaceId(_faceHandle, out val), "Failed to get value");
- return id;
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
}
{
get
{
- string mediaId;
- MediaContentRetValidator.ThrowIfError(
- Interop.Face.GetMediaId(_faceHandle, out mediaId), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Face.GetMediaId(_faceHandle, out val), "Failed to get value");
- return mediaId;
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
}
/// <summary>
{
get
{
- string tag;
- MediaContentRetValidator.ThrowIfError(
- Interop.Face.GetTag(_faceHandle, out tag), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Face.GetTag(_faceHandle, out val), "Failed to get value");
- return tag;
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Face.SetTag(_faceHandle, value), "Failed to set value");
}
}
get
{
int orientation;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Face.GetOrientation(_faceHandle, out orientation), "Failed to value");
return (MediaContentOrientation)orientation;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Face.SetOrientation(_faceHandle, (int)value), "Failed to set value");
}
}
using System;
using System.Collections.Generic;
+using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace Tizen.Content.MediaContent
{
get
{
- string id;
- MediaContentRetValidator.ThrowIfError(
- Interop.Folder.GetFolderId(_folderHandle, out id), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Folder.GetFolderId(_folderHandle, out val), "Failed to get value");
- return id;
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
}
{
get
{
- string parentId;
- MediaContentRetValidator.ThrowIfError(
- Interop.Folder.GetParentFolderId(_folderHandle, out parentId), "Failed to get value");
- return parentId;
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Folder.GetParentFolderId(_folderHandle, out val), "Failed to get value");
+
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
}
{
get
{
- string path;
- MediaContentRetValidator.ThrowIfError(
- Interop.Folder.GetPath(_folderHandle, out path), "Failed to get value");
- return path;
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Folder.GetPath(_folderHandle, out val), "Failed to get value");
+
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
}
{
get
{
- string name;
- MediaContentRetValidator.ThrowIfError(
- Interop.Folder.GetName(_folderHandle, out name), "Failed to get value");
- return name;
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Folder.GetName(_folderHandle, out val), "Failed to get value");
+
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Folder.SetName(_folderHandle, value), "Failed to set value");
}
}
{
get
{
- int type;
- MediaContentRetValidator.ThrowIfError(
+ ContentStorageType type;
+ MediaContentValidator.ThrowIfError(
Interop.Folder.GetStorageType(_folderHandle, out type), "Failed to get value");
- return (ContentStorageType)type;
+ return type;
}
}
{
get
{
- string storageId;
- MediaContentRetValidator.ThrowIfError(
- Interop.Folder.GetStorageId(_folderHandle, out storageId), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Folder.GetStorageId(_folderHandle, out val), "Failed to get value");
- return storageId;
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
}
get
{
DateTime date;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Folder.GetModifiedTime(_folderHandle, out date), "Failed to get value");
return date;
get
{
int order;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Folder.GetOrder(_folderHandle, out order), "Failed to get value");
return order;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Folder.SetOrder(_folderHandle, value), "Failed to set value");
}
}
{
int mediaCount;
IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Folder.GetMediaCountFromDb(Id, handle, out mediaCount), "Failed to get count");
return mediaCount;
Interop.Folder.MediaInfoCallback callback = (IntPtr mediaHandle, IntPtr data) =>
{
Interop.MediaInformation.SafeMediaInformationHandle newHandle;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone");
mediaContents.Add(new MediaInformation(newHandle));
return true;
};
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Folder.ForeachMediaFromDb(Id, handle, callback, IntPtr.Zero), "Failed to get information");
tcs.TrySetResult(mediaContents);
{
int count = 0;
IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetTagCount(MediaId, handle, out count), "Failed to get count");
return count;
/// <param name="destination">The Destination path</param>
public void Move(string destination)
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.MoveToDB(_handle, destination), "Failed to move");
}
/// void </returns>
public void Refresh()
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.RefreshMetadataToDB(MediaId), "Failed to refresh");
}
var task = new TaskCompletionSource<string>();
Interop.MediaInformation.MediaThumbnailCompletedCallback thumbnailResult = (MediaContentError createResult, string path, IntPtr userData) =>
{
- MediaContentRetValidator.ThrowIfError(createResult, "Failed to create thumbnail");
+ MediaContentValidator.ThrowIfError(createResult, "Failed to create thumbnail");
task.SetResult(path);
};
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.CreateThumbnail(_handle, thumbnailResult, IntPtr.Zero), "Failed to create thumbnail");
return await task.Task;
{
var task = new TaskCompletionSource<string>();
cancellationToken.Register(() => {
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.CancelThumbnail(_handle), "Failed to cancel");
task.SetCanceled();
});
Interop.MediaInformation.MediaThumbnailCompletedCallback thumbnailResult = (MediaContentError createResult, string path, IntPtr userData) =>
{
- MediaContentRetValidator.ThrowIfError(createResult, "Failed to create thumbnail");
+ MediaContentValidator.ThrowIfError(createResult, "Failed to create thumbnail");
task.SetResult(path);
};
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.CreateThumbnail(_handle, thumbnailResult, IntPtr.Zero), "Failed to create thumbnail");
return await task.Task;
Interop.MediaInformation.MediaTagCallback tagsCallback = (IntPtr tagHandle, IntPtr userData) =>
{
IntPtr newHandle;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Tag.Clone(out newHandle, tagHandle), "Failed to clone");
coll.Add(new Tag(newHandle));
return true;
};
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetAllTags(MediaId, handle, tagsCallback, IntPtr.Zero), "Failed to get information");
task.SetResult(coll);
{
get
{
- string mediaId = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetMediaId(_handle, out mediaId), "Failed to get value");
- if (mediaId == null)
+ IntPtr val = IntPtr.Zero;
+ try
{
- mediaId = "";
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetMediaId(_handle, out val), "Failed to get value");
+
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
}
- return mediaId;
}
}
{
get
{
- string path = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetFilePath(_handle, out path), "Failed to get value");
- if (path == null)
+ IntPtr val = IntPtr.Zero;
+ try
{
- path = "";
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetFilePath(_handle, out val), "Failed to get value");
+
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
}
- return path;
}
}
{
get
{
- string displayname = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetDisplayName(_handle, out displayname), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetDisplayName(_handle, out val), "Failed to get value");
- if (displayname == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- displayname = "";
+ Interop.Libc.Free(val);
}
- return displayname;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.SetDisplayName(_handle, value), "failed to set value");
}
}
get
{
MediaContentType contentType = MediaContentType.Others;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetMediaType(_handle, out contentType), "Failed to get value");
return contentType;
{
get
{
- string mimeType = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetMimeType(_handle, out mimeType), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetMimeType(_handle, out val), "Failed to get value");
- if (mimeType == null)
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
{
- mimeType = "";
+ Interop.Libc.Free(val);
}
- return mimeType;
}
}
get
{
long size;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetSize(_handle, out size), "Failed to get value");
return size;
{
get
{
- DateTime addedAt;
int time;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetAddedTime(_handle, out time), "Failed to get value");
- DateTime utc;
- if (time != 0)
- {
- utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
- addedAt = utc.ToLocalTime();
- }
- else
- {
- addedAt = DateTime.Now;
- }
- return addedAt;
- }
+ DateTime utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
+ return utc.ToLocalTime();
+ }
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.SetAddedTime(_handle, (int)value.ToUniversalTime().Subtract(new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds), "failed to set time");
}
}
{
get
{
- DateTime modifiedAt;
int time;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetModifiedTime(_handle, out time), "Failed to get value");
- DateTime utc;
- if (time != 0)
- {
- utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
- modifiedAt = utc.ToLocalTime();
- }
- else
- {
- modifiedAt = DateTime.Now;
- }
- return modifiedAt;
+ DateTime utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
+
+ return utc.ToLocalTime();
}
}
{
get
{
- DateTime timeline;
int time;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetTimeline(_handle, out time), "Failed to get value");
- DateTime utc;
- if (time != 0)
- {
- utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
- timeline = utc.ToLocalTime();
- }
- else
- {
- timeline = DateTime.Now;
- }
- return timeline;
+ DateTime utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
+
+ return utc.ToLocalTime();
}
}
{
get
{
- string thumbnailPath = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetThumbnailPath(_handle, out thumbnailPath), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetThumbnailPath(_handle, out val), "Failed to get value");
- if (thumbnailPath == null)
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
{
- thumbnailPath = "";
+ Interop.Libc.Free(val);
}
- return thumbnailPath;
}
}
{
get
{
- string description = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetDescription(_handle, out description), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetDescription(_handle, out val), "Failed to get value");
- if (description == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- description = "";
+ Interop.Libc.Free(val);
}
- return description;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.SetDescription(_handle, value), "failed to set value");
}
}
get
{
double longitude = 0.0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetLongitude(_handle, out longitude), "Failed to get value");
return longitude;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.SetLongitude(_handle, value), "failed to set value");
}
}
get
{
double latitude = 0.0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetLatitude(_handle, out latitude), "Failed to get value");
return latitude;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.SetLatitude(_handle, value), "failed to set value");
}
}
get
{
double altitude = 0.0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetAltitude(_handle, out altitude), "Failed to get value");
return altitude;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.SetAltitude(_handle, value), "failed to set value");
}
}
{
get
{
- string weather = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetWeather(_handle, out weather), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetWeather(_handle, out val), "Failed to get value");
- if (weather == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- weather = "";
+ Interop.Libc.Free(val);
}
- return weather;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.SetWeather(_handle, value), "failed to set value");
}
}
get
{
int rating = 0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetRating(_handle, out rating), "Failed to get value");
return rating;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.SetRating(_handle, value), "failed to set value");
}
}
get
{
bool isFavourtite = false;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetFavorite(_handle, out isFavourtite), "Failed to get value");
return isFavourtite;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.SetFavorite(_handle, value), "failed to set value");
}
}
{
get
{
- string author = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetAuthor(_handle, out author), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetAuthor(_handle, out val), "Failed to get value");
- if(author == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- author = "";
+ Interop.Libc.Free(val);
}
- return author;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.SetAuthor(_handle, value), "failed to set value");
}
}
{
get
{
- string provider = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetProvider(_handle, out provider), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetProvider(_handle, out val), "Failed to get value");
- if (provider == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- provider = "";
+ Interop.Libc.Free(val);
}
- return provider;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.SetProvider(_handle, value), "failed to set value");
}
}
{
get
{
- string contentName = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetContentName(_handle, out contentName), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetContentName(_handle, out val), "Failed to get value");
- if (contentName == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- contentName = "";
+ Interop.Libc.Free(val);
}
- return contentName;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.SetContentName(_handle, value), "failed to set value");
}
}
{
get
{
- string title = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetTitle(_handle, out title), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetTitle(_handle, out val), "Failed to get value");
- if (title == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- title = "";
+ Interop.Libc.Free(val);
}
- return title;
}
}
{
get
{
- string category = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetCategory(_handle, out category), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetCategory(_handle, out val), "Failed to get value");
- if (category == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- category = "";
+ Interop.Libc.Free(val);
}
- return category;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.SetCategory(_handle, value), "failed to set value");
}
}
{
get
{
- string loationTag = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetLocationTag(_handle, out loationTag), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetLocationTag(_handle, out val), "Failed to get value");
- if (loationTag == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- loationTag = "";
+ Interop.Libc.Free(val);
}
- return loationTag;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.SetLocationTag(_handle, value), "failed to set value");
}
}
{
get
{
- string ageRating = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetAgeRating(_handle, out ageRating), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetAgeRating(_handle, out val), "Failed to get value");
- if (ageRating == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- ageRating = "";
+ Interop.Libc.Free(val);
}
- return ageRating;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.SetAgeRating(_handle, value), "Failed to set value");
}
}
{
get
{
- string keyword = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetKeyword(_handle, out keyword), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetKeyword(_handle, out val), "Failed to get value");
- if (keyword == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- keyword = "";
+ Interop.Libc.Free(val);
}
- return keyword;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.SetKeyword(_handle, value), "failed to set value");
}
}
{
get
{
- string storageId = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetStorageId(_handle, out storageId), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetStorageId(_handle, out val), "Failed to get value");
- if (storageId == null)
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
{
- storageId = "";
+ Interop.Libc.Free(val);
}
- return storageId;
}
}
get
{
bool isDRM = false;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.IsDrm(_handle, out isDRM), "Failed to get value");
return isDRM;
get
{
ContentStorageType storageType = ContentStorageType.Internal;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetStorageType(_handle, out storageType), "Failed to get value");
return storageType;
get
{
int playedCount = 0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetPlayedCount(_handle, out playedCount), "Failed to get value");
return playedCount;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.IncreasePlayedCount(_handle), "failed to set value");
}
}
{
get
{
- DateTime addedAt;
int time;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetPlayedAt(_handle, out time), "Failed to get value");
- DateTime utc;
- if (time != 0)
- {
- utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
- addedAt = utc.ToLocalTime();
- }
- else
- {
- addedAt = DateTime.Now;
- }
- return addedAt;
+ DateTime utc = DateTime.SpecifyKind(new DateTime(1970, 1, 1).AddSeconds(time), DateTimeKind.Utc);
+
+ return utc.ToLocalTime();
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.SetPlayedAt(_handle), "failed to set value");
}
}
using System;
using System.Collections.Generic;
+using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace Tizen.Content.MediaContent
Interop.Playlist.PlaylistMemberCallback callback = (int memberId, IntPtr mediaHandle, IntPtr data) =>
{
Interop.MediaInformation.SafeMediaInformationHandle newHandle;
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone media");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone media");
- string mediaId;
- Interop.MediaInformation.GetMediaId(newHandle, out mediaId);
- _dictionary.Add(mediaId, memberId);
- return true;
+ Interop.MediaInformation.GetMediaId(newHandle, out val);
+ _dictionary.Add(Marshal.PtrToStringAnsi(val), memberId);
+ return true;
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
};
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Playlist.ForeachMediaFromDb(Id, IntPtr.Zero, callback, IntPtr.Zero), "Failed to get playlist items");
}
get
{
int id;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Playlist.GetPlaylistId(_playlistHandle, out id), "Failed to get value");
return id;
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Playlist.SetName(_playlistHandle, value), "Failed to set value");
_playListName = value;
}
{
get
{
- string path;
- MediaContentRetValidator.ThrowIfError(
- Interop.Playlist.GetThumbnailPath(_playlistHandle, out path), "Failed to get value");
- return path;
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Playlist.GetThumbnailPath(_playlistHandle, out val), "Failed to get value");
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Playlist.SetThumbnailPath(_playlistHandle, value), "Failed to set value");
}
}
internal PlayList(IntPtr handle)
{
_playlistHandle = handle;
- MediaContentRetValidator.ThrowIfError(
- Interop.Playlist.GetName(handle, out _playListName), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Playlist.GetName(handle, out val), "Failed to get value");
+ _playListName = Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
/// <summary>
/// <param name="mediaContent">The AudioContent obect to be added</param>
public void AddItem(MediaInformation mediaContent)
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Playlist.AddMedia(_playlistHandle, mediaContent.MediaId), "Failed to add item");
}
int memberId = 0;
refreshPlaylistDictionary();
_dictionary.TryGetValue(media.MediaId, out memberId);
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Playlist.RemoveMedia(_playlistHandle, memberId), "Failed to remove item");
}
int memberId;
refreshPlaylistDictionary();
_dictionary.TryGetValue(media.MediaId, out memberId);
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Playlist.SetPlayOrder(_playlistHandle, memberId, playOrder), "Failed to set play order");
}
int memberId;
refreshPlaylistDictionary();
_dictionary.TryGetValue(media.MediaId, out memberId);
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Playlist.GetPlayOrder(_playlistHandle, memberId, out playOrder), "Failed to get play order");
return playOrder;
PlayList playList = null;
IntPtr playlistHandle;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Playlist.ImportFromFile(name, filePath, out playlistHandle), "Failed to import");
playList = new PlayList(name);
/// <returns>path The path to export the playlist</returns>
public static void Export(PlayList list, string filePath)
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Playlist.ExportToFile(list.Handle, filePath), "Failed to export playlist:" + filePath);
}
{
int mediaCount;
IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Playlist.GetMediaCountFromDb(Id, handle, out mediaCount), "Failed to get media count");
return mediaCount;
Interop.Playlist.PlaylistMemberCallback callback = (int memberId, IntPtr mediaHandle, IntPtr data) =>
{
Interop.MediaInformation.SafeMediaInformationHandle newHandle;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone media");
mediaContents.Add(new MediaInformation(newHandle));
return true;
};
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Playlist.ForeachMediaFromDb(Id, handle, callback, IntPtr.Zero), "Failed to get media information");
tcs.TrySetResult(mediaContents);
using System;
using System.Collections.Generic;
+using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace Tizen.Content.MediaContent
{
get
{
- string id;
- MediaContentRetValidator.ThrowIfError(
- Interop.Storage.GetId(_storageHandle, out id), "Failed to get value");
-
- return id;
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Storage.GetId(_storageHandle, out val), "Failed to get value");
+
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
}
{
get
{
- string path;
- MediaContentRetValidator.ThrowIfError(
- Interop.Storage.GetPath(_storageHandle, out path), "Failed to get value");
-
- return path;
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Storage.GetPath(_storageHandle, out val), "Failed to get value");
+
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
}
{
get
{
- string name;
- MediaContentRetValidator.ThrowIfError(
- Interop.Storage.GetName(_storageHandle, out name), "Failed to get value");
-
- return name;
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Storage.GetName(_storageHandle, out val), "Failed to get value");
+
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
}
{
get
{
- int storageType;
- MediaContentRetValidator.ThrowIfError(
+ ContentStorageType storageType;
+ MediaContentValidator.ThrowIfError(
Interop.Storage.GetType(_storageHandle, out storageType), "Failed to get value");
- return (ContentStorageType)storageType;
+ return storageType;
}
}
{
int mediaCount;
IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Storage.GetMediaCountFromDb(Id, handle, out mediaCount), "Failed to get count");
return mediaCount;
Interop.Storage.MediaInfoCallback callback = (IntPtr mediaHandle, IntPtr data) =>
{
Interop.MediaInformation.SafeMediaInformationHandle newHandle;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone media");
mediaContents.Add(new MediaInformation(newHandle));
return true;
};
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Storage.ForeachMediaFromDb(Id, handle, callback, IntPtr.Zero), "Failed to get information");
tcs.TrySetResult(mediaContents);
using System;
using System.Collections.Generic;
+using System.Runtime.InteropServices;
using System.Threading.Tasks;
namespace Tizen.Content.MediaContent
get
{
int id;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Tag.GetTagId(_tagHandle, out id), "Failed to get value");
return id;
}
}
set
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Tag.SetName(_tagHandle, value), "Failed to set value");
_tagName = value;
}
internal Tag(IntPtr tagHandle)
{
_tagHandle = tagHandle;
- MediaContentRetValidator.ThrowIfError(
- Interop.Tag.GetName(tagHandle, out _tagName), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.Tag.GetName(_tagHandle, out val), "Failed to get value");
+ _tagName = Marshal.PtrToStringAnsi(val);
+ }
+ finally
+ {
+ Interop.Libc.Free(val);
+ }
}
/// <summary>
/// Creates a Tag object which can be inserted to the media database using ContentManager:InsertToDatabaseAsync(ContentCollection)
/// <param name="mediaContent">The media info which is added</param>
public void AddItem(MediaInformation mediaContent)
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Tag.AddMedia(_tagHandle, mediaContent.MediaId), "Failed to add item");
}
/// <param name="mediaContent">The media info which is removed</param>
public void RemoveItem(MediaInformation mediaContent)
{
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Tag.RemoveMedia(_tagHandle, mediaContent.MediaId), "Failed to remove item");
}
{
int mediaCount;
IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Tag.GetMediaCountFromDb(Id, handle, out mediaCount), "Failed to get count");
return mediaCount;
Interop.Tag.MediaInfoCallback callback = (IntPtr mediaHandle, IntPtr data) =>
{
Interop.MediaInformation.SafeMediaInformationHandle newHandle;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone media");
mediaContents.Add(new MediaInformation(newHandle));
+ return true;
};
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.Tag.ForeachMediaFromDb(Id, handle, callback, IntPtr.Zero), "Failed to get information");
tcs.TrySetResult(mediaContents);
{
get
{
- string mediaId = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.VideoInformation.GetMediaId(_handle, out mediaId), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.VideoInformation.GetMediaId(_handle, out val), "Failed to get value");
- if (mediaId == null)
+ return Marshal.PtrToStringAnsi(val);
+ }
+ finally
{
- mediaId = "";
+ Interop.Libc.Free(val);
}
- return mediaId;
}
}
{
get
{
- string album = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.VideoInformation.GetAlbum(_handle, out album), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.VideoInformation.GetAlbum(_handle, out val), "Failed to get value");
- if (album == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- album = "";
+ Interop.Libc.Free(val);
}
- return album;
}
}
{
get
{
- string artist = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.VideoInformation.GetArtist(_handle, out artist), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.VideoInformation.GetArtist(_handle, out val), "Failed to get value");
- if (artist == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- artist = "";
+ Interop.Libc.Free(val);
}
- return artist;
}
}
{
get
{
- string albumArtist = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.VideoInformation.GetAlbumArtist(_handle, out albumArtist), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.VideoInformation.GetAlbumArtist(_handle, out val), "Failed to get value");
- if (albumArtist == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- albumArtist = "";
+ Interop.Libc.Free(val);
}
- return albumArtist;
}
}
{
get
{
- string genre = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.VideoInformation.GetGenre(_handle, out genre), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.VideoInformation.GetGenre(_handle, out val), "Failed to get value");
- if (genre == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- genre = "";
+ Interop.Libc.Free(val);
}
- return genre;
}
}
{
get
{
- string composer = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.VideoInformation.GetComposer(_handle, out composer), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.VideoInformation.GetComposer(_handle, out val), "Failed to get value");
- if (composer == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- composer = "";
+ Interop.Libc.Free(val);
}
- return composer;
}
}
{
get
{
- string year = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.VideoInformation.GetYear(_handle, out year), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.VideoInformation.GetYear(_handle, out val), "Failed to get value");
- if (year == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- year = "";
+ Interop.Libc.Free(val);
}
- return year;
}
}
{
get
{
- string recordedDate = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.VideoInformation.GetRecordedDate(_handle, out recordedDate), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.VideoInformation.GetRecordedDate(_handle, out val), "Failed to get value");
- if (recordedDate == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- recordedDate = "";
+ Interop.Libc.Free(val);
}
- return recordedDate;
}
}
{
get
{
- string copyright = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.VideoInformation.GetCopyright(_handle, out copyright), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.VideoInformation.GetCopyright(_handle, out val), "Failed to get value");
- if (copyright == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- copyright = "";
+ Interop.Libc.Free(val);
}
- return copyright;
}
}
{
get
{
- string trackNumber = "";
- MediaContentRetValidator.ThrowIfError(
- Interop.VideoInformation.GetTrackNum(_handle, out trackNumber), "Failed to get value");
+ IntPtr val = IntPtr.Zero;
+ try
+ {
+ MediaContentValidator.ThrowIfError(
+ Interop.VideoInformation.GetTrackNum(_handle, out val), "Failed to get value");
- if (trackNumber == null)
+ return MediaContentValidator.CheckString(Marshal.PtrToStringAnsi(val));
+ }
+ finally
{
- trackNumber = "";
+ Interop.Libc.Free(val);
}
- return trackNumber;
}
}
get
{
int bitrate = 0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.VideoInformation.GetBitRate(_handle, out bitrate), "Failed to get value");
return bitrate;
get
{
int duration = 0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.VideoInformation.GetDuration(_handle, out duration), "Failed to get value");
return duration;
get
{
int width = 0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.VideoInformation.GetWidth(_handle, out width), "Failed to get value");
return width;
get
{
int height = 0;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.VideoInformation.GetHeight(_handle, out height), "Failed to get value");
return height;
{
int count = 0;
IntPtr handle = (filter != null) ? filter.Handle : IntPtr.Zero;
- MediaContentRetValidator.ThrowIfError(
+ MediaContentValidator.ThrowIfError(
Interop.MediaInformation.GetBookmarkCount(MediaId, handle, out count), "Failed to get count");
return count;
{
var task = new TaskCompletionSource<IEnumerable<MediaBookmark>>();
- Collection<MediaBookmark> coll = new Collection<MediaBookmark>();
+ Collection<MediaBookmark> result = new Collection<MediaBookmark>();
IntPtr filterHandle = (filter != null) ? filter.Handle : IntPtr.Zero;
- Interop.MediaInformation.MediaBookmarkCallback bookmarksCallback = (IntPtr handle, IntPtr userData) =>
+ Interop.MediaInformation.MediaBookmarkCallback callback = (IntPtr handle, IntPtr userData) =>
{
- IntPtr newHandle;
- MediaContentRetValidator.ThrowIfError(
+ IntPtr newHandle = IntPtr.Zero;
+ MediaContentValidator.ThrowIfError(
Interop.MediaBookmark.Clone(out newHandle, handle), "Failed to clone Tag");
- coll.Add(new MediaBookmark(newHandle));
+ result.Add(new MediaBookmark(newHandle));
return true;
};
- MediaContentRetValidator.ThrowIfError(
- Interop.MediaInformation.GetAllBookmarks(MediaId, filterHandle, bookmarksCallback, IntPtr.Zero), "Failed to get value");
+ MediaContentValidator.ThrowIfError(
+ Interop.MediaInformation.GetAllBookmarks(MediaId, filterHandle, callback, IntPtr.Zero), "Failed to get value");
- task.SetResult(coll);
+ task.SetResult(result);
return task.Task;
}