Video preview question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I implemented the suggestion made below and parented the window handle created by pjsip to a TPanel in my C++ Builder application.  However, I?m finding that my window parenting doesn?t work if the sender?s camera does not support the initial resolution requested by pjsip.  In the debugger, I find that my parenting code is run and doesn?t generate any errors, but no video is displayed.  If I comment the parenting code out, video is displayed in its own window.

For example, when using the H263+ codec, pjsip tries to open the camera with a resolution of 352x288. One of my test cameras only supports 320x240 or 640x480. Pjsip fails to open the camera at 352x288 and tries again with 640x480. The camera is successfully opened, but no video is displayed at the remote endpoint if my window parenting code is run. If I remove my window parenting code, the remote endpoint displays video. If both cameras support 352x288, my window parenting code works. 

Here?s my window parenting code.  It is run when the on_call_media_state callback receives a PJMEDIA_TYPE_VIDEO media type.  As I indicated above, if I comment out the three Win32 API calls (SetParent, SetWindowPos, and ShowWindow), I always see the incoming video.  If I leave these calls in, I only see the incoming video if the sending machine was able to open the camera at 352x288.  Can anyone see where I?ve made a mistake?

pjsua_call_info pjCallInfo;
pj_status_t status = pjsua_call_get_info(m_nCallID, &pjCallInfo);

if (status == PJ_SUCCESS)
{
   for (UINT i = 0; i < pjCallInfo.media_cnt; ++i)
   {
      if ((pjCallInfo.media[i].type == PJMEDIA_TYPE_VIDEO) &&
          (pjCallInfo.media[i].dir & PJMEDIA_DIR_DECODING))
      {
         pjsua_vid_win_info wi;
         status = pjsua_vid_win_get_info(pjCallInfo.media[i].stream.vid.win_in, &wi);

         if (status != PJ_SUCCESS)
         {
            TCHAR szError[PJ_ERR_MSG_SIZE];
            pj_strerror(status, szError, PJ_ERR_MSG_SIZE);

            throw uis::uis_exception(status, _T("Failed querying incoming video parameters: %s"), szError);
         }

         HWND hwndOld = ::SetParent(wi.hwnd.info.window, pnlVideo->Handle);
         if (hwndOld == NULL)
         {
            DebugMessage(_T("SetParent failed (%lu)."), ::GetLastError());
         }

         BOOL bResult = ::SetWindowPos(wi.hwnd.info.window, HWND_TOP, 4, 4, wi.size.w, wi.size.h, SWP_ASYNCWINDOWPOS);
         if (bResult == FALSE)
         {
            DebugMessage(_T("SetWindowPos failed (%lu)."), ::GetLastError());
         }

         pjsua_vid_win_set_show(pjCallInfo.media[i].stream.vid.win_in, true);

         ::ShowWindow(wi.hwnd.info.window, SW_SHOW);

         break;
      }
   }
}



From: Andreas Ahland 
Sent: Monday, November 07, 2011 11:25 AM
To: pjsip at lists.pjsip.org 
Subject: Re: Video preview question

If you get the window handle created from pjsua, you can change the owner to your delphi app and then use it as your window.

Andreas


Am 07.11.2011 19:08, schrieb Benny Prijono: 
  On Fri, Nov 4, 2011 at 10:38 PM, Jonathan Martin <jmartin at akcode.com> wrote:

    Hi,

    I?m working with pjsip 2.0 alpha 2 on Windows with Delphi.  Is it possible to somehow provide a window handle (HWND) to the video API so that it will render video preview using that window handle?  In other words, my application creates a child form and I would like pjsip?s video preview to use that form?s window handle, rather than pjsip creating it?s own video preview window.


  At the moment that's not possible. The reason is because some platforms (notably Linux, and Windows too with some things) don't allow a window created by one thread to be drawn by other thread (in this case, our video worker thread). The only portable way to do video is to do things in the same thread, which is what we do now. So I'm afraid you'll have to find a way to integrate the native window handle that we return in your app GUI, somehow. We've given the example with Qt in the vidgui sample.


  Benny




   

_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip at lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org

   

  eMail ist virenfrei.
  Von AVG ?berpr?ft - www.avg.de
  Version: 10.0.1411 / Virendatenbank: 2092/4002 - Ausgabedatum: 07.11.2011 



--------------------------------------------------------------------------------
_______________________________________________
Visit our blog: http://blog.pjsip.org

pjsip mailing list
pjsip at lists.pjsip.org
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20111111/767711b7/attachment.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux