Lync API - CaptureVideoWindow and RenderVideoWindow are Null

。_饼干妹妹 提交于 2019-12-13 15:30:29

问题


I have downloaded the SDK for Lync 2013 and am having a problem with the code sample found in AudioVideoConversation.csproj. This project is supposed to demonstrate the use of Audio/Video conversations through the Lync API. I am having trouble getting the video portion to function in the sample application. The problem is in this method:

    /// <summary>
    /// Called when the video state changes.
    /// 
    /// Will show Incoming/Outgoing video based on the channel state.
    /// </summary>
    void videoChannel_StateChanged(object sender, ChannelStateChangedEventArgs e)
    {
        //posts the execution into the UI thread
        this.BeginInvoke(new MethodInvoker(delegate()
        {
            //updates the status bar with the video channel state
            toolStripStatusLabelVideoChannel.Text = e.NewState.ToString();


            //*****************************************************************************************
            //                              Video Content
            //
            // The video content is only available when the Lync client is running in UISuppressionMode.
            //
            // The video content is not directly accessible as a stream. It's rather available through
            // a video window that can de drawn in any panel or window.
            //
            // The outgoing video is accessible from videoChannel.CaptureVideoWindow
            // The window will be available when the video channel state is either Send or SendReceive.
            // 
            // The incoming video is accessible from videoChannel.RenderVideoWindow
            // The window will be available when the video channel state is either Receive or SendReceive.
            //
            //*****************************************************************************************

            //if the outgoing video is now active, show the video (which is only available in UI Suppression Mode)
            if ((e.NewState == ChannelState.Send 
                || e.NewState == ChannelState.SendReceive) && videoChannel.CaptureVideoWindow != null)
            {
                //presents the video in the panel
                ShowVideo(panelOutgoingVideo, videoChannel.CaptureVideoWindow);
            }

            //if the incoming video is now active, show the video (which is only available in UI Suppression Mode)
            if ((e.NewState == ChannelState.Receive 
                || e.NewState == ChannelState.SendReceive) && videoChannel.RenderVideoWindow != null)
            {
                //presents the video in the panel
                ShowVideo(panelIncomingVideo, videoChannel.RenderVideoWindow);
            }

        }));
    }

The variables videoChannel.CaptureVideoWindow and videoChannel.RenderVideoWindow are always null (please note that, unlike this question, the videoChannel variable is NOT null).

Some things you should know:

  1. I am running Lync in UI Suppression mode (achieved by adding the registry key UISuppressionMode [DWORD] as 1 at location HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Lync)
  2. The audio portion of the sample works perfectly
  3. The sample is actually sending my video stream to the remote party successfully
  4. When the conversation is done setting up, e.NewState == ChannelState.SendReceive evaluates to true
  5. I am working in Visual Studio 2012 and Microsoft Lync 2013

回答1:


I fired up an old demo (January 2014 time frame) I built and everything worked fine. I then installed the latest version of the SDK and ran the sample and sure enough, I had the same issue.

The issue is due to an exception when you try to set the owner of the Microsoft.Lync.Model.Conversation.AudioVideo.VideoWindow.

It turns out, there was a change in how permissions are handled for taking over this window. The "fix" for now is to place the application into the user folder of the account running the program. I tried this and it does, indeed work.

Here is the offending from ConversationWindow.cs:line 1128...

//sets the properties required for the native video window to draw itself
videoWindow.Owner = videoPanel.Handle.ToInt32();

Here is the error:

A first chance exception of type 'System.UnauthorizedAccessException' occurred in Microsoft.Lync.Model.dll System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) at Microsoft.Office.Uc.VideoWindowClass.set_Owner(Int32 Owner) at Microsoft.Lync.Model.Conversation.AudioVideo.VideoWindow.set_Owner(Int32 value) at AudioVideoConversation.ConversationWindow.ShowVideo(Panel videoPanel, VideoWindow videoWindow) in c:\Program Files (x86)\Microsoft Office 2013\LyncSDK\samples\AudioVideoConversation\Conversation\ConversationWindow.cs:line 1128

References: UISuppression Video Issues

A clarification from the Lync API engineering team: The unauthorized access (or COM) exception that you may get when assigning an owner handle to the VideoWindow is resolved by copying the sample project out of the \Program Files(x86)... folder to a user folder. Compile and run the project in the user folder and you will not get an exception.



来源:https://stackoverflow.com/questions/16524693/lync-api-capturevideowindow-and-rendervideowindow-are-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!