Skip to content

Commit

Permalink
[MediaContent] Remove deprecated CreateThumbnailAsync API (#6603)
Browse files Browse the repository at this point in the history
  • Loading branch information
hsgwon authored Feb 7, 2025
1 parent 772cc29 commit 0d1c45d
Showing 1 changed file with 0 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -861,122 +861,6 @@ public bool Move(string mediaId, string newPath)
return true;
}

#region CreateThumbnailAsync
/// <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>
/// <param name="mediaId">The media ID to create the thumbnail.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the 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>
/// <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);
}

/// <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>
/// <param name="mediaId">The media ID to create the thumbnail.</param>
/// <param name="cancellationToken">The token to cancel the operation.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the 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>
/// <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();

return cancellationToken.IsCancellationRequested ? Task.FromCanceled<string>(cancellationToken) :
CreateThumbnailAsyncCore(mediaId, cancellationToken);
}

private async Task<string> CreateThumbnailAsyncCore(string mediaId, CancellationToken cancellationToken)
{
ValidationUtil.ValidateNotNullOrEmpty(mediaId, nameof(mediaId));

var tcs = new TaskCompletionSource<string>();

using (var handle = ValidateFile(mediaId))
{
string thumbnailPath = null;
MediaContentError ret = MediaContentError.None;
Task thumbTask = null;

if (cancellationToken.CanBeCanceled)
{
cancellationToken.Register(() =>
{
if (tcs.Task.IsCompleted)
{
return;
}

tcs.TrySetCanceled();
});
}

thumbTask = Task.Factory.StartNew( () =>
{
ret = Interop.MediaInfo.GenerateThumbnail(handle);

if (ret != MediaContentError.None)
{
tcs.TrySetException(ret.AsException("Failed to create thumbnail"));
}
else
{
thumbnailPath = InteropHelper.GetString(handle, Interop.MediaInfo.GetThumbnailPath, true);
tcs.TrySetResult(thumbnailPath);
}
}, cancellationToken,
TaskCreationOptions.DenyChildAttach | TaskCreationOptions.LongRunning,
TaskScheduler.Default);

return await tcs.Task;
}
}
#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.
Expand Down

0 comments on commit 0d1c45d

Please sign in to comment.