Example #1
0
 private  static  void OnSessionMp4InfoStateNotify(long channel_id,int code, NIMVChatMP4State mp4_info)
 {
     string log = "";
     if (mp4_info != null)
     {
         if (mp4_info.MP4_Close != null)
         {
             log += "close:channel_id:" + channel_id.ToString() + " file_path:" + mp4_info.MP4_Close.FilePath + " duration:" + mp4_info.MP4_Close.Duration;
         }
         if (mp4_info.MP4_Start != null)
         {
             log += "start:channel_id:" + channel_id.ToString() + "file_path:" + mp4_info.MP4_Start.FilePath + " duration:" + mp4_info.MP4_Start.Duration;
         }
     }
     DemoTrace.WriteLine("SessionMp4Info " + log);
 }
Example #2
0
        private static void VChatSessionStatusCallback(NIMVideoChatSessionType type, long channel_id, int code, string json_extension, IntPtr user_data)
        {
            System.Diagnostics.Debug.WriteLine("type:" + type.ToString() + "json: " + json_extension);
            if (json_extension == null)
            {
                return;
            }
            NIMVChatSessionInfo info = null;

            switch (type)
            {
            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeStartRes:
            {
                if (session_status.onSessionStartRes != null)
                {
                    session_status.onSessionStartRes.DynamicInvoke(channel_id, code);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeInviteNotify:
            {
                if (session_status.onSessionInviteNotify != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    if (info != null)
                    {
                        session_status.onSessionInviteNotify.DynamicInvoke(channel_id, info.Uid, info.Type, info.Time, info.CustomInfo);
                    }
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeCalleeAckRes:
            {
                if (session_status.onSessionCalleeAckRes != null)
                {
                    session_status.onSessionCalleeAckRes.DynamicInvoke(channel_id, code);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeCalleeAckNotify:
            {
                if (session_status.onSessionCalleeAckNotify != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    if (info != null)
                    {
                        session_status.onSessionCalleeAckNotify.DynamicInvoke(channel_id, info.Uid, info.Type, info.Accept > 0);
                    }
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeControlRes:
            {
                if (session_status.onSessionControlRes != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    if (info != null)
                    {
                        session_status.onSessionControlRes.DynamicInvoke(channel_id, code, info.Type);
                    }
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeControlNotify:
            {
                if (session_status.onSessionControlNotify != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    if (info != null)
                    {
                        session_status.onSessionControlNotify.DynamicInvoke(channel_id, info.Uid, info.Type);
                    }
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeConnect:
            {
                if (session_status.onSessionConnectNotify != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    if (info != null)
                    {
                        session_status.onSessionConnectNotify.DynamicInvoke(channel_id, code, info.RecordFile, info.VideoRecordFile);
                    }
                    else
                    {
                        session_status.onSessionConnectNotify.DynamicInvoke(channel_id, code, null, null);
                    }
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypePeopleStatus:
            {
                if (session_status.onSessionPeopleStatus != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    if (info != null)
                    {
                        if (code == Convert.ToInt32(NIMVideoChatSessionStatus.kNIMVideoChatSessionStatusLeaved))
                        {
                            if (info.Status == Convert.ToInt32(NIMVideoChatUserLeftType.kNIMVChatUserLeftTimeout))
                            {
                                code = Convert.ToInt32(NIMVideoChatSessionStatus.kNIMVideoChatSessionStatusTimeOutLeaved);
                            }
                        }
                        session_status.onSessionPeopleStatus.DynamicInvoke(channel_id, info.Uid, code);
                    }
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeNetStatus:
            {
                if (session_status.onSessionNetStatus != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    if (info != null)
                    {
                        session_status.onSessionNetStatus.DynamicInvoke(channel_id, code, info.Uid);
                    }
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeHangupRes:
            {
                if (session_status.onSessionHangupRes != null)
                {
                    session_status.onSessionHangupRes.DynamicInvoke(channel_id, code);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeHangupNotify:
            {
                if (session_status.onSessionHangupNotify != null)
                {
                    session_status.onSessionHangupNotify.DynamicInvoke(channel_id, code);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeSyncAckNotify:
            {
                if (session_status.onSessionSyncAckNotify != null)
                {
                    info = NIMVChatSessionInfo.Deserialize(json_extension);
                    if (info != null)
                    {
                        session_status.onSessionSyncAckNotify.DynamicInvoke(channel_id, code, info.Uid, info.Type, info.Accept > 0, info.Time, info.Client);
                    }
                }
            }
            break;

#if NIMAPI_UNDER_WIN_DESKTOP_ONLY
            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeMp4Notify:
            {
                if (session_status.onSessionMp4InfoStateNotify != null)
                {
                    NIMVChatMP4State mp4_info = NIMVChatMP4State.Deserialize(json_extension);
                    session_status.onSessionMp4InfoStateNotify(channel_id, code, mp4_info);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeInfoNotify:
                if (session_status.onSessionRealtimeStateNotify != null)
                {
                    var state = NIMVChatRealtimeState.Deserialize(json_extension);
                    session_status.onSessionRealtimeStateNotify(channel_id, code, state);
                }
                break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeVolumeNotify:
                if (session_status.onSessionVolumeStateChanged != null)
                {
                    var volume = NIMVchatAudioVolumeState.Deserialize(json_extension);
                    session_status.onSessionVolumeStateChanged(channel_id, code, volume);
                }
                break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeAuRecordNotify:
            {
                if (session_status.onSessionAuRecordInfoStateNotify != null)
                {
                    NIMVChatAuRecordState record_state = NIMVChatAuRecordState.Deserialize(json_extension);
                    session_status.onSessionAuRecordInfoStateNotify(channel_id, code, record_state);
                }
            }
            break;

            case NIMVideoChatSessionType.kNIMVideoChatSessionTypeLiveState:
            {
                if (session_status.onSessionLiveStateNotify != null)
                {
                    var state = NIMVChatLiveState.Deserialize(json_extension);
                    session_status.onSessionLiveStateNotify(channel_id, code, state);
                }
            }
            break;
#endif
            }
        }