How can Tomcat and Media Servers work together? - java

I am planning on building a Java web app that will have lots of integrated video (original content) being streamed from our backend. I'm having a difficult time seeing the forest through the trees: I want all non-media, client-side content (HTML, CSS, JS, etc.) to be served from my Tomcat server, but I want the media content (videos) to be served from an actual media server like Red5 or Wowza.
So my problem is: on the backend, how do you make 1 request for http://myapp.example.org/videos/vid2449 return content from 2 servers (Tomcat and the media server)?

You can also serve the two things on two different ports
Web page generated from http://yourserver.com/videos returns
<html>
Link to stream
<!-- or you can embed a player and feed it
</html>

Req #1 returns stuff for views etc from TC. This response includes ffollowing
Link on where to get media meta data bound to that session/request. A collection of playables
Link on where to get a session Mgr player
JS on client does follow with response
Bootstrap player
Marshall media info is links to streams
Bootstrap wrapper for player state ( Idle Paused PLaying Buffering )
Start player on a stream from list of links which will require a second network connection ( http stream )
Manage player state
Manage socket stream
Manage player ui controls events
Player callbacks
--EDIT--
if your media is self hosted as opposed to coming from the cloud, you can use apache 'ajp' connectors or whatever and have single server running Apache in front of the connectors and infront of TC. Apache will stream the static media files while TC handles other stuff and it all runs from the some domain host.

You didn't specify the type of media being served except in one comment you mention m3u8 which indicates HLS. Your tags indicate you're going to stream Flash media. Red5 includes an embedded tomcat server, so everything can be served from one server.
Your given url could be handled with JavaScript and a swf player; simply read the video id and pass it to the player.

Related

Android app communication with web server?

I am coming from java based web application background where client is thin client i.e. browser and all UI pages(HTML,CSS,JS) along with
data comes from server. But with recent read on net about android based mobile apps and based on Q/A on stack overflow came with this understanding
Android app with backend(where data is fetched from server) is like two application communicating with each other on http. When I say two app , these
are one on mobile which is java(android) application and second is on server which is generally exposed through web services which can be in any language
like java/dot net. Is it correct ?
If yes I have one doubt when comparing it with java server based web app This is in regard of where UI pages . In web application,
UI views are returned from server in the forms of HTML. But I am confused where UI pages resides in android app. Is it generally on client side(all ui pages
are downloaded with app . With different events app serves the UI from client side itself but data comes from server) or they are served from server ?
If from server are they served again as HTML or there is some other format that android better gels with ?
May be android app generally should not expect any UI pages from server which means downloaded app should have all UI pages with it.
I think the UI is still on the client while the content for filling of the UI is from the server. This content is transported in HTTP(s) protocol, therefore in HTML format as you said. But one can use other protocols to get the response from the server I guess.

update java arraylist changes dynamically in html

I have a array list in java which contains notification messages which will be displayed in a html page.
Is there way that when the array list gets updated(i will update this array list from the listeners in smack chat library) the list in html also gets updated simultaneously without refreshing the page.
I am not interested in hitting the controller using any scheduler that will update the list every x minutes.I need the list to be updated simultaneously.
I have heard that we can use web sockets on this.I have no idea on this.Is that the way to go.If so kindly provide the tutorial for the same.
There are many technology to make chatting application over web browser.
HTTP server push - nothing but HTTP streaming, which uses WebSocket API and browser should support HTML5, server can push the message to the client.
Pushlet - it takes the advantages of the persistent HTTP connections. and communicate using that connection.
Long polling - pull the data using ajax and jquery or any ajax based technique.
Flash XMLSocket - when your browser does not support HTML5 that time this can be used.
I worked with same kind of application where , we developed all the technique depending upon the user browser support, we invoke the appropriate technique.
you can get more info about WebSocket here

How to stream a video using Play Framework and videojs?

Relating to Streaming video in play framework using videojs I'd like to know the best way to stream a video using a Play controller.
I store my videos on the filesystem, and since not every user is allowed to watch every video, I want to restrict access using a controller. So my question is, how can I stream a video from within the controller to the client (running videojs)?
Thank you!
your video is a static content like an image or a .css file. you can use any webserver to serve this content.
if you want control the access there are many techniques. you can create a controller who validate the request, open the video and write bytes in the response. I never try this, for me is much more interesting generate a security token and serve the file over a apache or nginx who use some security plugin.
but if you think in something different than progressive download (like http live streaming or rtmp, rtsp, etc) you need a video server like wowza, flash media server or red5. you can use the same strategy of tokens

Retrieve data from IP address/port using browser applet

My goal is to send data from a PC to a Viewing Station (running Linux, on the same network) so that the user at the Viewing Station (VS) can view a graph of the data. I am not allowed to install any applications on the Viewing Station but it does have a browser (something like Firefox or Chrome).
The only way I could think of doing this is to create a java applet which is opened in the browser (on the viewing station), which reads data from the IP address/ port on the viewing station.
Is this possible? How can I go about doing this? Thanks
edit: I cannot send the data to be graphed, outside of the local network. The data is sent from the PC to a local IP address where the viewing station is located.
Scenario:
PC starts sending data to be graphed, to a fixed IP address (where the viewing station is located).
User opens up a browser in the viewing station and opens something that shows the graph. The graph should contain the data received from a predefined port/IP address.
New values are added every 240ms.
edit2: We have shelved this feature for now so I am unable to try any of the mentioned solutions. Thanks for the input though
If a server-side solution is not practical, I'd look to implement simple graphs using JS and the HTML 5 canvas. For more complex graphs, find a JS API.
If a server-side solution is practical, use JFreeChart (or JCharts etc.) to produce an image on the server-side, then provide that image to the client.
Although browsers may be installed on the client, it does not necessarily mean that Java is installed & enabled in those browsers.
Use JCharts. It allows you to make graphs and charts and display them via servlet, applet, or standalone UI. Code it up into some servlets on your server side and then you can view them on the client browsers.
The main problem with your plan is that you cannot 'push' data to your viewer unless there is a service there to accept it. If you cannot install such a service, your options are limited.
1: Map a network drive. The 'producer' dumps the data here, and the 'viewer' can read it. It is unlikely given your restrictions that you will be allowed to do this.
2: Use any of the graph libraries suggested by others and configure your webserver to restrict access to a whitelist of hosts. Your 'producer' runs a webserver which will only serve pages to a specific IP or subnet, your 'consumer' connects to said webserver. See here or here for setting up a webserver which only allows access from a specific IP.

Async data fetching from Java WebService

I'm implementing a client-server GPS application. Client side is a J2ME midlet that sends GPS location via HTTP/XML to a Java Webservice (Tomcat servlet). The servlet stores positions in SQL database. The other client app is a web browser that can login and see the actual position of midlet using Google Maps. This client is written using GWT. All is deployed on the same Tomcat container. Now I'm wondering how to dynamically update current position in webrowser Google Maps of the mobile so that the client can see how the mobile moves. How to do it in GWT - should I create a timer object in GWT client and asynchronously send HTTP request to server for getting the actual positions? Or is there any mechanism in AJAX/GWT to notify client (web browser) about the data update?
Thanks
Dominik
Regardless of all the talk about "push", the standard HTTP model is still one where the client has to ask the server for updates.
In a GWT app, you should use the well-supported Ajax functionality to request small-granular updates (polling, I guess) from the server at regular intervals (5 seconds, maybe?) and use the newly obtained information to update your map info.
There is a detailed article on the GWT incubator web site about Server Push and how to achieve it with GWT. From the article:
Explains Server Push, sometimes known as 'comet', and how you can achieve this with GWT.
Then, if you take a look at the comments, you can find interested related information and open implementations as gwt-comet, GWTEventService ...
I agree with rok.
If your deployment is going to be small enough to be able to support one permanent connection per web browser client go with Server Push/ Hanging RPC/ Long Polling or whatever you want to call it.

Categories