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

« back to all changes in this revision

Viewing changes to mpeglib/example/yaf/yafvorbis/vorbis_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) 2000  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
// Set for local include
 
15
#define DIRECT_INCLUDE
 
16
 
 
17
#include "../yafcore/yaf_control.h"
 
18
#include "../yafxplayer/inputDecoderYAF.h"
 
19
 
 
20
 
 
21
 
 
22
#include <iostream.h>
 
23
#include <stdio.h>
 
24
#include <stdlib.h>
 
25
#include <math.h>
 
26
 
 
27
// for dynamic loading
 
28
#include <dlfcn.h>
 
29
 
 
30
#include "../../../lib/decoder/vorbisPlugin.h"
 
31
 
 
32
#if defined(HAVE_GETOPT_H) 
 
33
#include <getopt.h>
 
34
#endif
 
35
 
 
36
 
 
37
 
 
38
 
 
39
void control_vorbis(InputInterface* input,OutputInterface* output,
 
40
                   InputDecoder* decoder) {
 
41
 
 
42
 
 
43
  cout<< "Command:0 Msg:protocol yaf-0.1" << endl;
 
44
  cout<< "Command:0 Msg:implements xplayer" << endl;
 
45
  cout<< "Command:0 Msg:decoder vorbis Version:20000223" << endl;
 
46
  cout<< "Command:0 Msg:mimetypes audio/ogg;" << endl;
 
47
  cout<< "Command:0 Msg:comment vorbis by Monty http://www.xiph.org/" << endl;
 
48
  cout<< "Command:0 Msg:comment yaf port by mvogt@rhrk.uni-kl.de"<<endl;
 
49
  cout<< "Command:0 Msg:comment based on sources from vorbis"<<endl;
 
50
  cout<< "Command:0 Msg:comment enter 'help' " << endl;
 
51
 
 
52
 
 
53
  
 
54
 
 
55
  
 
56
  yaf_control(input,output,decoder);
 
57
}
 
58
 
 
59
 
 
60
void usage() {
 
61
  cout << "yaf-vorbis is a interactive frontend for the vorbis decoder"<<endl;
 
62
  cout << "Usage : yaf-vorbis [url]"<<endl;
 
63
  cout << endl;
 
64
  cout << "-a : no internal audio device"<<endl;
 
65
  cout << "-y : autoplay off"<<endl;
 
66
  cout << endl;
 
67
  cout << "THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! " \
 
68
       << "USE AT YOUR OWN RISK!"<<endl;
 
69
  cout << endl;
 
70
  cout << "for more help type 'help' in interactive mode"<<endl;
 
71
}
 
72
 
 
73
 
 
74
 
 
75
int main(int argc, char** argv) {
 
76
  int c;
 
77
  int lInternalAudio=true;
 
78
 
 
79
 
 
80
  pow(6.0,3.0);            // fixes bug in __math.h
 
81
  InputInterface* input=new InputInterface();
 
82
  OutputInterface output(&cout);
 
83
 
 
84
  YafOutputStream* yafOutput=new YafOutputStream(input);
 
85
 
 
86
 
 
87
  VorbisPlugin* plugin=new VorbisPlugin();
 
88
 
 
89
  plugin->setOutputPlugin(yafOutput);
 
90
  InputDecoderYAF decoder(plugin,yafOutput);
 
91
 
 
92
 
 
93
 
 
94
  while(1) { 
 
95
    c = getopt (argc, argv, "2amhy");
 
96
    if (c == -1) break;
 
97
    switch(c) {
 
98
    case 'a': {    
 
99
      lInternalAudio=false;
 
100
      break;
 
101
    }
 
102
    case 'h': {
 
103
      usage();
 
104
      exit(0);
 
105
    }
 
106
    case '2': {
 
107
      plugin->config("-2","true",NULL);
 
108
      break;
 
109
    }
 
110
    case 'y': {
 
111
      decoder.setAutoPlay(false);
 
112
      break;
 
113
    }
 
114
    case 'm': {
 
115
      plugin->config("-m","true",NULL);
 
116
      break;
 
117
    }
 
118
    case 'r': {
 
119
      plugin->config("runtime","on",NULL);
 
120
      break;
 
121
    }
 
122
    case 'c': {
 
123
      plugin->config("-c","true",NULL);
 
124
      break;
 
125
    }
 
126
    default:
 
127
      printf ("?? getopt returned character code 0%o ??\n", c);
 
128
      usage();
 
129
      exit(-1);
 
130
    }
 
131
  }
 
132
  if (optind < argc ) {
 
133
    Buffer buffer(300);
 
134
    buffer.append("open ");
 
135
    buffer.append(argv[optind]);
 
136
    buffer.append("\n");
 
137
    
 
138
    input->addInputLine(&buffer);
 
139
 
 
140
  }
 
141
 
 
142
 
 
143
 
 
144
  yafOutput->internalDevice(lInternalAudio);
 
145
  control_vorbis(input,&output,&decoder);
 
146
  delete plugin;
 
147
  delete yafOutput;
 
148
 
 
149
}
 
150
 
 
151