// RRCM.idl : IDL source for rrcm.dll
//

// This file will be processed by the MIDL tool to
// produce the type library (mp.tlb) and marshalling code.

import "oaidl.idl";
import "ocidl.idl";

cpp_quote("//")
cpp_quote("//	The following declarations within the 'if 0' block are dummy typedefs used to make")
cpp_quote("//	the idl file build.  The actual definitions are contained in WINSOCK2.H")
cpp_quote("//")
cpp_quote("#if 0")

#ifndef WSAOVERLAPPED
typedef struct _OVERLAPPED {
    DWORD   Internal;
    DWORD   InternalHigh;
    DWORD   Offset;
    DWORD   OffsetHigh;
    HANDLE  hEvent;
} WSAOVERLAPPED, *LPWSAOVERLAPPED;
#endif

typedef
void
(__stdcall * LPWSAOVERLAPPED_COMPLETION_ROUTINE)(
    DWORD dwError,
    DWORD cbTransferred,
    WSAOVERLAPPED *lpOverlapped,
    DWORD dwFlags
    );

typedef struct _WSABUF {
    ULONG      len;     /* the length of the buffer */
    char *  buf;     /* the pointer to the buffer */
} WSABUF, * LPWSABUF;

// from qos.h
typedef ULONG SERVICETYPE;
typedef struct _flowspec
{
    ULONG       TokenRate;              /* In Bytes/sec */
    ULONG       TokenBucketSize;        /* In Bytes */
    ULONG       PeakBandwidth;          /* In Bytes/sec */
    ULONG       Latency;                /* In microseconds */
    ULONG       DelayVariation;         /* In microseconds */
    SERVICETYPE ServiceType;
    ULONG       MaxSduSize;             /* In Bytes */
    ULONG       MinimumPolicedSize;     /* In Bytes */

} FLOWSPEC, *PFLOWSPEC, * LPFLOWSPEC;

cpp_quote ("#endif")

typedef struct {
	UINT ssrc;			// RTP stream source id
	UINT payload;		// RTP payload
	UINT packetsSent;	// num packets sent by source
	UINT packetsDelivered;	// num packets that reached receiver
	UINT packetsLost;	// num packets that receiver knows it dropped
	UINT jitter;		// inter-packet jitter
	UINT packetErrors;	// local Winsock errors
	UINT bytesSent;		// num bytes sent by source
	UINT bytesDelivered;	// num bytest that reached (valid only in recv side)
} RTP_STATS;

typedef BOOL (* PRTPRECVCALLBACK)(HANDLE_PTR dwCallback, WSABUF *pNetBuf);
interface IRTPRecv;


	[
	
		uuid(26FCF000-61D1-11D1-AA66-00C04FC9B202),
		local,
		helpstring("IRTPControl Interface"),
		pointer_default(unique)
	]
	interface IRTPSession : IUnknown
	{
		HRESULT SetLocalAddress([in] BYTE *sockaddr, [in]UINT addrlen);
		HRESULT GetLocalAddress([out] const BYTE **sockaddr, [out] UINT *paddrlen);
		HRESULT SetRemoteRTPAddress([in] BYTE *rtpaddr, [in] UINT addrlen);
		HRESULT SetRemoteRTCPAddress([in] BYTE *rtcpaddr, [in] UINT addrlen);
		HRESULT GetRemoteRTPAddress([out] const BYTE **sockaddr, [out] UINT *paddrlen);
		HRESULT GetRemoteRTCPAddress([out] const BYTE **sockaddr, [out] UINT *paddrlen);
		HRESULT SetSendFlowspec([in] FLOWSPEC *pFlowspec);
		HRESULT SetRecvFlowspec([in] FLOWSPEC *pFlowspec);
		HRESULT CreateRecvRTPStream([in]DWORD ssrc, [out] IRTPRecv **ppIRTPRecv);
	};

	[
	
		uuid(44F9B073-641C-11D1-AA67-00C04FC9B202),
		local,
		helpstring("IRTPSend Interface"),
		pointer_default(unique)
	]
	interface IRTPSend : IUnknown
	{
		HRESULT Send(WSABUF *pWsabufs,UINT nWsabufs,WSAOVERLAPPED *pOverlapped,LPWSAOVERLAPPED_COMPLETION_ROUTINE pWSAPC );
		HRESULT GetSendStats([out] RTP_STATS *pRTPStats);

	};
	
	[
		uuid(fcedc784-afdc-11d1-aa91-00c04fc9b202),
		local,
		helpstring("IRTPRecvSink Interface"),
		pointer_default(unique)
	
	]
	interface IRTPRecvSink : IUnknown
	{
		BOOL ReceivePacket(WSABUF *pPacket);
	};
	
	[
		uuid(76c7f79c-afdc-11d1-aa91-00c04fc9b202),
		local,
		helpstring("IRTPRecv Interface"),
		pointer_default(unique)
	
	]
	interface IRTPRecv : IUnknown
	{
		HRESULT SetRecvNotification([in] PRTPRECVCALLBACK pIRTPRecvSink, [in] HANDLE_PTR dwCB, [in] UINT nBufs);
		HRESULT CancelRecvNotification();
		HRESULT FreePacket([in] WSABUF *pPacket);
		HRESULT GetRecvStats([out] RTP_STATS *pRTPStats);
	};
/*	
	[
	uuid(2fe04e9c-8917-11d1-aa78-00c04fc9b202),
	version(1.0)
	]
	interface IRTPSink: IUnknown
	{
		HRESULT AddSession(IRTPSession *pSess);
		HRESULT RemoveSession(IRTPSession *pSess);
		HRESULT SetMediaStream(IRTPMediaStream *pStream);
	};
*/

/* OpenSession flags */		
enum {
	SESSIONF_RECV	= 0x1,
	SESSIONF_SEND	= 0x2,
	SESSIONF_MULTICAST = 0x4,
	SESSIONF_AUDIO	= 0x8,
	SESSIONF_VIDEO	= 0x10,
	SESSIONF_EXISTING = 0x80
	};

	[
	
		uuid(06CE0C39-8917-11D1-AA78-00C04FC9B202),
	
		helpstring("IRTP Interface"),
		pointer_default(unique)
	]
	interface IRTP : IUnknown
	{
		HRESULT OpenSession([in] UINT sessionId, [in] DWORD dwFlags, [in] BYTE *localaddr, [in]UINT addrlen, [out] IRTPSession **ppIRTPSession);
		//HRESULT CreateSink([out] IRTPSink **ppIRTPSink);
	};



[
	uuid(3C90D0D2-5F80-11D1-AA64-00C04FC9B202),
	version(1.0),
	helpstring("RRCM 1.0 Type Library")
]
library RRCMLib
{
	importlib("stdole2.tlb");


	[
		uuid(06CE0C3A-8917-11D1-AA78-00C04FC9B202),
		helpstring("RTP Class")
	]
	coclass RTP
	{
		[default] interface IRTP;
	};

};
