IPCamAppBar/IPCamLib/ICamera.cs

39 lines
1.4 KiB
C#

using System.Drawing;
using System.Threading;
using System.Threading.Tasks;
namespace IPCamLib
{
/// <summary>
/// Receives frames from an ICamera.
/// </summary>
public interface ICameraObserver
{
/// <summary>
/// Called when a frame has been decoded from an ICamera.
/// </summary>
/// <param name="image">The decoded image.</param>
Task OnFrame(Image image);
}
/// <summary>
/// Abstracts an IP camera stream.
/// </summary>
public interface ICamera
{
/// <summary>
/// Starts receiving frames.
/// </summary>
/// <remarks>
/// The implementation should continue receiving frames until it is disconnected (if streaming),
/// a request fails (if polling) or the cancellationToken is cancelled. Reconnecting is done by
/// the caller which will call Fetch again. Do not keep connection-specific state between calls to Fetch.
/// Running on a separate thread is also handled by the caller, the returning Task should not complete until disconnected.
/// </remarks>
/// <param name="observer">The observer implementation to receive frames.</param>
/// <param name="cancellationToken">A CancellationToken which will stop the camera stream when cancelled.</param>
Task Fetch(ICameraObserver observer, CancellationToken cancellationToken);
}
}