Re: motion jpeg and wicket
Hello The complex way of solving your problem would be by means of an IRequestHandler and an IRequestMapper. I use this same system to generate JSON responses in my projects without the need of using another servlet thus sharing all of my wicket Session security information. Your IRequestHandler should proxy the WebCam output to your response in a way similar to this: public void respond(IRequestCycle requestCycle) { //Send bytes to the response you would need to gather your bytes first requestCycle.getResponse().write(/* bytes*/); //Get direct acces to outputStream so you can send bytes without holding them in memory... requestCycle.getResponse().getOutputStream(); //This may also be useful if (requestCycle.getResponse() instanceof WebResponse) { ((WebResponse) requestCycle.getResponse()).setContentType(YOUR/MIME/TYPE; charset=YOUR-CONTENT-ENCODING); } } Then you should program some kind of IRequestMapper that will handle your Requests and return your custom IRequestHandler. Regards -- Marc Nuri www.marcnuri.com On Fri, Jan 11, 2013 at 11:19 PM, Martin Grigorov mgrigo...@apache.orgwrote: You may try to push the updates with Atmosphere/Native WebSockets. Also see https://github.com/videlalvaro/gifsockets. May be useful for you. On Sat, Jan 12, 2013 at 12:14 AM, Decebal Suiu decebal.s...@asf.ro wrote: Hi @Marc Implementation using AjaxSelfUpdatingTimerBehavior is better that nothing, it's quick and dirty but it's not scalable. Think at some webcams on the same page with a FPS (frame per second) around 5. @Ernesto Cabzola has a streamer based on multipart/x-mixed-replace mime type but it uses a SocketServer to servers the clients and I want to use my servlet container that host my wicket application. I can use mjpg-streamer [1] or motion [2] to achieve the same functionality but I don't want to install additional software on my machine. Also I can write a StreamerServlet that serves requests related to motion jpeg but my idea is to use the security, page parameters from my wicket application. For example on http://webcamapp/webcam?fps=2webcamId=1request I want to have the freedom to response with a multipart/x-mixed-replace mime type and writing my image bytes on response.getOutputStream(); I want here to do what I must do in a StreamerServlet [3] . Is it possible to have access completely to http response from wicket? Must I use a mapper or a bookmarkable page? Does my idea make sense? Another idea of mine is to use websocket (I want to explore more on this field :)) but I don't know if it's recommended for my scenario. [1] http://sourceforge.net/projects/mjpg-streamer/ [2] http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome [3] out.writeBytes(Content-Type: multipart/x-mixed-replace;boundary= + BOUNDARY + \r\n); out.writeBytes(\r\n); out.writeBytes(-- + BOUNDARY + \n); byte[] imageBytes = ... ; while (true) { out.writeBytes(Content-type: image/jpeg\n\n); out.write(imageBytes); // pseudo code out.writeBytes(-- + BOUNDARY + \n); out.flush(); Thread.sleep(500); } Best regards, Decebal -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/motion-jpeg-and-wicket-tp4655294p4655309.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com http://jweekend.com/
Re: motion jpeg and wicket
On Mon, Jan 14, 2013 at 11:23 AM, Ernesto Reinaldo Barreiro reier...@gmail.com wrote: Marc, You could still use another servlet and have access to wicket session via WicketSessionFilter. Or use #mountReference(new MyResourceReference()) with MyIResourceImpl(). On Mon, Jan 14, 2013 at 10:12 AM, Marc Nuri San Félix m...@marcnuri.com wrote: Hello The complex way of solving your problem would be by means of an IRequestHandler and an IRequestMapper. I use this same system to generate JSON responses in my projects without the need of using another servlet thus sharing all of my wicket Session security information. Your IRequestHandler should proxy the WebCam output to your response in a way similar to this: public void respond(IRequestCycle requestCycle) { //Send bytes to the response you would need to gather your bytes first requestCycle.getResponse().write(/* bytes*/); //Get direct acces to outputStream so you can send bytes without holding them in memory... requestCycle.getResponse().getOutputStream(); //This may also be useful if (requestCycle.getResponse() instanceof WebResponse) { ((WebResponse) requestCycle.getResponse()).setContentType(YOUR/MIME/TYPE; charset=YOUR-CONTENT-ENCODING); } } Then you should program some kind of IRequestMapper that will handle your Requests and return your custom IRequestHandler. Regards -- Marc Nuri www.marcnuri.com On Fri, Jan 11, 2013 at 11:19 PM, Martin Grigorov mgrigo...@apache.org wrote: You may try to push the updates with Atmosphere/Native WebSockets. Also see https://github.com/videlalvaro/gifsockets. May be useful for you. On Sat, Jan 12, 2013 at 12:14 AM, Decebal Suiu decebal.s...@asf.ro wrote: Hi @Marc Implementation using AjaxSelfUpdatingTimerBehavior is better that nothing, it's quick and dirty but it's not scalable. Think at some webcams on the same page with a FPS (frame per second) around 5. @Ernesto Cabzola has a streamer based on multipart/x-mixed-replace mime type but it uses a SocketServer to servers the clients and I want to use my servlet container that host my wicket application. I can use mjpg-streamer [1] or motion [2] to achieve the same functionality but I don't want to install additional software on my machine. Also I can write a StreamerServlet that serves requests related to motion jpeg but my idea is to use the security, page parameters from my wicket application. For example on http://webcamapp/webcam?fps=2webcamId=1request I want to have the freedom to response with a multipart/x-mixed-replace mime type and writing my image bytes on response.getOutputStream(); I want here to do what I must do in a StreamerServlet [3] . Is it possible to have access completely to http response from wicket? Must I use a mapper or a bookmarkable page? Does my idea make sense? Another idea of mine is to use websocket (I want to explore more on this field :)) but I don't know if it's recommended for my scenario. [1] http://sourceforge.net/projects/mjpg-streamer/ [2] http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome [3] out.writeBytes(Content-Type: multipart/x-mixed-replace;boundary= + BOUNDARY + \r\n); out.writeBytes(\r\n); out.writeBytes(-- + BOUNDARY + \n); byte[] imageBytes = ... ; while (true) { out.writeBytes(Content-type: image/jpeg\n\n); out.write(imageBytes); // pseudo code out.writeBytes(-- + BOUNDARY + \n); out.flush(); Thread.sleep(500); } Best regards, Decebal -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/motion-jpeg-and-wicket-tp4655294p4655309.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com http://jweekend.com/ -- Regards - Ernesto Reinaldo Barreiro Antilia Soft http://antiliasoft.com/ http://antiliasoft.com/antilia -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com http://jweekend.com/
Re: motion jpeg and wicket
Hi Marc Thanks for response. A custom Mapper with a RequestHandler that do my job was one of ideas but onRespond I must implement a while loop and I know if it's ok. For example: public void respond(IRequestCycle requestCycle) { // se content type to multipart/x-mixed-replace;boundary=myboundry // set no cache // send grab images while (!stop) { // send next images // sleep some milliseconds related to FPS (frames on second) } } A solution is to use an external servlet that handles request related to webcam or a wicket push technic. For me, wicket is a (nice) hammer on web development and the problem is that I intend to resolve all problems this hammer :) Best regards, Decebal -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/motion-jpeg-and-wicket-tp4655294p4655340.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: motion jpeg and wicket
Ernesto I prefer to have all my URL mappings centralized, so I try to use the Wicket way where available. Although it's interesting to know that you can access wicket Session this way. What I'd really do is try to proxy/tunnel the stream directly from the webcam to the client using an appropriate format once I've checked the request is from an identified client. This would be the most memory efficient way. I suppose that if the webcam offers some kind of streamable video format (instead of buffered images), you could forward the response output from the webcam to the client. This way the client would make a single request to your wicket server and cpu and memory usage would be minimized. Regards -- Marc Nuri www.marcnuri.com On Mon, Jan 14, 2013 at 10:30 AM, Decebal Suiu decebal.s...@asf.ro wrote: Hi Marc Thanks for response. A custom Mapper with a RequestHandler that do my job was one of ideas but onRespond I must implement a while loop and I know if it's ok. For example: public void respond(IRequestCycle requestCycle) { // se content type to multipart/x-mixed-replace;boundary=myboundry // set no cache // send grab images while (!stop) { // send next images // sleep some milliseconds related to FPS (frames on second) } } A solution is to use an external servlet that handles request related to webcam or a wicket push technic. For me, wicket is a (nice) hammer on web development and the problem is that I intend to resolve all problems this hammer :) Best regards, Decebal -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/motion-jpeg-and-wicket-tp4655294p4655340.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: motion jpeg and wicket
Hello This is not a motion jpeg, but it can be used to accomplish your needs without major complications You can create a Panel with an image that replaces the image every time it renders overriding the onBeforeRender method: addOrReplace(new Image(image, new BufferedDynamicImageResource(image))) and add AjaxSelfUpdatingTimerBehavior to the Panel with the specified refresh rate. I believe this is the easiest and most straightforward way of doing what you need. Cheers -- Marc Nuri www.marcnuri.com On Fri, Jan 11, 2013 at 4:19 PM, Decebal Suiu decebal.s...@asf.ro wrote: Hi Is it possible to implement a motion jpeg in wicket [1]. I want to implement a webcam viewer in wicket. I have a library that give me BufferedImage(s) from a webcam. Now I can display an BufferedImage in wicket but I want to move to the next level. I see two option: --- Implement M-JPEG over HTTP HTTP streaming separates each image into individual HTTP replies on a specified marker. RTP streaming creates packets of a sequence of JPEG images that can be received by clients such as QuickTime or VLC. In response to a GET request for a MJPEG file or stream, the server streams the sequence of JPEG frames over HTTP. A special mime-type content type multipart/x-mixed-replace;boundary=boundary-name informs the client to expect several parts (frames) as an answer delimited by boundary-name. This boundary name is expressly disclosed within the MIME-type declaration itself. The TCP connection is not closed as long as the client wants to receive new frames and the server wants to provide new frames. --- I can use wicket 6.x websocket (atmosphere or native) to push the next image frame to wicket component. See you another approach? Any advice is welcome. [1] http://en.wikipedia.org/wiki/Motion_JPEG Best regards, Decebal -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/motion-jpeg-and-wicket-tp4655294.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: motion jpeg and wicket
Hi, On Fri, Jan 11, 2013 at 4:19 PM, Decebal Suiu decebal.s...@asf.ro wrote: Hi Is it possible to implement a motion jpeg in wicket [1]. I want to implement a webcam viewer in wicket. I have a library that give me BufferedImage(s) from a webcam. Now I can display an BufferedImage in wicket but I want to move to the next level. I see two option: --- Implement M-JPEG over HTTP HTTP streaming separates each image into individual HTTP replies on a specified marker. RTP streaming creates packets of a sequence of JPEG images that can be received by clients such as QuickTime or VLC. In response to a GET request for a MJPEG file or stream, the server streams the sequence of JPEG frames over HTTP. A special mime-type content type multipart/x-mixed-replace;boundary=boundary-name informs the client to expect several parts (frames) as an answer delimited by boundary-name. This boundary name is expressly disclosed within the MIME-type declaration itself. The TCP connection is not closed as long as the client wants to receive new frames and the server wants to provide new frames. --- I can use wicket 6.x websocket (atmosphere or native) to push the next image frame to wicket component. See you another approach? Any advice is welcome. Isn't http://www.charliemouse.com/code/cambozola/ suitable for your needs? -- Regards - Ernesto Reinaldo Barreiro Antilia Soft http://antiliasoft.com/ http://antiliasoft.com/antilia
Re: motion jpeg and wicket
Hi @Marc Implementation using AjaxSelfUpdatingTimerBehavior is better that nothing, it's quick and dirty but it's not scalable. Think at some webcams on the same page with a FPS (frame per second) around 5. @Ernesto Cabzola has a streamer based on multipart/x-mixed-replace mime type but it uses a SocketServer to servers the clients and I want to use my servlet container that host my wicket application. I can use mjpg-streamer [1] or motion [2] to achieve the same functionality but I don't want to install additional software on my machine. Also I can write a StreamerServlet that serves requests related to motion jpeg but my idea is to use the security, page parameters from my wicket application. For example on http://webcamapp/webcam?fps=2webcamId=1 request I want to have the freedom to response with a multipart/x-mixed-replace mime type and writing my image bytes on response.getOutputStream(); I want here to do what I must do in a StreamerServlet [3] . Is it possible to have access completely to http response from wicket? Must I use a mapper or a bookmarkable page? Does my idea make sense? Another idea of mine is to use websocket (I want to explore more on this field :)) but I don't know if it's recommended for my scenario. [1] http://sourceforge.net/projects/mjpg-streamer/ [2] http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome [3] out.writeBytes(Content-Type: multipart/x-mixed-replace;boundary= + BOUNDARY + \r\n); out.writeBytes(\r\n); out.writeBytes(-- + BOUNDARY + \n); byte[] imageBytes = ... ; while (true) { out.writeBytes(Content-type: image/jpeg\n\n); out.write(imageBytes); // pseudo code out.writeBytes(-- + BOUNDARY + \n); out.flush(); Thread.sleep(500); } Best regards, Decebal -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/motion-jpeg-and-wicket-tp4655294p4655309.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: motion jpeg and wicket
You may try to push the updates with Atmosphere/Native WebSockets. Also see https://github.com/videlalvaro/gifsockets. May be useful for you. On Sat, Jan 12, 2013 at 12:14 AM, Decebal Suiu decebal.s...@asf.ro wrote: Hi @Marc Implementation using AjaxSelfUpdatingTimerBehavior is better that nothing, it's quick and dirty but it's not scalable. Think at some webcams on the same page with a FPS (frame per second) around 5. @Ernesto Cabzola has a streamer based on multipart/x-mixed-replace mime type but it uses a SocketServer to servers the clients and I want to use my servlet container that host my wicket application. I can use mjpg-streamer [1] or motion [2] to achieve the same functionality but I don't want to install additional software on my machine. Also I can write a StreamerServlet that serves requests related to motion jpeg but my idea is to use the security, page parameters from my wicket application. For example on http://webcamapp/webcam?fps=2webcamId=1request I want to have the freedom to response with a multipart/x-mixed-replace mime type and writing my image bytes on response.getOutputStream(); I want here to do what I must do in a StreamerServlet [3] . Is it possible to have access completely to http response from wicket? Must I use a mapper or a bookmarkable page? Does my idea make sense? Another idea of mine is to use websocket (I want to explore more on this field :)) but I don't know if it's recommended for my scenario. [1] http://sourceforge.net/projects/mjpg-streamer/ [2] http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome [3] out.writeBytes(Content-Type: multipart/x-mixed-replace;boundary= + BOUNDARY + \r\n); out.writeBytes(\r\n); out.writeBytes(-- + BOUNDARY + \n); byte[] imageBytes = ... ; while (true) { out.writeBytes(Content-type: image/jpeg\n\n); out.write(imageBytes); // pseudo code out.writeBytes(-- + BOUNDARY + \n); out.flush(); Thread.sleep(500); } Best regards, Decebal -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/motion-jpeg-and-wicket-tp4655294p4655309.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com http://jweekend.com/