private MLResult InternalAdd(ref MLScreensWatchHistoryEntry entry, Texture2D thumbnailImage)
        {
            if (!entry.IsValid)
            {
                return(MLResult.Create(MLResult.Code.InvalidParam, "Invalid entry parameter"));
            }

            if (thumbnailImage != null && thumbnailImage.format != TextureFormat.RGB24)
            {
                return(MLResult.Create(MLResult.Code.InvalidParam, "Invalid thumbnail parameter format"));
            }

            MLScreensNativeBindings.MLScreensWatchHistoryEntryNative nativeEntry = MLScreensNativeBindings.MLScreensWatchHistoryEntryNative.Create();
            nativeEntry.Data = entry;

            MLImageNativeBindings.MLImageNative thumbnail =
                thumbnailImage == null ? _defaultGrayThumbnailImage : CreateThumbnailImage(thumbnailImage);
            MLResult.Code resultCode =
                MLScreensNativeBindings.MLScreensInsertWatchHistoryEntry(ref nativeEntry, ref thumbnail);

            if (thumbnail.Image != IntPtr.Zero && thumbnail.Image != _defaultGrayThumbnailImage.Image)
            {
                Marshal.FreeHGlobal(thumbnail.Image);
            }

            Marshal.FreeHGlobal(nativeEntry.Title);
            Marshal.FreeHGlobal(nativeEntry.Subtitle);
            Marshal.FreeHGlobal(nativeEntry.CustomData);

            var result = MLResult.Create(resultCode);

            if (result.IsOk)
            {
                entry.Id = nativeEntry.Id;
                _watchHistory.Add(entry.Id, entry);
            }

            return(result);
        }