[Metadata] Deprecate MetadataEditor module (#5837)
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.Metadata / MetadataEditor / MetadataEditor.cs
old mode 100755 (executable)
new mode 100644 (file)
index aeda76e..a00cdc9
@@ -1,4 +1,4 @@
-/*
+/*
  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
  *
  * Licensed under the Apache License, Version 2.0 (the License);
@@ -18,17 +18,22 @@ using System;
 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 internal storage,
-    /// you should add privilege http://tizen.org/privilege/mediastorage. \n
-    /// Or if you want to access only external storage,
-    /// you should add privilege http://tizen.org/privilege/externalstorage. \n
+    /// If you want to access only an internal storage,
+    /// 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.
     /// </privilege>
+    /// <since_tizen> 3 </since_tizen>
+    [Obsolete("Deprecated in API12; Will be removed in API14")]
     public class MetadataEditor : IDisposable
     {
         private bool _disposed = false;
@@ -52,12 +57,13 @@ namespace Tizen.Multimedia
         /// Initializes a new instance of the <see cref="MetadataEditor"/> class with the specified path.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        /// <param name="path">The path of the media file to edit metadata.</param>
+        /// <param name="path">The path of the media file to edit the metadata.</param>
         /// <exception cref="ArgumentNullException"><paramref name="path"/> is null.</exception>
         /// <exception cref="ArgumentException"><paramref name="path"/> is a zero-length string, contains only white space.</exception>
         /// <exception cref="FileFormatException">The file is not supported.</exception>
-        /// <exception cref="FileNotFoundException">File does not exist.</exception>
-        /// <exception cref="UnauthorizedAccessException">Caller does not have required privilege to access the file.</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)
@@ -70,17 +76,17 @@ namespace Tizen.Multimedia
                 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;
             }
         }
@@ -91,14 +97,14 @@ namespace Tizen.Multimedia
 
             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);
             }
         }
 
@@ -109,15 +115,22 @@ namespace Tizen.Multimedia
                 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="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed.</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
@@ -135,8 +148,15 @@ namespace Tizen.Multimedia
         /// Gets or sets the title of media.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        /// <exception cref="InvalidOperationException">The file is read-only.</exception>
-        /// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed.</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
@@ -154,8 +174,15 @@ namespace Tizen.Multimedia
         /// 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="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed.</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
@@ -173,8 +200,15 @@ namespace Tizen.Multimedia
         /// Gets or sets the genre of media.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        /// <exception cref="InvalidOperationException">The file is read-only.</exception>
-        /// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed.</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
@@ -192,8 +226,15 @@ namespace Tizen.Multimedia
         /// Gets or sets the author of media.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        /// <exception cref="InvalidOperationException">The file is read-only.</exception>
-        /// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed.</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
@@ -211,8 +252,15 @@ namespace Tizen.Multimedia
         /// Gets or sets the copyright of media.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        /// <exception cref="InvalidOperationException">The file is read-only.</exception>
-        /// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed.</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
@@ -231,11 +279,18 @@ namespace Tizen.Multimedia
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
         /// <remarks>
-        /// If the media contains 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.
+        /// 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="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed.</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
@@ -253,8 +308,15 @@ namespace Tizen.Multimedia
         /// Gets or sets the description of media.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        /// <exception cref="InvalidOperationException">The file is read-only.</exception>
-        /// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed.</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
@@ -272,8 +334,15 @@ namespace Tizen.Multimedia
         /// Gets or sets the comment of media.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        /// <exception cref="InvalidOperationException">The file is read-only.</exception>
-        /// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed.</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
@@ -291,8 +360,15 @@ namespace Tizen.Multimedia
         /// 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="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed.</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
@@ -310,7 +386,8 @@ namespace Tizen.Multimedia
         /// Gets the count of album arts of media.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        /// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed.</exception>
+        /// <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;
@@ -320,8 +397,15 @@ namespace Tizen.Multimedia
         /// Gets or sets the conductor of media.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        /// <exception cref="InvalidOperationException">The file is read-only.</exception>
-        /// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed.</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
@@ -339,8 +423,15 @@ namespace Tizen.Multimedia
         /// 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="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed.</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
@@ -358,11 +449,13 @@ namespace Tizen.Multimedia
         /// 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.</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)
@@ -370,23 +463,23 @@ namespace Tizen.Multimedia
                 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>
         /// Gets the artwork image in the media file.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        /// <param name="index">The index of picture to import.</param>
-        /// <returns> Artwork included in the media file.</returns>
-        /// <returns>Artwork included in the media file.</returns>
+        /// <param name="index">The index of the picture to import.</param>
+        /// <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.</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)
@@ -406,7 +499,7 @@ namespace Tizen.Multimedia
 
             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)
@@ -423,12 +516,12 @@ namespace Tizen.Multimedia
             {
                 if (data != IntPtr.Zero)
                 {
-                    Interop.Libc.Free(data);
+                    Marshal.FreeHGlobal(data);
                 }
 
                 if (mimeType != IntPtr.Zero)
                 {
-                    Interop.Libc.Free(mimeType);
+                    Marshal.FreeHGlobal(mimeType);
                 }
             }
         }
@@ -437,17 +530,20 @@ namespace Tizen.Multimedia
         /// Appends the picture to the media file.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        /// <param name="path">The path of picture for adding to the metadata.</param>
+        /// <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"> Picture path is null</exception>
-        /// <exception cref="FileNotFoundException">File does not exist.</exception>
-        /// <exception cref="UnauthorizedAccessException">Caller does not have required privilege to access the file.</exception>
-        /// <exception cref="ObjectDisposedException">The <see cref="MetadataEditor"/> has already been disposed.</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)
@@ -465,7 +561,7 @@ namespace Tizen.Multimedia
                 throw new InvalidOperationException("The media file is read-only.");
             }
 
-            Interop.MetadataEditor.AddPicture(Handle, path).
+            Native.AddPicture(Handle, path).
                 ThrowIfError("Failed to append picture");
         }
 
@@ -473,18 +569,19 @@ namespace Tizen.Multimedia
         /// Removes the picture from the media file.
         /// </summary>
         /// <since_tizen> 3 </since_tizen>
-        /// <param name="index">The index of picture to remove.</param>
+        /// <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.</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)
@@ -503,21 +600,31 @@ namespace Tizen.Multimedia
                 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);
         }
 
+        /// <summary>
+        /// Releases the resources used by the <see cref="MetadataEditor"/> object.
+        /// </summary>
+        /// <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;
                 }
 
@@ -528,6 +635,8 @@ namespace Tizen.Multimedia
         /// <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);