blob: d114eba9f086e4e4b2527820e6a20e4e7983f13a (
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
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
|
/* MPEG/WAVE Sound library
(C) 1997 by Jung woo-jae */
// Mpegtoraw.cpp
// Server which get mpeg format and put raw format.
#include "mpegsound.h"
#include "synthesis.h"
#include "dump.h"
#include "../frame/audioFrame.h"
#include <iostream>
using namespace std;
Mpegtoraw::Mpegtoraw(MpegAudioStream* mpegAudioStream,
MpegAudioHeader* mpegAudioHeader) {
this->mpegAudioStream=mpegAudioStream;
this->mpegAudioHeader=mpegAudioHeader;
this->lOutputStereo=true;
setStereo(true);
setDownSample(false);
dump=new Dump();
synthesis=new Synthesis();
initialize();
}
Mpegtoraw::~Mpegtoraw() {
delete synthesis;
delete dump;
}
void Mpegtoraw::setStereo(int flag) {
lWantStereo=flag;
}
void Mpegtoraw::setDownSample(int flag) {
lDownSample=flag;
}
int Mpegtoraw::getStereo() {
return lWantStereo;
}
int Mpegtoraw::getDownSample() {
return lDownSample;
}
// Convert mpeg to raw
// Mpeg headder class
void Mpegtoraw::initialize() {
layer3initialize();
}
// Convert mpeg to raw
int Mpegtoraw::decode(AudioFrame* audioFrame) {
int back=true;
this->audioFrame=audioFrame;
if (audioFrame->getSize() < RAWDATASIZE) {
cout << "audioFrame needs at least:"<<RAWDATASIZE<<" size"<<endl;
exit(0);
}
audioFrame->clearrawdata();
synthesis->clearrawdata();
int layer=mpegAudioHeader->getLayer();
this->lOutputStereo=lWantStereo & mpegAudioHeader->getInputstereo();
if (mpegAudioHeader->getProtection()==false) {
mpegAudioStream->getbyte();
mpegAudioStream->getbyte();
}
switch(layer) {
case 3:
extractlayer3();
break;
case 2:
extractlayer2();
break;
case 1:
extractlayer1();
break;
default:
cout << "unknown layer:"<<layer<<endl;
back=false;
}
//
// Now put the frequencies/output etc.. in the frame
//
audioFrame->setFrameFormat(lOutputStereo,
mpegAudioHeader->getFrequencyHz()>>lDownSample);
audioFrame->putFloatData(synthesis->getOutputData(),synthesis->getLen());
return back;
}
|