Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Multimedia.Vision / MediaVision / SurveillanceSource.cs
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 using System;
18 using static Interop.MediaVision.Surveillance;
19
20 namespace Tizen.Multimedia
21 {
22     /// <summary>
23     /// Provides the ability to push source to surveillance engines.
24     /// </summary>
25     /// <seealso cref="MovementDetector"/>
26     /// <seealso cref="PersonAppearanceDetector"/>
27     /// <seealso cref="PersonRecognizer"/>
28     /// <since_tizen> 3</since_tizen>
29     public class SurveillanceSource
30     {
31         private static int _nextStreamId = int.MinValue;
32
33         private static int GetNextStreamId()
34         {
35             if (_nextStreamId == int.MaxValue)
36             {
37                 return _nextStreamId = int.MinValue;
38             }
39             return _nextStreamId++;
40         }
41
42         /// <summary>
43         /// Initializes a new instance of the <see cref="SurveillanceSource"/> class.
44         /// </summary>
45         /// <since_tizen> 3</since_tizen>
46         public SurveillanceSource()
47         {
48             StreamId = GetNextStreamId();
49         }
50
51         /// <summary>
52         /// Pushes source to the surveillance system to detect events.
53         /// </summary>
54         /// <param name="source">The media source used for surveillance.</param>
55         /// <exception cref="ArgumentNullException"><paramref name="source"/> is null.</exception>
56         /// <exception cref="ObjectDisposedException"><paramref name="source"/> has already been disposed of.</exception>
57         /// <exception cref="InvalidOperationException">This <see cref="SurveillanceSource"/> has not been added yet.</exception>
58         /// <seealso cref="MovementDetector.AddSource(SurveillanceSource)"/>
59         /// <seealso cref="MovementDetector.AddSource(SurveillanceSource, MovementDetectionConfiguration)"/>
60         /// <seealso cref="PersonAppearanceDetector.AddSource(SurveillanceSource)"/>
61         /// <seealso cref="PersonAppearanceDetector.AddSource(SurveillanceSource, PersonAppearanceDetectionConfiguration)"/>
62         /// <seealso cref="PersonRecognizer.AddSource(SurveillanceSource, PersonRecognitionConfiguration)"/>
63         /// <since_tizen> 3</since_tizen>
64         public void Push(MediaVisionSource source)
65         {
66             if (source == null)
67             {
68                 throw new ArgumentNullException(nameof(source));
69             }
70
71             PushSource(source.Handle, StreamId).Validate("Failed to push source");
72         }
73
74         internal int StreamId { get; }
75     }
76 }