/// <summary> /// This method is called when an Async call to PrepareForConnection returns. Only /// the AVPlayList class will ever call that method. /// </summary> /// <param name="sender"></param> /// <param name="RemoteProtocolInfo"></param> /// <param name="PeerConnectionManager"></param> /// <param name="PeerConnectionID"></param> /// <param name="Direction"></param> /// <param name="ConnectionID"></param> /// <param name="AVTransportID"></param> /// <param name="RcsID"></param> /// <param name="e"></param> /// <param name="Handle"></param> protected void PrepareForConnectionSink(CpConnectionManager sender, System.String RemoteProtocolInfo, System.String PeerConnectionManager, System.Int32 PeerConnectionID, CpConnectionManager.Enum_A_ARG_TYPE_Direction Direction, System.Int32 ConnectionID, System.Int32 AVTransportID, System.Int32 RcsID, UPnPInvokeException e, object Handle) { AVConnection c = null; bool IsNew = true; if (e != null) { // Since only the AVPlayList class will call PrepareForConnection, we need to fire // this other event, because it's too early to notify the user. Only AVPlayList needs // to know about this, so it can continue to setup the connection for the user OnCreateConnectionFailedEvent2.Fire(this, AVRenderer.CreateFailedReason.CREATE_ATTEMPT_DENIED, Handle); return; } lock (InstanceList) { foreach (AVConnection a in InstanceList) { if (a.ConnectionID == ConnectionID) { // We Already Have this ID From somewhere IsNew = false; c = a; break; } } if (IsNew == true) { // Does not Exist c = new AVConnection(MainDevice, AVTransportID, RcsID, ConnectionID, new AVConnection.OnReadyHandler(_ReadySink), Handle); c._Parent = this; InstanceList.Add(c); } } if (IsNew == true) { // Wait for Ready event from the AVConnection, since we can't return it // until it is initialized. } else { // Recycled OnRecycledConnectionEvent2.Fire(this, c, Handle); } }
protected void InitialState_GetCurrentConnectionInfoSink(CpConnectionManager sender, System.Int32 ConnectionID, System.Int32 RcsID, System.Int32 AVTransportID, System.String ProtocolInfo, System.String PeerConnectionManager, System.Int32 PeerConnectionID, CpConnectionManager.Enum_A_ARG_TYPE_Direction Direction, CpConnectionManager.Enum_A_ARG_TYPE_ConnectionStatus Status, UPnPInvokeException e, object __tag) { this.ProtocolInfoString = ProtocolInfo; bool OK = false; lock (this) { --StateCounter; if (StateCounter == 0) { this.UpdateCurrentItem(); OK = true; } } if (OK) { if (OnReady != null) { OnReady(this, Tag); } } }
protected void ConnectionInfoSink(CpConnectionManager sender, System.Int32 ConnectionID, System.Int32 RcsID, System.Int32 AVTransportID, System.String ProtocolInfo, System.String PeerConnectionManager, System.Int32 PeerConnectionID, CpConnectionManager.Enum_A_ARG_TYPE_Direction Direction, CpConnectionManager.Enum_A_ARG_TYPE_ConnectionStatus Status, UPnPInvokeException e, object Handle) { if (e != null) { return; } AVConnection av = null; lock (InstanceList) { foreach (AVConnection a in InstanceList) { if (a.ConnectionID == ConnectionID) { av = a; break; } } if (av == null) { av = new AVConnection(MainDevice, AVTransportID, RcsID, ConnectionID, new AVConnection.OnReadyHandler(ReadySink), Handle); av._Parent = this; InstanceList.Add(av); } else { return; // Don't need to trigger event } } // Wait for Ready before sending OnCreateConnection }
/// <summary> /// This is called when GetCurrentConnectionInfo completes. /// </summary> /// <param name="sender"></param> /// <param name="ConnectionID"></param> /// <param name="RcsID"></param> /// <param name="AVTransportID"></param> /// <param name="ProtocolInfo"></param> /// <param name="PeerConnectionManager"></param> /// <param name="PeerConnectionID"></param> /// <param name="Direction"></param> /// <param name="Status"></param> /// <param name="e"></param> /// <param name="Tag"></param> protected void ConnectionInfoSink(CpConnectionManager sender, System.Int32 ConnectionID, System.Int32 RcsID, System.Int32 AVTransportID, System.String ProtocolInfo, System.String PeerConnectionManager, System.Int32 PeerConnectionID, CpConnectionManager.Enum_A_ARG_TYPE_Direction Direction, CpConnectionManager.Enum_A_ARG_TYPE_ConnectionStatus Status, UPnPInvokeException e, object Tag) { if (e != null) { return; } MediaResource = ResourceBuilder.CreateResource(MediaResource.ContentUri, ProtocolInfo); if (OnMediaResourceChanged != null) { OnMediaResourceChanged(this, MediaResource); } }