forked from FoxCouncil/Steamworks.Core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SteamVideo.cs
74 lines (55 loc) · 1.97 KB
/
SteamVideo.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// !! // Steamworks.Core - SteamVideo.cs
// *.-". // Created: 2016-10-22 [10:02 PM]
// | | // Copyright 2016 // MIT License // The Fox Council
// Modified by: Fox Diller on 2016-10-22 @ 10:12 PM
#region Usings
using System;
using System.Runtime.InteropServices;
#endregion
namespace Steamworks.Core
{
public class SteamVideo : ISteamVideo
{
private readonly IntPtr m_instancePtr;
public SteamVideo(IntPtr c_instancePtr)
{
m_instancePtr = c_instancePtr;
}
private void CheckIfUsable()
{
if (m_instancePtr == IntPtr.Zero)
{
throw new InvalidOperationException("Steam Video Not Initialized!");
}
}
#region Native Methods
[DllImport("Steam_api", EntryPoint = "SteamAPI_ISteamVideo_GetVideoURL")]
private static extern void SteamAPI_ISteamVideo_GetVideoURL(IntPtr c_instancePtr, uint c_unVideoAppId);
[DllImport("Steam_api", EntryPoint = "SteamAPI_ISteamVideo_IsBroadcasting")]
private static extern bool SteamAPI_ISteamVideo_IsBroadcasting(IntPtr c_instancePtr, ref int c_pnNumViewers);
#endregion
#region Overrides of ISteamVideo
public override IntPtr GetIntPtr()
{
return m_instancePtr;
}
public override void GetVideoUrl(uint c_unVideoAppId)
{
CheckIfUsable();
SteamAPI_ISteamVideo_GetVideoURL(m_instancePtr, c_unVideoAppId);
}
public override bool IsBroadcasting(ref int c_pnNumViewers)
{
CheckIfUsable();
var a_result = SteamAPI_ISteamVideo_IsBroadcasting(m_instancePtr, ref c_pnNumViewers);
return a_result;
}
#endregion
}
public abstract class ISteamVideo
{
public abstract IntPtr GetIntPtr();
public abstract void GetVideoUrl(uint c_unVideoAppId);
public abstract bool IsBroadcasting(ref int c_pnNumViewers);
}
}