media streamer and player

Upload: tarik-setia

Post on 05-Apr-2018

234 views

Category:

Documents


4 download

TRANSCRIPT

  • 8/2/2019 Media Streamer and Player

    1/33

    Mini Project ReportSemester V

    CSD 301

    BySiddharth 09ITMG1086CSE

    Sumit Thakran 09ITMG1090CSETanmay Chaudhry 09ITMG1095CSE

    Tarik Setia 09ITGM1097CSE

  • 8/2/2019 Media Streamer and Player

    2/33

    Me!a Streamer

    and

    Player

  • 8/2/2019 Media Streamer and Player

    3/33

    Certificate

    This is certify that Project work, Media Streamer and Player a benefice workhas been successfully carried out and submitted in the fulfillment of therequirement for the fifth semesters Bachelor of Engineering from ITM UNIVERSITY,during the academic year 2011-2012. It is certified that all correction /suggestion indicated for the internal Assessment have been incorporated in theReport. The Project report has been approved as it satisfied the academicrequirement in respect of Minor Project work prescribed for the Bachelor ofTechnology and Engineering Degree.

    This project is done under the guidance ofMr. Ezaz Ahmed by Siddharth Sumit Thakran Tanmay Chaudhry Tarik Setia

    Signature .

    (Course Co-ordinator)

  • 8/2/2019 Media Streamer and Player

    4/33

    Acknowledgement

    The project you are holding is the result of dedication ofMr. Ezaz Ahmed underwhose guidance ,We did such a great job of bringing and shepherding the project.This person always kept the things on track and helped us in getting the things ingood shape. It was nice experience working with him.

    Lastly we wish to thank each and every person involved in making our projectsuccessful.

  • 8/2/2019 Media Streamer and Player

    5/33

    Table of Contents

    1.Introduction1.1 Overview of Media Streaming

    1.1.1 Architecture of Media Streaming

    2.Feasibility Study2.1 Economical Feasibility Study2.2 Technical Feasibility Study2.3 Behavioral Changes Study

    3.Technologies Used

    3.1 Server Side3.1.1 Transport Layer- UDP3.1.2 Application Layer- RTP/RTSP

    3.2 Client Side3.2.1 Java Media Framework

    4.Project Description

    5.Requirement Analysis5.1 Hardware Requirements

    5.2 Software Requirements

    6.System Requirement Specification6.1 Server Side

    6.1.1 External Interface Specification6.1.2 Functional Specifications

    7.Design7.1 Server Side

    7.1.1 Class Diagrams7.1.2 Dependencies Diagram

    7.2 Client Side7.2.1 Class Diagrams

    8.Snapshots

    9.Conclusion

    10.Future Scope

    11.References

  • 8/2/2019 Media Streamer and Player

    6/33

    1.Introduction

    Media ServerIt all started in 1975 when a two networked TCP/IP communication was successfully testedbetween Stanford and University of London. After the success of TCP/IP the ARPNET migratedfrom its traditional way communication is Circuit Switching to TCP/IP. The migration of theARPANET to TCP/IP was officially completed on flag January 1, 1983, when the new protocolswere permanently activated. That day was the Foundation of Modern Internet. Back theninternet was only supposed to transmit textual data over distances. But with development andsuccessful implementation of various network and application layers the internet communicationcrossed the line of textual services and became what it is today, The Youtube, The Facebook etcwhere the every kind of media whether audio or video flows through the computer networks.

    This flow of media is called media streaming in which a host sends packets of data to the enduser where all the packet are combined to form the media package.This project Terminal Media Server is the basic implementation of a media streaming serverthat use RTP as application layer and UDP as Transport layer. It also provides the feature ofconverting media formats falling under same categories.The next few section will go through the architectural and abstract technologies practiced tobuild this project.

    Java Media Player

    Media player is a term typically used to describe computer software for playing

    backmultimedia files. While many media players can play bothaudioand video, others focus

    only on one media type or the other. Such players are known as eitheraudio playersorvideo

    playersand often have auser interface tailored for the specific media type.

    Media players often display icons known from physical devices such as tap recorders andCD

    players. Examples of these icons are (play), (pause), and (stop).

    Recently, Media player become popular in this generation. Most of the software companiesdevelop so many types of player which support Multimedia files (e.g. Winamp, Window MediaPlayer, Real, RealOne, etc). But there is not all of the software which are suitable for all

    different users.

    Our Java Media Player is basically a facility for music lovers to control playback ofMultimedia files right from the local network. Also it can work as a standalone media system torun media files .We chosen java as the implementing language because java is platformindependent so what will get can be run on any platform, following javas Write once runeverywhere title.

    We built our media player with the help of Java Media player framework (JMF),we will discusslater about it in the Technology used section.

  • 8/2/2019 Media Streamer and Player

    7/33

    1.1 Overview of a Media Streaming

    Streaming media is multimedia that is constantly received by and presented to an end user whilebeing delivered by a streaming provider.The name refers to the delivery method of the mediumrather than to the medium itself. The distinction is usually applied to media that are distributed

    over telecommunication network, as most other delivery systems are either inherently streaming(e.g.,radio, TV) or inherently non-streaming (e.g., books, video cassettes, audio CDs). The verb'to stream' is also derived from this term, meaning to deliver media in this manner. InternetTelevision is a commonly streamed medium.

    1.1.1Architecture of a Media Streamer

    Client-Server Architecture

    SERVER

    CLIENTS

    The clientserver model of computing is a distributed application that partitions

    tasks or workloads between the providers of a resource or service, called servers

    and service requesters, called clients. Often clients and servers communicate over

    a computer network on separate hardware, but both client and server may reside in

    the same system. A server machine is a host that is running one or more server

    programs which share their resources with clients. A client does not share any of its

    resources, but requests a server's content or service function. Clients therefore

    initiate communication sessions with servers which await incoming requests.

  • 8/2/2019 Media Streamer and Player

    8/33

    Peer-To-Peer

    HUB

    Peer to Peer (p2p) computing or networking is a distributed application architecture

    that partitions tasks or workloads among peers. Peers are equally privileged,

    equipotent participants in the application. They are said to form a peer-to-peer

    network of nodes.

    Peers make a portion of their resources, such as processing power, disk storage ornetwork bandwidth, directly available to other network participants, without the need

    for central coordination by servers or stable hosts. Peers are both suppliers and

    consumers of resources, in contrast to the traditional client-Server model where

    only servers supply (send), and clients consume (receive).

  • 8/2/2019 Media Streamer and Player

    9/33

    2.Feasibility StudyA feasibility study could be used to test a new working system, which could be usedbecause:

    The current system may no longer suit its purpose,Technological advancement may have rendered the current system redundant,The business is expanding, allowing it to cope with extra work load,Customers are complaining about the speed and quality of work the business provides,Competitors are now winning a big enough market share due to an effective integrationof a computerized system.

    Within a feasibility study, six areas must be reviewed, including those of Economics,Technical, Schedule, Organizational, Cultural, and Legal.

    2.1 Economic feasibility studyThis involves questions such as whether the firm can afford to build the system, whetherits benefits should substantially exceed its costs, and whether the project has higherpriority and profits than other projects that might use the same resources. This alsoincludes whether the project is in the condition to fulfill all the eligibility criteria andthe responsibility of both sides in case there are two parties involved in performing anyproject.

    ** This project has no economical value as its being made for open source contributionand for sole purpose of learning.

    2.2 Technical feasibility study

    This involves questions such as whether the technology needed for the system exists,how difficult it will be to build, and whether the firm has enough experience using thattechnology. The assessment is based on an outline design of system requirements interms of Input, Output, Fields, Programs, and Procedures. This can be qualified in termsof volumes of data, trends, frequency of updating etc.In order to give an introduction to

    the technical system.

    **Needed Technologies are known but whether they work together is question ofresearch. We drop it on learning and analyzing with the help of so many code snippetsand check their functionality.**Streaming of audio as well as video data of all formats is possible or not (whether theplayer will support all formats).

  • 8/2/2019 Media Streamer and Player

    10/33

    2.3 Behavioral changes study

    This involves questions such as whether the system has enough support to beimplemented successfully, whether it brings an excessive amount of change, and

    whether the organization is changing too rapidly to absorb it.

    **All the behaviors are expected to be in favor of our candidate system as its promisingflexibility in controlling the music they way you liked and too without worrying aboutthe operating system you use.

    **As it is an open source project, it can be downloaded by anybody and can be modifiedaccording to their taste and functional need.

  • 8/2/2019 Media Streamer and Player

    11/33

    3.Technologies Used

    3.1 Server-Side - TMediaServer

    3.1.1The Transport layer - UDP

    The User Datagram Protocol (UDP) is one of the core members of the internet protocol suite,the set of network protocols used for the Internet. With UDP, computer applications can sendmessages, in this case referred to as datagrams, to other hosts on an internet protocol (IP)network without requiring prior communications to set up special transmission channels or datapaths.

    DP uses a simple transmission model without implicit handshaking dialogues for providingreliability, ordering, or data integrity. Thus, UDP provides an unreliable service and datagramsmay arrive out of order, appear duplicated, or go missing without notice. UDP assumes that errorchecking and correction is either not necessary or performed in the application, avoiding theoverhead of such processing at the network interface level. Time-sensitive applications often useUDP because dropping packets is preferable to waiting for delayed packets, which may not be anoption in a real-time system.If error correction facilities are needed at the network interfacelevel, an application may use the TCP or Stream Control Transmission Protocol (SCTP) which aredesigned for this purpose.

    3.1.1.1 Packet Structure

    UDP is a minimal message-oriented Transport Layer protocol that is documented in IETF RFC 768.

    UDP provides no guarantees to the Upper Layer Protocol for message delivery and the UDPprotocol layer retains no state of UDP messages once sent. For this reason, UDP is sometimesreferred to as Unreliable Datagram Protocol.

    UDP provides application multiplexing (via port number) and integrity verification (viachecksum) of the header and payload. If transmission reliability is desired, it must beimplemented in the user's application.

    offset (bits) 0 15 16 31

    0 Source Port Number Destination Port Number

    32 Length Checksum

    64+ Data

    fig:UDP Datagram

  • 8/2/2019 Media Streamer and Player

    12/33

    The UDP header consists of 4 fields, each of which is 2 bytes (16 bits). The use of two of those isoptional in IPv4 (pink background in table). In IPv6 only the source port is optional (see below).

    Source port numberThis field identifies the sender's port when meaningful and should be assumed to be the port toreply to if needed. If not used, then it should be zero. If the source host is the client, the portnumber is likely to be an ephemeral port number. If the source host is the server, the portnumber is likely to be a well-known port number.

    Destination port numberThis field identifies the receiver's port and is required. Similar to source port number, if theclient is the destination host then the port number will likely be an ephemeral port number andif the destination host is the server then the port number will likely be a well-known portnumber.

    LengthA field that specifies the length in bytes of the entire datagram: header and data. The minimumlength is 8 bytes since that's the length of the header. The field size sets a theoretical limit of65,535 bytes (8 byte header + 65,527 bytes of data) for a UDP datagram. The practical limit for

    the data length which is imposed by the underlying IPv4 protocol is 65,507 bytes (65,535

    8 byteUDP header 20 byte IP header).

    3.1.2 The Application layer - RTP/RTSP

    3.1.2.1 RTP

    RTP was developed by the Audio/Video Transport working group of the IETF standardsorganization. RTP is used in conjunction with other protocols such as H.323 and RTSP. The RTPstandard defines a pair of protocols, RTP and RTCP. RTP is used for transfer of multimedia data,and the RTCP is used to periodically send control information

    RTP is designed for end to end, real time , transfer of stream data. The protocol provides facilityfor jitter compensation and detection of out of sequence arrival in data, that are commonduring transmissions on an IP network. RTP supports data transfer to multiple destinationsthrough IP Multicast. RTP is regarded as the primary standard for audio/video transport in IPnetworks and is used with an associated profile and payload format.

    3.1.2.2 RTSP

    The Real Time Streaming Protocol (RTSP) is a network control protocol designed for use inentertainment and communications systems to control streaming media servers. The protocol isused for establishing and controlling media sessions between end points. Clients of mediaservers issue VCR-like commands, such as play and pause, to facilitate real-time control ofplayback of media files from the server.

    The transmission of streaming data itself is not a task of the RTSP protocol. Most RTSP serversuse the RTP for media stream delivery, however some vendors implement proprietary transportprotocols.

  • 8/2/2019 Media Streamer and Player

    13/33

    1.3.2.1 RTSP Commands

    OPTIONS

    An OPTIONS request returns the request types the server will accept.

    DESCRIBE

    A DESCRIBE request includes an RTSP URL (rtsp://...), and the type of reply data that canbe handled. The default port for the RTSP protocol is 554. This reply includes the presentationdescription. Among other things, the presentation description lists the media streams controlledwith the aggregate URL. In the typical case, there is one media stream each for audio and video.

    SETUP

    A SETUP request specifies how a single media stream must be transported. This must bedone before a PLAY request is sent. The request contains the media stream URL and a transportspecifier. This specifier typically includes a local port for receiving RTP data (audio or video),

    and another for RTCP data (meta information). The server reply usually confirms the chosenparameters, and fills in the missing parts, such as the server's chosen ports. Each media streammust be configured using SETUP before an aggregate play request may be sent.

    PLAY

    A PLAY request will cause one or all media streams to be played. Play requests can bestacked by sending multiple PLAY requests. The URL may be the aggregate URL (to play all mediastreams), or a single media stream URL (to play only that stream). A range can be specified. If norange is specified, the stream is played from the beginning and plays to the end, or, if thestream is paused, it is resumed at the point it was paused.

    PAUSE

    A PAUSE request temporarily halts one or all media streams, so it can later be resumedwith a PLAY request. The request contains an aggregate or media stream URL. A range parameteron a PAUSE request specifies when to pause. When the range parameter is omitted, the pauseoccurs immediately and indefinitely.

    RECORD

    The RECORD request can be used to send a stream to the server for storage.

    TEARDOWN

    A TEARDOWN request is used to terminate the session. It stops all media streams andfrees all session related data on the server.

  • 8/2/2019 Media Streamer and Player

    14/33

    3.2 Client-Side

    Java Media Framework(JMF)

    The Java Media Framework (JMF) is a recent API for Java dealing with real-time multimediapresentation and effects processing. JMF handles time-based media, media which changes withrespect to time. Examples of this are video from a television source, audio from a raw-audioformat file and animations. The beta JMF 2.0 specification will be used for this report, as they

    currently reflect the features that will appear in the final version.

    JMF Media Processing Model

    During the input stage, data is read from a source and passed in buffers to the processingstage. The input stage may consist of reading data from a local capture device (such as awebcam or TV capture card), a file on disk or stream from the network.

    The processing stage consists of a number of codecs and effects designed to modify the datastream to one suitable for output. These codecs may perform functions such as compressing ordecompressing the audio to a different format, adding a watermark of some kind, cleaning up

    noise or applying an effect to the stream (such as echo to the audio).

    Once the processing stage has applied its transformations to the stream, it passes theinformation to the output stage. The output stage may take the stream and pass it to a file ondisk, output it to the local video display or transmit it over the network.

    For example, a JMF system may read input from a TV capture card from the local systemcapturing input from a VCR in the input stage. It may then pass it to the processing stage to adda watermark in the corner of each frame and finally broadcast it over the local Intranet in theoutput stage.

  • 8/2/2019 Media Streamer and Player

    15/33

    4.Project Description

    PLAY AUDIO FILE.

    PLAY VIDEO FILE

    STREAM AUDIO FILE

    STREAM VIDEO FILE

    CONVERT AUDIO FILE

    CONVERT VIDEO FILE

    fig: Use Case UML of Media Streamer and Player

  • 8/2/2019 Media Streamer and Player

    16/33

    Project Functions

    Playing an audio file

    Playing a video file

    Streaming an audio file

    Streaming a video file converting an audio file

    converting a video file

    User Characteristics

    Any user from any actor group can use this software

    User must carry full administrator privileges.

    Software Dependencies

    Python Interpreter

    Twisted Matrix Libraries

    ffmpeg liberaries

    GStreamer Liberaries

    Ubuntu Operating System

    Java Media Framework

    Java Runtime Envt.

  • 8/2/2019 Media Streamer and Player

    17/33

    5. Requirement Analysis

    5.1 Hardware RequirementsA computer with minimum following requirements.

    Minimum Recommended

    Processor 233MHz 300 MHz or higher

    Memory 64MB RAM 128 MB RAM or higher

    Video adapter and monitor Super VGA(800 x 600) Super VGA (800 x 600)Or higher resolution

    Hard drive disk free space 1.5GB 1.5 GB or higher

    Devices Keyboard and mouse Keyboard and mouse

    Others Sound card, speakers Sound card, speakers

    5.2 Software Requirements

    Operating System

    Platform Independent but UNIX is recommended

    Java Runtime environment (JRE)A software bundle from Sun Microsystems that allows a computer system to run a Javaapplication. Java applications are in wide spread use and necessary to view many Internetpages. The software bundle consists of the Java Virtual Machine and programminginterface(API). The API provides a set of standard class libraries. The virtual machine and APIhave to be consistent with each other and are therefore bundled together as the JRE. This canbe considered a virtual computer in which the virtual machine is the processor and the API isthe user interface.

  • 8/2/2019 Media Streamer and Player

    18/33

  • 8/2/2019 Media Streamer and Player

    19/33

    6.Software RequirementSpecification

    This section deals with the requirement specification of this project and offersthe complete description of the behavior of the system to be developed

    6.1 Server Side

    6.1.1 External Interfaces Specification.

    User Interfaces

    TMediaServer should provide user a way to interact with thesoftware. This can be done via UNIX Command Line ToolTERMINAL.TMediaServer may also provide a GUI for interaction

    Hardware Interface

    TMediaServer should be implemented on UNIX Platform. Thisis because the dependencies we would be using as unixspecific.

    Software Interfaces.

    No software interfaces except for the Python subsystem are

    necessary.

  • 8/2/2019 Media Streamer and Player

    20/33

    7.Design

    7.1 Server Side

    7.1.1 Class Diagrams

    RTPStreamer

    sockseqNoinvtervalbufsizepacketsSenyreleaserpeerAddressfileSize

    loadfile(filename)startProtocol()setBufferSize(bufsize)setPeerAddress(addr)setupStreaming(fileToPlay,buf,addr)startStreaming(fileToPlay,speed)continueStreaming()

    datagramProtocol

    Module:RTPServer.py

    RTSPMessage

    rtspCommandURIpathnamecseqbandwidthbufsize

    sessionspeedrtspMsg

    tostring()fromstring()parse()parseURL()

    Module:RTSPMessage.py

    Launcher

    startUI()playMedia()streamMedia()transcodeMedia()exit()

    Module:Launcher.py

    Player

    fileName

    player()

    Module:GPlayer.py

    Converter

    fileName

    convert()

    Module:FPlayer.py

  • 8/2/2019 Media Streamer and Player

    21/33

    RTSPServer

    messageHandlersessioncurrentSessiondata

    connectionMade()connectionLost(reason)

    lineRecieved()process()sendReply()describeRequest(msg)optionRequest(msg)setupRequest(msg)playRequest(msg)teardownRequest(msg);

    lineReceiver

    Module:RTSPServer.py

    Init

    RTP Sent

    Packets

    Ready

    PlayPause

    SETUP

    TEARDOWN

    TEARDOWNTEARDOWN

    PLAY

    PLAY

    PAUSE

  • 8/2/2019 Media Streamer and Player

    22/33

    7.1.2 Dependencies Diagram

    RTPServer

    twisted.internet.protocol.datagramprotocol

    twisted.internet.udp

    twisted.internet.re

    actor

    twisted.internet.task

    RTSPMessage

    url re(regular

    urlparse

    RTSPServer

    twisted.internet.protocol

    twisted.internet.lineReceiver

    Launcher

    GStreamer ffmpeg Converter

    fig:Various Dependencies of TMediaServer

  • 8/2/2019 Media Streamer and Player

    23/33

    7.2 Client Side

    7.2.1 Class Diagrams

    fig: Class Diagram of Java Player

  • 8/2/2019 Media Streamer and Player

    24/33

    fig: Video Class Diagram

  • 8/2/2019 Media Streamer and Player

    25/33

    8.Snapshots

    8.1 Client-Side

    Figure1 Home window

    Figure 2 Opening Media file

  • 8/2/2019 Media Streamer and Player

    26/33

    Figure 3 Audio Playing

    Fiqure 4 Video Playing

    Fiqure5 RTP Streaming

  • 8/2/2019 Media Streamer and Player

    27/33

    8.2 Server-Side

    Home Screen

    fig: Main

  • 8/2/2019 Media Streamer and Player

    28/33

    Play a Media File

    fig:Pl

  • 8/2/2019 Media Streamer and Player

    29/33

    Transcode

    fi :Tran

  • 8/2/2019 Media Streamer and Player

    30/33

    Data Stream

    fi :Data

  • 8/2/2019 Media Streamer and Player

    31/33

    9.Conclusion

    Working on this project was quite difficult as even till date project is partly complete.We really enjoyed this work because of the following reasons

    There is no book available on JMF and RTP/RTSP architecture so it was quitedifficult to learn as we had to follow learn by work technique, originally beenmain motto at ITM.

    Got to know about optional APIs of java and python, it started understanding oftheir main utility , that is its expandability and being open source in nature.

    As even we kept this project as open source, many others will be using our codeand they can make it better and complete.

    Learned how media files work and got to now internal file structure of MP3 file.

  • 8/2/2019 Media Streamer and Player

    32/33

    10.Future scope Capture audio and video with your microphone and video camera, then store

    the data in a supported format.

    Process time-based media and change the content-type format.

    Transmit audio and video in realtime on the Internet.

    Live Broadcasting of College Lectures/Events.

    Video Conferencing.

    Broadcasting Media to Mobile Devices.

  • 8/2/2019 Media Streamer and Player

    33/33

    11.References

    http://www.cs.columbia.edu/~hgs/rtp/

    www.oracle.com/technetwork/java/javase/tech/index-jsp-140239.htmlhttp://www.twistedmatrix.com

    http://www.twistedmatrix.com/http://www.twistedmatrix.com/http://www.oracle.com/technetwork/java/javase/tech/index-jsp-140239.htmlhttp://www.oracle.com/technetwork/java/javase/tech/index-jsp-140239.htmlhttp://www.cs.columbia.edu/~hgs/rtp/http://www.cs.columbia.edu/~hgs/rtp/