Hey Marco,

2011/12/20 Marco Faletra <m.fale...@gmail.com>:
>  I need to display an image stream from a video server that sends 4
> images sequentially (about 20 fps).
>  The best is to tell the browser: at this IP you can find the video
> server (the IP address is not the same of web server), take the image
> e show them. Unfortunately, try also without Wt, I found the
> "Cross-site scripting" and "same origin policy" problem. If someone
> know a solution I would be very grateful. Next step, if can do it,

Modern browsers support CORS (Cross-Origin Resource Sharing).

>  For this problem, a great solution, would be make a proxy-server in
> order to bypass the "same origin policy": unfortunately I don't know
> how code it with Wt.

Wt supports CORS, and can serve resources across origin. More
important for you is probably
that your source server which could server the image directly to the
browser, implements
CORS.

>  Trying to give a solution to the problem, I insert a WImage and
> refresh it every time an image arrive to Wt web server: in this manner
> I have a worst refresh (I lose about 10-15% of image) and also I need
> to refresh the whole page for "only" one image.

When you refresh a resource, like you do below, only the image is
updated though, not the whole page ?

>  m_imageResource = new Wt::WMemoryResource("image/telecamera", this);
>  m_link.setResource (m_imageResource);
>  m_telecamera = new WImage (m_link, "Telecamera1");
>
>  while, when an image arrive:
>
>  m_imageResource->setData (inStream_);
>  Wt::WApplication::UpdateLock lock(Wt::WApplication::instance());

You need to swap these two lines -- update the image resource while
holding the update lock. This should have the effect of marking the
image as dirty and a subsequent rendering will pick this up.

>  if (lock) {
>   // Push the changes to the browser
>   Wt::WApplication::instance()->triggerUpdate();
>  }

This looks good, but, you need to enableUpdates() first from within
the normal event loop (e.g. constructor).

> refresh is done, about, every 5/6 seconds.

That is the normal keep-alive logic on which the update piggy-backs.

Regards,
koen

------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create 
new or port existing apps to sell to consumers worldwide. Explore the 
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to