/// <exception cref="ArgumentNullException"><paramref name="mediaId"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="mediaId"/> is a zero-length string, contains only white space.</exception>
/// <since_tizen> 4 </since_tizen>
+ [Obsolete("Deprecated since API11; Will be removed in API13.")]
public int CountFaceInfo(string mediaId, CountArguments arguments)
{
ValidateDatabase();
/// <exception cref="ArgumentNullException"><paramref name="mediaId"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="mediaId"/> is a zero-length string, contains only white space.</exception>
/// <since_tizen> 4 </since_tizen>
+ [Obsolete("Deprecated since API11; Will be removed in API13.")]
public MediaDataReader<FaceInfo> SelectFaceInfo(string mediaId)
{
return SelectFaceInfo(mediaId, null);
/// <exception cref="ArgumentNullException"><paramref name="mediaId"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="mediaId"/> is a zero-length string, contains only white space.</exception>
/// <since_tizen> 4 </since_tizen>
+ [Obsolete("Deprecated since API11; Will be removed in API13.")]
public MediaDataReader<FaceInfo> SelectFaceInfo(string mediaId, SelectArguments arguments)
{
ValidateDatabase();
/// <exception cref="UnsupportedContentException">
/// The thumbnail is not available for the given media.<br/>
/// -or-<br/>
- /// The media is in the external USB storage (<see cref="MediaInfo.StorageType"/> is <see cref="StorageType.ExternalUsb"/>).
+ /// The media is in the external USB storage.
/// </exception>
/// <since_tizen> 4 </since_tizen>
+ [Obsolete("Deprecated since API10; Will be removed in API12. Please use CreateThumbnail instead.")]
public Task<string> CreateThumbnailAsync(string mediaId)
{
return CreateThumbnailAsync(mediaId, CancellationToken.None);
/// <exception cref="UnsupportedContentException">
/// The thumbnail is not available for the given media.<br/>
/// -or-<br/>
- /// The media is in the external USB storage (<see cref="MediaInfo.StorageType"/> is <see cref="StorageType.ExternalUsb"/>).
+ /// The media is in the external USB storage.
/// </exception>
/// <since_tizen> 4 </since_tizen>
+ [Obsolete("Deprecated since API10; Will be removed in API12. Please use CreateThumbnail instead.")]
public Task<string> CreateThumbnailAsync(string mediaId, CancellationToken cancellationToken)
{
ValidateDatabase();
}
#endregion
+ /// <summary>
+ /// Creates the thumbnail image for the given media.
+ /// If the thumbnail already exists for the given media, the existing path will be returned.
+ /// </summary>
+ /// <privilege>http://tizen.org/privilege/content.write</privilege>
+ /// <privilege>http://tizen.org/privilege/mediastorage</privilege>
+ /// <privilege>http://tizen.org/privilege/externalstorage</privilege>
+ /// <param name="mediaId">The ID of the media for which the thumbnail will be created.</param>
+ /// <returns>A created thumbnail path.</returns>
+ /// <exception cref="InvalidOperationException">
+ /// The <see cref="MediaDatabase"/> is disconnected.<br/>
+ /// -or-<br/>
+ /// An internal error occurred while executing.
+ /// </exception>
+ /// <exception cref="ObjectDisposedException">The <see cref="MediaDatabase"/> has already been disposed.</exception>
+ /// <exception cref="MediaDatabaseException">An error occurred while executing the command.</exception>
+ /// <exception cref="ArgumentNullException"><paramref name="mediaId"/> is null.</exception>
+ /// <exception cref="RecordNotFoundException"><paramref name="mediaId"/> does not exist in the database.</exception>
+ /// <exception cref="ArgumentException">
+ /// <paramref name="mediaId"/> is a zero-length string, contains only white space.
+ /// </exception>
+ /// <exception cref="FileNotFoundException">The file of the media does not exists; moved or deleted.</exception>
+ /// <exception cref="UnsupportedContentException">
+ /// The thumbnail is not available for the given media.<br/>
+ /// -or-<br/>
+ /// The media is in the external USB storage.
+ /// </exception>
+ /// <exception cref="UnauthorizedAccessException">The caller has no required privilege.</exception>
+ /// <since_tizen> 10 </since_tizen>
+ public string CreateThumbnail(string mediaId)
+ {
+ ValidateDatabase();
+
+ ValidationUtil.ValidateNotNullOrEmpty(mediaId, nameof(mediaId));
+
+ using (var handle = ValidateFile(mediaId))
+ {
+ Interop.MediaInfo.GenerateThumbnail(handle).ThrowIfError("Failed to create thumbnail");
+
+ return InteropHelper.GetString(handle, Interop.MediaInfo.GetThumbnailPath, true);
+ }
+ }
+
private Interop.MediaInfoHandle ValidateFile(string mediaId)
{
Interop.MediaInfo.GetMediaFromDB(mediaId, out var handle).ThrowIfError("Failed to create thumbnail");
{
var path = InteropHelper.GetString(handle, Interop.MediaInfo.GetFilePath);
+ if (String.IsNullOrEmpty(path) || File.Exists(path) == false)
+ {
+ throw new FileNotFoundException($"The media file does not exist. Path={path}.", path);
+ }
+
foreach (var extendedInternal in StorageManager.Storages.Where(s => s.StorageType == StorageArea.ExtendedInternal))
{
if (path.Contains(extendedInternal.RootDirectory))
throw new UnsupportedContentException("The media is in external usb storage.");
}
}
-
- if (File.Exists(path) == false)
- {
- throw new FileNotFoundException($"The media file does not exist. Path={path}.", path);
- }
}
catch (Exception ex)
{
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
/// <exception cref="UnauthorizedAccessException">The caller has no required privilege.</exception>
/// <since_tizen> 4 </since_tizen>
+ [Obsolete("Deprecated since API11; Will be removed in API13.")]
public Task<int> DetectFaceAsync(string mediaId)
{
return DetectFaceAsync(mediaId, CancellationToken.None);
/// <exception cref="UnsupportedContentException">
/// Face detection is not available for the given media.<br/>
/// -or-<br/>
- /// The media is in the external USB storage (<see cref="MediaInfo.StorageType"/> is <see cref="StorageType.ExternalUsb"/>).
+ /// The media is in the external USB storage.
/// </exception>
/// <exception cref="NotSupportedException">The required feature is not supported.</exception>
/// <since_tizen> 4 </since_tizen>
+ [Obsolete("Deprecated since API11; Will be removed in API13.")]
public Task<int> DetectFaceAsync(string mediaId, CancellationToken cancellationToken)
{
if (Features.IsSupported(Features.FaceRecognition) == false)
using (handle)
{
- if (InteropHelper.GetValue<StorageType>(handle, Interop.MediaInfo.GetStorageType) == StorageType.ExternalUsb)
- {
- throw new UnsupportedContentException("The media is in external usb storage.");
- }
-
if (InteropHelper.GetValue<MediaType>(handle, Interop.MediaInfo.GetMediaType) != MediaType.Image)
{
throw new UnsupportedContentException("Only image is supported.");
using (RegisterCancelFaceDetection(cancellationToken, tcs, handle))
using (var cbKeeper = ObjectKeeper.Get(GetFaceDetectionCallback(tcs)))
{
- Interop.MediaInfo.StartFaceDetection(handle, cbKeeper.Target).ThrowIfError("Failed to detect faces");
+ var ret = Interop.MediaInfo.StartFaceDetection(handle, cbKeeper.Target);
+ if (ret == MediaContentError.InvalidParameter)
+ {
+ throw new UnsupportedContentException("The media is in external usb storage.");
+ }
+
+ ret.ThrowIfError("Failed to detect faces");
return await tcs.Task;
}