-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
using System.IO;
using System.Runtime.InteropServices;
+using Native = Interop.MetadataEditor;
+
namespace Tizen.Multimedia
{
/// <summary>
- /// Provides a means to edit the metadata of the media file.
+ /// Provides a means to edit the metadata of MP3 and MP4 files.
+ /// Since 6.0, WAV, FLAC, OGG files are supported as well.
/// </summary>
/// <privilege>
/// If you want to access only an internal storage,
- /// you should add privilege http://tizen.org/privilege/mediastorage. \n
+ /// you should add privilege http://tizen.org/privilege/mediastorage.<br/>
/// Or if you want to access only an external storage,
- /// you should add privilege http://tizen.org/privilege/externalstorage. \n
+ /// you should add privilege http://tizen.org/privilege/externalstorage.
/// </privilege>
+ /// <since_tizen> 3 </since_tizen>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public class MetadataEditor : IDisposable
{
private bool _disposed = false;
/// <exception cref="FileFormatException">The file is not supported.</exception>
/// <exception cref="FileNotFoundException">The file does not exist.</exception>
/// <exception cref="UnauthorizedAccessException">The caller does not have required privilege to access the file.</exception>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public MetadataEditor(string path)
{
if (path == null)
throw new ArgumentException($"{nameof(path)} is a zero-length string.", nameof(path));
}
- Interop.MetadataEditor.Create(out _handle).ThrowIfError("Failed to create metadata");
+ Native.Create(out _handle).ThrowIfError("Failed to create metadata");
try
{
- Interop.MetadataEditor.SetPath(Handle, path).ThrowIfError("Failed to set path");
+ Native.SetPath(Handle, path).ThrowIfError("Failed to set path");
_isFileReadOnly = File.GetAttributes(path).HasFlag(FileAttributes.ReadOnly);
}
catch (Exception)
{
- Interop.MetadataEditor.Destroy(_handle);
+ Dispose(false);
throw;
}
}
try
{
- Interop.MetadataEditor.GetMetadata(Handle, attr, out val)
+ Native.GetMetadata(Handle, attr, out val)
.ThrowIfError("Failed to get metadata");
return Marshal.PtrToStringAnsi(val);
}
finally
{
- Interop.Libc.Free(val);
+ Marshal.FreeHGlobal(val);
}
}
throw new InvalidOperationException("The media file is read-only.");
}
- Interop.MetadataEditor.SetMetadata(Handle, attr, value).ThrowIfError("Failed to set value");
+ Native.SetMetadata(Handle, attr, value).ThrowIfError("Failed to set value");
}
/// <summary>
/// Gets or sets the artist of media.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <exception cref="InvalidOperationException">The file is read-only.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// The file is read-only.<br/>
+ /// -or-<br/>
+ /// The malformed file which cannot be updatable.<br/>
+ /// -or-<br/>
+ /// Internal error.
+ /// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed of.</exception>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public string Artist
{
get
/// Gets or sets the title of media.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <exception cref="InvalidOperationException">The file is read-only.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// The file is read-only.<br/>
+ /// -or-<br/>
+ /// The malformed file which cannot be updatable.<br/>
+ /// -or-<br/>
+ /// Internal error.
+ /// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed of.</exception>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public string Title
{
get
/// Gets or sets the album name of media.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <exception cref="InvalidOperationException">The file is read-only.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// The file is read-only.<br/>
+ /// -or-<br/>
+ /// The malformed file which cannot be updatable.<br/>
+ /// -or-<br/>
+ /// Internal error.
+ /// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed of.</exception>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public string Album
{
get
/// Gets or sets the genre of media.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <exception cref="InvalidOperationException">The file is read-only.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// The file is read-only.<br/>
+ /// -or-<br/>
+ /// The malformed file which cannot be updatable.<br/>
+ /// -or-<br/>
+ /// Internal error.
+ /// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed of.</exception>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public string Genre
{
get
/// Gets or sets the author of media.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <exception cref="InvalidOperationException">The file is read-only.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// The file is read-only.<br/>
+ /// -or-<br/>
+ /// The malformed file which cannot be updatable.<br/>
+ /// -or-<br/>
+ /// Internal error.
+ /// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed of.</exception>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public string Author
{
get
/// Gets or sets the copyright of media.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <exception cref="InvalidOperationException">The file is read-only.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// The file is read-only.<br/>
+ /// -or-<br/>
+ /// The malformed file which cannot be updatable.<br/>
+ /// -or-<br/>
+ /// Internal error.
+ /// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed of.</exception>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public string Copyright
{
get
/// If the media contains the ID3 tag, this refers to the recorded date.
/// If the media is a mp4 format, this refers to the year, and the value to set will be converted into integer.
/// </remarks>
- /// <exception cref="InvalidOperationException">The file is read-only.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// The file is read-only.<br/>
+ /// -or-<br/>
+ /// The malformed file which cannot be updatable.<br/>
+ /// -or-<br/>
+ /// Internal error.
+ /// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed of.</exception>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public string Date
{
get
/// Gets or sets the description of media.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <exception cref="InvalidOperationException">The file is read-only.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// The file is read-only.<br/>
+ /// -or-<br/>
+ /// The malformed file which cannot be updatable.<br/>
+ /// -or-<br/>
+ /// Internal error.
+ /// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed of.</exception>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public string Description
{
get
/// Gets or sets the comment of media.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <exception cref="InvalidOperationException">The file is read-only.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// The file is read-only.<br/>
+ /// -or-<br/>
+ /// The malformed file which cannot be updatable.<br/>
+ /// -or-<br/>
+ /// Internal error.
+ /// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed of.</exception>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public string Comment
{
get
/// Gets or sets the track number of media.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <exception cref="InvalidOperationException">The file is read-only.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// The file is read-only.<br/>
+ /// -or-<br/>
+ /// The malformed file which cannot be updatable.<br/>
+ /// -or-<br/>
+ /// Internal error.
+ /// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed of.</exception>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public string TrackNumber
{
get
/// </summary>
/// <since_tizen> 3 </since_tizen>
/// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed of.</exception>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public int PictureCount
{
get => int.TryParse(GetParam(MetadataEditorAttr.PictureCount), out var value) ? value : 0;
/// Gets or sets the conductor of media.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <exception cref="InvalidOperationException">The file is read-only.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// The file is read-only.<br/>
+ /// -or-<br/>
+ /// The malformed file which cannot be updatable.<br/>
+ /// -or-<br/>
+ /// Internal error.
+ /// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed of.</exception>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public string Conductor
{
get
/// Gets or sets the unsynchronized lyrics of media.
/// </summary>
/// <since_tizen> 3 </since_tizen>
- /// <exception cref="InvalidOperationException">The file is read-only.</exception>
+ /// <exception cref="InvalidOperationException">
+ /// The file is read-only.<br/>
+ /// -or-<br/>
+ /// The malformed file which cannot be updatable.<br/>
+ /// -or-<br/>
+ /// Internal error.
+ /// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed of.</exception>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public string UnsyncLyrics
{
get
/// Writes the modified metadata to the media file.
/// </summary>
/// <exception cref="InvalidOperationException">
- /// An internal error occurs.\n
- /// -or-\n
- /// The file is read-only.
+ /// The file is read-only.<br/>
+ /// -or-<br/>
+ /// Internal error.<br/>
/// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed of.</exception>
+ /// <since_tizen> 3 </since_tizen>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public void Commit()
{
if (_isFileReadOnly)
throw new InvalidOperationException("The media file is read-only.");
}
- Interop.MetadataEditor.UpdateMetadata(Handle).ThrowIfError("Failed to update file");
+ Native.UpdateMetadata(Handle).ThrowIfError("Failed to update file");
}
/// <summary>
/// <returns>The artwork included in the media file.</returns>
/// <exception cref="InvalidOperationException">An internal error occurs.</exception>
/// <exception cref="ArgumentOutOfRangeException">
- /// <paramref name="index"/> is less than zero.\n
- /// -or-\n
- /// <paramref name="index"/> is greater than or equal to <see cref="PictureCount"/>.\n
+ /// <paramref name="index"/> is less than zero.<br/>
+ /// -or-<br/>
+ /// <paramref name="index"/> is greater than or equal to <see cref="PictureCount"/>.
/// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed of.</exception>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public Artwork GetPicture(int index)
{
if (index < 0)
try
{
- Interop.MetadataEditor.GetPicture(Handle, index, out data, out var size, out mimeType).
+ Native.GetPicture(Handle, index, out data, out var size, out mimeType).
ThrowIfError("Failed to get the value");
if (size > 0)
{
if (data != IntPtr.Zero)
{
- Interop.Libc.Free(data);
+ Marshal.FreeHGlobal(data);
}
if (mimeType != IntPtr.Zero)
{
- Interop.Libc.Free(mimeType);
+ Marshal.FreeHGlobal(mimeType);
}
}
}
/// <since_tizen> 3 </since_tizen>
/// <param name="path">The path of the picture for adding to the metadata.</param>
/// <exception cref="InvalidOperationException">
- /// An internal error occurs.\n
- /// -or-\n
- /// The media file is read-only.
+ /// The file is read-only.<br/>
+ /// -or-<br/>
+ /// The malformed file which cannot be updatable.<br/>
+ /// -or-<br/>
+ /// Internal error.
/// </exception>
- /// <exception cref="ArgumentNullException"><paramref name="path"/> is null</exception>
+ /// <exception cref="ArgumentNullException"><paramref name="path"/> is null.</exception>
/// <exception cref="FileNotFoundException">The file does not exist.</exception>
/// <exception cref="UnauthorizedAccessException">The caller does not have required privilege to access the file.</exception>
/// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed of.</exception>
/// <exception cref="FileFormatException">The specified file is not supported.</exception>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public void AddPicture(string path)
{
if (path == null)
throw new InvalidOperationException("The media file is read-only.");
}
- Interop.MetadataEditor.AddPicture(Handle, path).
+ Native.AddPicture(Handle, path).
ThrowIfError("Failed to append picture");
}
/// <since_tizen> 3 </since_tizen>
/// <param name="index">The index of the picture to remove.</param>
/// <exception cref="InvalidOperationException">
- /// An internal error occurs.\n
- /// -or-\n
+ /// An internal error occurs.<br/>
+ /// -or-<br/>
/// The media file is read-only.
/// </exception>
/// <exception cref="ArgumentOutOfRangeException">
- /// <paramref name="index"/> is less than zero.\n
- /// -or-\n
- /// <paramref name="index"/> is greater than or equal to <see cref="PictureCount"/>.\n
+ /// <paramref name="index"/> is less than zero.<br/>
+ /// -or-<br/>
+ /// <paramref name="index"/> is greater than or equal to <see cref="PictureCount"/>.
/// </exception>
/// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed of.</exception>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public void RemovePicture(int index)
{
if (index < 0)
throw new InvalidOperationException("The media file is read-only.");
}
- Interop.MetadataEditor.RemovePicture(Handle, index).ThrowIfError("Failed to remove picture");
+ Native.RemovePicture(Handle, index).ThrowIfError("Failed to remove picture");
}
+ /// <summary>
+ /// Finalizes an instance of the MetadataEditor class.
+ /// </summary>
~MetadataEditor()
{
Dispose(false);
/// <param name="disposing">
/// true to release both managed and unmanaged resources; false to release only unmanaged resources.
/// </param>
+ /// <since_tizen> 3 </since_tizen>
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
if (_handle != IntPtr.Zero)
{
- Interop.MetadataEditor.Destroy(_handle);
+ Native.Destroy(_handle);
_handle = IntPtr.Zero;
}
/// <summary>
/// Releases all resources used by the <see cref="MetadataEditor"/> object.
/// </summary>
+ /// <since_tizen> 3 </since_tizen>
+ [Obsolete("Deprecated in API12; Will be removed in API14")]
public void Dispose()
{
Dispose(true);