private LocalConnectionState_t ReadLocalConnectionInfo(IStructReader reader) { try { logger.Info("CSTAConferencedParser.ReadLocalConnectionInfo: BaseStream.Position={0};BaseStream.Length={1};", reader.BaseStream.Position, reader.BaseStream.Length); if ((reader.BaseStream.Length - reader.BaseStream.Position) >= 4) { logger.Info("CSTAConferencedParser.ReadLocalConnectionInfo: read local connection state from stream..."); int value = reader.ReadInt32(); logger.Info("CSTAConferencedParser.ReadLocalConnectionInfo: value={0}", value); if (Enum.IsDefined(typeof(LocalConnectionState_t), value)) { LocalConnectionState_t localConnectionInfo = (LocalConnectionState_t)value; logger.Info("CSTAConferencedParser.ReadLocalConnectionInfo: localConnectionInfo={0}", localConnectionInfo); return(localConnectionInfo); } } } catch (Exception err) { logger.Error(string.Format("Error in CSTAConferencedParser.ReadLocalConnectionInfo: {0}", err)); } return(LocalConnectionState_t.CS_NONE); }
public object MarshalNativeToManaged(System.IntPtr pNativeData) { Marshal.PtrToStructure(pNativeData, this.marshaledObj.evt); if (this.marshaledObj.evt.eventHeader.eventClass.eventClass == Csta.CSTACONFIRMATION) { this.marshaledObj.evt.cstaConfirmation = (CSTAConfirmationEvent)Aux.ByteArrayToStructure <CSTAConfirmationEvent>(this.marshaledObj.evt.heap); } // Marshal SnapShotCall Event if (this.marshaledObj.evt.eventHeader.eventClass.eventClass == Csta.CSTACONFIRMATION && this.marshaledObj.evt.eventHeader.eventType.eventType == Csta.CSTA_SNAPSHOT_CALL_CONF) { this.marshaledObj.evt.cstaConfirmation.snapshotCall = (Csta.CSTASnapshotCallConfEvent_t)Aux.ByteArrayToStructure <Csta.CSTASnapshotCallConfEvent_t>(this.marshaledObj.evt.cstaConfirmation.heap); int infoCount = this.marshaledObj.evt.cstaConfirmation.snapshotCall.snapshotData.count; IntPtr pInfo = this.marshaledObj.evt.cstaConfirmation.snapshotCall.snapshotData.pInfo; Csta.CSTASnapshotCallResponseInfo_t[] infoArray = new CSTASnapshotCallResponseInfo_t[infoCount]; int infoSize = Marshal.SizeOf(new CSTASnapshotCallResponseInfo_t()); for (int i = 0; i < infoCount; i++) { infoArray[i] = (CSTASnapshotCallResponseInfo_t)Marshal.PtrToStructure(new IntPtr(pInfo.ToInt32() + infoSize * i), typeof(CSTASnapshotCallResponseInfo_t)); } this.marshaledObj.auxData.Add("snapCallInfo", infoArray); } // Marshal SnapShotDevice Event if (this.marshaledObj.evt.eventHeader.eventClass.eventClass == Csta.CSTACONFIRMATION && this.marshaledObj.evt.eventHeader.eventType.eventType == Csta.CSTA_SNAPSHOT_DEVICE_CONF) { this.marshaledObj.evt.cstaConfirmation.snapshotDevice = (CSTASnapshotDeviceConfEvent_t)Aux.ByteArrayToStructure <CSTASnapshotDeviceConfEvent_t>(this.marshaledObj.evt.cstaConfirmation.heap); int infoCount = this.marshaledObj.evt.cstaConfirmation.snapshotDevice.snapshotData.count; IntPtr pInfo = this.marshaledObj.evt.cstaConfirmation.snapshotDevice.snapshotData.pInfo; Csta.CSTASnapshotDeviceResponseInfo_t[] infoArray = new CSTASnapshotDeviceResponseInfo_t[infoCount]; int infoSize = Marshal.SizeOf(new CSTASnapshotDeviceResponseInfo_t()); for (int i = 0; i < infoCount; i++) { infoArray[i] = (CSTASnapshotDeviceResponseInfo_t)Marshal.PtrToStructure(new IntPtr(pInfo.ToInt32() + infoSize * i), typeof(CSTASnapshotDeviceResponseInfo_t)); int stateCount = infoArray[i].localCallState.count; IntPtr pState = infoArray[i].localCallState.pState; LocalConnectionState_t[] stateArray = new LocalConnectionState_t[stateCount]; for (int j = 0; j < stateCount; j++) { stateArray[j] = (LocalConnectionState_t)Marshal.ReadInt32(pState, (sizeof(int) * j)); } this.marshaledObj.auxData.Add("snapDeviceState" + i, stateArray); } this.marshaledObj.auxData.Add("snapDeviceInfo", infoArray); } return(this.marshaledObj); }
public object MarshalNativeToManaged(System.IntPtr pNativeData) { Marshal.PtrToStructure(pNativeData, this.marshaledObj.evt); if (this.marshaledObj.evt.eventHeader.eventClass.eventClass == Csta.CSTACONFIRMATION) { this.marshaledObj.evt.cstaConfirmation = (CSTAConfirmationEvent)Aux.ByteArrayToStructure<CSTAConfirmationEvent>(this.marshaledObj.evt.heap); } // Marshal SnapShotCall Event if (this.marshaledObj.evt.eventHeader.eventClass.eventClass == Csta.CSTACONFIRMATION && this.marshaledObj.evt.eventHeader.eventType.eventType == Csta.CSTA_SNAPSHOT_CALL_CONF) { this.marshaledObj.evt.cstaConfirmation.snapshotCall = (Csta.CSTASnapshotCallConfEvent_t)Aux.ByteArrayToStructure<Csta.CSTASnapshotCallConfEvent_t>(this.marshaledObj.evt.cstaConfirmation.heap); int infoCount = this.marshaledObj.evt.cstaConfirmation.snapshotCall.snapshotData.count; IntPtr pInfo = this.marshaledObj.evt.cstaConfirmation.snapshotCall.snapshotData.pInfo; Csta.CSTASnapshotCallResponseInfo_t[] infoArray = new CSTASnapshotCallResponseInfo_t[infoCount]; int infoSize = Marshal.SizeOf(new CSTASnapshotCallResponseInfo_t()); for (int i = 0; i < infoCount; i++) { infoArray[i] = (CSTASnapshotCallResponseInfo_t)Marshal.PtrToStructure(new IntPtr(pInfo.ToInt32() + infoSize * i), typeof(CSTASnapshotCallResponseInfo_t)); } this.marshaledObj.auxData.Add("snapCallInfo", infoArray); } // Marshal SnapShotDevice Event if (this.marshaledObj.evt.eventHeader.eventClass.eventClass == Csta.CSTACONFIRMATION && this.marshaledObj.evt.eventHeader.eventType.eventType == Csta.CSTA_SNAPSHOT_DEVICE_CONF) { this.marshaledObj.evt.cstaConfirmation.snapshotDevice = (CSTASnapshotDeviceConfEvent_t)Aux.ByteArrayToStructure<CSTASnapshotDeviceConfEvent_t>(this.marshaledObj.evt.cstaConfirmation.heap); int infoCount = this.marshaledObj.evt.cstaConfirmation.snapshotDevice.snapshotData.count; IntPtr pInfo = this.marshaledObj.evt.cstaConfirmation.snapshotDevice.snapshotData.pInfo; Csta.CSTASnapshotDeviceResponseInfo_t[] infoArray = new CSTASnapshotDeviceResponseInfo_t[infoCount]; int infoSize = Marshal.SizeOf(new CSTASnapshotDeviceResponseInfo_t()); for (int i = 0; i < infoCount; i++) { infoArray[i] = (CSTASnapshotDeviceResponseInfo_t)Marshal.PtrToStructure(new IntPtr(pInfo.ToInt32() + infoSize * i), typeof(CSTASnapshotDeviceResponseInfo_t)); int stateCount = infoArray[i].localCallState.count; IntPtr pState = infoArray[i].localCallState.pState; LocalConnectionState_t[] stateArray = new LocalConnectionState_t[stateCount]; for (int j = 0; j < stateCount; j++) { stateArray[j] = (LocalConnectionState_t)Marshal.ReadInt32(pState, (sizeof(int) * j)); } this.marshaledObj.auxData.Add("snapDeviceState" + i, stateArray); } this.marshaledObj.auxData.Add("snapDeviceInfo", infoArray); } return this.marshaledObj; }