[pjsip] bug report: SDL_CreateRenderer() assumes a non-hidden window?

Eeri Kask Eeri.Kask at mailbox.tu-dresden.de
Fri May 2 08:22:09 EDT 2014


Hello,

while experimenting with pjsua (in pjsip-app/src/pjsua/* of PJSIP
version 2.2.1) in a multicamera environment how to switch cameras during
a SIP session I discovered something which probably is a bug in SDL (1.3.0).

The problem seems to be that SDL_CreateRenderer() (in sdl_create_rend()
in "sdl_dev.c") expects a window which is not hidden (i.e. is visible on
screen).  If a hidden window is provided, then SDL-warning (or error?)
messages about 'invalid drawable' appear in floods if the experiment
given below is carried out.  (A hidden window is unavoidable if one
doesn't activate "local preview" prior to initiating a call.)

In oder to reproduce the issue one camera is enough, the "colorbar
generator" is suffient as the second capture device needed.

The 'invalid drawable'-problem by SDL is triggered even during the
initial SIP-call setup below:  while setting up TX.


Then later "vid call cap 1 1" switches from the attached optical camera
to the colorbar generator (for stream '1', capture device '1') resulting
in an endless 'invalid drawable' flood.

A fix is attached which temporarily un-hides the window while executing
SDL_CreateRenderer().  This approach has the side effect, that the
preview-window is mapped for a very short period into the middle of the
computer screen which is due to

        x = y = SDL_WINDOWPOS_CENTERED;

in sdl_create_rend().

Is there any better solution to the issue?  :-)

    Eeri Kask


========8<========8<========8<========8<========8<========

pjsua --video
m
sip:192.168.2.101


13:40:40.382    pjsua_vid.c  ......Video channel update..
13:40:40.399 vstenc0x1048aa  .......Encoder stream started
13:40:40.399 vstdec0x1048aa  .......Decoder stream started
13:40:40.399    pjsua_vid.c  .......Setting up RX..
13:40:40.399    pjsua_vid.c  ........Creating video window: type=stream,
cap_id=-1, rend_id=2
13:40:40.399     vid_port.c  .........Opening device SDL renderer [SDL]
for render: format=I420, size=256x192 @22:1 fps
13:40:40.499     vid_port.c !.........Device SDL renderer [SDL] opened:
format=I420, size=256x192 @22:1 fps
13:40:40.499    pjsua_vid.c  .........stream window id 0 created for
cap_dev=-1 rend_dev=2
13:40:40.499    pjsua_vid.c  .........Window 0 created
13:40:40.499      sdl_dev.c  ........Starting sdl video stream
13:40:40.499    pjsua_vid.c  .......Setting up TX..
13:40:40.499    pjsua_vid.c  ........Creating video window:
type=preview, cap_id=0, rend_id=2
13:40:40.499     vid_port.c  .........Opening device Camera [QT] for
capture: format=UYVY, size=160x120 @15:1 fps
13:40:40.509     vid_port.c  .........Device Camera [QT] opened:
format=UYVY, size=160x120 @15:1 fps
13:40:40.511     vid_port.c  .........Opening device SDL renderer [SDL]
for render: format=I420, size=160x120 @15:1 fps
2014-05-02 13:40:40.522 pjsua-x86_64-apple-darwin10.8.0[39589:a0f]
invalid drawable
13:40:40.527     vid_port.c  .........Device SDL renderer [SDL] opened:
format=I420, size=160x120 @15:1 fps
13:40:40.527    pjsua_vid.c  .........preview window id 1 created for
cap_dev=0 rend_dev=2
13:40:40.528    pjsua_vid.c  .........Window 1 created
13:40:40.528       qt_dev.c  ........Starting qt video stream
13:40:40.528  pjsua_media.c  ......Video updated, stream #1: H264 (sendrecv)


dq

vid call cap 1 1


13:45:52.654    pjsua_vid.c  Call 0: set video stream, op=4
13:45:52.655    pjsua_vid.c  .Creating video window: type=preview,
cap_id=1, rend_id=2
13:45:52.655     vid_port.c  ..Opening device Colorbar generator
[Colorbar] for capture: format=I420, size=160x120 @15:1 fps
13:45:52.655     vid_port.c  ..Device Colorbar generator [Colorbar]
opened: format=I420, size=160x120 @15:1 fps
13:45:52.655     vid_port.c  ..Opening device SDL renderer [SDL] for
render: format=I420, size=160x120 @15:1 fps
2014-05-02 13:45:52.668 pjsua-x86_64-apple-darwin10.8.0[39597:a0f]
invalid drawable
13:45:52.671     vid_port.c  ..Device SDL renderer [SDL] opened:
format=I420, size=160x120 @15:1 fps
13:45:52.671    pjsua_vid.c  ..preview window id 2 created for cap_dev=1
rend_dev=2
13:45:52.671    pjsua_vid.c  ..Window 2 created
13:45:52.671      sdl_dev.c  .Starting sdl video stream
13:45:52.671 colorbar_dev.c  .Starting cbar video stream
13:45:52.671    pjsua_vid.c  .Window 1: destroying..
13:45:52.694       qt_dev.c  ..Stopping qt video stream
2014-05-02 13:45:52.807 pjsua-x86_64-apple-darwin10.8.0[39597:a0f]
invalid drawable
2014-05-02 13:45:52.821 pjsua-x86_64-apple-darwin10.8.0[39597:a0f]
invalid drawable
2014-05-02 13:45:52.871 pjsua-x86_64-apple-darwin10.8.0[39597:a0f]
invalid drawable
2014-05-02 13:45:53.004 pjsua-x86_64-apple-darwin10.8.0[39597:a0f]
invalid drawable
2014-05-02 13:45:53.071 pjsua-x86_64-apple-darwin10.8.0[39597:a0f]
invalid drawable
2014-05-02 13:45:53.138 pjsua-x86_64-apple-darwin10.8.0[39597:a0f]
invalid drawable
2014-05-02 13:45:53.205 pjsua-x86_64-apple-darwin10.8.0[39597:a0f]
invalid drawable
2014-05-02 13:45:53.271 pjsua-x86_64-apple-darwin10.8.0[39597:a0f]
invalid drawable
13:45:53.318     vid_port.c !..Closing Camera..
13:45:53.318       qt_dev.c  ..Stopping qt video stream
13:45:53.319      sdl_dev.c  ..Stopping sdl video stream
13:45:53.319     vid_port.c  ..Closing SDL renderer..
13:45:53.319      sdl_dev.c  ..Stopping sdl video stream
>>> 2014-05-02 13:45:53.338 pjsua-x86_64-apple-darwin10.8.0[39597:a0f]
invalid drawable
2014-05-02 13:45:53.405 pjsua-x86_64-apple-darwin10.8.0[39597:a0f]
invalid drawable
2014-05-02 13:45:53.472 pjsua-x86_64-apple-darwin10.8.0[39597:a0f]
invalid drawable
2014-05-02 13:45:53.537 pjsua-x86_64-apple-darwin10.8.0[39597:a0f]
invalid drawable
2014-05-02 13:45:53.604 pjsua-x86_64-apple-darwin10.8.0[39597:a0f]
invalid drawable
2014-05-02 13:45:53.671 pjsua-x86_64-apple-darwin10.8.0[39597:a0f]
invalid drawable
2014-05-02 13:45:53.738 pjsua-x86_64-apple-darwin10.8.0[39597:a0f]
invalid drawable

                        [...]

q

========8<========8<========8<========8<========8<========

-------------- next part --------------
--- pjmedia/src/pjmedia-videodev/sdl_dev.c.orig	2014-05-02 08:17:33.000000000 +0200
+++ pjmedia/src/pjmedia-videodev/sdl_dev.c	2014-05-02 11:06:50.000000000 +0200
@@ -676,8 +676,9 @@
 
 static pj_status_t sdl_create_rend(struct sdl_stream * strm,
                                    pjmedia_format *fmt)
 {
+    Uint32 flags;
     sdl_fmt_info *sdl_info;
     const pjmedia_video_format_info *vfi;
     pjmedia_video_format_detail *vfd;
 
@@ -712,10 +713,9 @@
     }
 #endif /* PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL */
 
     if (!strm->window) {
-        Uint32 flags = 0;
-        
+        flags = 0;
         if (strm->param.flags & PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW_FLAGS) {
             if (!(strm->param.window_flags & PJMEDIA_VID_DEV_WND_BORDER))
                 flags |= SDL_WINDOW_BORDERLESS;
             if (strm->param.window_flags & PJMEDIA_VID_DEV_WND_RESIZABLE)
@@ -771,14 +771,21 @@
     /**
       * We must call SDL_CreateRenderer in order for draw calls to
       * affect this window.
       */
+    flags = SDL_GetWindowFlags(strm->window);
+    if (flags & SDL_WINDOW_HIDDEN)
+	SDL_ShowWindow(strm->window); /* creating renderer on hidden window results in 'invalid drawable' */
+
     strm->renderer = SDL_CreateRenderer(strm->window, -1, 0);
     if (!strm->renderer) {
 	sdl_log_err("SDL_CreateRenderer()");
         return PJMEDIA_EVID_SYSERR;
     }
 
+    if (flags & SDL_WINDOW_HIDDEN)
+	SDL_HideWindow(strm->window);
+
 #if PJMEDIA_VIDEO_DEV_SDL_HAS_OPENGL
     if (strm->param.rend_id == OPENGL_DEV_IDX) {
         strm->gl_context = SDL_GL_CreateContext(strm->window);
         if (!strm->gl_context) {


More information about the pjsip mailing list