Beispiel #1
0
 public static void findOrCreatPanel(string strUid, AliRtcVideoTrack videoTrack, out Panel panel_)
 {
     if (videoTrack == AliRtcVideoTrack.AliRtcVideoTrackCamera)
     {
         if (m_camaraUid2panelHash.Contains(strUid))
         {
             panel_ = (Panel)m_camaraUid2panelHash[strUid];
         }
         else
         {
             panel_           = new System.Windows.Forms.Panel();
             panel_.BackColor = System.Drawing.SystemColors.ControlDark;
             m_camaraUid2panelHash.Add(strUid, panel_);
         }
     }
     else if (videoTrack == AliRtcVideoTrack.AliRtcVideoTrackScreen)
     {
         if (m_screenUid2panelHash.Contains(strUid))
         {
             panel_ = (Panel)m_screenUid2panelHash[strUid];
         }
         else
         {
             panel_           = new System.Windows.Forms.Panel();
             panel_.BackColor = System.Drawing.SystemColors.ControlDark;
             m_screenUid2panelHash.Add(strUid, panel_);
         }
     }
     else
     {
         panel_ = null;
     }
 }
Beispiel #2
0
        public static void DeleteViewInfo(string struUid, AliRtcVideoTrack videoTrack)
        {
            Debug.Assert(videoTrack == AliRtcVideoTrack.AliRtcVideoTrackCamera ||
                         videoTrack == AliRtcVideoTrack.AliRtcVideoTrackScreen);
            List <viewInfo> deleteViewList = new List <viewInfo>();

            foreach (viewInfo viewInfo_ in m_viewInfoList)
            {
                if (viewInfo_.strUid == struUid &&
                    viewInfo_.videoTrack == videoTrack)
                {
                    deleteViewList.Add(viewInfo_);
                }
            }
            foreach (viewInfo deleteView in deleteViewList)
            {
                deleteView.showPanel.Hide();
                m_viewInfoList.Remove(deleteView);
            }
        }
Beispiel #3
0
        public static void findOrCreatPanel_(string strUid, AliRtcVideoTrack videoTrack, out Panel panel_)
        {
            panel_ = null;
            foreach (viewInfo viewInfo_ in m_viewInfoList)
            {
                if (viewInfo_.strUid == strUid &&
                    viewInfo_.videoTrack == videoTrack)
                {
                    panel_ = viewInfo_.showPanel;
                    return;
                }
            }
            viewInfo tempViewInfo;

            tempViewInfo.strUid              = strUid;
            tempViewInfo.videoTrack          = videoTrack;
            tempViewInfo.showPanel           = new System.Windows.Forms.Panel();
            tempViewInfo.showPanel.BackColor = System.Drawing.SystemColors.ControlDark;
            panel_ = tempViewInfo.showPanel;
            m_viewInfoList.AddLast(tempViewInfo);
        }
 [DllImport("AliRTCEngineCWrapper.dll", CallingConvention = CallingConvention.Cdecl)] // 是否允许推送次要视频流
 public static extern int configLocalSimulcast(bool bEnabled, AliRtcVideoTrack track);
 [DllImport("AliRTCEngineCWrapper.dll", CallingConvention = CallingConvention.Cdecl)] // 订阅视频流
 public static extern void setRemoteViewConfig(IntPtr hWndShowID, String pUid, AliRtcVideoTrack videoTrack,
                                               AliRtcRenderMode RenderMode, AliRtcScaleRatio ScaleRatio, bool bIsfFlip);
 public static extern void muteLocalCamera(bool bMute, AliRtcVideoTrack track);       //是否将停止本地视频采集
Beispiel #7
0
        public static void onRemoteTrackAvailableNotify(string strUid, AliRtcAudioTrack audioTrack, AliRtcVideoTrack videoTrack)
        {
            if (!m_ParamInfo.bAutoSub)
            {
                //当自动订阅开关关闭时,所有用户都手动订阅
                if (audioTrack == AliRtcAudioTrack.AliRtcAudioTrackMic)
                {
                    ImportDll.configRemoteAudio(strUid, true);
                }
                else
                {
                    ImportDll.configRemoteAudio(strUid, false);
                }
                if (videoTrack == AliRtcVideoTrack.AliRtcVideoTrackCamera ||
                    videoTrack == AliRtcVideoTrack.AliRtcVideoTrackBoth)
                {
                    ImportDll.configRemoteCameraTrack(strUid, true, true);
                }
                else
                {
                    ImportDll.configRemoteCameraTrack(strUid, true, false);
                }

                if (videoTrack == AliRtcVideoTrack.AliRtcVideoTrackScreen ||
                    videoTrack == AliRtcVideoTrack.AliRtcVideoTrackBoth)
                {
                    ImportDll.configRemoteScreenTrack(strUid, true);
                }
                else
                {
                    ImportDll.configRemoteScreenTrack(strUid, false);
                }
                ImportDll.setSubscribeResultCB SubscribeResultCB;
                SubscribeResultCB = new ImportDll.setSubscribeResultCB(onSubscribeResult);
                ImportDll.setSubscribeResultCallBack(SubscribeResultCB);

                bool bRet = ImportDll.subscribe(strUid);

                if (bRet == false)
                {
                    AliRtcSample.mainFrm.listBox_Tips.Items.Add("订阅失败,是否调用onSubscribeResultCallBack回调?");
                }
            }
            else
            {
                //开启自动订阅开关时,订阅所有有流的用户
                onSubscribeResult(strUid, audioTrack, videoTrack);
            }
        }
Beispiel #8
0
 public static void onSubscribeChangedNotify(string strUid, AliRtcAudioTrack audioTrack, AliRtcVideoTrack videoTrack)
 {
 }
Beispiel #9
0
 public static void onSubscribeResult(string strUid, AliRtcAudioTrack audioTrack, AliRtcVideoTrack videoTrack)
 {
     AliRtcSample.mainFrm.listBox_Tips.Items.Add("订阅成功:" + strUid);
     AliRtcSample.mainFrm.listBox_Tips.Items.Add("订阅视频流:" + audioTrack.ToString());
     AliRtcSample.mainFrm.listBox_Tips.Items.Add("订阅音频流:" + videoTrack.ToString());
     if (mainFrm.InvokeRequired)
     {
         Object[] parametors = new Object[] { strUid, audioTrack, videoTrack };
         mainFrm.Invoke(new SubscribeResultDelegate(onSubscribeResultDE_), parametors);
     }
 }
Beispiel #10
0
        public static void onSubscribeResultDE(string strUid, AliRtcAudioTrack audioTrack, AliRtcVideoTrack videoTrack)
        {
            if (videoTrack == AliRtcVideoTrack.AliRtcVideoTrackNo ||
                videoTrack == AliRtcVideoTrack.AliRtcVideoTrackEnd)
            {
                if (m_uidList.Contains(strUid))
                {
                    m_uidList.Remove(strUid);
                }
                if (m_camaraUid2panelHash.Contains(strUid))
                {
                    m_camaraUid2panelHash.Remove(strUid);
                }
                if (m_screenUid2panelHash.Contains(strUid))
                {
                    m_screenUid2panelHash.Remove(strUid);
                }
            }

            else if (videoTrack == AliRtcVideoTrack.AliRtcVideoTrackCamera)
            {
                if (!m_uidList.Contains(strUid))
                {
                    m_uidList.AddLast(strUid);
                }
                if (m_screenUid2panelHash.Contains(strUid))
                {
                    m_screenUid2panelHash.Remove(strUid);
                }
                Panel panel_camera;
                findOrCreatPanel(strUid, videoTrack, out panel_camera);
                Debug.Assert(panel_camera != null);
                ImportDll.setRemoteViewConfig(panel_camera.Handle, strUid, videoTrack,
                                              AliRtcRenderMode.AliRtcRenderModeAuto, AliRtcScaleRatio.AliRtcScaleRatio_16_9, false);
            }
            else if (videoTrack == AliRtcVideoTrack.AliRtcVideoTrackScreen)
            {
                if (!m_uidList.Contains(strUid))
                {
                    m_uidList.AddLast(strUid);
                }
                if (m_camaraUid2panelHash.Contains(strUid))
                {
                    m_camaraUid2panelHash.Remove(strUid);
                }
                Panel panel_screen;
                findOrCreatPanel(strUid, videoTrack, out panel_screen);
                Debug.Assert(panel_screen != null);
                ImportDll.setRemoteViewConfig(panel_screen.Handle, strUid, videoTrack,
                                              AliRtcRenderMode.AliRtcRenderModeAuto, AliRtcScaleRatio.AliRtcScaleRatio_16_9, false);
            }
            else if (videoTrack == AliRtcVideoTrack.AliRtcVideoTrackBoth)
            {
                if (!m_uidList.Contains(strUid))
                {
                    m_uidList.AddLast(strUid);
                }
                Panel panel_camera;
                Panel panel_screen;
                findOrCreatPanel(strUid, AliRtcVideoTrack.AliRtcVideoTrackCamera, out panel_camera);
                findOrCreatPanel(strUid, AliRtcVideoTrack.AliRtcVideoTrackScreen, out panel_screen);
                Debug.Assert(panel_camera != null);
                Debug.Assert(panel_screen != null);
                ImportDll.setRemoteViewConfig(panel_camera.Handle, strUid, AliRtcVideoTrack.AliRtcVideoTrackCamera,
                                              AliRtcRenderMode.AliRtcRenderModeAuto, AliRtcScaleRatio.AliRtcScaleRatio_16_9, false);
                ImportDll.setRemoteViewConfig(panel_screen.Handle, strUid, AliRtcVideoTrack.AliRtcVideoTrackScreen,
                                              AliRtcRenderMode.AliRtcRenderModeAuto, AliRtcScaleRatio.AliRtcScaleRatio_16_9, false);
            }
            Layout_RemoteView();
        }
Beispiel #11
0
 public static void onSubscribeResultDE_(string strUid, AliRtcAudioTrack audioTrack, AliRtcVideoTrack videoTrack)
 {
     if (videoTrack == AliRtcVideoTrack.AliRtcVideoTrackNo ||
         videoTrack == AliRtcVideoTrack.AliRtcVideoTrackEnd)
     {
         DeleteViewInfo(strUid, AliRtcVideoTrack.AliRtcVideoTrackCamera);
         DeleteViewInfo(strUid, AliRtcVideoTrack.AliRtcVideoTrackScreen);
     }
     else if (videoTrack == AliRtcVideoTrack.AliRtcVideoTrackCamera)
     {
         Panel panel_camera;
         DeleteViewInfo(strUid, AliRtcVideoTrack.AliRtcVideoTrackScreen);
         findOrCreatPanel_(strUid, videoTrack, out panel_camera);
         Debug.Assert(panel_camera != null);
         ImportDll.setRemoteViewConfig(panel_camera.Handle, strUid, videoTrack,
                                       AliRtcRenderMode.AliRtcRenderModeFill, AliRtcScaleRatio.AliRtcScaleRatio_16_9, false);
     }
     else if (videoTrack == AliRtcVideoTrack.AliRtcVideoTrackScreen)
     {
         Panel panel_screen;
         DeleteViewInfo(strUid, AliRtcVideoTrack.AliRtcVideoTrackCamera);
         findOrCreatPanel_(strUid, videoTrack, out panel_screen);
         Debug.Assert(panel_screen != null);
         ImportDll.setRemoteViewConfig(panel_screen.Handle, strUid, videoTrack,
                                       AliRtcRenderMode.AliRtcRenderModeFill, AliRtcScaleRatio.AliRtcScaleRatio_16_9, false);
     }
     else if (videoTrack == AliRtcVideoTrack.AliRtcVideoTrackBoth)
     {
         Panel panel_camera;
         Panel panel_screen;
         findOrCreatPanel_(strUid, AliRtcVideoTrack.AliRtcVideoTrackCamera, out panel_camera);
         findOrCreatPanel_(strUid, AliRtcVideoTrack.AliRtcVideoTrackScreen, out panel_screen);
         Debug.Assert(panel_camera != null);
         Debug.Assert(panel_screen != null);
         ImportDll.setRemoteViewConfig(panel_camera.Handle, strUid, AliRtcVideoTrack.AliRtcVideoTrackCamera,
                                       AliRtcRenderMode.AliRtcRenderModeFill, AliRtcScaleRatio.AliRtcScaleRatio_16_9, false);
         ImportDll.setRemoteViewConfig(panel_screen.Handle, strUid, AliRtcVideoTrack.AliRtcVideoTrackScreen,
                                       AliRtcRenderMode.AliRtcRenderModeFill, AliRtcScaleRatio.AliRtcScaleRatio_16_9, false);
     }
     Layout_RemoteView_();
 }