DESIGN AND REALIZATION OF A LINUX BASED PVR SYSTEM ON AN XBOX by wuxiangyu

VIEWS: 2 PAGES: 62

									Design and realization of an XBOX PVR system
______________________________________________________




     DESIGN AND REALIZATION OF A LINUX
       BASED PVR SYSTEM ON AN XBOX

                                 By



                         David Lynam

   B.E. Electronic & Computer Engineering Project
                       Report

                Supervisor: Peter Corcoran




                                  I
Design and realization of an XBOX PVR system
______________________________________________________




I hearby declare that this thesis is my own original work except where stated



Signature:__________________________________ Date:_______________




                                       II
Design and realization of an XBOX PVR system
______________________________________________________



Acknowledgements


I would like to thank my supervisor Peter Corcoran for his advice, support and
assistance throughtout the project. I would also like to thank him for providing me
with a project that I found interesting and motivated to complete. It was a joy to
undertake.


I also wish to thank Frank Callaly for his extensive input into the project. Without his
genius I would have never have come so far. Sorry for all the constant hasseling but i
really appriciate your help.


I would also like to thank the technitions Martin, Myles, Shaun and Aodh. For
without them obtaining my hardward which was essential to the project would have
being a nighmare. Thanks guys.


To my fellow class mates, it has being a pleasure these last four years to know you. I
have made many friends and the I would like to thank for the good and bad times.
Especially Annie, Dallan, Amanda, Steve, Bryan, Tomas and Dunning. Let there be
many more times together.


I would like to thank Debra for just being the best.


To my parents Larry and Jean and my family. Their support for me can never be
rivaled. I shall be forever grateful for there help of me persuing my goal. Thanks so
much.


Finally I would like to thank my grandparents. Every week went by another prayer
was said for me and I am eternally grateful. They have never stopped in their support
and generosity for me. This is for ye!




                                           III
Design and realization of an XBOX PVR system
______________________________________________________
Abstract


Many PVR(personal video recorder) systems are widely available to the general
public. However these systems are generally expensive and incure a montly cost rate.
It is propossed in this project to build and customise a cheap PVR system using a
home PC.


My PVR system uses an open-source Linux based program called MythTv. It takes in
analogue radio signals generated by the Local TV rely masts and using a Capture card
produces and images to the screen.


As the project suggests a Linux distribution needs to be installed on a PC in order for
MythTv to be compiled and run. Linux is an opensouce operating system based on the
Unix operating system and using . It is an example of a GPL (general public licence)
which is a free software licence written by Richard Stallman for the GNU project.


The project proposes to use microsoft XBOX gaming console as our medium to
encapsulate the PVR system. This will allow us to watch Live TV along with the
added capabilities of a normal PVR system.


Using some of MythTv added functionality it is also proposed that I implement a
seperate server and client type architecture. Using the MythTv program I should be
able to watch Live Tv on multiple meduims simutaneously.




                                          IV
Design and realization of an XBOX PVR system
______________________________________________________

Table of Contents
Chapter 1: Introduction.............................................................................................. 1
Chapter 2: Project Outline ......................................................................................... 3
  2.1 MythTv Overview ........................................................................................... 3
  2.2 Linux............................................................................................................... 5
  2.3 Signal Trasmission .......................................................................................... 7
Chapter 3: Capture Card ............................................................................................ 8
  3.1 About IVTV 150 Hauupage PVR Capture card................................................ 8
  3.2 MPEG-2 .......................................................................................................... 9
  3.3 Video Coding .................................................................................................. 9
Chapter 4 Networks and Protocols........................................................................... 12
  4.1 IP................................................................................................................... 12
  4.2 UDP .............................................................................................................. 12
  4.3 TCP/IP........................................................................................................... 13
  4.4 IP Addresses.................................................................................................. 16
  4.5 Practical Gateway/Sub-Network .................................................................... 18
Chapter 5 MYTHTV Installation............................................................................. 20
  5.1 uPnP .............................................................................................................. 20
  5.2 Adjusting the sources list ............................................................................... 21
  5.3 MySQL/MySQL protocol .............................................................................. 22
  5.4 XMLTV ........................................................................................................ 25
  5.5 MythTV Installation and Configuration ......................................................... 26
  5.6 Frontend Configuration.................................................................................. 28
Chapter 6 XBOX modification ................................................................................ 29
  6.1 Xchanger chip................................................................................................ 29
  6.2 Opening the XBOX ....................................................................................... 30
  6.3 Finding the XBOX version ............................................................................ 32
  6.4 Soldering the chip.......................................................................................... 34
  6.5 XBMC........................................................................................................... 34
  6.6 Samba Server and configuration .................................................................... 35
  6.7 XBOX Mythfrontend settings ........................................................................ 38
Chapter 7 MythTV Protocol Investigation ............................................................... 39
  7.1 Packet Sniffing/Ethereal ................................................................................ 39
  7.2 Catching Packets ........................................................................................... 40
  7.3 MythTV Protocol........................................................................................... 40
  7.4 Other Attempts at Documenting the Protocol ................................................. 45
Chapter 8 Unihome Introduction ............................................................................. 47
Chapter 9 Conclusion .............................................................................................. 49
  9.1 Problems encountered.................................................................................... 49
  9.2 Experience..................................................................................................... 50
  9.3 Final Status.................................................................................................... 51
Glossary .................................................................................................................. 53
References............................................................................................................... 54
Appendix................................................................................................................. 55




                                                             V
Design and realization of an XBOX PVR system
______________________________________________________

Table of Figures
Figure 1-0-1 Overview .............................................................................................. 2
Figure 2-0-1 Blue Theme .......................................................................................... 3
Figure 2-0-2 Burning Theme ..................................................................................... 4
Figure 2-0-3 MythTV Plugin -MythWeather ............................................................. 5
Figure 3-0-1 PVR-150............................................................................................... 8
Figure 4-0-1 UDP Datagram.................................................................................... 13
Figure 4-2 Full TCP Protocol .................................................................................. 14
Figure 4-0-3 TCP Connection Establishment.......................................................... 14
Figure 4-0-4 Connection Termination...................................................................... 16
Figure 4-0-5 Network at a Glance............................................................................ 18
Figure 4-0-6 Practical Sub-Network ........................................................................ 19
Figure 6-0-1 Modification Chip............................................................................... 29
Figure 6-0-2 Removing Cushins .............................................................................. 30
Figure 6-0-3 After Removing Lid ............................................................................ 31
Figure 6-0-4 After Taking out the Hard Drive ......................................................... 32
Figure 0-5 Description of the Soldering on 1.6b ...................................................... 34
Figure 7-0-1 Frontend Connection........................................................................... 41
Figure 7-0-2 Mythfilldatabase ................................................................................. 42
Figure 7-0-3 Program Guide Button ........................................................................ 44
Figure 8-0-1 Unihome ............................................................................................. 47




                                                         VI
Design and realization of an XBOX PVR system
______________________________________________________

Chapter introductions


Chapter 1
Is a basic introduction to my project and outlines the goals that were hoped to be
achieved.


Chapter 2
Is a project outline. It describes some of the major applications used in the project. It
also gives some theory on how a signal is received.


Chapter 3
Describes how the PVR-150 capture card works. It describes how MPEG encoding
works and what exacly MPEG ‘s are.


Chapter 4
Describes network make ups and the protocols used such as UDP and TCP. It also
describes how IP addesses are made up and how they are assigned.


Chapter 5
Describes the entire installation of MythTV using both a client and server type
architecture. It also includes a description of uPuP and other used tools in the build.


Chapter 6
Describes the XBOX modification from opening the XBOX to soldering the chip onto
the mother board.


Chapter 7
Describes my investigation of the MythTV protocol and my findings. It shows how I
used a packet sniffing application and compared it to existing investigations.


Chapter 8
Is my project conclusions and what I got out of the project.



                                           VII
Design and realization of an XBOX PVR system
______________________________________________________



Chapter 1: Introduction
In the last two years we have seen a huge change in the area of recording video from a
TV input. The change has being so big that we have almost seen two technologies
become totally obsolete from electronic wholesalers and production. A few years ago
a huge portion of the population would have relied on the unreliable (VCR) video
cassette recorder. All video was captured on these magnetic tapes that could not be
exposed and could not be touched. Within the last five years we have seen the
introduction on a mass scale of the (DVD) digital versatile disc. They were originally
very dear and there was a time when it looked like the technology wouldn’t take off
but as the prices fell the sales shot up and now the DVD reigns supreme in the area of
video storage devices…until now. In the last few years there has being a slow move
again to the area of (PVR) personal video recorder. This piece of equipment needs no
external disk in which to store video. It uses a hard drive to store the digital
information. And because it uses a hard drive it can accommodate many other features
to entice in the punters. It allows for a GUI system to arrange recording at the hearth
of many others. Sky were among some of the big boys in digital TV broadcast to get
involved with their version “Sky plus”. However the price for these systems is still at
an extreme peak which is makes it unavailable to most of the common public. This is
where open source software comes in to allow the more cash restricted of us to
manipulate our home PC to be used as a duel PVR system. However most people
would not be happy with sitting at their PC watching their soaps instead of lying back
on the couch in from to the box. This is why a project of turning a home gaming
console into a home entertainment system including a PVR system and a very cheap
price.


The aim of my final year project was to implement a PVR system on an XBOX and
another client machine using the MythTv program.


It should be possible that a person can site at the Tv with the XBOX and controller
and with no knowledge of the background workings on the program, be able to move
through a GUI interface to watch live TV , record live TV, pause, rewind and



                                          1
Design and realization of an XBOX PVR system
______________________________________________________
fastforward live TV and to schedual recordings. The user should find the GUI simple
to manuveour about and easy to understand. He/She should not be worried about
where the file needs to be saved or how it needs to be saved. They should be just
concerned about what they want to watch and what they would like to record.
Other users should be able to similataneously watch Tv on another box an request
recordings at their will. With multiple capture cards many users can watch different
channels on many PVR client machines. This is the whole concept of MythTv.




                                                                INTERNET




                                         MythTV Backend




   MythTV Frontends




                                                          XBOX Frontend



                        Users

Figure 1-0-1 Overview




                                         2
Design and realization of an XBOX PVR system
______________________________________________________


Chapter 2: Project Outline

2.1 MythTv Overview
MythTv is a free open source software that in combination with certain hardware
allows some devices to be transformed form the their everyday using into a fully
functional PVR system. MythTv is a Linux application that is available from the
home website www.mythtv.org . Users can freely download the software as it is
covered by the general public licence. It is based in a Linux operating system however
with some techniques it cant be slightly modified and used the XBOX’s alternative
operation system Window’s xbox media center.


The software provides the user with a well designed GUI interface that they can easily
manipulate. Theme for the icons and backgrounds are easily available and can be
downloaded and altered as the user wishes. Also as this is an on-going open source
project many developers are currently working on enhancing its features and skins.
New themes are a regular occurance on the site with some crazy configurations
available for all users preferances. And if you can’t find one you like you can always
take up the option of designing your own as the MythTv code is readily available.




Figure 2-0-1 Blue Theme




                                          3
Design and realization of an XBOX PVR system
______________________________________________________




Figure 2-0-2 Burning Theme


As there is a large amount of developers working on the project at any one given time
plugins become an essential part of encouraging more people to take part in the
project if not just to give them another reason to install the program. Also it provides
another scope on things and gives the user something else to do rather than sit in front
of TV all day. Loads of plugins are available but the official list consists of
MythArchive, MythBrowser, MythControls, MythDVD, MythFlix, MythGallary,
MythGame, MythMusic, MythNews, MythPhone, MythVideo, MythWeather and
MythWeb. All of which are easily downloadable from the mythtv home page. I
installed the MythWeather plugin and found it exciting. It was simple to use and had
no settings to configure. It was litteraly plug and play. It provides the user with a
realtime weather conditions in the area of choice. It pulls the data from a web site in
XML format everytime the user opens the application so it is an upto date conditions.
It has a nice graphical GUI too and shows the conditions in a graphical way as well
and nummerical and text format.




                                           4
Design and realization of an XBOX PVR system
______________________________________________________




Figure 2-0-3 MythTV Plugin -MythWeather



2.2 Linux

Linux is an operating system based on the similar but different Unix operating system.
Its uses a number of libraries and system utilties and runs on a Linux kernal. It is part
of the GPL and GNU project and the source code is available to the public. However
different distributions may be sold by companies as long as the source code is
released with the sale. Linux is considered a good, low cost alternative to other
expensive operating systems such as Windows.


Linux was developed between 1991 and 1994 by a Finnish student know as Linus
Torvalds. He developed the Linux kernal as a suitable commercial replacement for the
Unix based Minix kernal. In 1994 he released his first verion 0.02 of his Linux kernal.


Over the years Linux has grown a huge amount in support and development has
continued at a fast rate. Many companies jumped on board the Linux wagon and
invested in its deveopment. In 1997, Miduel de Icaza developed the now hugely
popular Gnome desktop environment. Then in 1998, Netscape release its source code
for its browser which gave rise to the now well known Mozilla Firefox. Linux has
now got its basis in many networking systems and embedded systems.




                                           5
Design and realization of an XBOX PVR system
______________________________________________________
To get to grips of Linux, one must master quite alot of commands in order to be able
to acutally get things done. It not a simple Microsoft Windows operating system.
Some of the most useful, basic commands that are a must are listed.


   •      CD is used to change the current directory from one to another
   •      CP is used to copy one file into another location or file
   •      LOCATE is used to quickly find a file with a given name
   •      LS is used to list the files contained in the current directory
   •      MV is used to move a file from one location to another
   •      SUDO is the super user in UBUNTU and should be used where something is
          edited or accessed.
   •      NANO is a text editor that is good for editing files
   •      Apt-get install is a command that is used for downloading and installing an
          application. It is very handy and quick to use provided the source list allows
          access to the file.


The sources list in Ubuntu is like a permissions list that can only be altered by the
sudo user. It defines the websites that applications can be downloaded from and the
type of files that can be downloaded. There are four types of permissable application
downloads in Ubuntu repositories. They include Main, Restricted, Universe and
Multiverse. They are based on the amount of support currently provided for the
application. Main is the offically supported application, Restricted is software that is
supported but is not available entirely under a free licence, Universe is software that is
free but maintained by the community and multiverse is software that is not free to the
public.




                                               6
Design and realization of an XBOX PVR system
______________________________________________________



2.3 Signal Trasmission
There are a number of steps involved in TV signal transmission. Local TV is
transmitted using radio waves while Satilite TV is transmitted using microwaves. The
difference in the waves is that radio waves use low frequencies and long wavelengths
while microwaves use shorter wavelengths and high frequencies.


A radio wave contains an electric field that pushes on any electric charge it
encounters. When a radio wave passes your antenna of your TV it causes electric
charges to accelerate up and down. There is a circuit connected to the antenna that
oscillates strongly when charge is pushed up and down the antenna at the exact
frequency of the resonant frequecncy of the circuit. If the circuit frequency is the
same as that as the radio wave, the small pushes exerted on the charges in the antenna
add up so that the charge moves more and more vigorously though the resonant
circuit. But if your TV isn’t tuned to the frequency of the radio wave, the overall
motion of the charge on the antenna is small. This in turn produces a poor quatily
video/audio signal. When you change your channel, the frequency of the resonant
circuit changes allowing you to tune into different radio frequencies and hence view
different channels.




                                          7
Design and realization of an XBOX PVR system
______________________________________________________

                             Chapter 3: Capture Card

3.1 About IVTV 150 Hauupage PVR Capture card




                                  Figure 3-0-1 PVR-150


Hauppauge manufactures the WinTv-PVR 150 and others in the range. They retail at
about $55 and are widely available. A number of these were ordered in by the college
for use in final year projects.


It allows you to watch TV on your PC screen on 125 channels. It also allows you to
surf the net simultaneously. Records TV programs and makes it possible to save these
shows to a hard drive. It has a built in MPEG-2 encoder, which is used to process the
incoming signals to images. It uses on average one to 2 G per hour hard drive space
for recording video. Its main advantage is that it does all the processing of the video
images so that the PC is free to do its own thing.


Their purpose is to simply transform your home PC or Linux workstation into a
custom PVR system. It can simply be installed in the PC by opening the box and
fitting it into the PCI card slots. When it came to installing the software drivers it was
noted that the accompanied CD drives did not include drivers for the Linux operation
system. It was found that these drivers and a step by step were available on the
company’s website and installation was made easy using these steps.




                                              8
Design and realization of an XBOX PVR system
______________________________________________________



3.2 MPEG-2
(Motion Pictures Expert Group) MPEG-2 is the standard for the generic coding of
moving pictures and associated information. It is the second of a number of standards
that MPEG have released. It is extremely popular around the world where it is used to
specify information for television signals over terrestrial, cable or even satellite
systems. It is also used to determine the format of movies and other information on
DVD’s and other similar disks. It allows text video and audio all in the one data
stream to be compressed neatly. Hence this allows digital TV providers to provide
extra services over their TV box encoder. They provide such features such as TV
listings, information about programs and even some small basic games to their
customers.




3.3 Video Coding
When generating video, the camera generates a raw stream of bits. If your home
digital box is to be able to encode this stream of bits it must be compressed in order to
fit on the bandwidth assigned to the TV channels and also to enable the video to be
placed on to DVD. Compression in video signals works well because many images
will be similar for a number of frames. Such as a pitch in a soccer match will be green
over most frames.


The way the human eye detects colours also plays a big part. The human eye cannot
detect well very minute changes in colours well and as a result it does not notice the
missing frames. It does however notice quite well slight changes in shade of colour.


In Europe the TV cameras generates 50 frames a second, In America however the
frame rate is a bit higher, Typically 59.94 frames per second. When these frames are
generated, a process needs to occur in order for the frames to be read my digital
devices such as computers and home digital encoders. This process in known as
digitisation or quantization and is done through computer hardware. Each pixel is
produced by a 3D array. The array contains three values, which determine the


                                           9
Design and realization of an XBOX PVR system
______________________________________________________
brightness of the pixel, the primary colour and the amount of white in the colour. This
produces an output pixel colour, which can then be sent to the screen.


Interlaced video and progressive video are two old methods that reduce the amount of
data that is processed every second to produce the video. Interlaced separates the
picture into two fields, the “top field” and the “bottom field”. The top field is the odd
numbered rows in the image and the bottom field is the even numbered rows in the
image. The two fields are displayed alternatively producing the interlaced video.
Progressive does not use interlacing.


Another way to achieve this works using the theory that the human eye is more
responsive to brightness than to actual colours. It works by reducing the number of
values in the colour and whiteness values contained in the 3D matrix. Since there are
less frames of colour the eye only picks up the brightness intensity and hence less
computational and with a similar output.


M-PEG 2 specifies that the raw frames can be compressed into three kinds of frames.
I-frames (intra-coded), P-frames (predictive-coded) and B-frames (bi-directional
predictive-coded).


I-Frame is a single compressed version of a previously uncompressed raw frame. It
works off the eyes lack of ability to detect certain changes in images. A simple
breakdown of the procedure is as follows.
            •   Raw frame divided into 8 * 8 pixel blocks
            •   Data in each pixel block goes through the cosine transform
            •   Coefficients are produced as a result
            •   Quantization of the coefficients
            •   High frequencies will be zero
            •   Quantized coefficients and compressed


        Typically every 15th frame or so will be an I-frame




                                            10
Design and realization of an XBOX PVR system
______________________________________________________
      P-Frame is compression type that use data from previous I-frame or P-frame
      to reconstruct the compressed image. A breakdown of the procedure is as
      follows.
         •   Frame divided up into 16 * 16 pixel “macro blocks”
         •   Referenced frame is searched for each macro block to find the best
             match macro block form the reference frame
         •   Creates a motion vector with frequency reference zero
         •   Computes two strings of coefficients and subtracts
         •   Amends the motion vector and sends the result to receiver


      B-Frame is quite similar to the P-Frame type. However it uses the picture in
      the following reference frame as well to calculate the picture providing a
      better standard of compression.




                                        11
Design and realization of an XBOX PVR system
______________________________________________________

Chapter 4 Networks and Protocols

4.1 IP
The internet protocol (IP) is a network layer protcol which achieves packet switched
inter-networking by allowing all nodes in the inter-network to behave as if they were
attached to a single network. IP attempts to provide a best-effort way to transport IP
packets or datagrams from one host to another regardless of whether these hosts are
on the same network or there are other networks to switch between.


The transport layer in an IP network fragments a data stream into IP packets typically
in accordance with the Maximum Transmission Unit(MTU) of hte data-link layer
protocol to which the host is attached. This packet is transported through the network
as an independant entity which knows where its going independantly of the stream to
which it belongs, and is routed by means of a 32-bit IP address through inter-
connected networks by routers.


4.2 UDP
UDP(User datagram protocol) is a protocol used in communitation between
computers. It offers a limited or “best effort” amount of service it provides when
transfering messages across a network that used the Internet protocol. It is an
alternative to TCP(Transport control protocol) and is normally used together with IP
to transfer data units of datagrams from computer to computer. However UDP does
not provide some key services that are essential for some applications. It has no way
of sorting the order of datagrams when they arrive at the destination. This could cause
chaos if the application was audio or video. It also has no way of letting the sender
know that the destination has recieved the datagram alright. Once the host sends it, it
is done with it and moves on to another task. Network applications that are sending
very small files and hence very small data units tend to use UDP instead of TCP
because it will be faster and more efficient without having to worry about ordering
and ensure data will arrive.




                                          12
Design and realization of an XBOX PVR system
______________________________________________________



+    BITS 0 – 15                              BITS 16 -31
0    Source Port                              Destination Port
32   Length                                   Checksum
64   Data
Figure 4-0-1 UDP Datagram


An image of a UDP packet is shown above. UDP uses port numbers to allow
applications to communicate. The port number is given by a 16 bit binary number
which is a range of 0 – 65,535 number of ports. The function of these ports are
seperated out. Port 0 is reserved, while ports 1 to 1023 are well-known prots used in
Unix operating systems. Ports 1024 – 49, 151 are registered ports and the remaining
ports are used as temporary ports used by the client while communicating with the
server.


4.3 TCP/IP
Transmission Control Protocol is at the core of the internet protocol collection. It is
central because it allows hosts on a network to connect directly to other hosts which
they can transfer streams of data. The transmission control protocol takes care of the
re-ordering of packets and guarentees sucessful delivery of packets with key
operations of the protocol.
TCP also supports most of the more popular internet applications such as world wide
web, e-mail, file transfer protocol and secure shell.




                                           13
Design and realization of an XBOX PVR system
______________________________________________________




Figure 4-2 Full TCP Protocol
Figure 4.2 shows the transmission control protocol, notice that UDP has the ability to
start sending datagrams straight away where TCP begins a three state process.
                1. Connection establishment


                               SYN MESSAGE




     CLIENT                                        SERVER
                          SYN ACK MESSAGE




                                  ACK




Figure 4-0-3 TCP Connection Establishment



                                             14
Design and realization of an XBOX PVR system
______________________________________________________
In the first phase of TCP transmission (connection establishment), a connection
between the client and server is created. It starts off with the client sending a SYN
message to the server. This asks the server for permission to communicate. The server
sends back a message to say it got the message and its ok to communicate. The client
then sends back a message (ACK) to say ok I’ve got that message let’s start.


Phase two is the actual data transfer. This is where TCP is really set apart from UDP.
UDP doesn’t care where a packet arrives or if it arrives, it basically just spits out the
packets in the hope they will arrive. TCP accommodates for this and ensures both the
packets arrive in the correct order and ensures that the data arrives safe and sound. It
also provides a number of other tasks such as discarding duplicate packets and
congestion control.
In the initial handshake where both client and server get setup to transmit packets an
initial sequenced number (ISN) is exchanged. This number identifies the order of the
packets being sent from computer to computer. Every time a packet is transmitted this
number is incremented. The number in practice is stored in the sequence number
field and the receiver sends an acknowledgement value of the next byte they expect to
receive.
In basic TCP when if an error occurred in multiple packets containing a stream on
data, the client would have to resend the entire data load again. However a new option
called SACK (selective acknowledgment) allows TCP to only send the packets that
were corrupted or never arrived in the first place. It works by allowing the receiver to
send ACK’s of which packets that were received ok and to request the missing
packets. It gives each packet a sequence number for the bits it contains and then if the
ACK for a particular sequence never arrives then the client knows to resend that
packet.
The last stage of TCP is the connection termination.




                                           15
Design and realization of an XBOX PVR system
______________________________________________________

                3. Connection Termination


                            FIN MESSAGE




    CLIENT                                          SERVER
                          FIN ACK MESSAGE




                            FIN MESSAGE




                         FIN ACK MESSAGE

Figure 4-0-4 Connection Termination
It is normally a four way handshake in which either side can initiate. One side will
send a FIN packet in which it requests to finish the conversation. The opposite site
will send an ACKnowledgment to this and will then send its own FIN message to
which the initiated side will send the ACKnowledgment packet. A 3 way handshake
is also possible to end the conversation. It happens when the first ACK has included a
FIN message in the same packet.


4.4 IP Addresses
Every machine connected to a network or sub-network needs to have some address in
which another terminal knows where to connect to it. It is similar to our postal
service. Every house has an address in which letters can be dropped off or picked up.
Computers work very similar. An IP address in a number assigned to the computer
statically or dynamically for a temporary or permanent period in which other
computers can see and connect to. An IP address consists of a 32bit binary number
which is divided up into octets and converted to decimal so that the human brain will
find it easier to remember. The total pool of IP addresses are divided up into 3 classes.
Class A, Class B and Class C. However there are some reserved IP addresses such as:




                                            16
Design and realization of an XBOX PVR system
______________________________________________________
    •   0.0.0.0 which is the default network
    •   127.0.0.1 which is the loop back address and is used when a computer wants
        to send message to itself
    •   255.255.255.255 is the broadcast address for messages that are to be sent to
        the entire network


Class A is used for very large networks such as major international companies. Its
first octet is in the range of 1 to 126 which means there are 126 class A networks
available each containing 16,777,214 possible hosts and a total of 2,147,483,648
unique IP address. They account for half the total available IP addresses. Important to
note that class A addresses binary number always begin wit ‘0’.


Class B is used for medium sized networks such as a large college campus. They have
their first octet in the range of 128 to 191. The also include the second octet as part of
the Net identifier. The class B IP address pool accounts for a quarter of the total of all
the IP addresses. Lastly their first binary value will be a ‘1’ and the second most
significant bit will be a ‘0’.

Class C addresses are commonly used for small to mid-size businesses. IP addresses
with a first octet from 192 to 223 are part of this class. Class C addresses also include
the second and third octets as part of the Net identifier. The last octet is used to
identify each host. Class C networks make up an eighth of the total available IP
addresses. Class C networks have a first bit value of 1, second bit value of 1 and a
third bit value of 0 in the first octet.




                                           17
Design and realization of an XBOX PVR system
______________________________________________________

4.5 Practical Gateway/Sub-Network
The concept of setting up a network is simple. We want to have a network that can
communicate freely with other terminals inside the networks and we also want an
access point where traffic and access larger networks such as the internet. This access
point is called a gateway.




                                      Sub-Network




 Larger Network



Figure 4-0-5 Network at a Glance



It is not as straight forward as this though in practice. We need a terminal to act as the
gateway. We use a HUB for the small sub-network in order to connect up the multiple
terminals and allow them access the to the single network port on the gateway
terminal similtaneously. The correct setup for the small sub-network is shown in fig
4.6.




                                           18
Design and realization of an XBOX PVR system
______________________________________________________




Figure 4-0-6 Practical Sub-Network


In this sub-network, the gateway terminal will have two network cards. They should
be named eth0 and eth1. One will be used as a connection for the larger network
(possibly the Internet) and the other will be configured to for the use of the sub
network.


    •   The IPtables should be configured to allow the eth0 and eth1 network card
        communicate.
    •   The HUB should be connected and powered on.
    •   Terminals added to the HUB
    •   IP addressed set Statically on the terminals
    •   It should use the default gateway address of the network card and it should
        point to the gateway IP address.
The IP address of the sub-network card and all terminals of the sub-network should
look like
                        192.168.0.X
    Where X is the user defined fourth octet.




                                           19
Design and realization of an XBOX PVR system
______________________________________________________

Chapter 5 MYTHTV Installation

5.1 uPnP
As MythTV architecture is based on client and server technology it implements a plug
and play protocol in order for new frontends to be easily added. The uPnP or
Universal Plug aNd Play protocol is implemented by MythTV in order to allow this
feature.


Universal Plug aNd Play extends the simplicity of the plug and play to include the
entire network, enabling discovery and control of networked devices and services
such as network attached printers, internet gateways and consumer electronics
equipment.
UPnP is more than just a simple extension of the plug and play peripheral model. It is
designed to support zero-configuration “invisible” networking and automatic
discovery fro a breadth of device categories from a wide rage of venders.


-Discovery Once devices are attached to the network and addressed appropriately,
discovery can take place. Discovery is handled by SSDP (simple service discovery
protocol). When a device is added to the network, SSDP allows that device to
advertise its services to control points on the network. When a control point is added
to the network, SSDP allows that control point to search for devices of interest on the
network. The fundamental exchange in both cases is a discovery message containing a
few essential specifics about the device or one of its services, for example its type,
identifier and a pointer to its XML device description document.


-Description After a control point has discovered a device, it still knows very little
about it. For the control point to learn more or interact it must receive the devices
description from the URL provided by the device in the discovery message. The uPnP
description for the devices is expressed in XML form and vendor specific,
manufacturer information including the model name and number, URL’s to vendor
specific web sites etc.




                                          20
Design and realization of an XBOX PVR system
______________________________________________________
-Control After a control point has retrieved a description of the device, it has the
essentials for device control. Each service on the device has a description which
includes a list of commands or actions that the service responds to. To control a
device, a control point sends an action request to a devices service. To do this the
control point sends a suitable control message to the control URL for the service.
They are expressed in XML using SOAP.


-Eventing The service publishes updates of its current status by sending event
messages. These messages contain one or more variable and the state and value of the
variables. They are based on XML and are formatted using GENA.


-Presentation If a device has a URL for presentation, then the control point can
retrieve this page and load it up in a browser. Depending on the page capabilities
allow the user to control the device.


5.2 Adjusting the sources list
Using Ubuntu’s many features there are few ways in which to install MythTV. For
arguments sake it was found easier to install it through the command line. The first
thing that needs to be done while installing programs on Ubuntu is to adjust the
source list to allow access to the different type of restricted files. The source list is a
configuration file that is located in the /etc/apt/ directory. This directory can be
accessed using the change directory command such as :

   •   sudo cd /etc/apt/


Using the text editor nano manipulate the file to allow the programs you want to be
downloaded. Open up the sources.list file in nano with the command:



   •   sudo nano /etc/apt/sources.list




                                            21
Design and realization of an XBOX PVR system
______________________________________________________




Alter the file so it should read like this:


    •   deb http://archive.ubuntu.com/ubuntu/ edgy main restricted universe multiverse
    •   deb http://archive.ubuntu.com/ubuntu/ edgy-updates main restricted universe multiverse
    •   deb http://security.ubuntu.com/ubuntu/ edgy-security main restricted universe multiverse
    •   deb http://archive.ubuntu.com/ubuntu/ edgy-backports main restricted universe multiverse


Now exit the source list and save the file, overwriting the current file. At this point the
system should be updated. This will renew the extra downloadable material and allow
the MythTV tarball to be downloaded. The following two code extras will update the
system. It will also upgrade your system packages to the newest available packets.


    •   sudo apt-get update
    •   sudo apt-get upgrade




Now the system is ready for the main parts of the MythTV installation. The first part
of the installation is to have a MySQL database up and running.


5.3 MySQL/MySQL protocol
MySQL is a multithreaded, multi-user SQL database management system that is
extremely popular around the world. MythTV uses the semi open source database
software of a way of storing vital pieces of information such as files, passwords,
usernames and video images.


Some basic commands for maneuverability are as follows. It is important to put the
semi-colon after the command as it is a command and will not execute unless you do.


    •   create database [databasename];
This command creates a new database with the name of the new database instead of
the brackets.

    •   drop database [database name];


                                                22
Design and realization of an XBOX PVR system
______________________________________________________
This command deletes the database requested.


   •   show databases;
This command list all the available databases


   •   use [database];
This command uses the database selected.


   •   Show tables;
This shows the tables that are contained in the database.


   •   Describe [table];
This command allows u to view the table selected and the value inside.




MySQL Protocol is based across a client and server negotiation. It includes agreeing
the protocol features and authentication. It uses a series of requests and responses
between the client and server until one of the two issues a QUIT message or the
connection is broken. The client message is sent as a single packet however the server
response may consist of a number of packets.


The structure of the packet begins with a 4-byte header. The first 3 bytes show the
length of the body and the fourth gives the packet number. The message body then
follows that.

Connection

The first packet will be sent by the server containing the MySQL database. It will
send information in this packet describing itself. The first byte of the message body is
the protocol version. This is followed by a version string and then by a 4-byte integer
giving the ID of the server thread handling the request. The next 8 bytes are used for
encryption. Then there are 2-bytes to tell the client about the servers capabilities. This
is followed by 16 bytes of there severs characteristics. The last 12 bytes are the
remaining part of the encryption.



                                           23
Design and realization of an XBOX PVR system
______________________________________________________
Authentication

It is now the clients turn to send it information about itself. First thing sent is the
password along with some information regarding a secure connection. This is then
follow by the maximum packet size and the clients character set. It then sets its SSL
bit then to allow security with the server. This is then followed by a username and a
encoded password. Also if a client is trying to connect to a particular database, this
will be included and permissions checked. The client then wait for the server to send
an OK message. After the OK message the client can begin giving orders.
Response
Most commands produce a simple “OK” response from the server. The OK response
of the initial authenication will be numbered 2. More responses will follow as the
client issues commands.


MySQL Cofiguration for Mythfrontend
In order for MySQL to be accessed remotely, as in this project my the Mythfrontend
in order to access MPEG files and other such files stored on the backend server,
access has to be granted using the mysql configuration file. This can be accessed
using a text editor to alter the settings. The following command will open up the
configuration file.



          1.     # sudo nano /etc/mysql/my.cnf


Scroll through this file until you come across the line that states the following.



               bind-address= 127.0.0.1


My commenting this out using an “#” (astrix) it takes the binding away from only the
local computer and allows remote access into the data base. When you exit the file
and save you will then need to restart the mysql server with the command.

          # sudo /etc/init.d/mysql restart




                                                 24
Design and realization of an XBOX PVR system
______________________________________________________
You may need to create a user and add it to the table of users for a remote user. This
should then allow you to access the database provided passwords and usernames are
correct.


5.4 XMLTV
XMLTV is a set of utilities to manage your TV viewing. They work with TV listings
stored in XMLTV format which is based on XML. The idea is to seperate out the
backend (getting the listings) from the frontend(displaying them to the user) and to
implement useful operations like picking out your favourite programmes as filters that
read and write XML documents. At present backends grabbing TV listings for
Austraila, Belguim, Luxemburg, Brazil, Britian and Ireland, Denmark, Estonia,
Finland, France, Germany, Hungry, Romania, Iceland, Italy, Japan, Netherlands,
North America, Norway, Portugal, South Africa, Spain, Sweeden and Switzerland.
There are filters to sort the listings to date, remove shows that have already been
broadcast and a couple of programs to organise your viewing by storing preferences
of what shows you watch. Some backends can produce a printed output.




                                         25
Design and realization of an XBOX PVR system
______________________________________________________


5.5 MythTV Installation and Configuration
To install all the applications, severs and databases required for MythTV you can use
numerous commands on the one line which will install them all at the same time. The
commands together will look like this.


           o   sudo apt-get install mythtv-frontend gdm ubuntu-artwork xterm openbox gnome-
               screensaver xserver-xorg gsfonts-x11 xfonts-100dpi xfonts-75dpi msttcorefonts
               xfonts-base mysql-server mythtv-backend mythtv-database usplash-theme-ubuntu



This will install the MythTV front-end software, the MySQL server, the backend
server and the database. A mythtv user will be created and added to the MySQL
database. The database will be installed into the MySQL and some initial
configuration will be performed. It will ask you for the password for the root user of
MySQL (well it should) but by default there will be none. (see problems)

From here you will be able to run the MythTV setup with the command.


   # sudo mythtv-setup


This will load up the GUI setup screen and you will be given a number of options.

   •   General
   •   Capture Cards
   •   Video Sources
   •   Input Connections
   •   Channel Editor




                                              26
Design and realization of an XBOX PVR system
______________________________________________________
This is the tricky part of the installation. Depending of the type of setup you are going
to have there are some different configurations. For example a backend/front-end
machine will not have the same configuration as a separate backend server and front-
end client. For the separate client and server machines the setup up should be close to
as follows.

General The IP address should be changed from the default 127.0.0.1 to the address
of the Backend server which is it statically assigned address of the current machine.
Most of the other settings in this part can be left as default.

Capture Cards This configuration deals with the hardware that you have installed in
order to capture the TV as is probably obvious in this case is a capture card. To add a
new capture card to the MythTV database, select “new capture card”. Move across
using the directional arrows to find the type of card installed and then press finish.

Video Sources This menu is used to configure your sources from the type off grabber
that you are using. When it opens up it ask you to add a new video source. It then asks
you to name it. A simple name like “Antenna” will do just fine. It then asks you some
general questions such as what type of grabber will you be using and for what country
it will be grabbing information. An XMLTV grabber will be used to grab information
from Ireland listings.

Input Connections When you open this menu you will be presented with the video
sources that you have defined previously. You must make a selection of one at a time
in order to configure their inputs. At the bottom of the menu it gives you two options.
One will be to scan for channels, which basically is like an automatic scan for
channels on your television set. It starts at a low frequency and keeps increments until
the resonant circuit vibrates enough to determine a signal has being picked and it
stores this frequency as a hexadecimal number and continues like this until it has gone
through the entire range of frequencies. The other option is to scan for channel
listings. This works by using the grabber for the predefined area, which as a set array
of channels already allocated. My switching to the command line the user can choose
which channel listing’s he or she would like to download. This is quite a tedious
process.




                                            27
Design and realization of an XBOX PVR system
______________________________________________________
Channel Editor This is just basic setting that allows you to scan for channels and
then to edit their names, numbers and position in sequence. It also allows you to
define a starting point for live TV when first turned on.




5.6 Frontend Configuration

The installation for a separate frontend is pretty straight forward, as there is no
MySQL database to be created of backend sever. Basically you just need to install the
software and allow the frontend access to the MySQL database. Firstly install all
software with the command.


           o   sudo apt-get install mythtv-frontend gdm openbox gnome-screensaver xserver-xorg
               gsfonts-x11 xfonts-100dpi xfonts-75dpi msttcorefonts xfonts-base ubuntu-artwork
               xterm usplash-theme-ubuntu


Like before this will install all the software needed to run the frontend. The next step
is the key step in the frontend installation. The best option before tying to configure
the frontend is too ensure the frontend has access to the MySQL database. This can be
done by trying to log into the database remotely. Ensure that the permissions have
being set and that password is correct before accessing. Once you are sure you can
access it, the configuration should be a breeze.


Run the mythTV frontend software to be presented with the frontend setup. Ensure
that the MySQL password is right and the IP address of the backend server is pointing
to the right backend. The MythTV frontend should kick up just like on the
backend/frontend machine and all the options should be available.




                                              28
Design and realization of an XBOX PVR system
______________________________________________________


Chapter 6 XBOX modification


6.1 Xchanger chip
The Xchanger chip is a modification chip for the XBOX developed my teamXchanger
and is from a number of sites on the internet. It allows the XBOX to bypass the
original BIOS settings and allows them to create a number of changes to the software.
The impressive little chip comes with its own impressive specs. It has an onboard
memory size of 1024K, two separate bios banks of 256K and 512K and has its own
customizable boot menu.




Figure 6-0-1 Modification Chip


It is a simple, cheap soloution to alter the XBOX for MythTV and comes with some
nice features along the way. It allows you to flash the XBOX harddrive either from
the internet or by using a CD. With a little detailed soldering it can be easily installed.
It fits nicely into its installation point and provides the easest possible soldering
access.




                                            29
Design and realization of an XBOX PVR system
______________________________________________________


6.2 Opening the XBOX
(images taken from http://store.richspsxparts.com/howtoopxboxc.html )

Believe it or not opening the XBOX is possibly the toughest part of the whole
modification. Before opening the XBOX you will need some special tools to gain
access. You will need a TORX T-10 and a TORX T-20 screwdriver as the XBOX
case has six T-20 screws and a few more T-10 screws.


It should be noted that by opening the XBOX you are voiding all warranties with
Microsoft and they will not be liable for any damage afterwards.


On the underside of the XBOX there are four rubber protective pads. Under these
pads are four of the six T-20 screws. Gently remove the pads as you may wish to re-
apply them later. Unscrew the screws. Another screw is conveniently located under
the Microsoft warranty sticker which you must tear in order to access the screw.




Figure 6-0-2 Removing Cushins


There may be other screws depending on your XBOX version. After you have removed all six screws
simply turn over the XBOX and gently lift off the lid.




                                                  30
Design and realization of an XBOX PVR system
______________________________________________________




Figure 6-0-3 After Removing Lid


After you lift the top off, this is what you will see. There are three screws, circled in
yellow, that you will need to remove the DVD ROM drive and power supply. To
change the power supply, you must remove the hard drive from the xbox. There is no
need to remove the power supply connector to the hard drive, but you will need to
remove the IDE Cable. Don't forget to replace it when you're done, or you will get a
customer service error code 7.


Below is a visual after you remove the IDE cable from the hard drive, and remove the
hard drive.

From here you need to remove lots of the small cables such as the controllers and
power cables in order to allow you to remove the mother board.




                                           31
Design and realization of an XBOX PVR system
______________________________________________________




Figure 6-0-4 After Taking out the Hard Drive


6.3 Finding the XBOX version
(taken from http://www.xbox-linux.org/wiki/Xbox_Versions_HOWTO )

There are a number of good ways to determine which XBOX version you have. A
simple way is to check the serial number and compare it against a graph on the
internet.

On the bottom of the Xbox, you can see the manufacturing date and the serial number.
The manufacturing date is in the following format.

YYYY-MM-DD

The serial number is a twelve digit long number and is divided up into the following
format.

LNNNNNN YWWFF

The L is the number of the production line within the factory, The N’s are the number
of the XBOX produced that week, the Y is the last digit of the year, the WW is the




                                               32
Design and realization of an XBOX PVR system
______________________________________________________
week number in that year and the FF is the factory code ie what country it was
created in.




Look at the factory code, i.e. the last two digits of the serial number.

If the factory code is "03" (Hungary), you are done: You can be sure that it is a 1.0
Xbox. You can even be sure that it contains a Thomson DVD drive

If the factory code is "02" (Mexico), it is either a 1.0 or a 1.1 Xbox. Look at the
manufacturing date: If it is November 2002 or later, you have a 1.1 Xbox, else it's a
1.0.

If the factory code is "05" (China), you have at least a 1.1 Xbox.

If the factory code is "06" (Taiwan), you have at least a 1.3 Xbox

If you have a "Halo Special Edition" Xbox (translucent green), you have version 1.2,
which has been made in weeks 8 and 9 of 2003 on lines 2, 5 and 6.

If you have a "Crystal Special Edition" Xbox (translucent white), you either have a
version 1.5 or 1.6 which were made in weeks 32 to 34 of 2004.(Which is not on the
list below)

Find out the production line of the Xbox, which is the first digit of the serial number.
Then find out the year and week of your Xbox. The first digit of the second block is
the last digit of the year (i.e. 2 or 3 for 2002 or 2003), and the following two digits are
the number of the week. For example, the serial "1111111 31205" is from week
12/2003.

Now look up the box corresponding to the week and the production line in the
following table. The legend below the table will tell you the meaning of the colors.
Note: Anything After 18\04 Is mainly Unknown and is most likely to be a version 1.6
or 1.6b.




                                            33
Design and realization of an XBOX PVR system
______________________________________________________




6.4 Soldering the chip
Image taken from http://www.teamxchanger.com/?page=manuals




Figure 0-5 Description of the Soldering on 1.6b


6.5 XBMC
XBOX Media Center is an open source (under GPL) that is developed by the XBOX
team at Microsoft that provides a home media center application on the games
console machine. It is simply a nice GUI system that presents the user with a lot of
options. It provides the user with access to the hard drive on the XBOX and allows
the user to download scripts to the hard drive. Many of the scripts are used to play
video files from usually another source such as the internet. The software provides
support for a large number of video formats such as DVD-Video, VCD/SVCD,
MPEG-1/2/4, DivX, Mp3, AAC, JPG, GIF and PNG. Using Samba or another file
transfer system scripts can be transferred to the XBOX for the use by XBMC.




                                                  34
Design and realization of an XBOX PVR system
______________________________________________________
This large range of video formats included MPEG and PNG which are used by
MythTV and as a result MythTV is an ideal candidate for an XBMC script.




6.6 Samba Server and configuration
Sama is an open source server application that has been around since 1992. It
provided file and print services to all SMB clients including clients from a Microsoft
Windows operating system. It is freely available under the GNU public license.
Samba is used to transfer files from the backend to the XBOX frontend. It is used to
transfer over firstly the MythTV partial frontend from the PC to the XBOX. Samba
then needs to be configured in order to allow the XBOX frontend to use it to gain
access to the MPEG files that are stored when live TV is running or to replay back a
recording on the backends hard drive.


Before rushing into configure samba you need to know two important pieces of
information. First you need to know where the MPEG files for live TV and recorded
are saved. You will need to allow the samba client access to this directory, also to
allow the XBOX frontend to request LiveTV of its own you need to either give it
permissions to the capture card or mythTV’s ringbuffer.


So after find that the MPEG’s are stored in /usr/share/ you need to give samba client
access to both this directory and /dev/video0. To do this you first need to create a user
name and password that will have the access. To do this you use the command.


sudo smbpasswd -a system_username
sudo nano /etc/samba/smbusers


After you type the first line you will be prompted to set a password. Type the
password and then a second time and remember it as you will need it while accessing
TV from the XBOX. The open up the samba users file with nano and insert the user
into the file and exit and save.




                                           35
Design and realization of an XBOX PVR system
______________________________________________________
Now to actually configuring the configuration samba file. It is probably best to make
a copy of the file first so copy the file into a back up file using the command.


sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup

Now open the configuration file using nano as the root user sudo using the command.


sudo nano /etc/samba/smb.conf



Find the line that looks like.
; security = user



And replace it with the user file you created, so it should look like this.


security = user
username map = /etc/samba/smbusers



This takes care of giving the new user access to samba but there still is the matter of
the permissions to the directories. To change the permissions on these directories you
need to use the commands.


sudo chmod 777 /dev/video0



sudo chmod 777 /usr/share/



This changes the files to read, write and executable. You now need to back into the
configuration file and create the script by adding these two pieces of code to the
bottom.
[Video]
 comment = Video Folder
 path = /dev/video0
 public = yes
 writable = no
 valid users = system_username1 system_username2


                                              36
Design and realization of an XBOX PVR system
______________________________________________________

 create mask = 0700
 directory mask = 0700
 force user = nobody
 force group = nogroup
[Recordings]
 comment = Recordings Folder
 path = /usr/share/
 public = yes
 writable = no
 valid users = system_username1 system_username2
 create mask = 0700
 directory mask = 0700
 force user = nobody
 force group = nogroup



You should exit and now have samba configured and ready for use.




                                             37
Design and realization of an XBOX PVR system
______________________________________________________


6.7 XBOX Mythfrontend settings
When you first run the XBMC MythTV script it will do a number of things. It will
first check that there is a full connection to the backend connection. If this fail it
means that some where in you internet setup you IP addresses have gone wrong.
There are a number of settings you should check to ensure this is ok. You should
check to see if your IP address of you machine is OK, there is a default gateway
address as well. If you are using a sub-network with the gateway as a PC with two
network cards this should be the IP address of the network card that the XBOX is
connected to. Other address to note should be the DNS server address.


When this is connected you should see news scrolling across the main XBMC screen.
You can now run the MythTV script. You should be presented with a basic frontend
allowing you to do most of the frontend activities such as watch live TV, schedule a
recording, watch a recording etc. In order for these to work you will need to ensure
that Samba has being configured properly so these MPEG’s can be accessed remotely.
If it has then you should go into settings and where it says paths, point the paths for
live TV and recordings to the path that you have created with access to the media
streams. Once this is done the XBOX will work just like the basic frontend without
any plugins.




                                          38
Design and realization of an XBOX PVR system
______________________________________________________

               Chapter 7 MythTV Protocol Investigation


7.1 Packet Sniffing/Ethereal
Ethereal or Wireshark as the version for Ubuntu 6.10 is called is an open source
software that is used for analyzing protocols or trouble shooting network issues. It is
called a packet sniffer application because basically it monitors the packets being
transferred between two points on a network and allows the user to analyze them in
sequence in the hope that the user can see what is happening on the network.
The application is very straight forward compared to other applications providing the
same service. It has a simple and pleasant GUI system which has three main buttons.
The first allows you to setup a new capture session and in this asks where it should be
capturing the packet from, such as at the network card point or else where. The
second button allows you to filter out packets that you don’t want to be concerned
with, such as the endless ACK packets in TCP. This is a very helpful feature when
trying to analyze very minute details of a protocol. The third is basically to re-run a
new capture session with the same settings as the previous which just takes away from
the slight hassle of reconfiguring your session.
Ethereal/Wireshark is a software that understands and knows the structure of different
network protocols such as TCP, IP, UDP and MySQL. When capturing these packets
is assigns them a protocol tag which allows the user to quickly determine which
protocol is being used. It shows you the group of bytes captured for each packet, and
then neatly places the information into a structured Tree. The user can open up the
tree system an view all the information captured. It is clear to read and very well
presented.




                                           39
Design and realization of an XBOX PVR system
______________________________________________________



7.2 Catching Packets
In order to capture packets across your network, you first need to ensure that your
network has not broken down anywhere. Use a simple ping command to ensure that
one terminal can see another. Next download the packet sniffing software Ethereal
from the packet manager feature in Ubuntu. After you have downloaded this it should
be available in the applications menu. Open up Wireshark using root. This will bring
you to the main GUI for the application. You will have the three main buttons to your
top left. They will look like little circuits or chips. Click the one on the very left and
this will bring up some options. You should see one with the name of you local IP
address and a button opposite saying capture. Click on this and it will begin capturing
traffic across this network cards port. From here the MythTV protocol can begin to be
analyzed.



7.3 MythTV Protocol
To investigate the MythTV protocol is quite difficult because there is so much
happening. I decided the best way was to individually press buttons and monitor the
packets being transfer while I did that. I would stop the capturing process just after I
pressed the button so I would just capture what happended in that moment. The first
thing I captured was the process of what happened when the client initiated the
MythTV frontend software the following is the observed process.




                                           40
Design and realization of an XBOX PVR system
______________________________________________________

               MythTV frontend connection to Backend
                                             TCP




                                      TCP (SYN,ACK)


                                        TCP (ACK)
                                                          DNS QUERY
    CLIENT                                                                SERVER




                                                       DNS REQUEST

                                        DNS
                                      SERVER
   FRONTEND                                                               BACKEND
                                                       DNS RESPONSE




                                   MySQL Greeting




                                       TCP ACK




                                          MySQL info




                                          TCP ACK




                                     MySQL REQUEST



                                      MySQL RESPONSE




Figure 7-0-1 Frontend Connection


   •   Firstly the backend initiates a TCP connection with the frontend using the TCP
       three way handshake.
   •   The backend then queries the DNS server to see if its name is in its database,
       and the DNS will return and answer.
   •   The backend will then send the MySQL greeting packet using the MySQL
       protocol.



                                           41
Design and realization of an XBOX PVR system
______________________________________________________
    •    An ACKnowledgment will be send back by the client in TCP follow the
         clients informatin using the MySQL protocol.
    •    A TCP ACK is sent back from the server.
    •    Now the client can begin giving orders.

Another major part of the MythTV protocol is the mythfilldatabase command. This is
basically where the grabbers are used to grab TV listings from the internet and then it
populates the MySQL database. I setup the packet sniffer to capture this in action.
Note that mythfilldatabase can only be executed from the backend server.

                   M ythfilldatabase Events
                                                                  D NS Q UERY


                                                                 DNS R ESPONSE
                                            DNS
                                          SER VER
                                                                   U DP ACK




 212.58.235.206                                                                  SERVER

                                                    TC P SYN




                                              TCP (SYN,ACK)



  W w w.radiotim                                                                 BACKEND
     es.com                                     TC P (AC K)




                                              D ATA REQU EST



                                               TCP SEGM ENT




                                                TC P (AC K)




                                                    TC P (FIN)




                                               TCP (FIN,ACK)



                                                TC P (AC K)




Figure 7-0-2 Mythfilldatabase




                                              42
Design and realization of an XBOX PVR system
______________________________________________________
   •   The backend queries the DNS for a location of www.radiotimes.com. The
       DNS returns the address of 212.58.235.206 is returned. A quick UDP ACK is
       then sent.
   •   TCP handshaking begins between the backend server and the given location
       from the DNS.
   •   The backend then asks for a Data using TCP, The website then begins sending
       TCP segments containing the listings. After each segment a TCP ACK is sent
       back confirming they have arrived OK. The segments can contain plain text in
       some cases.
   •   Finally when all data has being transferred a three way TCP handshake ends
       the communication with a FIN TCP packet.




For most of the other operations such as pressing buttons work pretty much the same
with slight differences. When you record what happens when you press the program
guide button the following will occur.




                                         43
Design and realization of an XBOX PVR system
______________________________________________________
             PROGRAM GUIDE EVENTS


                                     MySQL QUERY




                                    MySQL RESPONSE




    CLIENT                             TCP (ACK)                      SERVER




                                     MySQL QUERY




                                    MySQL RESPONSE

  FRONTEND                                                            BACKEND




                                TCP (PUSH ACK)



                                TCP (PUSH ACK)




                                      TCP (ACK)




Figure 7-0-3 Program Guide Button


   •   The client sends a MySQL request to the database, the database sends a
       response using the MySQL protocol and the client sends a TCP ACK to say
       the data arrived fine.
   •   This persists until all the guide information has arrived over, it will depend on
       how many days listing you have selected and stored.
   •   The client then sends a TCP PUSH ACK which is too say all the data arrived
       over fine.
   •   The database replies with another TCP PUSH ACK to say the same and the
       client replyies with a normal TCP ACK to say he got that fine.



Most of the other button used this method of the MySQL protocol when pressed, they
query the database and receive a response and send and ACK back to the database




                                                  44
Design and realization of an XBOX PVR system
______________________________________________________
until all information has being transfer over. This is the same for deleting recordings
or selecting recording and even transferring over Live TV mpeg files.


7.4 Other Attempts at Documenting the Protocol
There have being very few other attempt to document the MythTV protocol that are
published on the internet. The very few that are found are very basic almost idea’s
about how it works. It seems that very few people have an interest in how it works
more so how the picture looks. This is an extract from an attempt that is published on
http://winmyth.sourceforge.net/mythprotocol.html.
20       MYTH_PROTO_VERSION 8
That will yield an "ACCEPTED" response.
Now we need to add ourselves to do stuff, this is done using the ANN command
(otherwise the other functions don’t work)
22       ANN Playback Myputer 0
Commands available through the protocol:

     •     ANN - Tells mythbackend "i'm here and i want to communicate" (Must be
           done to get any of the other commands to work)
              o ANN                      Method                 Host              Number
                   Method
                           Playback - So far, Playback is the only method i know, lets you
                           use      query_getallpending        and     probably      more
                           Host - Looks like you can put anything here, but your host
                           name                is             most             appropriate
                           Number - Possibly in case of multpile connections from one
                           host, here's an ID number (i use 0)
                           FileTransfer - I dunno
                           RingBuffer - I dunno
     •     DONE - Tells mythbackend "im done, i wanna go home" (closes the port)
     •     QUERY_RECORDINGS - Dunno ditto
     •     QUERY_FREESPACE - check free space on server i guess
     •     QUERY_CHECKFILE - check if file exists i guess
     •     QUERY_TRANSCODE - maybe check if something transcoded?
     •     QUERY_TRANSCODE_CUTLIST - dunno, check for something transcoded
           with the cutlist used
     •     QUERY_TRANSCODE_STOP - Done adding witty quotes
     •     STOP_RECORDING
     •     CHECK_RECORDING
     •     DELETE_RECORDING
     •     FORGET_RECORDING
     •     QUERY_GETALLPENDING - ask for all shows to be recorded (back end
           sends it back in standard myth list form)
     •     QUERY_GETALLSCHEDULED
     •     QUERY_GETCONFLICTING


                                             45
Design and realization of an XBOX PVR system
______________________________________________________
   •   GET_FREE_RECORDER
   •   GET_NEXT_FREE_RECORDER
   •   QUERY_RECORDER
   •   QUERY_REMOTEENCODER
   •   GET_RECORDER_FROM_NUM
   •   GET_RECORDER_NUM
   •   QUERY_FILETRANSFER
   •   QUERY_GENPIXMAP
   •   QUERY_ISRECORDING
   •   MESSAGE
   •   FILL_PROGRAM_INFO
          o FILL_PROGRAM_INFO                         program                   string
             Program string - the information you have in the myth program string
             format
             don't know what it returns, although i think its the filled out program
             info you had missing when you sent in the program string
   •   LOCK_TUNER
   •   FREE_TUNER
   •   QUERY_IS_ACTIVE_BACKEND
   •   SHUTDOWN_NOW
   •   BACKEND_MESSAGE

He seems to have tried to investigate the protocol using the code, I can imagine this
was very time consuming because I began doing it myself and there is so much code
contained in the Myth application that it would be a very big job for one person. I can
see why he only got a small piece of it done. Using the packet sniffer application over
a client and server architecture is a far more efficient way of investigating the
protocol.




                                          46
Design and realization of an XBOX PVR system
______________________________________________________

                       Chapter 8 Unihome Introduction

Unihome is an ongoing project undertaking by a number of researchers in which a
middleware program controlls the digial electronics in the house hold. Currently there
is no intergration with PVR’s and as such none with MythTv. If the understanding of
MythTv engineering is good enough some progress may be made towards uniting the
two technologies. A basic image of the Unihome structure is shown. (taken from
http://www.unihome.com/ )




Figure 8-0-1 Unihome


The idea of the Unihome project is to see if connecting the community to an
intergrated digital network is a concievable way to communicate better and share
resources. It connects home to a network and allows this network to connect to other
local networks such as schools, retail stores and educational institutes.


The are some main topical features of the project and they include family ties, estate
connect, DIY community platform, medical reminder and appointment system, school
applications and KidzGrow Connection



                                           47
Design and realization of an XBOX PVR system
______________________________________________________


Family Ties The idea of this application is to open up the possiblities and co-
ordination of family events by means of the interconnected networks. In theory it
should be possible to send invites many different means such as mobile phones and
other personal devices. It also aims to allow streaming of digial pictures accross the
networks to allow everyone to virtually attend.


Estate Connect Is an application that allows feedback from residents of an estate to
the local county council or persons incharge of running the estate. Feedback would be
based on the quality of services available and also may be possible to pay for the
services provided over the Unihome connection.


DIY Community Platform This would allow the community to arrange local advents
over the Unihome connection. They could create their own portal for each community
and then the members of that community could log in and voice their opinions.


Ipals School Applications Aims to provide better communication between the
parents of a student and that students teachers. The students progress in school can be
monitored easily through online communication between the parent and the teacher.


Medical Appointment and Reminder System This application will allow the home
user access to book online appointments to healthcare clinics. It will also provide
reminders to the clients about their appointments.


KidzGrow Connection Is used as a consultation medium for parents with learning
difficulties. It allows users to log in and chat with other parents in the same situation
and to have online consultations and attend webcast seminars.




                                           48
Design and realization of an XBOX PVR system
______________________________________________________

Chapter 9 Conclusion
As technology advances and people interest leans towards a unified home digital
center we will see a greater amalgamation of digital devices in the average house
hold. This transformation has already begun with the ever increasing number of PVR
systems being produced and high numbers of sales to the public on the ever increase.
This is a trend that for the foreseeable future will not decrease. Recently a new high
definition television sets have begun to sell. Television broadcast stations are already
broadcasting high definition channels to the public. As the price begins to plummet
with time, it is my belief that the device will be transformed into a high definition
personal video recording set.


For the time being the online community will continue to develop newer and better
features and plugins to add to the existing great selection of open source PVR
software’s available. While the hassle on self building continues to outweigh the
crazy price of buying a companies system people will continue these projects.


I found the project extremely enjoyable to undertake. It was a project that kept me
interested until the end and there would be many more things I would like to have
incorporated into it, but simply just ran out of time. MythTV is a huge online project
and this can be noticed with the huge support they generate on the mailing lists and
forms. For an open source software to have so many followers and devolopers around
the world is pretty impressive. I hope they keep up the good work and keep turning
out great plugins.



9.1 Problems encountered
During the project I under came some problems which dragged and slowed down the
process enormous. A lot of these problems are small things but are tough to discover
when you don’t know what you are looking for. My first main problem was that the
capture card (PVR-150) comes with only drives for widow’s machines. As I was
using Linux it would be a little difficult. However after a little investigation I found
that the Ubuntu community form had a detailed guide on how to install the drives and
modules. The next issue that arose was the configuration of the Myth



                                          49
Design and realization of an XBOX PVR system
______________________________________________________
backend/frontend single machine. The actual settings for these are very hazy. The
installation guide I was following from the Ubuntu community site told me to refer to
mythtv.org which basically gave me a short description of what each setting menu
was. It ended up being a basic trial and error setup until it eventually kicked off and
began capturing TV. Another issue I had was the MySQL password. When trying to
log in remotely it refused to allow me even after I had configured the configuration
file. I figured it was an issue with the password and realized my root password would
not even let me in. After a while I found a guide that showed me how to change the
root password and this allowed me to log in remotely.


9.2 Experience
Over the course of this project I have gained plenty of valuable experience. The main
area of experience was in the area of networking. Such as how files are transferred
across the network and the protocol that act on them. I have learned about different
applications used for transferring files such as SSH, FTP and Samba. I have learned
how to use these software’s and the issues surrounding each.


I have also learned a great deal about Linux, maneuvering between directories and
files have become second nature to me. This knowledge will surely be useful to me in
the long run.


I have also learned some basic MySQL operations and commands while searching
through the databases and configuration files.




                                          50
Design and realization of an XBOX PVR system
______________________________________________________


9.3 Final Status
Over the five milestones that were set out as the initial goals, I made some good
progress through them. The following is a list of the goals and their completion status
to date.


(i) Become familiar with the basics of Linux; install Linux on a desktop PC; install
MythTV on a desktop PC; demonstrate video capture, playback and live pause on a
single desktop PC


This step has been fully completed. I have installed Linux on a total of three
machines, with a total of four installations. I installed Gentoo distribution on the first
machine and then erased it to the preferred distribution of Ubuntu and then again on a
separated front-end machine. I then copied the back end hard drive onto an identical
machines hard drive in order to have two backend servers. I then installed the
MythTV application and demonstrated capture playback and live pause.


(ii) Become familiar with the MythTV application; install separate MythTV server
and client machines; preliminary investigation of the MythTV protocol;
investigate methods for capturing, analyzing and disassembling the client-server
communications


Over the course of the project I have become very familiar with the MythTV
application, I have installed a separate backend machine and two separate front ends. I
have investigated the Myth protocol and documented my findings. I have compared
these findings with the current attempts published on the Internet.


(iii) Modify an Xbox console and install Linux on XBox ; install MythTV and
get Myth client running on modded Xbox; demonstrate advanced Myth
functionality on Xbox




                                           51
Design and realization of an XBOX PVR system
______________________________________________________
I have soldered a modification chip onto the motherboard of an XBOX and installed
Gentoo Linux on the XBOX, I have also taken a second XBOX with a preinstalled
XBMC and added the MythTV script and configured the MythTV front-end. I have
shown some advanced techniques in MythTV such as scheduling recordings, deleting
recordings etc.


(iv) Study the Myth protocol; become familiar with the basic Unihome architecture
and review some simple Uhihome plugins; investigate the practical aspects of
integrating Myth with Uhihome and write a detailed report on this;
design and implement a basic Unihome plugin for Myth


I have studied the Myth protocol for some time and become familiar with how it
works, I have documented my findings in my thesis report. I have a brief
understanding of Unihome and how it works but I have not got any investigation done
regarding a plugin with MythTV.


(v) Become familiar with architecture and basic programming/configuring of
MythTV; demonstrate some customization of the standard system; test and
demonstrate some advanced application code; design and implement a
working means to integrate MythTV with UhiHome


I have ever so slightly investigate the code for MythTV, there is an awful lot and
would have being very tough to get it all done. The pieces I did look at I understood. I
have not written any advanced code to implement MythTV with Uhihome.




                                          52
Design and realization of an XBOX PVR system
______________________________________________________

                                      Glossary
OS- Operating System. It performs all the tasks executed on the computer and is at
the hearth of what the computer runs.

OSS- Open Source software is software that is freely provided to the public. It
includes the source code.

GNOME- GNU Network Object Model Environment. It the open source GUI system
used in Linux.

LINUX- Is an open source operating system developed by Linus Torvalds and is
based on the UNIX operation system.

GNU- is a free open source operating system consisting of kernels, libraries and a
compiler. It is a recurring acronym for GNU Not Unix.

GPL- General Public License is a widely used free software license, originally
written by Richard Stallman for the GNU project.

FTP- File Transfer Protocol is a system that allows safe transfer of files from server
to clients.

SSH- Secure Shell allows safe passage of file across a network.

NANO- is a text editor in Ubuntu that allows the user to create or edit a file.

SUDO- Super User DO, is the command in Ubuntu to fill the void of the root user.
Use this to give permission to run commands.




                                           53
Design and realization of an XBOX PVR system
______________________________________________________

                                   References

http://www.newegg.com/Product/Product.asp?Item=N82E16815116633

www.ubuntu.org

www.mythtv.org

http://www.usd.edu/trio/tut/start/gateway.shtml

https://help.ubuntu.com/community/Install_IVTV_Edgy

http://www.mythtv.org/wiki/index.php/Ubuntu_Installation

https://help.ubuntu.com/community/MythTV

www.wikipedia.org

www.XMLTV.org

https://help.ubuntu.com/community/Install_IVTV_Edgy

https://help.ubuntu.com/community/MythTV_Edgy

Image in chapter 4.3 taken from
www.wikipedia.org

Image in chapter 6.1 taken from
www.teamxchanger.com

Images in chapter 6.2 taken from http://store.richspsxparts.com/howtoopxboxc.html

Images in chapter 6.3 taken from
http://www.xbox-linux.org/wiki/Xbox_Versions_HOWTO

Image in chapter 8 taken from
http://www.unihome.com/




                                         54
Design and realization of an XBOX PVR system
______________________________________________________

                                   Appendix
Table of Passwords

Application                 Username                    Password
Ubuntu(frontend)            Dave                        Pcor
Ubuntu(backend)             Dave                        pcor
MySQL                       Root                        Madlad
MySQL(remote)               Mythtv                      Mythtv
MySQL(mythtv)               Mythtv                      Jjqinzfx
Samba(XBOX)                 Dave                        Madlad

Please find enclosed my sub-Network and XBOX PVR System.
I also enclose 2 XBOX’s one using XBOX media center and running the MythTV
frontend script and the second running XGentoo Linux. Please also find enclosed one
dual backend/frontend MythTV box. This machine also contains a PVR-150 PCI
capture card. Also there is separate Linux machine which houses a separate MythTV
frontend software. This is linked to the backend by means of a network HUB and
using the same monitor, keyboard and mouse with their own HUB.




                                        55

								
To top