Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MediaContent] Remove deprecated CreateThumbnailAsync API #6270

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading