List Info

Thread: How can I render to a "invisible" gdk window




How can I render to a "invisible" gdk window
user name
2007-12-06 00:07:50

Hi All:

I know there is some feature in dtdriver can do thumbnail, but I haven̵7;t tried it successfully.

I tried to create thumbnail in another way. That is:

1> create a player and rendering to a GDK window.

2> capture an image from the GDK window as thumbnail.

 

Now it works to some extent—if the gdk window is visible.

But when the GDK window is not visible ( move it out of the screen or covered by another window), I can’t get the image correctly.

It seems the engine stop to render to the gdk window when it is invisible.

I want to create thumbnail in the background, then how to force the engine keep rendering to the gdk window even if it is invisible.

 

Attached file is my implementation for creating thumbnail, thanks.

 

bool

tnplayer_get_thumbnail(TnPlayer* tnplayer, gchar* uri, gchar* file)

{

    int ret = 0;

    XID xid;

    PRINT_MARK;

    int i = 0,j = 0,  repeat_count = 0;

    int window_pos_x, window_pos_y, window_width, window_height, depth;

GdkWindow* pWrapForeignWindow;

    HxPlayer* thumb_nail_service = tnplayer->thumb_nail_service;

    GdkColormap* gdk_colormap = NULL;

    GdkPixbuf* gdk_pixbuf = NULL;

    GError* error = NULL;

    #define TRY_TIMES   16

 

    PRINTF("file: %sn",file);

    thumb_nail_service->bInitialized = 0;

    if(!(thumb_nail_service->window))

    {

        GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP);

        #if 1

           ; gtk_window_move(GTK_WINDOW(window), gdk_screen_width()-300,gdk_screen_height()-300);

        #else

           ; gtk_window_move(GTK_WINDOW(window), gdk_screen_width()+300,gdk_screen_height()+300);

        #endif

        GtkWidget *Draw = gtk_drawing_area_new();

        gtk_container_add(GTK_CONTAINER(window), Draw);

        gtk_widget_show_all(window);

        xid = gdk_x11_drawable_get_xid(Draw->window);

        PRINT_MARK;

        tnplayer->pWrapForeignWindow = Draw->window;

        if(tnplayer->pWrapForeignWindow)

        {

           ; PRINT_MARK;

           ; thumb_nail_service->window = g_new0(SHXClientWindow, 1);

           ; thumb_nail_service->window->display = XOpenDisplay(NULL);

           ; thumb_nail_service->window->window = (void*)xid;

           ; thumb_nail_service->clntXID = xid;

           ; thumb_nail_service->window->x = 0;

           ; thumb_nail_service->window->y = 0;

 

           ; int m_width, m_height;

           ; int x, y, depth;

           ; gdk_window_get_geometry(tnplayer->pWrapForeignWindow, &x, &y, &m_width, &m_height, &depth);

           ;

           ; thumb_nail_service->window->width = m_width;

           ; thumb_nail_service->window->height = m_height;

            thumb_nail_service->window->clipRect.left = thumb_nail_service->window->x;

           ; thumb_nail_service->window->clipRect.top = thumb_nail_service->window->y;

           ; thumb_nail_service->window->clipRect.right = thumb_nail_service->window->width;

            thumb_nail_service->window->clipRect.bottom = thumb_nail_service->window->height;

        }

        else

        {

           ; thumb_nail_service->window = NULL;

           ; return false;

        }

       

        PRINT_MARK;

       

        if(!ClientPlayerCreate(&thumb_nail_service->token, thumb_nail_service->window, thumb_nail_service, &HXCLIENT_CALLBACKS)) {

           ; PRINT_MARK;

           ; free(thumb_nail_service->window);

           ; thumb_nail_service->window = NULL;

           ; return false;

        }

 

        PRINT_MARK;

    }  ;    

 

    thumb_nail_service->bInitialized = 1;

    PRINT_MARK;

    ret = ClientPlayerOpenURL(thumb_nail_service->token,uri, NULL);

    ClientPlayerPlay(thumb_nail_service->token);

    ClientPlayerMute(thumb_nail_service->token,true);

   

    PRINT_MARK;

    tnplayer_pump(thumb_nail_service);

 

    guint length = ClientPlayerGetLength(thumb_nail_service->token);

 

 &nbsp;  for(i=0;i<;TRY_TIMES;i++)

 &nbsp;  {

 &nbsp; &nbsp; &nbsp;  if(length)

 &nbsp; &nbsp; &nbsp; &nbsp;   ; break;

 &nbsp; &nbsp; &nbsp;  tnplayer_pump(thumb_nail_service);

 &nbsp; &nbsp; &nbsp; 

 &nbsp;  }

 

 &nbsp;  PRINTF(";length: %dn",length);

 &nbsp;  guint position = 0;

 &nbsp;  guint pos_delta = 50;

 &nbsp;  if(length)

 &nbsp;  {

 &nbsp; &nbsp; &nbsp;  position = length/TRY_TIMES;

 &nbsp; &nbsp; &nbsp;  pos_delta = length/TRY_TIMES;

 &nbsp;  }

 &nbsp;  else

 &nbsp;  {

 &nbsp; &nbsp; &nbsp;  position = 0;

 &nbsp; &nbsp; &nbsp;  pos_delta = 50;

 &nbsp;  }

 &nbsp; 

 &nbsp;  PRINT_MARK;

 &nbsp;  // ClientPlayerPause(thumb_nail_service-&gt;token);

 &nbsp; 

 &nbsp;  for( repeat_count = 0; repeat_count < TRY_TIMES-1; repeat_count++)

 &nbsp;  {

 &nbsp; &nbsp; &nbsp;  PRINT_MARK;

 &nbsp; &nbsp; &nbsp;  tnplayer_pump(thumb_nail_service);

 &nbsp; &nbsp; &nbsp; 

 &nbsp; &nbsp; &nbsp;  gdk_window_get_geometry(tnplayer->pWrapForeignWindow, &window_pos_x,

 &nbsp; &nbsp; &nbsp;  &window_pos_y, &window_width, &window_height, &depth);

 &nbsp; &nbsp; &nbsp; 

 &nbsp; &nbsp; &nbsp;  gdk_colormap = gdk_drawable_get_colormap(GDK_DRAWABLE(tnplayer->pWrapForeignWindow));

 &nbsp; &nbsp; &nbsp;  if (gdk_colormap == NULL)

 &nbsp; &nbsp; &nbsp;  {

 &nbsp; &nbsp; &nbsp; &nbsp;   ; PRINTF(&quot;colormap NULLn";);

 &nbsp; &nbsp; &nbsp; &nbsp;   ; return false;

 &nbsp; &nbsp; &nbsp;  }

 

 &nbsp; &nbsp; &nbsp;  gdk_pixbuf = gdk_pixbuf_get_from_drawable(NULL, GDK_DRAWABLE(tnplayer->pWrapForeignWindow),

 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; gdk_colormap, 0, 0, 0, 0, window_width, window_height);

 &nbsp; &nbsp; &nbsp;  if (gdk_pixbuf == NULL)

 &nbsp; &nbsp; &nbsp;  {

 &nbsp; &nbsp; &nbsp; &nbsp;   ; PRINTF(&quot;pixbuf NULLn";);

 &nbsp; &nbsp; &nbsp; &nbsp;   ; return false;

 &nbsp; &nbsp; &nbsp;  }

 &nbsp; &nbsp; &nbsp; 

 &nbsp; &nbsp; &nbsp;  if (pixbuf_is_valid(gdk_pixbuf, window_width, window_height))

 &nbsp; &nbsp; &nbsp;  {

 &nbsp; &nbsp; &nbsp; &nbsp;   ; PRINTF(&quot;####valid imagen&quot;);

 &nbsp; &nbsp; &nbsp; &nbsp;   ; break;

 &nbsp; &nbsp; &nbsp;  }

 &nbsp; &nbsp; &nbsp;  else if (repeat_count == 10)

 &nbsp; &nbsp; &nbsp;  {

 &nbsp; &nbsp; &nbsp; &nbsp;   ; PRINTF(&quot;****invalid imagen&quot;);

 &nbsp; &nbsp; &nbsp; &nbsp;   ; return false;

 &nbsp; &nbsp; &nbsp;  }

 

 &nbsp; &nbsp; &nbsp;  ret = ClientPlayerSetPosition(thumb_nail_service->token,position);

 &nbsp; &nbsp; &nbsp;  position += pos_delta;

 &nbsp; &nbsp; &nbsp;  PRINTF(&quot;position:%dn",position);

 &nbsp;  }

 &nbsp; 

 &nbsp;  if (gdk_pixbuf_save(gdk_pixbuf, file, "png&quot;, &error, NULL))

 &nbsp;  {

 &nbsp; &nbsp; &nbsp;  ClientPlayerStop(thumb_nail_service->token);

 &nbsp; &nbsp; &nbsp;  return true; ; &nbsp;

 &nbsp;  }

 &nbsp;  else

 &nbsp;  {

 &nbsp; &nbsp; &nbsp;  ClientPlayerStop(thumb_nail_service->token);

 &nbsp; &nbsp; &nbsp;  return false;

 &nbsp;  }

}

 

ZHAO, Halley (Aihua)

Email: halley.zhaointel.com" title="mailto:hui.xueintel.com">intel.com

Tel: +86(21)61166476

iNet: 8821-6476

SSG/OTC/UMD

 

  
RE: How can I render to a "invisible" gdk window
user name
2007-12-06 03:57:25

Another question:

Could I get the video output buffer from CHXClientSite or CHXClientSupplier?

 

 


From: helix-client-dev-bounceshelixcommunity.org [mailto:helix-client-dev-bounceshelixcommunity.org] On Behalf Of Zhao, Halley
Sent: 2007
126 14:08
To: helix-client-devhelixcommunity.org
Subject: [Helix-client-dev] How can I render to a "invisible" gdk window

 

Hi All:

I know there is some feature in dtdriver can do thumbnail, but I haven¨t tried it successfully.

I tried to create thumbnail in another way. That is:

1> create a player and rendering to a GDK window.

2> capture an image from the GDK window as thumbnail.

 

Now it works to some extent!if the gdk window is visible.

But when the GDK window is not visible ( move it out of the screen or covered by another window), I can¨t get the image correctly.

It seems the engine stop to render to the gdk window when it is invisible.

I want to create thumbnail in the background, then how to force the engine keep rendering to the gdk window even if it is invisible.

 

Attached file is my implementation for creating thumbnail, thanks.

 

bool

tnplayer_get_thumbnail(TnPlayer* tnplayer, gchar* uri, gchar* file)

{

 &nbsp;  int ret = 0;

 &nbsp;  XID xid;

 &nbsp;  PRINT_MARK;

 &nbsp;  int i = 0,j = 0,  repeat_count = 0;

 &nbsp;  int window_pos_x, window_pos_y, window_width, window_height, depth;

GdkWindow* pWrapForeignWindow;

 &nbsp;  HxPlayer* thumb_nail_service = tnplayer-&gt;thumb_nail_service;

 &nbsp;  GdkColormap* gdk_colormap = NULL;

 &nbsp;  GdkPixbuf* gdk_pixbuf = NULL;

 &nbsp;  GError* error = NULL;

 &nbsp;  #define TRY_TIMES&nbsp;  16

 

 &nbsp;  PRINTF(&quot;file: %sn",file);

 &nbsp;  thumb_nail_service-&gt;bInitialized = 0;

 &nbsp;  if(!(thumb_nail_service->window))

 &nbsp;  {

 &nbsp; &nbsp; &nbsp;  GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP);

 &nbsp; &nbsp; &nbsp;  #if 1

 &nbsp; &nbsp; &nbsp; &nbsp;   ; gtk_window_move(GTK_WINDOW(window), gdk_screen_width()-300,gdk_screen_height()-300);

 &nbsp; &nbsp; &nbsp;  #else

 &nbsp; &nbsp; &nbsp; &nbsp;   ; gtk_window_move(GTK_WINDOW(window), gdk_screen_width()+300,gdk_screen_height()+300);

 &nbsp; &nbsp; &nbsp;  #endif

 &nbsp; &nbsp; &nbsp;  GtkWidget *Draw = gtk_drawing_area_new();

 &nbsp; &nbsp; &nbsp;  gtk_container_add(GTK_CONTAINER(window), Draw);

 &nbsp; &nbsp; &nbsp;  gtk_widget_show_all(window);

 &nbsp; &nbsp; &nbsp;  xid = gdk_x11_drawable_get_xid(Draw-&gt;window);

 &nbsp; &nbsp; &nbsp;  PRINT_MARK;

 &nbsp; &nbsp; &nbsp;  tnplayer-&gt;pWrapForeignWindow = Draw->window;

 &nbsp;  &nbsp;   ;if(tnplayer->pWrapForeignWindow)

 &nbsp; &nbsp; &nbsp;  {

 &nbsp; &nbsp; &nbsp; &nbsp;   ; PRINT_MARK;

 &nbsp; &nbsp; &nbsp; &nbsp;   ; thumb_nail_service->window = g_new0(SHXClientWindow, 1);

 &nbsp; &nbsp; &nbsp; &nbsp;   ; thumb_nail_service->window->display = XOpenDisplay(NULL);

 &nbsp; &nbsp; &nbsp; &nbsp;   ; thumb_nail_service->window->window = (void*)xid;

 &nbsp; &nbsp; &nbsp; &nbsp;   ; thumb_nail_service->clntXID = xid;

 &nbsp; &nbsp; &nbsp; &nbsp;   ; thumb_nail_service->window->x = 0;

 &nbsp; &nbsp; &nbsp; &nbsp;   ; thumb_nail_service->window->y = 0;

 

 &nbsp; &nbsp; &nbsp; &nbsp;   ; int m_width, m_height;

 &nbsp; &nbsp; &nbsp; &nbsp;   ; int x, y, depth;

 &nbsp; &nbsp; &nbsp; &nbsp;   ; gdk_window_get_geometry(tnplayer->pWrapForeignWindow, &x, &y, &amp;m_width, &m_height, &depth);

 &nbsp; &nbsp; &nbsp; &nbsp;   ;

 &nbsp; &nbsp; &nbsp; &nbsp;   ; thumb_nail_service->window->width = m_width;

 &nbsp; &nbsp; &nbsp; &nbsp;   ; thumb_nail_service->window->height = m_height;

 &nbsp; &nbsp; &nbsp; &nbsp;   &nbsp;thumb_nail_service->window->clipRect.left = thumb_nail_service->window->x;

 &nbsp; &nbsp; &nbsp; &nbsp;   ; thumb_nail_service->window->clipRect.top = thumb_nail_service->window->y;

 &nbsp; &nbsp; &nbsp; &nbsp;   ; thumb_nail_service->window->clipRect.right = thumb_nail_service->window->width;

  &nbsp; &nbsp;   ; &nbsp; &nbsp;thumb_nail_service->window->clipRect.bottom = thumb_nail_service-&gt;window-&gt;height;

 &nbsp; &nbsp; &nbsp;  }

 &nbsp; &nbsp; &nbsp;  else

 &nbsp; &nbsp; &nbsp;  {

 &nbsp; &nbsp; &nbsp; &nbsp;   ; thumb_nail_service->window = NULL;

 &nbsp; &nbsp; &nbsp; &nbsp;   ; return false;

 &nbsp; &nbsp; &nbsp;  }

 &nbsp; &nbsp; &nbsp; 

 &nbsp; &nbsp; &nbsp;  PRINT_MARK;

 &nbsp; &nbsp; &nbsp; 

 &nbsp; &nbsp; &nbsp;  if(!ClientPlayerCreate(&thumb_nail_service->token, thumb_nail_service->window, thumb_nail_service, &HXCLIENT_CALLBACKS)) {

 &nbsp; &nbsp; &nbsp; &nbsp;   ; PRINT_MARK;

 &nbsp; &nbsp; &nbsp; &nbsp;   ; free(thumb_nail_service->window);

 &nbsp; &nbsp; &nbsp; &nbsp;   ; thumb_nail_service->window = NULL;

 &nbsp; &nbsp; &nbsp; &nbsp;   ; return false;

 &nbsp; &nbsp; &nbsp;  }

 

 &nbsp; &nbsp; &nbsp;  PRINT_MARK;

 &nbsp;  }  ; &nbsp; &nbsp;

 

 &nbsp;  thumb_nail_service->bInitialized = 1;

 &nbsp;  PRINT_MARK;

 &nbsp;  ret = ClientPlayerOpenURL(thumb_nail_service-&gt;token,uri, NULL);

 &nbsp;  ClientPlayerPlay(thumb_nail_service->token);

 &nbsp;  ClientPlayerMute(thumb_nail_service->token,true);

 &nbsp; 

 &nbsp;  PRINT_MARK;

 &nbsp;  tnplayer_pump(thumb_nail_service);

 

 &nbsp;  guint length = ClientPlayerGetLength(thumb_nail_service-&gt;token);

 

 &nbsp;  for(i=0;i<;TRY_TIMES;i++)

 &nbsp;  {

 &nbsp; &nbsp; &nbsp;  if(length)

 &nbsp; &nbsp; &nbsp; &nbsp;   ; break;

 &nbsp; &nbsp; &nbsp;  tnplayer_pump(thumb_nail_service);

 &nbsp; &nbsp; &nbsp; 

 &nbsp;  }

 

 &nbsp;  PRINTF(";length: %dn",length);

 &nbsp;  guint position = 0;

 &nbsp;  guint pos_delta = 50;

 &nbsp;  if(length)

 &nbsp;  {

 &nbsp; &nbsp; &nbsp;  position = length/TRY_TIMES;

 &nbsp; &nbsp; &nbsp;  pos_delta = length/TRY_TIMES;

 &nbsp;  }

 &nbsp;  else

 &nbsp;  {

 &nbsp; &nbsp; &nbsp;  position = 0;

 &nbsp; &nbsp; &nbsp;  pos_delta = 50;

 &nbsp;  }

 &nbsp; 

 &nbsp;  PRINT_MARK;

 &nbsp;  // ClientPlayerPause(thumb_nail_service-&gt;token);

 &nbsp; 

 &nbsp;  for( repeat_count = 0; repeat_count < TRY_TIMES-1; repeat_count++)

 &nbsp;  {

 &nbsp; &nbsp; &nbsp;  PRINT_MARK;

 &nbsp; &nbsp; &nbsp;  tnplayer_pump(thumb_nail_service);

 &nbsp; &nbsp; &nbsp; 

 &nbsp; &nbsp; &nbsp;  gdk_window_get_geometry(tnplayer->pWrapForeignWindow, &window_pos_x,

 &nbsp; &nbsp; &nbsp;  &window_pos_y, &window_width, &window_height, &depth);

 &nbsp; &nbsp; &nbsp; 

 &nbsp; &nbsp; &nbsp;  gdk_colormap = gdk_drawable_get_colormap(GDK_DRAWABLE(tnplayer->;pWrapForeignWindow));

 &nbsp; &nbsp; &nbsp;  if (gdk_colormap == NULL)

 &nbsp; &nbsp; &nbsp;  {

 &nbsp; &nbsp; &nbsp; &nbsp;   ; PRINTF(&quot;colormap NULLn";);

 &nbsp; &nbsp; &nbsp; &nbsp;   ; return false;

 &nbsp; &nbsp; &nbsp;  }

 

 &nbsp; &nbsp; &nbsp;  gdk_pixbuf = gdk_pixbuf_get_from_drawable(NULL, GDK_DRAWABLE(tnplayer->pWrapForeignWindow),

 &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp; gdk_colormap, 0, 0, 0, 0, window_width, window_height);

 &nbsp; &nbsp; &nbsp;  if (gdk_pixbuf == NULL)

 &nbsp; &nbsp; &nbsp;  {

 &nbsp; &nbsp; &nbsp; &nbsp;   ; PRINTF(&quot;pixbuf NULLn";);

 &nbsp; &nbsp; &nbsp; &nbsp;   ; return false;

 &nbsp; &nbsp; &nbsp;  }

 &nbsp; &nbsp; &nbsp; 

 &nbsp; &nbsp; &nbsp;  if (pixbuf_is_valid(gdk_pixbuf, window_width, window_height))

 &nbsp; &nbsp; &nbsp;  {

 &nbsp; &nbsp; &nbsp; &nbsp;   ; PRINTF(&quot;####valid imagen&quot;);

 &nbsp; &nbsp; &nbsp; &nbsp;   ; break;

 &nbsp; &nbsp; &nbsp;  }

 &nbsp; &nbsp; &nbsp;  else if (repeat_count == 10)

 &nbsp; &nbsp; &nbsp;  {

 &nbsp; &nbsp; &nbsp; &nbsp;   ; PRINTF(&quot;****invalid imagen&quot;);

 &nbsp; &nbsp; &nbsp; &nbsp;   ; return false;

 &nbsp; &nbsp; &nbsp;  }

 

 &nbsp; &nbsp; &nbsp;  ret = ClientPlayerSetPosition(thumb_nail_service->token,position);

 &nbsp; &nbsp; &nbsp;  position += pos_delta;

 &nbsp; &nbsp; &nbsp;  PRINTF(&quot;position:%dn",position);

 &nbsp;  }

 &nbsp; 

 &nbsp;  if (gdk_pixbuf_save(gdk_pixbuf, file, "png&quot;, &error, NULL))

 &nbsp;  {

 &nbsp; &nbsp; &nbsp;  ClientPlayerStop(thumb_nail_service->token);

 &nbsp; &nbsp; &nbsp;  return true; ; &nbsp;

 &nbsp;  }

 &nbsp;  else

 &nbsp;  {

 &nbsp; &nbsp; &nbsp;  ClientPlayerStop(thumb_nail_service->token);

 &nbsp; &nbsp; &nbsp;  return false;

 &nbsp;  }

}

 

ZHAO, Halley (Aihua)

Email: halley.zhaointel.com" title="mailto:hui.xueintel.com">intel.com

Tel: +86(21)61166476

iNet: 8821-6476

SSG/OTC/UMD

 

Re: How can I render to a "invisible" gdk window
country flaguser name
United States
2007-12-06 12:29:31
Zhao, Halley wrote:
> Hi All:
> 
> I know there is some feature in dtdriver can do
thumbnail, but I haven't
> tried it successfully.
> 
> I tried to create thumbnail in another way. That is:
> 
> 1> create a player and rendering to a GDK window.
> 
> 2> capture an image from the GDK window as
thumbnail.

Have you given up on dtdrive? It does work, people are using
it. What
kind of problems did you run into?


> Now it works to some extent-if the gdk window is
visible.
> 
> But when the GDK window is not visible ( move it out of
the screen or
> covered by another window), I can't get the image
correctly.
> 
> It seems the engine stop to render to the gdk window
when it is
> invisible.
> 
> I want to create thumbnail in the background, then how
to force the
> engine keep rendering to the gdk window even if it is
invisible.
>  
> Attached file is my implementation for creating
thumbnail, thanks.


Well, if the window is hidden then its cliprect will be
empty and
nothing will be drawn. If you did get it to work, I think it
would
be fragile and might break under different window managers.
If you
have overlays on, then you will *never* get anything except
a color
square drawn to the GTK window. You can turn overlays off
and see
if it helps.

I would also look at:

     STDMETHOD(CanCapture) (THIS_ REF(HXBOOL) bCanCapture);
     STDMETHOD(Capture)    (THIS_ IHXSiteCaptureResponse*
pCaptureResponse, IHXBuffer* pCaptureBuffer,
		    		HXxSize* pOutputSize, INT32 nOutputCID);

on the site, it is used to capture a frame of video from the
site.


--greg.
> 
>  
> 
> bool
> 
> tnplayer_get_thumbnail(TnPlayer* tnplayer, gchar* uri,
gchar* file)
> 
> {
> 
>     int ret = 0;
> 
>     XID xid;
> 
>     PRINT_MARK;
> 
>     int i = 0,j = 0,  repeat_count = 0;
> 
>     int window_pos_x, window_pos_y, window_width,
window_height, depth;
> 
> GdkWindow* pWrapForeignWindow;
> 
>     HxPlayer* thumb_nail_service =
tnplayer->thumb_nail_service;
> 
>     GdkColormap* gdk_colormap = NULL;
> 
>     GdkPixbuf* gdk_pixbuf = NULL;
> 
>     GError* error = NULL;
> 
>     #define TRY_TIMES   16
> 
>  
> 
>     PRINTF("file: %sn",file);
> 
>     thumb_nail_service->bInitialized = 0;
> 
>     if(!(thumb_nail_service->window))
> 
>     {
> 
>         GtkWidget *window =
gtk_window_new(GTK_WINDOW_POPUP);
> 
>         #if 1
> 
>             gtk_window_move(GTK_WINDOW(window),
> gdk_screen_width()-300,gdk_screen_height()-300);
> 
>         #else
> 
>             gtk_window_move(GTK_WINDOW(window),
> gdk_screen_width()+300,gdk_screen_height()+300);
> 
>         #endif
> 
>         GtkWidget *Draw = gtk_drawing_area_new();
> 
>         gtk_container_add(GTK_CONTAINER(window),
Draw);
> 
>         gtk_widget_show_all(window);
> 
>         xid =
gdk_x11_drawable_get_xid(Draw->window);
> 
>         PRINT_MARK;
> 
>         tnplayer->pWrapForeignWindow =
Draw->window;
> 
>         if(tnplayer->pWrapForeignWindow)
> 
>         {
> 
>             PRINT_MARK;
> 
>             thumb_nail_service->window =
g_new0(SHXClientWindow, 1);
> 
>             thumb_nail_service->window->display =
XOpenDisplay(NULL);
> 
>             thumb_nail_service->window->window =
(void*)xid;
> 
>             thumb_nail_service->clntXID = xid;
> 
>             thumb_nail_service->window->x = 0;
> 
>             thumb_nail_service->window->y = 0;
> 
>  
> 
>             int m_width, m_height;
> 
>             int x, y, depth;
> 
>            
gdk_window_get_geometry(tnplayer->pWrapForeignWindow,
&x,
> &y, &m_width, &m_height, &depth);
> 
>             
> 
>             thumb_nail_service->window->width =
m_width; 
> 
>             thumb_nail_service->window->height =
m_height;
> 
>            
thumb_nail_service->window->clipRect.left =
> thumb_nail_service->window->x;
> 
>            
thumb_nail_service->window->clipRect.top =
> thumb_nail_service->window->y;
> 
>            
thumb_nail_service->window->clipRect.right =
> thumb_nail_service->window->width;
> 
>            
thumb_nail_service->window->clipRect.bottom =
> thumb_nail_service->window->height;
> 
>         }
> 
>         else
> 
>         {
> 
>             thumb_nail_service->window = NULL;
> 
>             return false;
> 
>         }
> 
>         
> 
>         PRINT_MARK;
> 
>         
> 
>        
if(!ClientPlayerCreate(&thumb_nail_service->token,
> thumb_nail_service->window, thumb_nail_service,
&HXCLIENT_CALLBACKS)) {
> 
>             PRINT_MARK;
> 
>             free(thumb_nail_service->window);
> 
>             thumb_nail_service->window = NULL;
> 
>             return false;
> 
>         }
> 
>  
> 
>         PRINT_MARK;
> 
>     }       
> 
>  
> 
>     thumb_nail_service->bInitialized = 1;
> 
>     PRINT_MARK;
> 
>     ret =
ClientPlayerOpenURL(thumb_nail_service->token,uri,
NULL);
> 
>     ClientPlayerPlay(thumb_nail_service->token);
> 
>    
ClientPlayerMute(thumb_nail_service->token,true);
> 
>     
> 
>     PRINT_MARK;
> 
>     tnplayer_pump(thumb_nail_service);
> 
>  
> 
>     guint length =
ClientPlayerGetLength(thumb_nail_service->token);
> 
>  
> 
>     for(i=0;i<TRY_TIMES;i++)
> 
>     {
> 
>         if(length)
> 
>             break;
> 
>         tnplayer_pump(thumb_nail_service);
> 
>         
> 
>     }
> 
>  
> 
>     PRINTF("length: %dn",length);
> 
>     guint position = 0;
> 
>     guint pos_delta = 50;
> 
>     if(length)
> 
>     {
> 
>         position = length/TRY_TIMES;
> 
>         pos_delta = length/TRY_TIMES;
> 
>     }
> 
>     else
> 
>     {
> 
>         position = 0;
> 
>         pos_delta = 50;
> 
>     }
> 
>     
> 
>     PRINT_MARK;
> 
>     //
ClientPlayerPause(thumb_nail_service->token);
> 
>     
> 
>     for( repeat_count = 0; repeat_count <
TRY_TIMES-1; repeat_count++)
> 
>     {
> 
>         PRINT_MARK;
> 
>         tnplayer_pump(thumb_nail_service);
> 
>         
> 
>        
gdk_window_get_geometry(tnplayer->pWrapForeignWindow,
> &window_pos_x, 
> 
>         &window_pos_y, &window_width,
&window_height, &depth);
> 
>         
> 
>         gdk_colormap =
>
gdk_drawable_get_colormap(GDK_DRAWABLE(tnplayer->pWrapFor
eignWindow));
> 
>         if (gdk_colormap == NULL)
> 
>         {
> 
>             PRINTF("colormap NULLn");
> 
>             return false;
> 
>         }
> 
>  
> 
>         gdk_pixbuf =
gdk_pixbuf_get_from_drawable(NULL,
> GDK_DRAWABLE(tnplayer->pWrapForeignWindow),
> 
>                                     gdk_colormap, 0, 0,
0, 0,
> window_width, window_height);
> 
>         if (gdk_pixbuf == NULL)
> 
>         {
> 
>             PRINTF("pixbuf NULLn");
> 
>             return false;
> 
>         }
> 
>         
> 
>         if (pixbuf_is_valid(gdk_pixbuf, window_width,
window_height))
> 
>         {
> 
>             PRINTF("####valid imagen");
> 
>             break;
> 
>         }
> 
>         else if (repeat_count == 10)
> 
>         {
> 
>             PRINTF("****invalid imagen");
> 
>             return false;
> 
>         }
> 
>  
> 
>         ret =
>
ClientPlayerSetPosition(thumb_nail_service->token,positio
n);
> 
>         position += pos_delta;
> 
>         PRINTF("position:%dn",position);
> 
>     }
> 
>     
> 
>     if (gdk_pixbuf_save(gdk_pixbuf, file,
"png", &error, NULL))
> 
>     {
> 
>        
ClientPlayerStop(thumb_nail_service->token);
> 
>         return true;    
> 
>     }
> 
>     else
> 
>     {
> 
>        
ClientPlayerStop(thumb_nail_service->token);
> 
>         return false;
> 
>     }
> 
> }
> 
>  
> 
> ZHAO, Halley (Aihua)
> 
> Email: halley.zhaointel.com <mailto:aihua.zhaointel.com> 
> 
> Tel: +86(21)61166476
> 
> iNet: 8821-6476
> 
> SSG/OTC/UMD
> 
>  
> 


_______________________________________________
Helix-client-dev mailing list
Helix-client-devhelixcommunity.org
http://lists.helixcommunity.org/mailman/listinf
o/helix-client-dev

RE: How can I render to a "invisible" gdk window
user name
2007-12-07 02:22:54
  
  Great thanks.
  Finally I make it done by
  XCompositeRedirectSubwindows(m_dpy,win,CompositeRedirect
Manual);
  
  Then even if the window is out of screen, it can still
be rendered.
  
  >-----Original Message-----
  >From: Greg Wright [mailto:gwrightreal.com]
  >Sent: 2007定12埖7晩 2:30
  >To: Zhao, Halley
  >Cc: helix-client-devhelixcommunity.org
  >Subject: Re: How can I render to a
"invisible" gdk window
  >
  >Zhao, Halley wrote:
  >> Hi All:
  >>
  >> I know there is some feature in dtdriver can do
thumbnail, but I haven't
  >> tried it successfully.
  >>
  >> I tried to create thumbnail in another way.
That is:
  >>
  >> 1> create a player and rendering to a GDK
window.
  >>
  >> 2> capture an image from the GDK window as
thumbnail.
  >
  >Have you given up on dtdrive? It does work, people
are using it. What
  >kind of problems did you run into?
  >
  >
  >> Now it works to some extent-if the gdk window
is visible.
  >>
  >> But when the GDK window is not visible ( move
it out of the screen or
  >> covered by another window), I can't get the
image correctly.
  >>
  >> It seems the engine stop to render to the gdk
window when it is
  >> invisible.
  >>
  >> I want to create thumbnail in the background,
then how to force the
  >> engine keep rendering to the gdk window even if
it is invisible.
  >>
  >> Attached file is my implementation for creating
thumbnail, thanks.
  >
  >
  >Well, if the window is hidden then its cliprect will
be empty and
  >nothing will be drawn. If you did get it to work, I
think it would
  >be fragile and might break under different window
managers. If you
  >have overlays on, then you will *never* get anything
except a color
  >square drawn to the GTK window. You can turn
overlays off and see
  >if it helps.
  >
  >I would also look at:
  >
  >     STDMETHOD(CanCapture) (THIS_ REF(HXBOOL)
bCanCapture);
  >     STDMETHOD(Capture)    (THIS_
IHXSiteCaptureResponse*
  >pCaptureResponse, IHXBuffer* pCaptureBuffer,
  >		    		HXxSize* pOutputSize, INT32 nOutputCID);
  >
  >on the site, it is used to capture a frame of video
from the site.
  >
  >
  >--greg.
  >>
  >>
  >>
  >> bool
  >>
  >> tnplayer_get_thumbnail(TnPlayer* tnplayer,
gchar* uri, gchar* file)
  >>
  >> {
  >>
  >>     int ret = 0;
  >>
  >>     XID xid;
  >>
  >>     PRINT_MARK;
  >>
  >>     int i = 0,j = 0,  repeat_count = 0;
  >>
  >>     int window_pos_x, window_pos_y,
window_width, window_height, depth;
  >>
  >> GdkWindow* pWrapForeignWindow;
  >>
  >>     HxPlayer* thumb_nail_service =
tnplayer->thumb_nail_service;
  >>
  >>     GdkColormap* gdk_colormap = NULL;
  >>
  >>     GdkPixbuf* gdk_pixbuf = NULL;
  >>
  >>     GError* error = NULL;
  >>
  >>     #define TRY_TIMES   16
  >>
  >>
  >>
  >>     PRINTF("file: %sn",file);
  >>
  >>     thumb_nail_service->bInitialized = 0;
  >>
  >>     if(!(thumb_nail_service->window))
  >>
  >>     {
  >>
  >>         GtkWidget *window =
gtk_window_new(GTK_WINDOW_POPUP);
  >>
  >>         #if 1
  >>
  >>            
gtk_window_move(GTK_WINDOW(window),
  >>
gdk_screen_width()-300,gdk_screen_height()-300);
  >>
  >>         #else
  >>
  >>            
gtk_window_move(GTK_WINDOW(window),
  >>
gdk_screen_width()+300,gdk_screen_height()+300);
  >>
  >>         #endif
  >>
  >>         GtkWidget *Draw =
gtk_drawing_area_new();
  >>
  >>        
gtk_container_add(GTK_CONTAINER(window), Draw);
  >>
  >>         gtk_widget_show_all(window);
  >>
  >>         xid =
gdk_x11_drawable_get_xid(Draw->window);
  >>
  >>         PRINT_MARK;
  >>
  >>         tnplayer->pWrapForeignWindow =
Draw->window;
  >>
  >>         if(tnplayer->pWrapForeignWindow)
  >>
  >>         {
  >>
  >>             PRINT_MARK;
  >>
  >>             thumb_nail_service->window =
g_new0(SHXClientWindow, 1);
  >>
  >>            
thumb_nail_service->window->display =
XOpenDisplay(NULL);
  >>
  >>            
thumb_nail_service->window->window = (void*)xid;
  >>
  >>             thumb_nail_service->clntXID =
xid;
  >>
  >>             thumb_nail_service->window->x
= 0;
  >>
  >>             thumb_nail_service->window->y
= 0;
  >>
  >>
  >>
  >>             int m_width, m_height;
  >>
  >>             int x, y, depth;
  >>
  >>            
gdk_window_get_geometry(tnplayer->pWrapForeignWindow,
&x,
  >> &y, &m_width, &m_height,
&depth);
  >>
  >>
  >>
  >>            
thumb_nail_service->window->width = m_width;
  >>
  >>            
thumb_nail_service->window->height = m_height;
  >>
  >>            
thumb_nail_service->window->clipRect.left =
  >> thumb_nail_service->window->x;
  >>
  >>            
thumb_nail_service->window->clipRect.top =
  >> thumb_nail_service->window->y;
  >>
  >>            
thumb_nail_service->window->clipRect.right =
  >> thumb_nail_service->window->width;
  >>
  >>            
thumb_nail_service->window->clipRect.bottom =
  >> thumb_nail_service->window->height;
  >>
  >>         }
  >>
  >>         else
  >>
  >>         {
  >>
  >>             thumb_nail_service->window =
NULL;
  >>
  >>             return false;
  >>
  >>         }
  >>
  >>
  >>
  >>         PRINT_MARK;
  >>
  >>
  >>
  >>        
if(!ClientPlayerCreate(&thumb_nail_service->token,
  >> thumb_nail_service->window,
thumb_nail_service, &HXCLIENT_CALLBACKS)) {
  >>
  >>             PRINT_MARK;
  >>
  >>            
free(thumb_nail_service->window);
  >>
  >>             thumb_nail_service->window =
NULL;
  >>
  >>             return false;
  >>
  >>         }
  >>
  >>
  >>
  >>         PRINT_MARK;
  >>
  >>     }
  >>
  >>
  >>
  >>     thumb_nail_service->bInitialized = 1;
  >>
  >>     PRINT_MARK;
  >>
  >>     ret =
ClientPlayerOpenURL(thumb_nail_service->token,uri,
NULL);
  >>
  >>    
ClientPlayerPlay(thumb_nail_service->token);
  >>
  >>    
ClientPlayerMute(thumb_nail_service->token,true);
  >>
  >>
  >>
  >>     PRINT_MARK;
  >>
  >>     tnplayer_pump(thumb_nail_service);
  >>
  >>
  >>
  >>     guint length =
ClientPlayerGetLength(thumb_nail_service->token);
  >>
  >>
  >>
  >>     for(i=0;i<TRY_TIMES;i++)
  >>
  >>     {
  >>
  >>         if(length)
  >>
  >>             break;
  >>
  >>         tnplayer_pump(thumb_nail_service);
  >>
  >>
  >>
  >>     }
  >>
  >>
  >>
  >>     PRINTF("length: %dn",length);
  >>
  >>     guint position = 0;
  >>
  >>     guint pos_delta = 50;
  >>
  >>     if(length)
  >>
  >>     {
  >>
  >>         position = length/TRY_TIMES;
  >>
  >>         pos_delta = length/TRY_TIMES;
  >>
  >>     }
  >>
  >>     else
  >>
  >>     {
  >>
  >>         position = 0;
  >>
  >>         pos_delta = 50;
  >>
  >>     }
  >>
  >>
  >>
  >>     PRINT_MARK;
  >>
  >>     //
ClientPlayerPause(thumb_nail_service->token);
  >>
  >>
  >>
  >>     for( repeat_count = 0; repeat_count <
TRY_TIMES-1; repeat_count++)
  >>
  >>     {
  >>
  >>         PRINT_MARK;
  >>
  >>         tnplayer_pump(thumb_nail_service);
  >>
  >>
  >>
  >>        
gdk_window_get_geometry(tnplayer->pWrapForeignWindow,
  >> &window_pos_x, 
  >>
  >>         &window_pos_y, &window_width,
&window_height, &depth);
  >>
  >>
  >>
  >>         gdk_colormap =
  >>
  >gdk_drawable_get_colormap(GDK_DRAWABLE(tnplayer->
pWrapForeignWindow));
  >>
  >>         if (gdk_colormap == NULL)
  >>
  >>         {
  >>
  >>             PRINTF("colormap
NULLn");
  >>
  >>             return false;
  >>
  >>         }
  >>
  >>
  >>
  >>         gdk_pixbuf =
gdk_pixbuf_get_from_drawable(NULL,
  >>
GDK_DRAWABLE(tnplayer->pWrapForeignWindow),
  >>
  >>                                    
gdk_colormap, 0, 0, 0, 0,
  >> window_width, window_height);
  >>
  >>         if (gdk_pixbuf == NULL)
  >>
  >>         {
  >>
  >>             PRINTF("pixbuf NULLn");
  >>
  >>             return false;
  >>
  >>         }
  >>
  >>
  >>
  >>         if (pixbuf_is_valid(gdk_pixbuf,
window_width, window_height))
  >>
  >>         {
  >>
  >>             PRINTF("####valid
imagen");
  >>
  >>             break;
  >>
  >>         }
  >>
  >>         else if (repeat_count == 10)
  >>
  >>         {
  >>
  >>             PRINTF("****invalid
imagen");
  >>
  >>             return false;
  >>
  >>         }
  >>
  >>
  >>
  >>         ret =
  >>
ClientPlayerSetPosition(thumb_nail_service->token,positio
n);
  >>
  >>         position += pos_delta;
  >>
  >>        
PRINTF("position:%dn",position);
  >>
  >>     }
  >>
  >>
  >>
  >>     if (gdk_pixbuf_save(gdk_pixbuf, file,
"png", &error, NULL))
  >>
  >>     {
  >>
  >>        
ClientPlayerStop(thumb_nail_service->token);
  >>
  >>         return true;
  >>
  >>     }
  >>
  >>     else
  >>
  >>     {
  >>
  >>        
ClientPlayerStop(thumb_nail_service->token);
  >>
  >>         return false;
  >>
  >>     }
  >>
  >> }
  >>
  >>
  >>
  >> ZHAO, Halley (Aihua)
  >>
  >> Email: halley.zhaointel.com
<mailto:aihua.zhaointel.com>
  >>
  >> Tel: +86(21)61166476
  >>
  >> iNet: 8821-6476
  >>
  >> SSG/OTC/UMD
  >>
  >>
  >>

_______________________________________________
Helix-client-dev mailing list
Helix-client-devhelixcommunity.org
http://lists.helixcommunity.org/mailman/listinf
o/helix-client-dev

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )