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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
/*
generic interactive controller
Copyright (C) 2000 Martin Vogt
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published by
the Free Software Foundation.
For more information look at the file COPYRIGHT in this package
*/
// Set for local include
#define DIRECT_INCLUDE
#include "../yafcore/yaf_control.h"
#include "../yafxplayer/inputDecoderYAF.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
// for dynamic loading
#include <dlfcn.h>
#include "../../../lib/decoder/vorbisPlugin.h"
#if defined(HAVE_GETOPT_H)
#include <getopt.h>
#endif
using namespace std;
void control_vorbis(InputInterface* input,OutputInterface* output,
InputDecoder* decoder) {
cout<< "Command:0 Msg:protocol yaf-0.1" << endl;
cout<< "Command:0 Msg:implements xplayer" << endl;
cout<< "Command:0 Msg:decoder vorbis Version:20000223" << endl;
cout<< "Command:0 Msg:mimetypes audio/ogg;" << endl;
cout<< "Command:0 Msg:comment vorbis by Monty http://www.xiph.org/" << endl;
cout<< "Command:0 Msg:comment yaf port by [email protected]"<<endl;
cout<< "Command:0 Msg:comment based on sources from vorbis"<<endl;
cout<< "Command:0 Msg:comment enter 'help' " << endl;
yaf_control(input,output,decoder);
}
void usage() {
cout << "yaf-vorbis is a interactive frontend for the vorbis decoder"<<endl;
cout << "Usage : yaf-vorbis [url]"<<endl;
cout << endl;
cout << "-a : no internal audio device"<<endl;
cout << "-y : autoplay off"<<endl;
cout << endl;
cout << "THIS SOFTWARE COMES WITH ABSOLUTELY NO WARRANTY! " \
<< "USE AT YOUR OWN RISK!"<<endl;
cout << endl;
cout << "for more help type 'help' in interactive mode"<<endl;
}
int main(int argc, char** argv) {
int c;
int lInternalAudio=true;
pow(6.0,3.0); // fixes bug in __math.h
InputInterface* input=new InputInterface();
OutputInterface output(&cout);
YafOutputStream* yafOutput=new YafOutputStream(input);
VorbisPlugin* plugin=new VorbisPlugin();
plugin->setOutputPlugin(yafOutput);
InputDecoderYAF decoder(plugin,yafOutput);
while(1) {
c = getopt (argc, argv, "2amhy");
if (c == -1) break;
switch(c) {
case 'a': {
lInternalAudio=false;
break;
}
case 'h': {
usage();
exit(0);
}
case '2': {
plugin->config("-2","true",NULL);
break;
}
case 'y': {
decoder.setAutoPlay(false);
break;
}
case 'm': {
plugin->config("-m","true",NULL);
break;
}
case 'r': {
plugin->config("runtime","on",NULL);
break;
}
case 'c': {
plugin->config("-c","true",NULL);
break;
}
default:
printf ("?? getopt returned character code 0%o ??\n", c);
usage();
exit(-1);
}
}
if (optind < argc ) {
Buffer buffer(300);
buffer.append("open ");
buffer.append(argv[optind]);
buffer.append("\n");
input->addInputLine(&buffer);
}
yafOutput->internalDevice(lInternalAudio);
control_vorbis(input,&output,&decoder);
delete plugin;
delete yafOutput;
}
|