~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to mpeglib/example/tplay/tplay.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 
 
3
  Example how the plugin interface works.(LINUX Open Sound System only!)
 
4
 
 
5
 
 
6
 
 
7
 
 
8
 
 
9
 */
 
10
 
 
11
 
 
12
#include "../../lib/decoder/tplayPlugin.h"
 
13
#include "../../lib/decoder/nukePlugin.h"
 
14
 
 
15
 
 
16
 
 
17
 
 
18
int main(int argc, char** argv) {
 
19
 
 
20
 
 
21
  if (argc <= 1) {
 
22
    printf("Usage:\n\n");
 
23
    printf("%s filename\n\n",argv[0]);
 
24
    exit(0);
 
25
  }
 
26
 
 
27
  //
 
28
  // The order is important !!!!
 
29
  // 1. construct
 
30
  // 2. set Output
 
31
  // 3. open input
 
32
  // 4. set input
 
33
  // 
 
34
  // you cannot set the input _before_ the output 
 
35
  // in fact you can, but this gives you a segfault!
 
36
    
 
37
  DecoderPlugin* plugin=new TplayPlugin();
 
38
  //DecoderPlugin* plugin=new NukePlugin();
 
39
  OutputStream* out=OutPlugin::createOutputStream(_OUTPUT_LOCAL,true);
 
40
  InputStream* in=InputPlugin::createInputStream(argv[1],true);
 
41
 
 
42
  // The plugin does not do "open"
 
43
  in->open(argv[1]);
 
44
 
 
45
  // watch the order!
 
46
  plugin->setOutputPlugin(out);
 
47
  plugin->setInputPlugin(in);
 
48
 
 
49
 
 
50
 
 
51
  plugin->play();
 
52
 
 
53
  while(plugin->getStreamState() != _STREAM_STATE_EOF) {
 
54
    TimeWrapper::sleep(1);
 
55
  }
 
56
  cout << "plugin eof"<<endl;
 
57
  plugin->close();
 
58
 
 
59
  delete plugin;
 
60
  delete in;
 
61
  delete out;
 
62
  return(0);
 
63
}
 
64