KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > applications > audioconf > Streamer


1 /*
2  * Lucane - a collaborative platform
3  * Copyright (C) 2004 Vincent Fiack <vfiack@mail15.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19 package org.lucane.applications.audioconf;
20
21 import java.io.*;
22
23 import org.lucane.applications.audioconf.audio.*;
24 import org.lucane.common.*;
25 import org.lucane.common.net.ObjectConnection;
26
27 public class Streamer implements AudioRecorderListener
28 {
29     private ObjectConnection connection;
30     private AudioConf plugin;
31     
32     public Streamer(AudioConf plugin, ObjectConnection oc)
33     {
34         this.plugin = plugin;
35         this.connection = oc;
36     }
37     
38     /**
39      * Recording started, init output stream
40      */

41     public void audioRecordingStarted(AudioConfig config)
42     {
43         Logging.getLogger().fine("Ready to record");
44     }
45     
46     /**
47      * Audio recorded, write to file
48      */

49     public void audioRecorded(byte[] data, int length)
50     {
51         try {
52             byte[] buffer = new byte[length];
53             System.arraycopy(data, 0, buffer, 0, length);
54             
55             this.connection.write(buffer);
56         } catch (IOException e) {
57             this.plugin.reportRecorderError(e);
58         }
59     }
60
61     /**
62      * Recording ended, close everything
63      */

64     public void audioRecordingEnded()
65     {
66         this.connection.close();
67     }
68 }
Popular Tags