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

« back to all changes in this revision

Viewing changes to mpeglib/example/yaf/yafmpgplay/mpg_control.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
  generic interactive controler 
 
3
  Copyright (C) 1998  Martin Vogt
 
4
 
 
5
  This program is free software; you can redistribute it and/or modify
 
6
  it under the terms of the GNU Library General Public License as published by
 
7
  the Free Software Foundation.
 
8
 
 
9
  For more information look at the file COPYRIGHT in this package
 
10
 
 
11
 */
 
12
 
 
13
 
 
14
 
 
15
 
 
16
// Set for local include
 
17
#define DIRECT_INCLUDE
 
18
 
 
19
#include "../yafcore/yaf_control.h"
 
20
#include "../yafxplayer/inputDecoderYAF.h"
 
21
 
 
22
 
 
23
 
 
24
 
 
25
#include <iostream.h>
 
26
#include <stdio.h>
 
27
#include <stdlib.h>
 
28
#include <math.h>
 
29
 
 
30
#if defined(HAVE_GETOPT_H) 
 
31
#include <getopt.h>
 
32
#endif
 
33
 
 
34
// we include our plugin here
 
35
#include "../../../lib/decoder/mpgPlugin.h"
 
36
 
 
37
#if defined(HAVE_GETOPT_H) 
 
38
#include <getopt.h>
 
39
#endif
 
40
 
 
41
 
 
42
                                          
 
43
 
 
44
 
 
45
void control_mpgplay(InputInterface* input,OutputInterface* output,
 
46
                   InputDecoder* decoder) {
 
47
 
 
48
 
 
49
  cout<< "Command:0 Msg:protocol yaf-0.1" << endl;
 
50
  cout<< "Command:0 Msg:implements xplayer" << endl;
 
51
  cout<< "Command:0 Msg:decoder splay Version:0.8.2" << endl;
 
52
  cout<< "Command:0 Msg:decoder mpeg_play Version:2.4.0" << endl;
 
53
  cout<< "Command:0 Msg:mimetypes video/mpeg;" << endl;
 
54
  cout<< "Command:0 Msg:comment splay by Woo-jae Jung" << endl;
 
55
  cout<< "Command:0 Msg:comment mpeg_play by University of California" << endl;
 
56
  cout<< "Command:0 Msg:comment yaf port by mvogt@rhrk.uni-kl.de"<<endl;
 
57
  cout<< "Command:0 Msg:comment based on sources from mpeg_play and splay"<<endl;
 
58
  cout<< "Command:0 Msg:comment enter 'help' " << endl;
 
59
 
 
60
 
 
61
  
 
62
 
 
63
  
 
64
  yaf_control(input,output,decoder);
 
65
}
 
66
 
 
67
 
 
68
void usage() {
 
69
  cout << "yaf-mpgplay is a interactive frontend for the mpeg I decoder"<<endl;
 
70
  cout << "Usage : yaf-mpgplay [2al:L:scb:mhpywd:] [url]"<<endl;
 
71
  cout << endl;
 
72
  cout << "-2 : playing with half frequency."<<endl;
 
73
  cout << "-m : force to mono."<<endl;
 
74
  cout << "-a : no internal audio device"<<endl;
 
75
  cout << "-c : no time calculation"<<endl;
 
76
  cout << "-s : no audio/video sync"<<endl;
 
77
  cout << "-b : audio buffer delay (bytes)[65535 byte]"<<endl;
 
78
  cout << "-p : measure performance (audio is decoded, but not played)"<<endl;
 
79
  cout << "-l : select audio Layer [0]"<<endl;
 
80
  cout << "-L : select video Layer [0]"<<endl;
 
81
  cout << "-w : write streams to disk [demultiplex]"<<endl;
 
82
  cout << "-y : autoplay off"<<endl;
 
83
  cout << "-d : [1..2] dump yuv images 1: single images 2: as stream"<<endl;
 
84
  cout << endl;
 
85
  cout << "THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! " \
 
86
       << "USE AT YOUR OWN RISK!"<<endl;
 
87
  cout << endl;
 
88
  cout << "for more help type 'help' in interactive mode"<<endl;
 
89
}
 
90
 
 
91
 
 
92
 
 
93
 
 
94
int main(int argc, char** argv) {
 
95
  int c;
 
96
  int lInternalAudio=true;
 
97
 
 
98
  pow(6.0,3.0);            // fixes bug in __math.h
 
99
  InputInterface input;
 
100
  OutputInterface output(&cout);
 
101
 
 
102
 
 
103
  
 
104
 
 
105
 
 
106
  YafOutputStream* yafOutput=new YafOutputStream(&input);
 
107
  MpgPlugin* plugin=new MpgPlugin();
 
108
 
 
109
  plugin->setOutputPlugin(yafOutput);
 
110
  InputDecoderYAF decoder(plugin,yafOutput);
 
111
 
 
112
  
 
113
 
 
114
  while(1) { 
 
115
    c = getopt (argc, argv, "2al:L:scb:mhpywd:");
 
116
    if (c == -1) break;
 
117
    switch(c) {
 
118
    case 'a': {    
 
119
      lInternalAudio=false;
 
120
      break;
 
121
    }
 
122
    case 'h': {
 
123
      usage();
 
124
      exit(0);
 
125
    }
 
126
    case 'y': {
 
127
      decoder.setAutoPlay(false);
 
128
      break;
 
129
    }
 
130
    case '2': {
 
131
      plugin->config("-2","true",NULL);
 
132
      break;
 
133
    }
 
134
    case 'm': {
 
135
      plugin->config("-m","true",NULL);
 
136
      break;
 
137
    }
 
138
    case 'c': {
 
139
      plugin->config("-c","true",NULL);
 
140
      break;
 
141
    }
 
142
    case 'w': {
 
143
      plugin->config("-w","true",NULL);
 
144
      break;
 
145
    }
 
146
    case 's': {
 
147
      yafOutput->config("-s","true",NULL);
 
148
      break;
 
149
    }
 
150
    case 'b': {
 
151
      yafOutput->config("-b",optarg,NULL);
 
152
      break;
 
153
    }    
 
154
    case 'd': {
 
155
      yafOutput->config("yufDump",optarg,NULL);
 
156
      break;
 
157
    }    
 
158
    case 'p': {
 
159
      yafOutput->config("-p",optarg,NULL);
 
160
      break;
 
161
    }    
 
162
    case 'l': {
 
163
      plugin->config("AudioLayer",optarg,NULL);
 
164
      cout << "trying to configure" << endl;
 
165
      break;
 
166
    }
 
167
    case 'L': {
 
168
      plugin->config("VideoLayer",optarg,NULL);
 
169
      break;
 
170
    }
 
171
 
 
172
 
 
173
    default:
 
174
      printf ("?? getopt returned character code 0%o ??\n", c);
 
175
      usage();
 
176
      exit(-1);
 
177
    }
 
178
  }
 
179
 
 
180
  if (optind < argc ) {
 
181
    Buffer buffer(300);
 
182
    buffer.append("open ");
 
183
    buffer.append(argv[optind]);
 
184
    buffer.append("\n");
 
185
    input.addInputLine(&buffer);
 
186
 
 
187
  }
 
188
  yafOutput->internalDevice(lInternalAudio);
 
189
  control_mpgplay(&input,&output,&decoder);
 
190
  delete plugin;
 
191
  delete yafOutput;
 
192
 
 
193
}
 
194
 
 
195