HRESULT CRTCAVSession::DeliverClient(RTC_CLIENT_EVENT_TYPE enEventType)
{
    switch(enEventType)
    {
    case RTCCET_VOLUME_CHANGE:
        // On volume change refresh the audio controls
        // so volume controls can be updated
        ShowAudio();
        break;

    case RTCCET_DEVICE_CHANGE:
        // On device change refresh the audio and video
        // controls as available devices may have changed
        ShowAudio();
        ShowVideo(RTCVD_PREVIEW, m_fShowPrev);
        ShowVideo(RTCVD_RECEIVE, m_fShowRecv);
        break;
    }

    return S_OK;
}
Exemple #2
0
int NETPlay(int Switch)
{
  char S[256],T[256],*P;
  int J;

  // Toggle connection if requested
  if(Switch==NET_TOGGLE) Switch=NETConnected()? NET_OFF:NET_ON;

  switch(Switch)
  {
    case NET_OFF:
      // Disconnect NetPlay
      NETClose();
      break;
    case NET_ON:
    case NET_SERVER:
      // If already connected, drop out
      if(NETConnected()==Switch) break;
      // If connecting in client mode, ask for hostname
      if((Switch==NET_SERVER)||CONInput(
        -1,-1,NET_FGCOLOR,NET_BGCOLOR,
        "Enter Hostname",S,sizeof(S)
      ))
      {
        // Compose title
        T[0]='~';
        if(!NETMyName(T+1,sizeof(T)-1)) strcpy(T+1,"Network Play");
        // Show "Connecting" message
        CONMsg(-1,-1,-1,-1,NET_FGCOLOR,NET_OKCOLOR,T," \0 Connecting... \0 \0");
        ShowVideo();
        // Convert string to lower case, remove spaces
        if(Switch==NET_SERVER)
        {
          for(J=0,P=S;*P;++P)
            if(*P>' ') S[J++]=(*P>='A')&&(*P<='Z')? *P+'a'-'A':*P;
          S[J]='\0';
        }
        // Connect second player, report problems if present
        if(!NETConnect(Switch==NET_SERVER? 0:S,NET_PORT))
          CONMsg(
            -1,-1,-1,-1,NET_FGCOLOR,NET_ERRCOLOR,
            T+1," \0    Failed!    \0 \0"
          );
      }
      break;
  }

  // Always return connection status
  return(NETConnected());
}
HRESULT CRTCAVSession::DeliverMedia(long lMediaType, RTC_MEDIA_EVENT_TYPE enType, RTC_MEDIA_EVENT_REASON enReason)
{
    RTC_VIDEO_DEVICE enVideo;
    BOOL fShow;
    HRESULT hr;

    // Which media type changed?
    switch (lMediaType)
    {
    case RTCMT_VIDEO_SEND:   
        enVideo = RTCVD_PREVIEW;
        break;

    case RTCMT_VIDEO_RECEIVE:
        enVideo = RTCVD_RECEIVE;
        break;

    default:
        return S_OK;
    }

    // Did the media start or stop?
    switch (enType) 
    {
    case RTCMET_STARTED:
        fShow = TRUE;
        break;

    case RTCMET_STOPPED:
    case RTCMET_FAILED:
        fShow = FALSE;
        break;

    default:
        return S_OK;
    }

    // Show or hide the video as appropriate
    hr = ShowVideo(enVideo, fShow);

    if (FAILED(hr))
    {
        // ShowVideo failed
        return hr;
    }

    return S_OK;
}
// Draw the egg head and the camera video with the mask superimposed.
BOOL SingleFace::PaintWindow(HDC hdc, HWND hWnd)
{
    static int errCount = 0;
    BOOL ret = FALSE;
    RECT rect;
    GetClientRect(hWnd, &rect);
    int width = rect.right - rect.left;
    int height = rect.bottom - rect.top;
    int halfWidth = width/2;

    // Show the video on the right of the window
    errCount += !ShowVideo(hdc, width - halfWidth, height, halfWidth, 0);

    // Draw the egg avatar on the left of the window
    errCount += !ShowEggAvatar(hdc, halfWidth, height, 0, 0);
    return ret;
}
// Draw the egg head and the camera video with the mask superimposed.
BOOL MultiFace::PaintWindow(HDC hdc, HWND hWnd)
{
    static int errCount = 0;
    BOOL ret = FALSE;
    RECT rect;
    GetClientRect(hWnd, &rect);
    int width = rect.right - rect.left;
    int height = rect.bottom - rect.top;
    int halfWidth = width/2;

    // Show the video on the right of the window
    errCount += !ShowVideo(hdc, width - halfWidth, height, halfWidth, 0);

    // Draw the egg avatar on the left of the window
    int avatarHeight = height/m_nbUsers;
    for (UINT i=0; i<m_nbUsers; i++)
    {
        errCount += !ShowEggAvatar(hdc, halfWidth, avatarHeight, 0, i*avatarHeight, i);
    }
    return ret;
}
LRESULT CRTCAVSession::OnSize(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    // Call the base class
    CRTCSession::OnSize(uMsg, wParam, lParam);

    RECT rcWnd, rcStatusBar;
    const int SIZE_EDGE = 5;
    const int TEXT_HEIGHT = 16;
    const int LEVEL_HEIGHT = 10;
    const int VOL_HEIGHT = 20;   

    GetClientRect(m_hWnd, &rcWnd);    
    GetClientRect(m_hStatusBar, &rcStatusBar);

    // Calculate video window size
    float fAspectRatio = (float)QCIF_CY_SIZE/(float)QCIF_CX_SIZE;
    m_lRecvWidth = rcWnd.right - rcWnd.left - 2*SIZE_EDGE;
    m_lRecvHeight = fAspectRatio * m_lRecvWidth;
    m_lPrevWidth = QQCIF_CX_SIZE;
    m_lPrevHeight = QQCIF_CY_SIZE;

    // Resize the receive video parent window  
    RECT rcRecvVid;

    rcRecvVid.left = rcWnd.left + SIZE_EDGE; 
    rcRecvVid.right = rcWnd.left + m_lRecvWidth + SIZE_EDGE;
    rcRecvVid.top = rcWnd.top + SIZE_EDGE;
    rcRecvVid.bottom = rcWnd.top + m_lRecvHeight + SIZE_EDGE;
    
    MoveWindow(
        m_hRecvVideoParent,
        rcRecvVid.left,
        rcRecvVid.top,
        m_lRecvWidth,
        m_lRecvHeight,
        TRUE);

    // Resize the preview video parent window
    RECT rcPrevVid;

    rcPrevVid.left = rcRecvVid.right - m_lPrevWidth; 
    rcPrevVid.right = rcRecvVid.right;
    rcPrevVid.top = rcRecvVid.bottom - m_lPrevHeight;
    rcPrevVid.bottom = rcRecvVid.bottom;         

    MoveWindow(
        m_hPrevVideoParent,
        rcPrevVid.left,
        rcPrevVid.top,
        m_lPrevWidth,
        m_lPrevHeight,
        TRUE);

    // Update video windows
    ShowVideo(RTCVD_RECEIVE, m_fShowRecv);
    ShowVideo(RTCVD_PREVIEW, m_fShowPrev);

    // Resize the speaker text window
    RECT rcSpkText;

    rcSpkText.left = rcRecvVid.left;
    rcSpkText.right = rcRecvVid.left + m_lRecvWidth/2 - SIZE_EDGE;
    rcSpkText.top = rcRecvVid.bottom + SIZE_EDGE;
    rcSpkText.bottom = rcSpkText.top + TEXT_HEIGHT;

    MoveWindow(
        m_hSpkText,
        rcSpkText.left,
        rcSpkText.top,
        (rcSpkText.right - rcSpkText.left),
        (rcSpkText.bottom - rcSpkText.top),
        TRUE);

    // Resize the microphone text window
    RECT rcMicText;

    rcMicText.left = rcRecvVid.right - m_lRecvWidth/2 + SIZE_EDGE;
    rcMicText.right = rcRecvVid.right;
    rcMicText.top = rcRecvVid.bottom + SIZE_EDGE;
    rcMicText.bottom = rcMicText.top + TEXT_HEIGHT;

    MoveWindow(
        m_hMicText,
        rcMicText.left,
        rcMicText.top,
        (rcMicText.right - rcMicText.left),
        (rcMicText.bottom - rcMicText.top),
        TRUE);

    // Resize the speaker level window
    RECT rcSpkLevel;

    rcSpkLevel.left = rcSpkText.left;
    rcSpkLevel.right = rcSpkText.right;
    rcSpkLevel.top = rcSpkText.bottom + SIZE_EDGE;
    rcSpkLevel.bottom = rcSpkLevel.top + LEVEL_HEIGHT;

    MoveWindow(
        m_hSpkLevel,
        rcSpkLevel.left,
        rcSpkLevel.top,
        (rcSpkLevel.right - rcSpkLevel.left),
        (rcSpkLevel.bottom - rcSpkLevel.top),
        TRUE);

    // Resize the microphone level window
    RECT rcMicLevel;

    rcMicLevel.left = rcMicText.left;
    rcMicLevel.right = rcMicText.right;
    rcMicLevel.top = rcMicText.bottom + SIZE_EDGE;
    rcMicLevel.bottom = rcMicLevel.top + LEVEL_HEIGHT;

    MoveWindow(
        m_hMicLevel,
        rcMicLevel.left,
        rcMicLevel.top,
        (rcMicLevel.right - rcMicLevel.left),
        (rcMicLevel.bottom - rcMicLevel.top),
        TRUE);


    // Resize the speaker volume window
    RECT rcSpkVol;

    rcSpkVol.left = rcSpkLevel.left;
    rcSpkVol.right = rcSpkLevel.right;
    rcSpkVol.top = rcSpkLevel.bottom + SIZE_EDGE;
    rcSpkVol.bottom = rcSpkVol.top + VOL_HEIGHT;

    MoveWindow(
        m_hSpkVol,
        rcSpkVol.left,
        rcSpkVol.top,
        (rcSpkVol.right - rcSpkVol.left),
        (rcSpkVol.bottom - rcSpkVol.top),
        TRUE);

    // Resize the microphone volume window
    RECT rcMicVol;

    rcMicVol.left = rcMicLevel.left;
    rcMicVol.right = rcMicLevel.right;
    rcMicVol.top = rcMicLevel.bottom + SIZE_EDGE;
    rcMicVol.bottom = rcMicVol.top + VOL_HEIGHT;

    MoveWindow(
        m_hMicVol,
        rcMicVol.left,
        rcMicVol.top,
        (rcMicVol.right - rcMicVol.left),
        (rcMicVol.bottom - rcMicVol.top),
        TRUE);

    // Resize the speaker mute window
    RECT rcSpkMute;

    rcSpkMute.left = rcSpkVol.left;
    rcSpkMute.right = rcSpkVol.right;
    rcSpkMute.top = rcSpkVol.bottom + SIZE_EDGE;
    rcSpkMute.bottom = rcSpkMute.top + TEXT_HEIGHT;

    MoveWindow(
        m_hSpkMute,
        rcSpkMute.left,
        rcSpkMute.top,
        (rcSpkMute.right - rcSpkMute.left),
        (rcSpkMute.bottom - rcSpkMute.top),
        TRUE);

    // Resize the microphone mute window
    RECT rcMicMute;

    rcMicMute.left = rcMicVol.left;
    rcMicMute.right = rcMicVol.right;
    rcMicMute.top = rcMicVol.bottom + SIZE_EDGE;
    rcMicMute.bottom = rcMicMute.top + TEXT_HEIGHT;

    MoveWindow(
        m_hMicMute,
        rcMicMute.left,
        rcMicMute.top,
        (rcMicMute.right - rcMicMute.left),
        (rcMicMute.bottom - rcMicMute.top),
        TRUE);

    // Update the audio windows
    ShowAudio();

    return 0;
}
Exemple #7
0
void PutImage(void)
{
  /* Show rendered screen buffer */
  ShowVideo();
}