1*d9f75844SAndroid Build Coastguard WorkerThis directory contains an example Unity native plugin for Windows OS and Android. 2*d9f75844SAndroid Build Coastguard Worker 3*d9f75844SAndroid Build Coastguard WorkerThe APIs use Platform Invoke (P/Invoke) technology as required by Unity native plugin. 4*d9f75844SAndroid Build Coastguard WorkerThis plugin dll can also be used by Windows C# applications other than Unity. 5*d9f75844SAndroid Build Coastguard Worker 6*d9f75844SAndroid Build Coastguard WorkerFor detailed build instruction on Android, see ANDROID_INSTRUCTION 7*d9f75844SAndroid Build Coastguard Worker 8*d9f75844SAndroid Build Coastguard WorkerAn example of wrapping native plugin into a C# managed class in Unity is given as following: 9*d9f75844SAndroid Build Coastguard Worker 10*d9f75844SAndroid Build Coastguard Workerusing System; 11*d9f75844SAndroid Build Coastguard Workerusing System.Collections.Generic; 12*d9f75844SAndroid Build Coastguard Workerusing System.Runtime.InteropServices; 13*d9f75844SAndroid Build Coastguard Worker 14*d9f75844SAndroid Build Coastguard Workernamespace SimplePeerConnectionM { 15*d9f75844SAndroid Build Coastguard Worker // A class for ice candidate. 16*d9f75844SAndroid Build Coastguard Worker public class IceCandidate { 17*d9f75844SAndroid Build Coastguard Worker public IceCandidate(string candidate, int sdpMlineIndex, string sdpMid) { 18*d9f75844SAndroid Build Coastguard Worker mCandidate = candidate; 19*d9f75844SAndroid Build Coastguard Worker mSdpMlineIndex = sdpMlineIndex; 20*d9f75844SAndroid Build Coastguard Worker mSdpMid = sdpMid; 21*d9f75844SAndroid Build Coastguard Worker } 22*d9f75844SAndroid Build Coastguard Worker string mCandidate; 23*d9f75844SAndroid Build Coastguard Worker int mSdpMlineIndex; 24*d9f75844SAndroid Build Coastguard Worker string mSdpMid; 25*d9f75844SAndroid Build Coastguard Worker 26*d9f75844SAndroid Build Coastguard Worker public string Candidate { 27*d9f75844SAndroid Build Coastguard Worker get { return mCandidate; } 28*d9f75844SAndroid Build Coastguard Worker set { mCandidate = value; } 29*d9f75844SAndroid Build Coastguard Worker } 30*d9f75844SAndroid Build Coastguard Worker 31*d9f75844SAndroid Build Coastguard Worker public int SdpMlineIndex { 32*d9f75844SAndroid Build Coastguard Worker get { return mSdpMlineIndex; } 33*d9f75844SAndroid Build Coastguard Worker set { mSdpMlineIndex = value; } 34*d9f75844SAndroid Build Coastguard Worker } 35*d9f75844SAndroid Build Coastguard Worker 36*d9f75844SAndroid Build Coastguard Worker public string SdpMid { 37*d9f75844SAndroid Build Coastguard Worker get { return mSdpMid; } 38*d9f75844SAndroid Build Coastguard Worker set { mSdpMid = value; } 39*d9f75844SAndroid Build Coastguard Worker } 40*d9f75844SAndroid Build Coastguard Worker } 41*d9f75844SAndroid Build Coastguard Worker 42*d9f75844SAndroid Build Coastguard Worker // A managed wrapper up class for the native c style peer connection APIs. 43*d9f75844SAndroid Build Coastguard Worker public class PeerConnectionM { 44*d9f75844SAndroid Build Coastguard Worker private const string dllPath = "webrtc_unity_plugin"; 45*d9f75844SAndroid Build Coastguard Worker 46*d9f75844SAndroid Build Coastguard Worker //create a peerconnection with turn servers 47*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 48*d9f75844SAndroid Build Coastguard Worker private static extern int CreatePeerConnection(string[] turnUrls, int noOfUrls, 49*d9f75844SAndroid Build Coastguard Worker string username, string credential); 50*d9f75844SAndroid Build Coastguard Worker 51*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 52*d9f75844SAndroid Build Coastguard Worker private static extern bool ClosePeerConnection(int peerConnectionId); 53*d9f75844SAndroid Build Coastguard Worker 54*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 55*d9f75844SAndroid Build Coastguard Worker private static extern bool AddStream(int peerConnectionId, bool audioOnly); 56*d9f75844SAndroid Build Coastguard Worker 57*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 58*d9f75844SAndroid Build Coastguard Worker private static extern bool AddDataChannel(int peerConnectionId); 59*d9f75844SAndroid Build Coastguard Worker 60*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 61*d9f75844SAndroid Build Coastguard Worker private static extern bool CreateOffer(int peerConnectionId); 62*d9f75844SAndroid Build Coastguard Worker 63*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 64*d9f75844SAndroid Build Coastguard Worker private static extern bool CreateAnswer(int peerConnectionId); 65*d9f75844SAndroid Build Coastguard Worker 66*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 67*d9f75844SAndroid Build Coastguard Worker private static extern bool SendDataViaDataChannel(int peerConnectionId, string data); 68*d9f75844SAndroid Build Coastguard Worker 69*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 70*d9f75844SAndroid Build Coastguard Worker private static extern bool SetAudioControl(int peerConnectionId, bool isMute, bool isRecord); 71*d9f75844SAndroid Build Coastguard Worker 72*d9f75844SAndroid Build Coastguard Worker [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 73*d9f75844SAndroid Build Coastguard Worker private delegate void LocalDataChannelReadyInternalDelegate(); 74*d9f75844SAndroid Build Coastguard Worker public delegate void LocalDataChannelReadyDelegate(int id); 75*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 76*d9f75844SAndroid Build Coastguard Worker private static extern bool RegisterOnLocalDataChannelReady( 77*d9f75844SAndroid Build Coastguard Worker int peerConnectionId, LocalDataChannelReadyInternalDelegate callback); 78*d9f75844SAndroid Build Coastguard Worker 79*d9f75844SAndroid Build Coastguard Worker [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 80*d9f75844SAndroid Build Coastguard Worker private delegate void DataFromDataChannelReadyInternalDelegate(string s); 81*d9f75844SAndroid Build Coastguard Worker public delegate void DataFromDataChannelReadyDelegate(int id, string s); 82*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 83*d9f75844SAndroid Build Coastguard Worker private static extern bool RegisterOnDataFromDataChannelReady( 84*d9f75844SAndroid Build Coastguard Worker int peerConnectionId, DataFromDataChannelReadyInternalDelegate callback); 85*d9f75844SAndroid Build Coastguard Worker 86*d9f75844SAndroid Build Coastguard Worker [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 87*d9f75844SAndroid Build Coastguard Worker private delegate void FailureMessageInternalDelegate(string msg); 88*d9f75844SAndroid Build Coastguard Worker public delegate void FailureMessageDelegate(int id, string msg); 89*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 90*d9f75844SAndroid Build Coastguard Worker private static extern bool RegisterOnFailure(int peerConnectionId, 91*d9f75844SAndroid Build Coastguard Worker FailureMessageInternalDelegate callback); 92*d9f75844SAndroid Build Coastguard Worker 93*d9f75844SAndroid Build Coastguard Worker [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 94*d9f75844SAndroid Build Coastguard Worker private delegate void AudioBusReadyInternalDelegate(IntPtr data, int bitsPerSample, 95*d9f75844SAndroid Build Coastguard Worker int sampleRate, int numberOfChannels, int numberOfFrames); 96*d9f75844SAndroid Build Coastguard Worker public delegate void AudioBusReadyDelegate(int id, IntPtr data, int bitsPerSample, 97*d9f75844SAndroid Build Coastguard Worker int sampleRate, int numberOfChannels, int numberOfFrames); 98*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 99*d9f75844SAndroid Build Coastguard Worker private static extern bool RegisterOnAudioBusReady(int peerConnectionId, 100*d9f75844SAndroid Build Coastguard Worker AudioBusReadyInternalDelegate callback); 101*d9f75844SAndroid Build Coastguard Worker 102*d9f75844SAndroid Build Coastguard Worker // Video callbacks. 103*d9f75844SAndroid Build Coastguard Worker [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 104*d9f75844SAndroid Build Coastguard Worker private delegate void I420FrameReadyInternalDelegate( 105*d9f75844SAndroid Build Coastguard Worker IntPtr dataY, IntPtr dataU, IntPtr dataV, 106*d9f75844SAndroid Build Coastguard Worker int strideY, int strideU, int strideV, 107*d9f75844SAndroid Build Coastguard Worker uint width, uint height); 108*d9f75844SAndroid Build Coastguard Worker public delegate void I420FrameReadyDelegate(int id, 109*d9f75844SAndroid Build Coastguard Worker IntPtr dataY, IntPtr dataU, IntPtr dataV, 110*d9f75844SAndroid Build Coastguard Worker int strideY, int strideU, int strideV, 111*d9f75844SAndroid Build Coastguard Worker uint width, uint height); 112*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 113*d9f75844SAndroid Build Coastguard Worker private static extern bool RegisterOnLocalI420FrameReady(int peerConnectionId, 114*d9f75844SAndroid Build Coastguard Worker I420FrameReadyInternalDelegate callback); 115*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 116*d9f75844SAndroid Build Coastguard Worker private static extern bool RegisterOnRemoteI420FrameReady(int peerConnectionId, 117*d9f75844SAndroid Build Coastguard Worker I420FrameReadyInternalDelegate callback); 118*d9f75844SAndroid Build Coastguard Worker 119*d9f75844SAndroid Build Coastguard Worker [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 120*d9f75844SAndroid Build Coastguard Worker private delegate void LocalSdpReadytoSendInternalDelegate(string type, string sdp); 121*d9f75844SAndroid Build Coastguard Worker public delegate void LocalSdpReadytoSendDelegate(int id, string type, string sdp); 122*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 123*d9f75844SAndroid Build Coastguard Worker private static extern bool RegisterOnLocalSdpReadytoSend(int peerConnectionId, 124*d9f75844SAndroid Build Coastguard Worker LocalSdpReadytoSendInternalDelegate callback); 125*d9f75844SAndroid Build Coastguard Worker 126*d9f75844SAndroid Build Coastguard Worker [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 127*d9f75844SAndroid Build Coastguard Worker private delegate void IceCandidateReadytoSendInternalDelegate( 128*d9f75844SAndroid Build Coastguard Worker string candidate, int sdpMlineIndex, string sdpMid); 129*d9f75844SAndroid Build Coastguard Worker public delegate void IceCandidateReadytoSendDelegate( 130*d9f75844SAndroid Build Coastguard Worker int id, string candidate, int sdpMlineIndex, string sdpMid); 131*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 132*d9f75844SAndroid Build Coastguard Worker private static extern bool RegisterOnIceCandidateReadytoSend( 133*d9f75844SAndroid Build Coastguard Worker int peerConnectionId, IceCandidateReadytoSendInternalDelegate callback); 134*d9f75844SAndroid Build Coastguard Worker 135*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 136*d9f75844SAndroid Build Coastguard Worker private static extern bool SetRemoteDescription(int peerConnectionId, string type, string sdp); 137*d9f75844SAndroid Build Coastguard Worker 138*d9f75844SAndroid Build Coastguard Worker [DllImport(dllPath, CallingConvention = CallingConvention.Cdecl)] 139*d9f75844SAndroid Build Coastguard Worker private static extern bool AddIceCandidate(int peerConnectionId, string sdp, 140*d9f75844SAndroid Build Coastguard Worker int sdpMlineindex, string sdpMid); 141*d9f75844SAndroid Build Coastguard Worker 142*d9f75844SAndroid Build Coastguard Worker public PeerConnectionM(List<string> turnUrls, string username, string credential) { 143*d9f75844SAndroid Build Coastguard Worker string[] urls = turnUrls != null ? turnUrls.ToArray() : null; 144*d9f75844SAndroid Build Coastguard Worker int length = turnUrls != null ? turnUrls.Count : 0; 145*d9f75844SAndroid Build Coastguard Worker mPeerConnectionId = CreatePeerConnection(urls, length, username, credential); 146*d9f75844SAndroid Build Coastguard Worker RegisterCallbacks(); 147*d9f75844SAndroid Build Coastguard Worker } 148*d9f75844SAndroid Build Coastguard Worker 149*d9f75844SAndroid Build Coastguard Worker public void ClosePeerConnection() { 150*d9f75844SAndroid Build Coastguard Worker ClosePeerConnection(mPeerConnectionId); 151*d9f75844SAndroid Build Coastguard Worker mPeerConnectionId = -1; 152*d9f75844SAndroid Build Coastguard Worker } 153*d9f75844SAndroid Build Coastguard Worker 154*d9f75844SAndroid Build Coastguard Worker // Return -1 if Peerconnection is not available. 155*d9f75844SAndroid Build Coastguard Worker public int GetUniqueId() { 156*d9f75844SAndroid Build Coastguard Worker return mPeerConnectionId; 157*d9f75844SAndroid Build Coastguard Worker } 158*d9f75844SAndroid Build Coastguard Worker 159*d9f75844SAndroid Build Coastguard Worker public void AddStream(bool audioOnly) { 160*d9f75844SAndroid Build Coastguard Worker AddStream(mPeerConnectionId, audioOnly); 161*d9f75844SAndroid Build Coastguard Worker } 162*d9f75844SAndroid Build Coastguard Worker 163*d9f75844SAndroid Build Coastguard Worker public void AddDataChannel() { 164*d9f75844SAndroid Build Coastguard Worker AddDataChannel(mPeerConnectionId); 165*d9f75844SAndroid Build Coastguard Worker } 166*d9f75844SAndroid Build Coastguard Worker 167*d9f75844SAndroid Build Coastguard Worker public void CreateOffer() { 168*d9f75844SAndroid Build Coastguard Worker CreateOffer(mPeerConnectionId); 169*d9f75844SAndroid Build Coastguard Worker } 170*d9f75844SAndroid Build Coastguard Worker 171*d9f75844SAndroid Build Coastguard Worker public void CreateAnswer() { 172*d9f75844SAndroid Build Coastguard Worker CreateAnswer(mPeerConnectionId); 173*d9f75844SAndroid Build Coastguard Worker } 174*d9f75844SAndroid Build Coastguard Worker 175*d9f75844SAndroid Build Coastguard Worker public void SendDataViaDataChannel(string data) { 176*d9f75844SAndroid Build Coastguard Worker SendDataViaDataChannel(mPeerConnectionId, data); 177*d9f75844SAndroid Build Coastguard Worker } 178*d9f75844SAndroid Build Coastguard Worker 179*d9f75844SAndroid Build Coastguard Worker public void SetAudioControl(bool isMute, bool isRecord) { 180*d9f75844SAndroid Build Coastguard Worker SetAudioControl(mPeerConnectionId, isMute, isRecord); 181*d9f75844SAndroid Build Coastguard Worker } 182*d9f75844SAndroid Build Coastguard Worker 183*d9f75844SAndroid Build Coastguard Worker public void SetRemoteDescription(string type, string sdp) { 184*d9f75844SAndroid Build Coastguard Worker SetRemoteDescription(mPeerConnectionId, type, sdp); 185*d9f75844SAndroid Build Coastguard Worker } 186*d9f75844SAndroid Build Coastguard Worker 187*d9f75844SAndroid Build Coastguard Worker public void AddIceCandidate(string candidate, int sdpMlineindex, string sdpMid) { 188*d9f75844SAndroid Build Coastguard Worker AddIceCandidate(mPeerConnectionId, candidate, sdpMlineindex, sdpMid); 189*d9f75844SAndroid Build Coastguard Worker } 190*d9f75844SAndroid Build Coastguard Worker 191*d9f75844SAndroid Build Coastguard Worker private void RegisterCallbacks() { 192*d9f75844SAndroid Build Coastguard Worker localDataChannelReadyDelegate = new LocalDataChannelReadyInternalDelegate( 193*d9f75844SAndroid Build Coastguard Worker RaiseLocalDataChannelReady); 194*d9f75844SAndroid Build Coastguard Worker RegisterOnLocalDataChannelReady(mPeerConnectionId, localDataChannelReadyDelegate); 195*d9f75844SAndroid Build Coastguard Worker 196*d9f75844SAndroid Build Coastguard Worker dataFromDataChannelReadyDelegate = new DataFromDataChannelReadyInternalDelegate( 197*d9f75844SAndroid Build Coastguard Worker RaiseDataFromDataChannelReady); 198*d9f75844SAndroid Build Coastguard Worker RegisterOnDataFromDataChannelReady(mPeerConnectionId, dataFromDataChannelReadyDelegate); 199*d9f75844SAndroid Build Coastguard Worker 200*d9f75844SAndroid Build Coastguard Worker failureMessageDelegate = new FailureMessageInternalDelegate(RaiseFailureMessage); 201*d9f75844SAndroid Build Coastguard Worker RegisterOnFailure(mPeerConnectionId, failureMessageDelegate); 202*d9f75844SAndroid Build Coastguard Worker 203*d9f75844SAndroid Build Coastguard Worker audioBusReadyDelegate = new AudioBusReadyInternalDelegate(RaiseAudioBusReady); 204*d9f75844SAndroid Build Coastguard Worker RegisterOnAudioBusReady(mPeerConnectionId, audioBusReadyDelegate); 205*d9f75844SAndroid Build Coastguard Worker 206*d9f75844SAndroid Build Coastguard Worker localI420FrameReadyDelegate = new I420FrameReadyInternalDelegate( 207*d9f75844SAndroid Build Coastguard Worker RaiseLocalVideoFrameReady); 208*d9f75844SAndroid Build Coastguard Worker RegisterOnLocalI420FrameReady(mPeerConnectionId, localI420FrameReadyDelegate); 209*d9f75844SAndroid Build Coastguard Worker 210*d9f75844SAndroid Build Coastguard Worker remoteI420FrameReadyDelegate = new I420FrameReadyInternalDelegate( 211*d9f75844SAndroid Build Coastguard Worker RaiseRemoteVideoFrameReady); 212*d9f75844SAndroid Build Coastguard Worker RegisterOnRemoteI420FrameReady(mPeerConnectionId, remoteI420FrameReadyDelegate); 213*d9f75844SAndroid Build Coastguard Worker 214*d9f75844SAndroid Build Coastguard Worker localSdpReadytoSendDelegate = new LocalSdpReadytoSendInternalDelegate( 215*d9f75844SAndroid Build Coastguard Worker RaiseLocalSdpReadytoSend); 216*d9f75844SAndroid Build Coastguard Worker RegisterOnLocalSdpReadytoSend(mPeerConnectionId, localSdpReadytoSendDelegate); 217*d9f75844SAndroid Build Coastguard Worker 218*d9f75844SAndroid Build Coastguard Worker iceCandidateReadytoSendDelegate = 219*d9f75844SAndroid Build Coastguard Worker new IceCandidateReadytoSendInternalDelegate(RaiseIceCandidateReadytoSend); 220*d9f75844SAndroid Build Coastguard Worker RegisterOnIceCandidateReadytoSend( 221*d9f75844SAndroid Build Coastguard Worker mPeerConnectionId, iceCandidateReadytoSendDelegate); 222*d9f75844SAndroid Build Coastguard Worker } 223*d9f75844SAndroid Build Coastguard Worker 224*d9f75844SAndroid Build Coastguard Worker private void RaiseLocalDataChannelReady() { 225*d9f75844SAndroid Build Coastguard Worker if (OnLocalDataChannelReady != null) 226*d9f75844SAndroid Build Coastguard Worker OnLocalDataChannelReady(mPeerConnectionId); 227*d9f75844SAndroid Build Coastguard Worker } 228*d9f75844SAndroid Build Coastguard Worker 229*d9f75844SAndroid Build Coastguard Worker private void RaiseDataFromDataChannelReady(string data) { 230*d9f75844SAndroid Build Coastguard Worker if (OnDataFromDataChannelReady != null) 231*d9f75844SAndroid Build Coastguard Worker OnDataFromDataChannelReady(mPeerConnectionId, data); 232*d9f75844SAndroid Build Coastguard Worker } 233*d9f75844SAndroid Build Coastguard Worker 234*d9f75844SAndroid Build Coastguard Worker private void RaiseFailureMessage(string msg) { 235*d9f75844SAndroid Build Coastguard Worker if (OnFailureMessage != null) 236*d9f75844SAndroid Build Coastguard Worker OnFailureMessage(mPeerConnectionId, msg); 237*d9f75844SAndroid Build Coastguard Worker } 238*d9f75844SAndroid Build Coastguard Worker 239*d9f75844SAndroid Build Coastguard Worker private void RaiseAudioBusReady(IntPtr data, int bitsPerSample, 240*d9f75844SAndroid Build Coastguard Worker int sampleRate, int numberOfChannels, int numberOfFrames) { 241*d9f75844SAndroid Build Coastguard Worker if (OnAudioBusReady != null) 242*d9f75844SAndroid Build Coastguard Worker OnAudioBusReady(mPeerConnectionId, data, bitsPerSample, sampleRate, 243*d9f75844SAndroid Build Coastguard Worker numberOfChannels, numberOfFrames); 244*d9f75844SAndroid Build Coastguard Worker } 245*d9f75844SAndroid Build Coastguard Worker 246*d9f75844SAndroid Build Coastguard Worker private void RaiseLocalVideoFrameReady( 247*d9f75844SAndroid Build Coastguard Worker IntPtr dataY, IntPtr dataU, IntPtr dataV, 248*d9f75844SAndroid Build Coastguard Worker int strideY, int strideU, int strideV, 249*d9f75844SAndroid Build Coastguard Worker uint width, uint height) { 250*d9f75844SAndroid Build Coastguard Worker if (OnLocalVideoFrameReady != null) 251*d9f75844SAndroid Build Coastguard Worker OnLocalVideoFrameReady(mPeerConnectionId, dataY, dataU, dataV, strideY, strideU, strideV, 252*d9f75844SAndroid Build Coastguard Worker width, height); 253*d9f75844SAndroid Build Coastguard Worker } 254*d9f75844SAndroid Build Coastguard Worker 255*d9f75844SAndroid Build Coastguard Worker private void RaiseRemoteVideoFrameReady( 256*d9f75844SAndroid Build Coastguard Worker IntPtr dataY, IntPtr dataU, IntPtr dataV, 257*d9f75844SAndroid Build Coastguard Worker int strideY, int strideU, int strideV, 258*d9f75844SAndroid Build Coastguard Worker uint width, uint height) { 259*d9f75844SAndroid Build Coastguard Worker if (OnRemoteVideoFrameReady != null) 260*d9f75844SAndroid Build Coastguard Worker OnRemoteVideoFrameReady(mPeerConnectionId, dataY, dataU, dataV, strideY, strideU, strideV, 261*d9f75844SAndroid Build Coastguard Worker width, height); 262*d9f75844SAndroid Build Coastguard Worker } 263*d9f75844SAndroid Build Coastguard Worker 264*d9f75844SAndroid Build Coastguard Worker 265*d9f75844SAndroid Build Coastguard Worker private void RaiseLocalSdpReadytoSend(string type, string sdp) { 266*d9f75844SAndroid Build Coastguard Worker if (OnLocalSdpReadytoSend != null) 267*d9f75844SAndroid Build Coastguard Worker OnLocalSdpReadytoSend(mPeerConnectionId, type, sdp); 268*d9f75844SAndroid Build Coastguard Worker } 269*d9f75844SAndroid Build Coastguard Worker 270*d9f75844SAndroid Build Coastguard Worker private void RaiseIceCandidateReadytoSend(string candidate, int sdpMlineIndex, string sdpMid) { 271*d9f75844SAndroid Build Coastguard Worker if (OnIceCandidateReadytoSend != null) 272*d9f75844SAndroid Build Coastguard Worker OnIceCandidateReadytoSend(mPeerConnectionId, candidate, sdpMlineIndex, sdpMid); 273*d9f75844SAndroid Build Coastguard Worker } 274*d9f75844SAndroid Build Coastguard Worker 275*d9f75844SAndroid Build Coastguard Worker public void AddQueuedIceCandidate(List<IceCandidate> iceCandidateQueue) { 276*d9f75844SAndroid Build Coastguard Worker if (iceCandidateQueue != null) { 277*d9f75844SAndroid Build Coastguard Worker foreach (IceCandidate ic in iceCandidateQueue) { 278*d9f75844SAndroid Build Coastguard Worker AddIceCandidate(mPeerConnectionId, ic.Candidate, ic.SdpMlineIndex, ic.SdpMid); 279*d9f75844SAndroid Build Coastguard Worker } 280*d9f75844SAndroid Build Coastguard Worker } 281*d9f75844SAndroid Build Coastguard Worker } 282*d9f75844SAndroid Build Coastguard Worker 283*d9f75844SAndroid Build Coastguard Worker private LocalDataChannelReadyInternalDelegate localDataChannelReadyDelegate = null; 284*d9f75844SAndroid Build Coastguard Worker public event LocalDataChannelReadyDelegate OnLocalDataChannelReady; 285*d9f75844SAndroid Build Coastguard Worker 286*d9f75844SAndroid Build Coastguard Worker private DataFromDataChannelReadyInternalDelegate dataFromDataChannelReadyDelegate = null; 287*d9f75844SAndroid Build Coastguard Worker public event DataFromDataChannelReadyDelegate OnDataFromDataChannelReady; 288*d9f75844SAndroid Build Coastguard Worker 289*d9f75844SAndroid Build Coastguard Worker private FailureMessageInternalDelegate failureMessageDelegate = null; 290*d9f75844SAndroid Build Coastguard Worker public event FailureMessageDelegate OnFailureMessage; 291*d9f75844SAndroid Build Coastguard Worker 292*d9f75844SAndroid Build Coastguard Worker private AudioBusReadyInternalDelegate audioBusReadyDelegate = null; 293*d9f75844SAndroid Build Coastguard Worker public event AudioBusReadyDelegate OnAudioBusReady; 294*d9f75844SAndroid Build Coastguard Worker 295*d9f75844SAndroid Build Coastguard Worker private I420FrameReadyInternalDelegate localI420FrameReadyDelegate = null; 296*d9f75844SAndroid Build Coastguard Worker public event I420FrameReadyDelegate OnLocalVideoFrameReady; 297*d9f75844SAndroid Build Coastguard Worker 298*d9f75844SAndroid Build Coastguard Worker private I420FrameReadyInternalDelegate remoteI420FrameReadyDelegate = null; 299*d9f75844SAndroid Build Coastguard Worker public event I420FrameReadyDelegate OnRemoteVideoFrameReady; 300*d9f75844SAndroid Build Coastguard Worker 301*d9f75844SAndroid Build Coastguard Worker private LocalSdpReadytoSendInternalDelegate localSdpReadytoSendDelegate = null; 302*d9f75844SAndroid Build Coastguard Worker public event LocalSdpReadytoSendDelegate OnLocalSdpReadytoSend; 303*d9f75844SAndroid Build Coastguard Worker 304*d9f75844SAndroid Build Coastguard Worker private IceCandidateReadytoSendInternalDelegate iceCandidateReadytoSendDelegate = null; 305*d9f75844SAndroid Build Coastguard Worker public event IceCandidateReadytoSendDelegate OnIceCandidateReadytoSend; 306*d9f75844SAndroid Build Coastguard Worker 307*d9f75844SAndroid Build Coastguard Worker private int mPeerConnectionId = -1; 308*d9f75844SAndroid Build Coastguard Worker } 309*d9f75844SAndroid Build Coastguard Worker} 310