Chapter 4. Streaming from a Computer

In this chapter we will cover:

  • All that is needed to stream media from your computer to Raspbmc
  • The advantages and disadvantages of remote streaming and local playback
  • Setting up streaming on Windows, Linux, and Mac OS X based computers

Remote streaming

We will primarily focus on streaming content from a remote system.

Remote streaming versus local playback

While remote streaming has some distinct advantages, it is not often necessary for this kind of setup. I've outlined a few reasons why remote streaming is advantageous and a few reasons why it may not be.

Advantages of network streaming

Disadvantages of network streaming

Content can be streamed from one machine to multiple devices simultaneously.

Remote system must be on whenever you wish to play content from it.

Maintaining your library across all devices can be done by updating a single location. Local playback requires identical content across multiple storage devices for each device to have the same content.

Higher energy consumption because the device your Pi is streaming from must be on as well.

Backups of media can be performed more easily as it is in a single location.

Generally, this works best on a server (a computer dedicated for the role of remote streaming), which can involve extra configuration steps.

A single system allows for larger hard drives, which gives a better £/GB ratio.

Central point of failure if the system is not properly maintained or backups are not made.

As we can see, if we are only planning to play content on one device at a time, it makes more sense to play the media locally. This can be achieved by attaching a USB drive to the Raspberry Pi, as we covered in Chapter 3, Managing Content.

Note

If you are not interested in configuring remote streaming, you may wish to skip this chapter.

Requirements for remote streaming

At the beginning of this book, we looked at why the Raspberry Pi was an ideal candidate for media center hardware. Likewise, there are suitable criteria that should be taken into consideration when choosing a computer to stream content from. These are ideally as follows:

  • A wired network connection: A wireless connection can fluctuate in signal strength and throughput, which can cause stuttering or frequent buffering due to dropouts and limited bandwidth. Protocol overhead can also affect this.
  • Low power consumption: A powerful computer is not particularly necessary for streaming, so we do not need to use components that consume a lot of power. Intel Atom barebones kits are available for around £50 and have very low power requirements. Alternatively, one can purchase a NAS, which provides a simple interface and easy storage configuration.
  • Device dedicated to streaming: Ideally, for best performance, the computer should only be used for streaming media and should be separate from desktop activities.

    Note

    While these characteristics are ideal for remote streaming, they are not a necessity.

On this system, we will set up network shares, which can then be added in XBMC on the Raspberry Pi to access content remotely.

Configuring network shares

Network shares permit the streaming of content remotely. We'll now look at how to achieve this on multiple platforms.

Configuring network shares on Windows

Windows has a built-in client-server implementation called Common Internet File System (CIFS). It allows access to files on remote shares that use the CIFS implementation as well as serving files to other systems that have an SMB/CIFS client implementation (such as Raspbmc).

Note that while all versions of Windows have the same CIFS client implementation, the CIFS server implementation in Windows varies depending on the edition you have. For example, Professional and Ultimate versions of Windows have support for Active Directory domains and thus allow for more fine-grained control over sharing permissions.

To share our content with Raspbmc, we will take advantage of Windows' built-in CIFS server implementation by creating a share as follows:

  1. First, we should either create or locate a folder which we will share the contents of.
  2. We should preferably ensure that the contents of this folder are all of the same type (that is, TV shows, movies, and music). This will make configuring Library mode much easier later on.
  3. Right-click on the folder and click on Properties, as shown in the following screenshot:
    Configuring network shares on Windows
  4. Now, click on the Sharing tab.
  5. Click on Advanced Sharing. We will use the Advanced Sharing settings so we can have fine control over Share name and simplified access to the source.
  6. Check the option entitled Share this folder and give the share a meaningful name as shown in the following screenshot:
    Configuring network shares on Windows
  7. By default, the share will grant all users read access. If you need to change this, you can do so by clicking on Permissions.
  8. Click on Apply and then on OK when you are done configuring the share. You can now close the Properties window.

We have now created a share. You can repeat these steps for all the different types of content you wish to serve, such as music, TV shows, and movies.

Your share is now accessible via \COMPUTER-NAME\SHARE-NAME, where SHARE-NAME is the name of the share you created (see the previous screenshot).

Note

Some home networks do not perform name resolution reliably. Thus, it is best to assign the computer that is to stream media a static IP address and substitute it for the computer name, for example, \192.168.1.2\SAM-MOVIES.

Configuring on Linux

We'll first look at installing the necessary packages for Network File System (NFS), and then we'll look at configuring them for our desired distribution.

Installing NFS

File sharing on Linux is typically done using the NFS protocol. This is advantageous to SMB as it has a lower CPU overhead (which is particularly ideal considering the CPU constraints of the Raspberry Pi) and is well implemented across platforms.

NFS server implementation can be done via the kernel or userspace. We will cover kernel-based implementation as userspace implementation is often deprecated in distributions.

The ensuing steps will assume you are running as the root user. In most distributions, you can also elevate your permissions using the sudo -s command.

Installation of NFS on Ubuntu/Debian/Linux Mint

Typically, these instructions will apply to any Linux distribution using Advanced Packaging Tool (APT) as its package manager. We'll need to enter these commands at the command line. In a UI, this can be accessed by opening the Terminal application:

apt-get update
apt-get install nfs-common nfs-kernel-server portmap
Installation on CentOS/Fedora/Redhat

Typically, these instructions will apply to any Linux distribution that is a derivative of Redhat and uses Redhat Packaging Manager (RPM) as its package manager. Here, you'll need to enter these commands at the command line, which can be accessed via Terminal if you are using a UI.

yum install nfs-utils nfs4-acl-tools portmap
Installation on Arch Linux

On Arch Linux, we can install the NFS utilities package via the command line, as follows:

pacman –S nfs-utils

Distribution independent configuration

We will now configure portmap. Note that, on some systems, this package is deprecated and replaced by rpcbind. Your package manager should inform you what package was selected. Follow the appropriate setup instructions given here:

  • For portmap:
    perl -pi -e 's/^OPTIONS/#OPTIONS/' /etc/default/portmap
    echo "portmap: 192.168.0." >> /etc/hosts.allow
    service portmap restart
    

    You should replace 192.168.0. in the example shown with your subnet, for example, 10.12.0.0.. This will allow devices on your LAN to access the NFS shares.

  • For rpcbind:

    Using your favorite text editor, edit the following line in /etc/default/rpcbind:

    OPTIONS="-w -l -h"
    

    Now, we can allow computers on the LAN to connect to our shares using the following command:

    echo "rpcbind: 192.168.0." >> /etc/hosts.allow
    

    You should replace 192.168.0. in the preceding command with your subnet.

    Note

    If you have a firewall installed, you should allow access to the ports UDP2049, TCP2049, UDP111, and TCP111.

Now that we have installed the necessary packages and configured the system, we need to create shares. This is called exporting as we are exporting a filesystem over NFS.

Shares are defined in /etc/exports. Let's open this file for editing with our favorite editor:

/home/sam/tvshows *(ro,all_squash,sync,no_subtree_check)

This example will export the folder /home/sam/tvshows to all systems and grant them read-only access. As this is a read-only filesystem, we could in fact specify the async parameter, which will improve performance. More information about the various NFS export options can be found in the Linux manual pages. After we make changes to this file, we need to restart the NFS server so that it will pick up the changes. This can be done as follows:

exportfs -a

Hopefully, we have now set up NFS file sharing.

Tip

Check what's shared

You can easily check shares you are exporting with the following command:

cat /etc/exports

Configuring on Mac OS X

OS X embraces Apple Filing Protocol (AFP) as its native file sharing protocol. After Lion, the SMB implementation changed, which caused issues with XBMC. Now that XBMC has gained native AFP support, configuring AFP is considered best practice for sharing files from a Mac.

  1. Click on the Apple logo and then select System Preferences.
  2. Click on the Sharing icon.
  3. Check the File Sharing checkbox if it is not checked already.
  4. Add any folders you wish to share by clicking on the + icon.
  5. Click on Options and check Share files and folders using AFP.
  6. Check the On checkbox for all users you wish to share these folders with.
  7. Click on Done.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset