Modified to consider media type when creating instance
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 23 Mar 2017 07:17:07 +0000 (16:17 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Thu, 23 Mar 2017 07:58:22 +0000 (16:58 +0900)
Change-Id: I14edacf41b87766f166a618da3827021418db839
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
packaging/csapi-media-content.spec
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Album.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentDatabase.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/ContentManager.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Group.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/MediaFolder.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/PlayList.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Storage.cs
src/Tizen.Content.MediaContent/Tizen.Content.MediaContent/Tag.cs

index 85cda39..94bc7fe 100755 (executable)
@@ -1,6 +1,6 @@
 Name:       csapi-media-content
 Summary:    Tizen Media Content API for C#
-Version:    1.0.12
+Version:    1.0.13
 Release:    1
 Group:      Development/Libraries
 License:    Apache-2.0
index 08ce8f8..63715b2 100755 (executable)
@@ -177,7 +177,37 @@ namespace Tizen.Content.MediaContent
                 MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone");
 
-                mediaContents.Add(new MediaInformation(newHandle));
+                MediaContentType type;
+                Interop.MediaInformation.GetMediaType(newHandle, out type);
+                if (type == MediaContentType.Image)
+                {
+                    Interop.ImageInformation.SafeImageInformationHandle imageInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetImage(mediaHandle, out imageInfo), "Failed to get image information");
+
+                    mediaContents.Add(new ImageInformation(imageInfo, newHandle));
+                }
+                else if ((type == MediaContentType.Music) || (type == MediaContentType.Sound))
+                {
+                    Interop.AudioInformation.SafeAudioInformationHandle audioInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetAudio(mediaHandle, out audioInfo), "Failed to get audio information");
+
+                    mediaContents.Add(new AudioInformation(audioInfo, newHandle));
+                }
+                else if (type == MediaContentType.Video)
+                {
+                    Interop.VideoInformation.SafeVideoInformationHandle videoInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetVideo(mediaHandle, out videoInfo), "Failed to get video information");
+
+                    mediaContents.Add(new VideoInformation(videoInfo, newHandle));
+                }
+                else if (type == MediaContentType.Others)
+                {
+                    mediaContents.Add(new MediaInformation(newHandle));
+                }
+
                 return true;
             };
             MediaContentValidator.ThrowIfError(
index 11f38d8..89bda70 100755 (executable)
@@ -190,7 +190,39 @@ namespace Tizen.Content.MediaContent
             MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.GetMediaFromDB(id, out mediaHandle), "Failed to get information");
 
-            return new MediaInformation(mediaHandle);
+            MediaContentType type;
+            MediaInformation res;
+            Interop.MediaInformation.GetMediaType(mediaHandle, out type);
+            if (type == MediaContentType.Image)
+            {
+                Interop.ImageInformation.SafeImageInformationHandle imageInfo;
+                MediaContentValidator.ThrowIfError(
+                    Interop.MediaInformation.GetImage(mediaHandle.DangerousGetHandle(), out imageInfo), "Failed to get image information");
+
+                res = new ImageInformation(imageInfo, mediaHandle);
+            }
+            else if ((type == MediaContentType.Music) || (type == MediaContentType.Sound))
+            {
+                Interop.AudioInformation.SafeAudioInformationHandle audioInfo;
+                MediaContentValidator.ThrowIfError(
+                    Interop.MediaInformation.GetAudio(mediaHandle.DangerousGetHandle(), out audioInfo), "Failed to get audio information");
+
+                res = new AudioInformation(audioInfo, mediaHandle);
+            }
+            else if (type == MediaContentType.Video)
+            {
+                Interop.VideoInformation.SafeVideoInformationHandle videoInfo;
+                MediaContentValidator.ThrowIfError(
+                    Interop.MediaInformation.GetVideo(mediaHandle.DangerousGetHandle(), out videoInfo), "Failed to get video information");
+
+                res = new VideoInformation(videoInfo, mediaHandle);
+            }
+            else
+            {
+                res = new MediaInformation(mediaHandle);
+            }
+
+            return res;
         }
 
         /// <summary>
@@ -608,21 +640,30 @@ namespace Tizen.Content.MediaContent
             {
                 MediaContentValidator.ThrowIfError(
                     Interop.ImageInformation.UpdateToDB(((ImageInformation)mediaInfo).ImageHandle), "Failed to update DB");
+
+                MediaContentValidator.ThrowIfError(
+                    Interop.MediaInformation.UpdateToDB(mediaInfo.MediaHandle), "Failed to update DB");
             }
             else if (type == typeof(AudioInformation))
             {
                 MediaContentValidator.ThrowIfError(
                     Interop.AudioInformation.UpdateToDB(((AudioInformation)mediaInfo).AudioHandle), "Failed to update DB");
+
+                MediaContentValidator.ThrowIfError(
+                    Interop.MediaInformation.UpdateToDB(mediaInfo.MediaHandle), "Failed to update DB");
             }
             else if (type == typeof(VideoInformation))
             {
                 MediaContentValidator.ThrowIfError(
                     Interop.VideoInformation.UpdateToDB(((VideoInformation)mediaInfo).VideoHandle), "Failed to update DB");
+
+                MediaContentValidator.ThrowIfError(
+                    Interop.MediaInformation.UpdateToDB(mediaInfo.MediaHandle), "Failed to update DB");
             }
             else if (type == typeof(MediaInformation))
             {
                 MediaContentValidator.ThrowIfError(
-                    Interop.MediaInformation.UpdateToDB(((MediaInformation)mediaInfo).MediaHandle), "Failed to update DB");
+                    Interop.MediaInformation.UpdateToDB(mediaInfo.MediaHandle), "Failed to update DB");
             }
             else
             {
index c5280ce..84539aa 100755 (executable)
@@ -87,7 +87,39 @@ namespace Tizen.Content.MediaContent
             MediaContentValidator.ThrowIfError(
                 Interop.MediaInformation.Insert(filePath, out mediaInformationHandle), "Failed to Insert MediaInformation to DB");
 
-            return new MediaInformation(mediaInformationHandle);
+            MediaContentType type;
+            MediaInformation res;
+            Interop.MediaInformation.GetMediaType(mediaInformationHandle, out type);
+            if (type == MediaContentType.Image)
+            {
+                Interop.ImageInformation.SafeImageInformationHandle imageInfo;
+                MediaContentValidator.ThrowIfError(
+                    Interop.MediaInformation.GetImage(mediaInformationHandle.DangerousGetHandle(), out imageInfo), "Failed to get image information");
+
+                res = new ImageInformation(imageInfo, mediaInformationHandle);
+            }
+            else if ((type == MediaContentType.Music) || (type == MediaContentType.Sound))
+            {
+                Interop.AudioInformation.SafeAudioInformationHandle audioInfo;
+                MediaContentValidator.ThrowIfError(
+                    Interop.MediaInformation.GetAudio(mediaInformationHandle.DangerousGetHandle(), out audioInfo), "Failed to get audio information");
+
+                res = new AudioInformation(audioInfo, mediaInformationHandle);
+            }
+            else if (type == MediaContentType.Video)
+            {
+                Interop.VideoInformation.SafeVideoInformationHandle videoInfo;
+                MediaContentValidator.ThrowIfError(
+                    Interop.MediaInformation.GetVideo(mediaInformationHandle.DangerousGetHandle(), out videoInfo), "Failed to get video information");
+
+                res = new VideoInformation(videoInfo, mediaInformationHandle);
+            }
+            else
+            {
+                res = new MediaInformation(mediaInformationHandle);
+            }
+
+            return res;
         }
 
         /// <summary>
index 6872031..e70aee3 100755 (executable)
@@ -93,7 +93,37 @@ namespace Tizen.Content.MediaContent
                 MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone MediaInformation instance");
 
-                mediaContents.Add(new MediaInformation(newHandle));
+                MediaContentType type;
+                Interop.MediaInformation.GetMediaType(newHandle, out type);
+                if (type == MediaContentType.Image)
+                {
+                    Interop.ImageInformation.SafeImageInformationHandle imageInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetImage(mediaHandle, out imageInfo), "Failed to get image information");
+
+                    mediaContents.Add(new ImageInformation(imageInfo, newHandle));
+                }
+                else if ((type == MediaContentType.Music) || (type == MediaContentType.Sound))
+                {
+                    Interop.AudioInformation.SafeAudioInformationHandle audioInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetAudio(mediaHandle, out audioInfo), "Failed to get audio information");
+
+                    mediaContents.Add(new AudioInformation(audioInfo, newHandle));
+                }
+                else if (type == MediaContentType.Video)
+                {
+                    Interop.VideoInformation.SafeVideoInformationHandle videoInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetVideo(mediaHandle, out videoInfo), "Failed to get video information");
+
+                    mediaContents.Add(new VideoInformation(videoInfo, newHandle));
+                }
+                else if (type == MediaContentType.Others)
+                {
+                    mediaContents.Add(new MediaInformation(newHandle));
+                }
+
                 return true;
             };
             MediaContentValidator.ThrowIfError(
index cacd6ac..f232588 100755 (executable)
@@ -279,7 +279,37 @@ namespace Tizen.Content.MediaContent
                 MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone");
 
-                mediaContents.Add(new MediaInformation(newHandle));
+                MediaContentType type;
+                Interop.MediaInformation.GetMediaType(newHandle, out type);
+                if (type == MediaContentType.Image)
+                {
+                    Interop.ImageInformation.SafeImageInformationHandle imageInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetImage(mediaHandle, out imageInfo), "Failed to get image information");
+
+                    mediaContents.Add(new ImageInformation(imageInfo, newHandle));
+                }
+                else if ((type == MediaContentType.Music) || (type == MediaContentType.Sound))
+                {
+                    Interop.AudioInformation.SafeAudioInformationHandle audioInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetAudio(mediaHandle, out audioInfo), "Failed to get audio information");
+
+                    mediaContents.Add(new AudioInformation(audioInfo, newHandle));
+                }
+                else if (type == MediaContentType.Video)
+                {
+                    Interop.VideoInformation.SafeVideoInformationHandle videoInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetVideo(mediaHandle, out videoInfo), "Failed to get video information");
+
+                    mediaContents.Add(new VideoInformation(videoInfo, newHandle));
+                }
+                else if (type == MediaContentType.Others)
+                {
+                    mediaContents.Add(new MediaInformation(newHandle));
+                }
+
                 return true;
             };
             MediaContentValidator.ThrowIfError(
index 5c12d86..9019938 100755 (executable)
@@ -288,7 +288,37 @@ namespace Tizen.Content.MediaContent
                 MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone media");
 
-                mediaContents.Add(new MediaInformation(newHandle));
+                MediaContentType type;
+                Interop.MediaInformation.GetMediaType(newHandle, out type);
+                if (type == MediaContentType.Image)
+                {
+                    Interop.ImageInformation.SafeImageInformationHandle imageInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetImage(mediaHandle, out imageInfo), "Failed to get image information");
+
+                    mediaContents.Add(new ImageInformation(imageInfo, newHandle));
+                }
+                else if ((type == MediaContentType.Music) || (type == MediaContentType.Sound))
+                {
+                    Interop.AudioInformation.SafeAudioInformationHandle audioInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetAudio(mediaHandle, out audioInfo), "Failed to get audio information");
+
+                    mediaContents.Add(new AudioInformation(audioInfo, newHandle));
+                }
+                else if (type == MediaContentType.Video)
+                {
+                    Interop.VideoInformation.SafeVideoInformationHandle videoInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetVideo(mediaHandle, out videoInfo), "Failed to get video information");
+
+                    mediaContents.Add(new VideoInformation(videoInfo, newHandle));
+                }
+                else if (type == MediaContentType.Others)
+                {
+                    mediaContents.Add(new MediaInformation(newHandle));
+                }
+
                 return true;
             };
             MediaContentValidator.ThrowIfError(
index 401c1ab..7ec5a60 100755 (executable)
@@ -172,7 +172,37 @@ namespace Tizen.Content.MediaContent
                 MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone media");
 
-                mediaContents.Add(new MediaInformation(newHandle));
+                MediaContentType type;
+                Interop.MediaInformation.GetMediaType(newHandle, out type);
+                if (type == MediaContentType.Image)
+                {
+                    Interop.ImageInformation.SafeImageInformationHandle imageInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetImage(mediaHandle, out imageInfo), "Failed to get image information");
+
+                    mediaContents.Add(new ImageInformation(imageInfo, newHandle));
+                }
+                else if ((type == MediaContentType.Music) || (type == MediaContentType.Sound))
+                {
+                    Interop.AudioInformation.SafeAudioInformationHandle audioInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetAudio(mediaHandle, out audioInfo), "Failed to get audio information");
+
+                    mediaContents.Add(new AudioInformation(audioInfo, newHandle));
+                }
+                else if (type == MediaContentType.Video)
+                {
+                    Interop.VideoInformation.SafeVideoInformationHandle videoInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetVideo(mediaHandle, out videoInfo), "Failed to get video information");
+
+                    mediaContents.Add(new VideoInformation(videoInfo, newHandle));
+                }
+                else if (type == MediaContentType.Others)
+                {
+                    mediaContents.Add(new MediaInformation(newHandle));
+                }
+
                 return true;
             };
             MediaContentValidator.ThrowIfError(
index 5797558..2d7e164 100755 (executable)
@@ -168,7 +168,37 @@ namespace Tizen.Content.MediaContent
                 MediaContentValidator.ThrowIfError(
                     Interop.MediaInformation.Clone(out newHandle, mediaHandle), "Failed to clone media");
 
-                mediaContents.Add(new MediaInformation(newHandle));
+                MediaContentType type;
+                Interop.MediaInformation.GetMediaType(newHandle, out type);
+                if (type == MediaContentType.Image)
+                {
+                    Interop.ImageInformation.SafeImageInformationHandle imageInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetImage(mediaHandle, out imageInfo), "Failed to get image information");
+
+                    mediaContents.Add(new ImageInformation(imageInfo, newHandle));
+                }
+                else if ((type == MediaContentType.Music) || (type == MediaContentType.Sound))
+                {
+                    Interop.AudioInformation.SafeAudioInformationHandle audioInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetAudio(mediaHandle, out audioInfo), "Failed to get audio information");
+
+                    mediaContents.Add(new AudioInformation(audioInfo, newHandle));
+                }
+                else if (type == MediaContentType.Video)
+                {
+                    Interop.VideoInformation.SafeVideoInformationHandle videoInfo;
+                    MediaContentValidator.ThrowIfError(
+                        Interop.MediaInformation.GetVideo(mediaHandle, out videoInfo), "Failed to get video information");
+
+                    mediaContents.Add(new VideoInformation(videoInfo, newHandle));
+                }
+                else if (type == MediaContentType.Others)
+                {
+                    mediaContents.Add(new MediaInformation(newHandle));
+                }
+
                 return true;
             };