1
// Microphone.cpp: ActionScript "Microphone" input class, for Gnash.
3
// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
5
// This program is free software; you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation; either version 3 of the License, or
8
// (at your option) any later version.
10
// This program 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
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program; if not, write to the Free Software
17
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
#include "gnashconfig.h"
24
#include "Microphone.h"
25
#include "as_object.h" // for inheritance
28
#include "smart_ptr.h" // for boost intrusive_ptr
29
#include "builtin_function.h" // need builtin_function
30
#include "Object.h" // for getObjectInterface
34
as_value microphone_get(const fn_call& fn);
35
as_value microphone_setgain(const fn_call& fn);
36
as_value microphone_setrate(const fn_call& fn);
37
as_value microphone_setsilencelevel(const fn_call& fn);
38
as_value microphone_setuseechosuppression(const fn_call& fn);
39
as_value microphone_ctor(const fn_call& fn);
42
attachMicrophoneInterface(as_object& o)
44
o.init_member("get", new builtin_function(microphone_get));
45
o.init_member("setGain", new builtin_function(microphone_setgain));
46
o.init_member("setRate", new builtin_function(microphone_setrate));
47
o.init_member("setSilenceLevel", new builtin_function(microphone_setsilencelevel));
48
o.init_member("setUseEchoSuppression", new builtin_function(microphone_setuseechosuppression));
52
getMicrophoneInterface()
54
static boost::intrusive_ptr<as_object> o;
57
o = new as_object(getObjectInterface());
58
attachMicrophoneInterface(*o);
63
class microphone_as_object: public as_object
68
microphone_as_object()
70
as_object(getMicrophoneInterface())
73
// override from as_object ?
74
//std::string get_text_value() const { return "Microphone"; }
76
// override from as_object ?
77
//double get_numeric_value() const { return 0; }
80
as_value microphone_get(const fn_call& /*fn*/) {
81
log_unimpl (__FUNCTION__);
84
as_value microphone_setgain(const fn_call& /*fn*/) {
85
log_unimpl (__FUNCTION__);
88
as_value microphone_setrate(const fn_call& /*fn*/) {
89
log_unimpl (__FUNCTION__);
92
as_value microphone_setsilencelevel(const fn_call& /*fn*/) {
93
log_unimpl (__FUNCTION__);
96
as_value microphone_setuseechosuppression(const fn_call& /*fn*/) {
97
log_unimpl (__FUNCTION__);
102
microphone_ctor(const fn_call& /* fn */)
104
boost::intrusive_ptr<as_object> obj = new microphone_as_object;
106
return as_value(obj.get()); // will keep alive
109
// extern (used by Global.cpp)
110
void microphone_class_init(as_object& global)
112
// This is going to be the global Microphone "class"/"function"
113
static boost::intrusive_ptr<builtin_function> cl;
117
cl=new builtin_function(µphone_ctor, getMicrophoneInterface());
118
// replicate all interface to class, to be able to access
119
// all methods as static functions
120
attachMicrophoneInterface(*cl);
124
// Register _global.Microphone
125
global.init_member("Microphone", cl.get());
130
} // end of gnash namespace