The Ripper Application
Ripper.ice
#include <Ice/BuiltinSequences.ice>
module Ripper {
exception EncodingFailedException {
string reason;
};
sequence<short> Samples;
interface Mp3Encoder {
// Input: PCM samples for left and right channels
// Output: MP3 frame(s).
Ice::ByteSeq encode(Samples leftSamples, Samples rightSamples)
throws EncodingFailedException;
// You must flush to get the last frame(s). Flush also
// destroys the encoder object.
Ice::ByteSeq flush()
throws EncodingFailedException;
};
interface Mp3EncoderFactory
{
Mp3Encoder* createEncoder();
};
};
MusicServer.cpp
#include <Ice/Ice.h>
#include "Ripper.h"
using namespace Ripper;
#include <iostream>
using namespace std;
class CMp3Encoder : public Mp3Encoder{
public:
virtual ::Ice::ByteSeq encode(const ::Ripper::Samples& leftSamples, const ::Ripper::Samples& rightSamples, const ::Ice::Current& curr) {
std::vector<unsigned char> vChar;
vChar.push_back('M'); vChar.push_back('u');vChar.push_back('s');vChar.push_back('i');vChar.push_back('c');
for(std::vector<unsigned char>::iterator it = vChar.begin(); it != vChar.end(); it++) {
cout << (*it);
}