+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Tizen.Multimedia
-{
- /// <summary>
- /// Range class containing min and max value.
- /// </summary>
- public class Range
- {
- internal Range(int min, int max)
- {
- Min = min;
- Max = max;
- }
-
- /// <summary>
- /// The minimum value of the range.
- /// </summary>
- public int Min
- {
- get;
- private set;
- }
-
- /// <summary>
- /// The maximum value of the range.
- /// </summary>
- public int Max
- {
- get;
- private set;
- }
- }
-}
-
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
namespace Tizen.Multimedia
{
/// <summary>
- /// This class represents a point in 2D space.
+ /// Represents a point in 2D space.
/// </summary>
- public class Point
+ public struct Point
{
- internal Point()
- {
- }
/// <summary>
- /// The constructor of Point class
+ /// Initializes a new instance of the Point with the specified coordinates.
/// </summary>
- /// <param name="x">X-axis coordinate of the point in 2D space</param>
- /// <param name="y">Y-axis coordinate of the point in 2D space</param>
- /// <code>
- ///
- /// </code>
+ /// <param name="x">X-axis coordinate of the point in 2D space.</param>
+ /// <param name="y">Y-axis coordinate of the point in 2D space.</param>
public Point(int x, int y)
{
X = x;
}
/// <summary>
- /// Gets X-axis coordinate of the point in 2D space
+ /// Gets or sets X-axis coordinate of the point in 2D space.
/// </summary>
public int X
{
get;
- internal set;
+ set;
}
/// <summary>
- /// Gets Y-axis coordinate of the point in 2D space
+ /// Gets or sets Y-axis coordinate of the point in 2D space.
/// </summary>
public int Y
{
get;
- internal set;
+ set;
+ }
+
+ public override string ToString() => $"X={X}, Y={Y}";
+
+ public override int GetHashCode()
+ {
+ return new { X, Y }.GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if ((obj is Point) == false)
+ {
+ return false;
+ }
+
+ Point rhs = (Point)obj;
+ return X == rhs.X && Y == rhs.Y;
+ }
+
+ public static bool operator ==(Point lhs, Point rhs)
+ {
+ return lhs.Equals(rhs);
}
- internal new string ToString()
+ public static bool operator !=(Point lhs, Point rhs)
{
- return string.Format("({0}, {1})", X, Y);
+ return !lhs.Equals(rhs);
}
}
}
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Tizen.Multimedia
+{
+ /// <summary>
+ /// Represents a range(min, max) value.
+ /// </summary>
+ public struct Range
+ {
+ /// <summary>
+ /// Initializes a new instance of the Range with the specified values.
+ /// </summary>
+ /// <param name="min">Minimum value of the range.</param>
+ /// <param name="max">Maximum value of the range.</param>
+ public Range(int min, int max)
+ {
+ if (min > max )
+ {
+ throw new ArgumentException($"min can't be greater than max.");
+ }
+ Min = min;
+ Max = max;
+ }
+
+ /// <summary>
+ /// Gets or sets minimum value of the range.
+ /// </summary>
+ public int Min
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Gets or sets maximum value of the range.
+ /// </summary>
+ public int Max
+ {
+ get;
+ set;
+ }
+
+ /// <summary>
+ /// Gets length of the range.
+ /// </summary>
+ public int Length => Max - Min;
+
+ /// <summary>
+ /// Determines if the specified value is inside of the range.
+ /// </summary>
+ /// <param name="value">A value to check.</param>
+ /// <returns>true if the value is inside of the range; otherwise false.</returns>
+ public bool IsInside(int value)
+ {
+ return Min <= value && value <= Max;
+ }
+
+ public override string ToString() => $"Min={Min}, Max={Max}";
+
+ public override int GetHashCode()
+ {
+ return new { Min, Max }.GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if ((obj is Range) == false)
+ {
+ return false;
+ }
+
+ Range rhs = (Range)obj;
+ return Min == rhs.Min && Max == rhs.Max;
+ }
+ }
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Tizen.Multimedia
+{
+ // TODO consider changing it to struct
+ /// <summary>
+ /// This class represents location of the object bounded by rectangle defined by
+ /// coordinates of top left corner, width and height.
+ /// </summary>
+ public class Rectangle
+ {
+ private Point _location;
+ private Size _size;
+
+ /// <summary>
+ /// Initializes a new instance of the Rectangle with default values.
+ /// </summary>
+ public Rectangle() : this(new Point(), new Size())
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the Rectangle with the specified values.
+ /// </summary>
+ /// <param name="x">The x-coordinate of the upper-left corner of the rectangle.</param>
+ /// <param name="y">The y-coordinate of the upper-left corner of the rectangle.</param>
+ /// <param name="width">The Width of the rectangle.</param>
+ /// <param name="height">The Height of the rectangle.</param>
+ public Rectangle(int x, int y, int width, int height) : this(new Point(x, y),
+ new Size(width, height))
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the Rectangle with the specified values.
+ /// </summary>
+ /// <param name="location">A <see cref="Point"/> that represents the upper-left corner of the rectangular region.</param>
+ /// <param name="size">A <see cref="Size"/> that represents the width and height of the rectangular region.</param>
+ public Rectangle(Point location, Size size)
+ {
+ _location = location;
+ _size = size;
+ }
+
+ //TODO rename
+ /// <summary>
+ /// Gets or sets the coordinates of the upper-left corner of the rectangle.
+ /// </summary>
+ public Point Point
+ {
+ get { return _location; }
+ set { _location = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the x-coordinate of the upper-left corner of the rectangle.
+ /// </summary>
+ public int X
+ {
+ get { return Point.X; }
+ set { _location.X = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the y-coordinate of the upper-left corner of the rectangle.
+ /// </summary>
+ public int Y
+ {
+ get { return Point.Y; }
+ set { _location.Y = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the width of the rectangle.
+ /// </summary>
+ public int Width
+ {
+ get { return _size.Width; }
+ set { _size.Width = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the height of the rectangle.
+ /// </summary>
+ public int Height
+ {
+ get { return _size.Height; }
+ set { _size.Height = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the size of the rectangle.
+ /// </summary>
+ public Size Size
+ {
+ get { return _size; }
+ set { _size = value; }
+ }
+
+ public override string ToString() => $"{_location}, {_size}";
+
+
+ public override int GetHashCode()
+ {
+ return new { Point, Size }.GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if ((obj is Rectangle) == false)
+ {
+ return false;
+ }
+
+ Rectangle rhs = (Rectangle)obj;
+ return Point == rhs.Point && Size == rhs.Size;
+ }
+
+ public static bool operator ==(Rectangle lhs, Rectangle rhs)
+ {
+ return lhs.Equals(rhs);
+ }
+
+ public static bool operator !=(Rectangle lhs, Rectangle rhs)
+ {
+ return !lhs.Equals(rhs);
+ }
+ }
+}
{
public struct Size
{
-
+ /// <summary>
+ /// Initializes a new instance of the Size with the specified values.
+ /// </summary>
+ /// <param name="width">Width of the size.</param>
+ /// <param name="height">Height of the size.</param>
public Size(int width, int height)
{
Width = width;
Height = height;
}
+ /// <summary>
+ /// Gets or sets the width of the Size.
+ /// </summary>
public int Width
{
get;
set;
}
+ /// <summary>
+ /// Gets or sets the height of the Size.
+ /// </summary>
public int Height
{
get;
set;
}
- public override string ToString()
+ public override string ToString() => $"Width={ Width }, Height={ Height }";
+
+ public override int GetHashCode()
+ {
+ return new { Width, Height }.GetHashCode();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if ((obj is Size) == false)
+ {
+ return false;
+ }
+
+ Size rhs = (Size)obj;
+ return Width == rhs.Width && Height == rhs.Height;
+ }
+
+ public static bool operator ==(Size lhs, Size rhs)
+ {
+ return lhs.Equals(rhs);
+ }
+
+ public static bool operator !=(Size lhs, Size rhs)
{
- return $"Width : { Width }, Height : { Height }";
+ return !lhs.Equals(rhs);
}
}
}
if (encoder)
{
- int ret = Interop.MediaCodec.SetVideoEncoderInfo(_handle, format.Width,
- format.Height, format.FrameRate, format.BitRate / 1000);
+ int ret = Interop.MediaCodec.SetVideoEncoderInfo(_handle, format.Size.Width,
+ format.Size.Height, format.FrameRate, format.BitRate / 1000);
MultimediaDebug.AssertNoError(ret);
}
else
{
- int ret = Interop.MediaCodec.SetVideoDecoderInfo(_handle, format.Width, format.Height);
+ int ret = Interop.MediaCodec.SetVideoDecoderInfo(_handle, format.Size.Width, format.Size.Height);
MultimediaDebug.AssertNoError(ret);
}
/// </summary>
public sealed class VideoMediaFormat : MediaFormat
{
- private const int DEFAULT_FRAME_RATE = 0;
- private const int DEFAULT_BIT_RATE = 0;
-
+ private const int DefaultFrameRate = 0;
+ private const int DefaultBitRate = 0;
/// <summary>
/// Initializes a new instance of the VideoMediaFormat class with the specified mime type, width and height.
/// <exception cref="System.ArgumentException">mimeType is invalid(i.e. undefined value).</exception>
/// <exception cref="System.ArgumentOutOfRangeException">width, or height is less than zero.</exception>
public VideoMediaFormat(MediaFormatVideoMimeType mimeType, int width, int height)
- : this(mimeType, width, height, DEFAULT_FRAME_RATE)
+ : this(mimeType, width, height, DefaultFrameRate)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the VideoMediaFormat class with the specified mime type, width and height.
+ /// </summary>
+ /// <param name="mimeType">The mime type of the format.</param>
+ /// <param name="size">The size of the format.</param>
+ /// <exception cref="System.ArgumentException">mimeType is invalid(i.e. undefined value).</exception>
+ /// <exception cref="System.ArgumentOutOfRangeException">width, or height is less than zero.</exception>
+ public VideoMediaFormat(MediaFormatVideoMimeType mimeType, Size size)
+ : this(mimeType, size, DefaultFrameRate)
{
}
/// <exception cref="System.ArgumentOutOfRangeException">width, height or frameRate is less than zero.</exception>
public VideoMediaFormat(MediaFormatVideoMimeType mimeType, int width, int height,
int frameRate)
- : this(mimeType, width, height, frameRate, DEFAULT_BIT_RATE)
+ : this(mimeType, width, height, frameRate, DefaultBitRate)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the VideoMediaFormat class with the specified mime type,
+ /// width, height and frame rate.
+ /// </summary>
+ /// <param name="mimeType">The mime type of the format.</param>
+ /// <param name="size">The video size of the format.</param>
+ /// <param name="height">The height value of the format</param>
+ /// <param name="frameRate">The frame rate of the format.</param>
+ /// <exception cref="System.ArgumentException">mimeType is invalid(i.e. undefined value).</exception>
+ /// <exception cref="System.ArgumentOutOfRangeException">width, height or frameRate is less than zero.</exception>
+ public VideoMediaFormat(MediaFormatVideoMimeType mimeType, Size size,
+ int frameRate)
+ : this(mimeType, size, frameRate, DefaultBitRate)
{
}
/// <exception cref="System.ArgumentOutOfRangeException">width, height, frameRate or bitRate is less than zero.</exception>
public VideoMediaFormat(MediaFormatVideoMimeType mimeType, int width, int height,
int frameRate, int bitRate)
+ : this(mimeType, new Size(width, height), frameRate, bitRate)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the VideoMediaFormat class with the specified mime type,
+ /// width, height, frame rate and bit rate.
+ /// </summary>
+ /// <param name="mimeType">The mime type of the format.</param>
+ /// <param name="size">The size of the format.</param>
+ /// <param name="frameRate">The frame rate of the format.</param>
+ /// <param name="bitRate">The bit rate of the format.</param>
+ /// <exception cref="System.ArgumentException">mimeType is invalid(i.e. undefined value).</exception>
+ /// <exception cref="System.ArgumentOutOfRangeException">width, height, frameRate or bitRate is less than zero.</exception>
+ public VideoMediaFormat(MediaFormatVideoMimeType mimeType, Size size,
+ int frameRate, int bitRate)
: base(MediaFormatType.Video)
{
if (!Enum.IsDefined(typeof(MediaFormatVideoMimeType), mimeType))
{
throw new ArgumentException($"Invalid mime type value : { (int)mimeType }");
}
- if (width < 0)
+ if (size.Width < 0)
{
- throw new ArgumentOutOfRangeException("Width value can't be less than zero.");
+ throw new ArgumentOutOfRangeException(nameof(size), size.Width, "Size.Width value can't be less than zero.");
}
- if (height < 0)
+ if (size.Height < 0)
{
- throw new ArgumentOutOfRangeException("Height value can't be less than zero.");
+ throw new ArgumentOutOfRangeException(nameof(size), size.Height, "Size.Height value can't be less than zero.");
}
if (frameRate < 0)
{
- throw new ArgumentOutOfRangeException("Frame rate can't be less than zero.");
+ throw new ArgumentOutOfRangeException(nameof(frameRate), frameRate, "Frame rate can't be less than zero.");
}
if (bitRate < 0)
{
- throw new ArgumentOutOfRangeException("Bit rate value can't be less than zero.");
+ throw new ArgumentOutOfRangeException(nameof(bitRate), bitRate, "Bit rate value can't be less than zero.");
}
MimeType = mimeType;
- Width = width;
- Height = height;
+ Size = size;
FrameRate = frameRate;
BitRate = bitRate;
}
GetFrameRate(handle, out frameRate);
MimeType = mimeType;
- Width = width;
- Height = height;
+ Size = new Size(width, height);
FrameRate = frameRate;
BitRate = bitRate;
}
int ret = Interop.MediaFormat.SetVideoMimeType(handle, (int)MimeType);
MultimediaDebug.AssertNoError(ret);
- ret = Interop.MediaFormat.SetVideoWidth(handle, Width);
+ ret = Interop.MediaFormat.SetVideoWidth(handle, Size.Width);
MultimediaDebug.AssertNoError(ret);
- ret = Interop.MediaFormat.SetVideoHeight(handle, Height);
+ ret = Interop.MediaFormat.SetVideoHeight(handle, Size.Height);
MultimediaDebug.AssertNoError(ret);
ret = Interop.MediaFormat.SetVideoAverageBps(handle, BitRate);
public MediaFormatVideoMimeType MimeType { get; }
/// <summary>
- /// Gets the width value of the current format.
+ /// Gets the size of the current format.
/// </summary>
- public int Width { get; }
-
- /// <summary>
- /// Gets the width value of the current format.
- /// </summary>
- public int Height { get; }
+ public Size Size { get; }
/// <summary>
/// Gets the frame rate value of the current format.
public override string ToString()
{
- return $"MimeType : { MimeType }, Width : { Width }, "
- + $"Height : { Height }, FrameRate : { FrameRate }, BitRate : { BitRate }";
+ return $"MimeType : { MimeType }, Size : ({ Size }), "
+ + $"FrameRate : { FrameRate }, BitRate : { BitRate }";
}
public override bool Equals(object obj)
return false;
}
- return MimeType == rhs.MimeType && Width == rhs.Width && Height == rhs.Height &&
+ return MimeType == rhs.MimeType && Size == rhs.Size &&
FrameRate == rhs.FrameRate && BitRate == rhs.BitRate;
}
public override int GetHashCode()
{
- return new { MimeType, Width, Height, FrameRate, BitRate }.GetHashCode();
+ return new { MimeType, Size, FrameRate, BitRate }.GetHashCode();
}
}
/// Gets the aac type of the current format.
/// </summary>
public MediaFormatAacType AacType { get; }
+
public override string ToString()
{
return $"MimeType : {MimeType }, Channel : { Channel }, SampleRate : { SampleRate }, "
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
/// <param name="config">The configuration of engine will be used for detecting. If NULL, then default settings will be used.</param>
/// <returns>Returns the FaceDetectionResult asynchronously</returns>
/// <code>
- ///
+ ///
/// </code>
public static async Task<FaceDetectionResult> DetectAsync(MediaVisionSource source, FaceEngineConfiguration config = null)
{
for (int i = 0; i < numberOfFaces; i++)
{
Interop.MediaVision.Rectangle location = (Interop.MediaVision.Rectangle)Marshal.PtrToStructure(facesLocations, typeof(Interop.MediaVision.Rectangle));
- Rectangle rect = new Rectangle(new Point(location.x, location.y), location.width, location.height);
+ Rectangle rect = new Rectangle(new Point(location.x, location.y),
+ new Size(location.width, location.height));
Log.Info(MediaVisionLog.Tag, String.Format("Face {0} detected at : ({1}, {2})", i + 1, rect.Point.X, rect.Point.Y));
locations.Add(rect);
facesLocations = IntPtr.Add(facesLocations, sizeof(int) * 4);
+++ /dev/null
-/*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Tizen.Multimedia
-{
- /// <summary>
- /// This class represents location of the object bounded by rectangle defined by
- /// coordinates of top left corner, width and height.
- /// </summary>
- public class Rectangle
- {
- internal Rectangle()
- {
- }
-
- /// <summary>
- /// The constructor of the Rectangle class
- /// </summary>
- /// <param name="point">Top left corner of rectangle coordinates</param>
- /// <param name="width">Width of the bounding rectangle</param>
- /// <param name="height">Height of the bounding rectangle</param>
- /// <code>
- ///
- /// </code>
- public Rectangle(Point point, int width, int height)
- {
- Point = point;
- Width = width;
- Height = height;
- }
-
- /// <summary>
- /// Gets top left corner of rectangle coordinates
- /// </summary>
- public Point Point { get; internal set; }
-
- /// <summary>
- /// Gets width of the bounding rectangle
- /// </summary>
- public int Width { get; internal set; }
-
- /// <summary>
- /// Gets height of the bounding rectangle
- /// </summary>
- public int Height { get; internal set; }
-
- internal new string ToString()
- {
- return string.Format("Point : [{0}, {1}], Width : {2}, Height : {3}", Point.ToString(), Width, Height);
- }
- }
-}
-/*
+/*
* Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the License);
IntPtr[] ptrArray = new IntPtr[value.Count];
for (int i = 0; i < value.Count; i++)
{
- if (value[i] == null)
- {
- throw new ArgumentException("Invalid parameter");
- }
-
Interop.MediaVision.Point point = new Interop.MediaVision.Point()
{
x = value[i].X,