using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using Steamworks.Data;

namespace Steamworks
{
	/// <summary>
	/// Class for utilizing the Steam Video API.
	/// </summary>
	public class SteamVideo : SteamClientClass<SteamVideo>
	{
		internal static ISteamVideo? Internal => Interface as ISteamVideo;

		internal override bool InitializeInterface( bool server )
		{
			SetInterface( server, new ISteamVideo( server ) );
			if ( Interface is null || Interface.Self == IntPtr.Zero ) return false;

			InstallEvents();

			return true;
		}

		internal static void InstallEvents()
		{
		}

		/// <summary>
		/// Return <see langword="true"/> if currently using Steam's live broadcasting
		/// </summary>
		public static bool IsBroadcasting
		{
			get
			{
				int viewers = 0;
				return Internal != null && Internal.IsBroadcasting( ref viewers );
			}
		}

		/// <summary>
		/// Returns the number of viewers that are watching the stream, or <c>0</c> if <see cref="IsBroadcasting"/> is <see langword="false"/>.
		/// </summary>
		public static int NumViewers
		{
			get
			{
				int viewers = 0;

				if ( Internal is null || !Internal.IsBroadcasting( ref viewers ) )
					return 0;

				return viewers;
			}
		}
	}
}
