From scarabaeus@convergence.de Thu, 09 Dec 1999 21:08:38 +0100
Date: Thu, 09 Dec 1999 21:08:38 +0100
From: Christian Wolff scarabaeus@convergence.de
Subject: [Livid-dev] 2 new modules: dvd_file and dvd_decoder

I just released 2 new modules for convergence, one is for file access to
DVD Video directories, the other one provides a simple interface to a
DVD decoder (stream demux and media decoder). =


Check out http://linuxtv.org/dvd/ for more information, you can download
the source here:
http://linuxtv.org/dvd/dvdfile_1999_12_09.tar.gz
http://linuxtv.org/dvd/dvddecoder_1999_12_09.tar.gz

Excerpts of the readme files:

---

This module, dvd_file, can be used to access DVD Video discs =

mounted onto the filesystem, e.g. an udf mounted DVD-ROM. =

This access does not place restrictions on the physical =

order of files or blocks on the medium, as direct DVD Video
access does. As a direct result of this, CSS is not working.
Only unencrypted DVD Video discs can be played.

This module, dvd_decoder, can be used to playback DVD Video media streams=

_____________________________________________________________________

How to access The DVD Video

First, you have to tell where the disc resides in the filesystem.
Pass the path to or into the VIDEO_TS directory (not case sensitive), =

as well as the requested block size (for DVD Video: 2048) to =

FileSetVideoPath(). Unless the path is set successfully, all =

other functions return with an error.

Then, you can use FileReadVMGM(), FileReadVTSM() and FileReadVTS()
to read a single block of VIDEO_TS.VOB, VTS_xx_0.VOB and VTS_xx_y.VOB, =

respectively. Where xx is the video title set number ('vtsn'), =

and y the segment number 1 to 9 of the title file. The segment =

number is determined automatically from the block number.
'lbnum' is the number of the block to read, relative to the
beginning of the file and starting from 0.
'data' has to point to at least 2048 bytes allocated memory.

simplified example:

#include "DVDPlayerAPI.h"
#include "dvd_file.h"

#define LB_LEN 2048  // Length of one logical block in bytes

int vtsn;          // current video title set number =

u32 lbn;           // logical block number currently being played
u32 vobu_ea;       // last block of current VOBU
DVDDomainID Domain;
unsigned char LB[LB_LEN];

int InfoFileParser(int VTS_number, void *infostruct) {
  int blocks;
  u8 *infodata;
  int bup=3D0;  // do we use the backup?
  int request;
  if ((VTS_number<0) || (VTS_number>99)) return 1;  // illegal title numb=
er
  request=3D((VTS_number)?2:1);
  while (1) {
    if (!(blocks=3DFileReadIFO(VTS_number,bup,&infodata))) return 1;
    if (ParseInfo(infodata,infostruct)!=3Drequest) {  // not provided her=
e
      free(infodata);
      if (bup++) return 1;
      continue;
    } else {
      return 0;
    }
  }
}

void Play() {
  int err;
  switch (Domain) {
    case DVDDomainVideoManagerMenu: =

      err=3DFileReadVMGM(lbn,LB);
      break;
    case DVDDomainVideoTitleSetMenu: =

      err=3DFileReadVTSM(vtsn,lbn,LB);
      break;
    case DVDDomainTitle: =

      err=3DFileReadVTS(vtsn,lbn,LB);
      break;
    default:
      lbn=3Dvobu_ea;
      err=3D1;
      break;
  }
  if (!err) {
    err=3Dparse_LB(LB);  // function not included in example
  }
  ps.lbn++;
}

int main (int argc, char* argv[]) {
  FileSetVideoPath(argv[1],LB_LEN);
  InfoFileParser(0,vmgi);
  // now, insert lots of magical dvd menu stuff.
  // results in "play title 1", for example.
  vtsn=3D1;
  InfoFileParser(vtsn,vtsi);
  Domain=3DDVDDomainTitle;  // this is done magically
  lbn=3D0;  // this as well. actual numbers may vary.
  while (ps.lbn<=3Dvobu_ea) Play();
}
_____________________________________________________________________

How to play a DVD Video

This dvd_decoder module is just a wrapper for the io-controls of the
convergence/LSI Logic DVD Decoder Card. By changing dvd_decoder.c to
your own needs, you can implement other underlying decoder =

architectures, such as a software stream demultiplexers and software =

or hardware decoder for MPEG2 video, MPEG audio, AC3, SPU and CSS.

First, you have to tell where the consuming device is. Pass the =

filename of the device to DecoderSetDevice(). This also initializes
the module.

=46rom the information retreived from the info files of the DVD, the =

demux and the decoder have to be set up with stream numbers and =

stream parameters. This is done with DecoderSetVideoStream(), =

DecoderSetAudioStream() and DecoderSetSubPictureStream() for the =

demux, DecoderSetVideoAttr() for the video decoder, =

DecoderSetAudioAttr() and DecoderSetKaraokeMix() for the audio =

decoder, and DecoderSetSubPicturePalette() and DecoderHighlight()
for the SPU (Sub Picture Unit, run-length encoded bitmaps to be
overlayed onto the video for menus and subtitles) decoder.
Also, a function DecoderPause() is provided to pause the decoding
process.

A number of CSS function is also provided: DecoderCSSBypass() =

bypasses the CSS module for unencrypted data. For encrypted data
the drive and the decoder have to authenticate to each other =

with DecoderCSSDriveAuthChallenge(), DecoderCSSDriveAuthResponse()
and DecoderCSSHostAuth(), then the keys for the disc and the title
have to be sent into the decoder with DecoderCSSDiscKey() and =

DecoderCSSTitleKey().

Then, you can use DecoderWrite() to write DVD data into the demux. =

The parsed PCI and DSI packets are only of interest for the navi-
gator, so they are passed back by polling DecoderGetNaviPack().

-- =

Christian Wolff     *196807101035    53=B08'2" N    8=B013'20" E
http://www.scarabaeus.org/  mailto:scarabaeus@scarabaeus.org
check out http://betalounge.com/   http://www.convergence.de
+49-30-4473 6926,  Norwegerstr. 5.1, D-10439 Berlin, Germany
PGP Fingerprint:B871 358C 3F10 A5ED C41C B1DB B9F9 3C44/2048