summaryrefslogtreecommitdiffstats
path: root/mpeglib/example/mpgplay/mpgplay.cpp
blob: c5c1d82c7fd5a8a615a649723b32610a6bbe333a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * main.c --
 *
 * Example program for mpegplay library.


 */

#include "../../lib/decoder/mpgPlugin.h"
#include "../../lib/util/timeWrapper.h"

#include <iostream>

using namespace std;

int main(int argc, char** argv) {


  if (argc <= 1) {
    printf("Usage:\n\n");
    printf("%s filename\n\n",argv[0]);
    exit(0);
  }
  //
  // The order is important !!!!
  // 1. construct
  // 2. set Output
  // 3. open input
  // 4. set input
  // 
  // you cannot set the input _before_ the output 
  // in fact you can, but this gives you a segfault!
    
  MpgPlugin* plugin=new MpgPlugin();
  OutputStream* out=OutPlugin::createOutputStream(_OUTPUT_LOCAL,true);
  InputStream* in=InputPlugin::createInputStream(argv[1],true);



  // The plugin does not do "open"
  in->open(argv[1]);





  // watch the order!
  plugin->setOutputPlugin(out);
  plugin->setInputPlugin(in);
  //plugin->seek(1950);
  cout << "hello 1 -s"<<endl;


  plugin->play();
  cout << "hello 1 -e"<<endl;


  while(1) {
    if (plugin->getStreamState() != _STREAM_STATE_EOF) {
      cout << "******* plugin->getStreamState() continue"<<endl;
      TimeWrapper::sleep(3);
      continue;
    }
    break;
  }
  cout << "********************plugin eof"<<endl;
  plugin->close();

  delete plugin;
  delete in;
  delete out;
  return(0);
}