Sunday, 13 May 2012

How to stream audio and video media online on a shoe-string budget

             There are many ways that one can stream audio and video materials online and we found a few ways that are cost effective and efficient enough to handle most of the online streaming activities.

             Here we list some of the technologies that we used to put together a system that may help anyone with their audio and vide streaming needs with a low or no budget. It will take some time, reading/researching and effort to accomplish it. We will describe briefly how we accomplished our goal of setting up a system on a shoe string budget. You may be able to extract a few ideas/points and build or come up with your own way of doing the same thing. It is possible to accomplish anything nowadays, as long as the Internet and Google is there.

             The main system we have is a Pentium IV with 512MB RAM memory and 40GB hard drive. We have DSL high-speed connection to the Internet. The system runs on ubuntu Linux operating system (almost all the software that we have used will run on Windows based system as well but MS Windows costs). In this system we have three streaming servers like “Shoutcast”, “Darwin” and “Red5” running at the same time (it is our test server, gets abused a lot). All these streaming servers are capable of streaming audio and/or video media effectively. The difference is mainly the format they use to broadcast the video signal.

             Shoutcast server from www.shoutcast.com/ works with “NSV” (Nullsoft video) format.
Darwin streaming server from www.apple.com is for QuickTime and mpeg movies (“mov” & “mp4”). Red5 server http://osflash.org/red5 works with flash (“flv”) videos. On the audio side all these servers can stream mp3 files without any problem.

             Depending on the need, a particular combination of the above can serve in any situation. For example a radio broadcasting station is possible with the following combination.

             A Linux (or Windows) based computer system with a decent hardware specification as mentioned above running the Shoutcast streaming server as the main system. A Windows 2000 or XP system with software like Winamp player with necessary plug-in is all what is needed to setup a powerful radio broadcasting system. Can say that this is the installation of this setup is the easiest of all.

                 This Windows based system should have a working sound card. Adding and automation software like “Zarasoft” (no cost of course) can even automate the radio station when and if the DJ is missing. Call-in talk shows are possible with a phone system integrated into this setup. This option will need a little more homework and work.

                 If your need is to stream QuickTime or mpeg movies then the same Linux (or Windows) system with Darwin streaming server will be a good choice. Darwin streaming server is as same as the Apple’s commercial product QuickTime streaming server but available for free from Apple’s website. Installing it and getting it up and running is not very difficult. A web based admin tool is available to manage the playlist files and other streaming media.

                  Flash has a big advantage over the others. Mainly, according to some Internet source 98% of the web browsers are installed with flash plug-in to play flash videos. It is a popular choice for many including movie producers for their online movie trailer streaming. The open source flash software “Red5” is equivalent to Adobe’s commercial software Flash Communication server. The combination Linux and Red5 (all for free of charge) has a few other features that are desirable in certain situation such as audio or video chat systems for an example.

                  All these combinations are capable of streaming real time events if needed. For fun and testing purposes we stream live local TV channels over the Internet for our friends who live in other countries. That is, with a second Windows based source computer equipped with a TV tuner which connected to the cable TV and to the main streaming server on the LAN (Local Area Network), this can be easily achieved.

                   The Linux operating system comes with a web server (Apache) and servers like MySQL and PHP software. With these amazing tools the audio and video streaming can be integrated into a website. This website can optionally hosted out side your home or office with an ISP (Internet Service Provider).

                   We may have spent less than $200 for the setup with all the combinations mentioned here. It took us about 3hours to finish the whole setup (took us 6-8 months initially to learn and reach this point). All the software, that is the OS, the streaming server software, the web server software, sourcing software with appropriate plug-ins, the automation software, weather watcher/announcement software, audio editing software like “Audacity”, video encoding software like “Super” and screen casting (screen capture) software such “Camstudio” and Wink2 were all obtained for free. Thus we built our audio and video streaming system that streams online on a shoe-string budget.
Our “audio and video streaming online – beginner’s guide” is available at www.aduioandvideostreaming.com has little more information on the “ubuntu Linux/Shoutcast” combination. Have a look at the overview to get an idea of the ebook contents along with couple of video tutorials.
Thank you.

Thursday, 10 May 2012

Core Java Questions with answers

1)What is the purpose of serialization?
Answer: Serialization is the conversion of an object to a series of bytes, so that the object can be easily saved to persistent storage or streamed across a communication link. The byte stream can then be deserialised – converted into a replica of the original object.
Source | Example
2)What is the difference between JDK and JRE?
Answer: Java Development Kit (JDK) is the most widely used Java Software Development Kit. Java Runtime Environment (JRE) is an implementation of the Java Virtual Machine which executes Java programs.
Source | JDK Wiki | JVM Wiki 
3)What is the difference between equals() and “==” ?
Answer: Equals is intended to check logical equality and == checks if both references point to same object. (Thanks Sandeep)
a == b;        // Compares references, not values.
a.equals(b);  // Compares values for equality.
Source
4)When will you use Comparator and Comparable interfaces? 
Answer: java.util.Comparator and java.lang.Comparable java.util.Comparator compares some other class’s instances, while java.lang.Comparable compares itself with another object.
Source | Example
5)What is the wait/notify mechanism?
Answer: This deals with concurrent programming. The wait() and notify() methods are designed to provide a mechanism to allow a thread to be block until a specific condition is met.
However, java.util.concurrent should be used instead of wait() and notify() to reduce complexity.
Source | Java API | Java Technical Article
6)What is the difference between checked and unchecked exceptions?
Answer:
In general, unchecked exceptions represent defects in the program (bugs), which are normally Runtime exceptions.
Furthermore, checked exceptions represent invalid conditions in areas outside the immediate control of the program.
Source
7)What is the difference between final, finally and finalize?
Answer: “final” is the keyword to declare a constant AND prevents a class from producing subclasses. (Thanks Tom Ellis)
“finally” is a block of code that always executes when the try block is finished, unless System.exit() was called. finalize() is an method that is invoked before an object is discarded by the garbage collector.
Source | Final Usage |Finally Usage | Finalize()
8)What is the difference between web server and app server?
Answer: A Web server exclusively handles HTTP requests, whereas an application server serves business logic to application programs through any number of protocols.
Source
9)Explain the Struts1/Struts2/MVC application architecture?
Answer: Struts was adopted by the Java developer community as a default web framework for developing web applications
The MVC(Model–view–controller) an application that consist of three distinct parts. The problem domain is represented by the Model. The output to the user is represented by the View. And, the input from the user is represented by Controller.
Source
10)What is the difference between forward and sendredirect?
Answer: Both method calls redirect you to new resource/page/servlet. The difference between the two is that sendRedirect always sends a header back to the client/browser, containing the data in which you wanted to be redirected.
Source
11)How does a 3 tier application differ from a 2 tier one?
Answer: Tiers are the physical units of separation or deployment, while layers are the logical units of separation.
Imagine that you’re designing an e-commerce website. A 3 tier architecture would consist of web pages, a web server and a database, with the corresponding 3 layers being the “Presentation”, “Business Logic” and “Database” layers.
If you take the database tier and layer out then your have a 2 tier architecture.
Source
12)How does the version control process works?
Answer: Initiate, pull, branch, merge, commit, push.
(Init) Make your own repository. (Pull) Download an existing repository from a url. (Branch / Merge )Make revisions. Commit then push your modifications.




 
13)What is the difference between JAR and WAR files?
Answer: JAR files (Java ARchive) allows aggregating many files into one, it is usually used to hold Java classes in a library.
WAR files (Web Application aRchive) stores XML, java classes, and JavaServer pages for Web Application purposes.
Source

14)What is a Left outer join?
Answer: This deals with SQL. Left outer join preserves the unmatched rows from the first (left) table, joining them with a NULL row in the shape of the second (right) table.
Source | Joins Wiki

15)What is the difference between UNION and UNION ALL?
Answer: This deals with SQL. UNION only selects distinct values, UNION ALL selects all values.
Source | Example