Sign up here and you can log into the forum!

Plugin: Dreambox E2 streaming

UMSP Plugin Depot, the place for sharing plugins & info about them. No requests, just plugins/code.

Plugin: Dreambox E2 streaming   

Postby Toni » Sun May 02, 2010 11:54 pm

Now, if only streaming would work... I still need to beatify the code, and also the recordings plugin is a bit ugly.

/conf/umsp.php
Code: Select all
<?php

global $myMediaItems;

$myMediaItems[] = array(   
   'id'      => 'umsp://plugins/dreambox-channels',   #Attribute of item
   'parentID'   => '0',                     #Attribute of item
   'restricted'   => '1',                     #Attribute of item
   'dc:creator'   => 'myCreator',
   'dc:title'   => 'Dreambox channels',
   'dc:date'   => '2009-12-30',
   'upnp:author'   => 'myAuthor',
   'upnp:artist'   => 'myArtist',
   'upnp:album'   => 'myAlbum',
   'upnp:genre'   => 'myGenre',
   'upnp:length'   => '2:10:20',
   'desc'      => 'myDesc',
   'upnp:class'   => 'object.container',
   'upnp:album_art'=> '',
#   'res'      => '',
   'duration'   => 'myDur3',            #Attribute of res
   'size'      => 'mySize3',            #Attribute of res in bytes
   'bitrate'   => 'myBitr',            #Attribute of res
#   'protocolInfo'   => '*:*:video/avi:*',      #Attribute of res
   'protocolInfo'   => '*:*:*:*',      #Attribute of res
   'resolution'   => 'myReso',            #Attribute of res
   'colorDepth'   => 'myColor',            #Attribute of res
);

$myMediaItems[] = array(   
   'id'      => 'umsp://plugins/dreambox-recordings',   #Attribute of item
   'parentID'   => '0',                     #Attribute of item
   'restricted'   => '1',                     #Attribute of item
   'dc:creator'   => 'myCreator',
   'dc:title'   => 'Dreambox recordings',
   'dc:date'   => '2009-12-30',
   'upnp:author'   => 'myAuthor',
   'upnp:artist'   => 'myArtist',
   'upnp:album'   => 'myAlbum',
   'upnp:genre'   => 'myGenre',
   'upnp:length'   => '2:10:20',
   'desc'      => 'myDesc',
   'upnp:class'   => 'object.container',
   'upnp:album_art'=> '',
#   'res'      => '',
   'duration'   => 'myDur3',            #Attribute of res
   'size'      => 'mySize3',            #Attribute of res in bytes
   'bitrate'   => 'myBitr',            #Attribute of res
#   'protocolInfo'   => '*:*:video/avi:*',      #Attribute of res
   'protocolInfo'   => '*:*:*:*',      #Attribute of res
   'resolution'   => 'myReso',            #Attribute of res
   'colorDepth'   => 'myColor',            #Attribute of res
);

?>


/etc/umsp/plugins/dreambox-channels.php
Code: Select all
<?php

function _pluginMain() {

   # Hardcoded Dreambox address
   $dreamboxAddress = 'dm7025';
   
   # Services URL, list all channel from the Favourites bouquet
   $dreamboxServiceUrl = 'web/getservices?sRef=1:7:1:0:0:0:0:0:0:0:FROM%20BOUQUET%20%22userbouquet.favourites.tv%22%20ORDER%20BY%20bouquet';
   
   $reader = new XMLReader();
   $channellistXML = file_get_contents('http://' . $dreamboxAddress . '/' . $dreamboxServiceUrl);
   
   $reader->XML($channellistXML);
   while ($reader->read()) {
      if (($reader->nodeType == XMLReader::ELEMENT) && ($reader->localName == 'e2service')) {
         #
         # Read channelinfo child nodes until end
         #
         do {
                 $reader->read();
                      if (($reader->nodeType == XMLReader::ELEMENT) && ($reader->localName == 'e2servicereference')) {
               $newChannel['id']  = $reader->readString();
            }   
                 if (($reader->nodeType == XMLReader::ELEMENT) && ($reader->localName == 'e2servicename')) {
               $newChannel['title'] = $reader->readString();
                 }
         } while (!(($reader->nodeType == XMLReader::END_ELEMENT) && ($reader->localName == 'e2service')));
         #
         # New channelinfo item parsed. Now add as media item:
         #
      
         $retMediaItems[] = array (
            'id'          => $newChannel['id'],
            'res'         => 'http://localhost/umsp/plugins/dreambox-proxy.php?itemUrl=http://' . $dreamboxAddress . ':8001/' . $newChannel['id'],
            'dc:title'       => $newChannel['title'],
            'upnp:class'      => 'object.item.videoitem',
            'upnp:album_art'   => 'http://localhost/umsp/picons/' . rawurlencode($newChannel['title']) . '.png',
#            'upnp:album_art'   => 'ftp://root:root@' . $dreamboxAddress . '/etc/picon/' . $newChannel['title'] . '.png',
            'protocolInfo'     => 'http-get:*:video/mpeg:*'
         );
      } # end if
   } #end while
   return $retMediaItems;   
} # end function
?>


/etc/umsp/plugins/dreambox-recordings.php
Code: Select all
<?php

function _pluginMain($prmQuery) {

  $queryData = array();
  parse_str($prmQuery, $queryData);
  if ($queryData['path'] != '') {
    $path = $queryData['path'];
  } else {
    $path = '/hdd/movie/';   
  }

  # Hardcoded Dreambox address
  $dreamboxAddress = 'dm7025';

# First, read the media player items, as this is the only way to read the subdirectories

  # Media URL, list all recordings
  $dreamboxMedialistUrl = 'web/mediaplayerlist?path=' . $path;
 
  $reader = new XMLReader();
  $medialistXML = file_get_contents('http://' . $dreamboxAddress . '/' . $dreamboxMedialistUrl);
 
  $reader->XML($medialistXML);
  while ($reader->read()) {
    if (($reader->nodeType == XMLReader::ELEMENT) && ($reader->localName == 'e2file')) {
      #
      # Read e2file child nodes until end
      #
      do {
          $reader->read();
          if (($reader->nodeType == XMLReader::ELEMENT) && ($reader->localName == 'e2isdirectory')) {
            $newDir['isdirectory']  = $reader->readString();
          }
          if (($reader->nodeType == XMLReader::ELEMENT) && ($reader->localName == 'e2servicereference')) {
            $newDir['directory'] = utf8_decode($reader->readString());
          }
      } while (!(($reader->nodeType == XMLReader::END_ELEMENT) && ($reader->localName == 'e2file')));
      #
      # New channelinfo item parsed. Now add as media item:
      #
   
      if ( $newDir['isdirectory'] == 'True' && $newDir['directory'] != '/hdd/' && $newDir['directory'] != '/hdd/movie/.trashcan/' ) {
        $retMediaItems[] = array (
          'id'        => 'umsp://plugins/dreambox-recordings?path=' . $newDir['directory'],
          'dc:title'  => basename($newDir['directory']),
          'upnp:class' => 'object.container'
        );
      }
    } # end if
  } #end while
 
 
# Now, read the movie information from this directory
 
  # Movies URL, list all recordings
  $dreamboxMovielistUrl = 'web/movielist?dirname=' . $path;
 
  #$reader = new XMLReader();
  $movielistXML = file_get_contents('http://' . $dreamboxAddress . '/' . $dreamboxMovielistUrl);
 
  $reader->XML($movielistXML);
  while ($reader->read()) {
    if (($reader->nodeType == XMLReader::ELEMENT) && ($reader->localName == 'e2movie')) {
      #
      # Read channelinfo child nodes until end
      #
      do {
          $reader->read();
              if (($reader->nodeType == XMLReader::ELEMENT) && ($reader->localName == 'e2filename')) {
          $newMovie['id']  = $reader->readString();
        }
              if (($reader->nodeType == XMLReader::ELEMENT) && ($reader->localName == 'e2title')) {
          $newMovie['title'] = utf8_decode($reader->readString());
              }
              if (($reader->nodeType == XMLReader::ELEMENT) && ($reader->localName == 'e2description')) {
          $newMovie['description'] = utf8_decode($reader->readString());
              }
              if (($reader->nodeType == XMLReader::ELEMENT) && ($reader->localName == 'e2filesize')) {
          $newMovie['filesize'] = $reader->readString();
              }
      } while (!(($reader->nodeType == XMLReader::END_ELEMENT) && ($reader->localName == 'e2movie')));
      #
      # New channelinfo item parsed. Now add as media item:
      #
   
      $retMediaItems[] = array (
        'id'        => $newMovie['id'],
        'res'       => 'http://localhost/umsp/plugins/dreambox-proxy.php?itemUrl=http://' . $dreamboxAddress . ':80/file?file=' . $newMovie['id'],
        'dc:title'  => $newMovie['title'],
        'desc'      => $newMovie['description'],
        'size'      => $newMovie['filesize'],
        'upnp:class'    => 'object.item.videoitem',
        'protocolInfo'    => 'http-get:*:video/mpeg:*'
      );
    } # end if
  } #end while
  return $retMediaItems; 
} # end function
?>


/etc/umsp/plugins/dreambox-proxy.php
Code: Select all
<?php

# Immediately respond to 'HEAD' requests
if ( $_SERVER[''] == 'HEAD' ) {
   header('Content-Type: video/mpeg');
   exit;
}

# itemUrl is like
# itemUrl=http://dm7025:8001/1:0:1:11:1001:20F6:EEEE0000:0:0:0:
# itemUrl=http://dm7025:80/file?file=/hdd/movie/20100430%202000%20-%20KinoTV%20-%20Taisteluplaneetta%20Galactica.ts

$rawURL = $_GET['itemUrl'];
$parsedURL = parse_url($rawURL);

$itemHost = $parsedURL['host'];
$itemPort = $parsedURL['port'];
$itemPath = $parsedURL['path'];
$itemQuery = $parsedURL['query'];

# Somewhat of a kludge, but only replace the spaces the parse_url decodes
if ( $itemQuery ) {
   $itemPath .= "?" . str_replace(" ", "%20", $itemQuery);
}

_dreamboxGet($itemHost, $itemPort, $itemPath);

function _dreamboxGet($prmHost, $prmPort, $prmPath) {
   $fp = fsockopen($prmHost, $prmPort, $errno, $errstr);
   if (!$fp) {
      echo "$errstr ($errno)<br />\n";
   } else {
      # Create the HTTP GET request
      
      $out  = "GET $prmPath HTTP/1.0\r\n";
      $out .= "User-Agent: Wget/1.12\r\n";
      $out .= "Accept: */*\r\n";
      $out .= "Host: $prmHost:$prmPort\r\n";
      $out .= "Connection: Keep-Alive\r\n";
      $out .= "\r\n";
   
      fwrite($fp, $out);
      
      # Create HTTP headers for WDTV
      
      header("Content-Type: video/mpeg");
#      header("Connection: Keep-Alive");
      
      # Ignore the original header
      
      $headerpassed = false;
      while ($headerpassed == false) {
         $line = fgets($fp);
         if ( $line == "\r\n" ) {
            $headerpassed = true;
         }
      }
         
      # Pass thru the DVB transport stream
      
      fpassthru($fp);
      fclose($fp);
   }
}
?>
Toni
Beta Tester
 
Posts: 57
Joined: Sun Apr 25, 2010 5:59 am

Re: Dreambox E2 streaming plugin   

Postby ace1774 » Mon May 03, 2010 1:07 am

I have a DM800HD with gemini project (that means also e2).

So how i get to use the code to stream to my wd my dreambox?
ace1774
n00b
 
Posts: 19
Joined: Fri Apr 23, 2010 11:29 am

Re: Dreambox E2 streaming plugin   

Postby Toni » Mon May 03, 2010 3:14 am

I've got the 1.02.21_B-RAD.CC_WDLXTV_LIVE-0.4.2.0 on flash, and it's running 1.02.21_B-RAD.CC_EXT3-BOOT_LIVE-0.4.2.0 from the USB memory stick. See the Firmware releases board. So, once you get the ext3 booted up, just save those files into the WDTV's file system, and these should show up within UMSP.

I have hardcoded a couple of things:
  • The Dreambox DNS name is 'dm7025'
  • It only supports the 'Favourites' bouquet (set of DVB channels)
  • It assumes that your recordings are at /hdd/media on the Dreambox

And it would work fine if the streaming plugin would just work...
Toni
Beta Tester
 
Posts: 57
Joined: Sun Apr 25, 2010 5:59 am

Re: Dreambox E2 streaming plugin   

Postby ace1774 » Mon May 03, 2010 4:37 am

Ok i copied everything.I already had ext3 running.

So if change this


# Hardcoded Dreambox address
$dreamboxAddress = 'dm7025';

to

# Hardcoded Dreambox address
$dreamboxAddress = 'xxx.xxx.xxx.xxx';

i mean with my dm800 ip i will be ok?
ace1774
n00b
 
Posts: 19
Joined: Fri Apr 23, 2010 11:29 am

Re: Dreambox E2 streaming plugin   

Postby b-rad.cc » Mon May 03, 2010 6:05 am

why not try and see? :roll: ;)
PM's are for private matters only, please post public matters on the forum to help others who might have the same issue.
:mrgreen:
User avatar
b-rad.cc
WDLXTV Team
 
Posts: 3003
Joined: Sat Apr 03, 2010 9:35 am
Location: New York

Re: Dreambox E2 streaming plugin   

Postby ace1774 » Mon May 03, 2010 10:45 am

Nope doesnt work
ace1774
n00b
 
Posts: 19
Joined: Fri Apr 23, 2010 11:29 am

Re: Dreambox E2 streaming plugin   

Postby Toni » Mon May 03, 2010 9:14 pm

ace1774 wrote:Nope doesnt work


This is really helpful... It would help troubleshooting quite a bit if you could elaborate a bit more.

First of all, do you have the Dreambox web interface running? I.e. can you navigate to the Dreambox using your favorite browser? Do you see the web interface in there?

The next thing you should check is if this command returns anything (if you run it on the WDTV shell)?

Code: Select all
wget http://dreambox/web/movielist


(Replace 'dreambox' with the IP address or name of your Dreambox)
Toni
Beta Tester
 
Posts: 57
Joined: Sun Apr 25, 2010 5:59 am

Re: Dreambox E2 streaming plugin   

Postby ace1774 » Mon May 03, 2010 10:37 pm

WDTVLIVE login: root
Password:
# wget http://xxx.xxx.xxx.xxx/web/movielist
--2010-05-04 06:36:00-- http://xxx.xxx.xxx.xxx/web/movielist
Connecting to xxx.xxx.xxx.xxx:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/xhtml+xml]
Saving to: `movielist'

[ <=> ] 1,448 --.-K/s in 0s

2010-05-04 06:36:03 (18.3 MB/s) - `movielist' saved [1448]

#


I hope that i helped
ace1774
n00b
 
Posts: 19
Joined: Fri Apr 23, 2010 11:29 am

Re: Dreambox E2 streaming plugin   

Postby b-rad.cc » Mon May 03, 2010 10:39 pm

contents of that movielist would probably help even more ;)

(put in 'code' tag when you do)
PM's are for private matters only, please post public matters on the forum to help others who might have the same issue.
:mrgreen:
User avatar
b-rad.cc
WDLXTV Team
 
Posts: 3003
Joined: Sat Apr 03, 2010 9:35 am
Location: New York

Re: Dreambox E2 streaming plugin   

Postby ace1774 » Tue May 04, 2010 1:02 am

Where i can find the movilist file?
ace1774
n00b
 
Posts: 19
Joined: Fri Apr 23, 2010 11:29 am

Next

Return to UMSP Plugins

Who is online

Users browsing this forum: No registered users and 2 guests