[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] /srv/bzr/gnash/trunk r10392: Renaming, cleanups.
From: |
Benjamin Wolsey |
Subject: |
[Gnash-commit] /srv/bzr/gnash/trunk r10392: Renaming, cleanups. |
Date: |
Fri, 05 Dec 2008 09:02:35 +0100 |
User-agent: |
Bazaar (1.5) |
------------------------------------------------------------
revno: 10392
committer: Benjamin Wolsey <address@hidden>
branch nick: trunk
timestamp: Fri 2008-12-05 09:02:35 +0100
message:
Renaming, cleanups.
renamed:
libcore/asobj/NetConnection.cpp => libcore/asobj/NetConnection_as.cpp
libcore/asobj/NetConnection.h => libcore/asobj/NetConnection_as.h
libcore/asobj/Selection.cpp => libcore/asobj/Selection_as.cpp
libcore/asobj/Selection.h => libcore/asobj/Selection_as.h
modified:
libcore/asobj/ClassHierarchy.cpp
libcore/asobj/Global.cpp
libcore/asobj/Makefile.am
libcore/asobj/NetStream_as.cpp
libcore/asobj/NetStream_as.h
libcore/asobj/Sound.cpp
libcore/asobj/Sound.h
libcore/asobj/NetConnection_as.cpp
libcore/asobj/NetConnection_as.h
libcore/asobj/Selection_as.cpp
------------------------------------------------------------
revno: 10391.1.1
committer: Benjamin Wolsey <address@hidden>
branch nick: work
timestamp: Fri 2008-12-05 08:35:49 +0100
message:
Tidy up code, rename some files and classes.
renamed:
libcore/asobj/NetConnection.cpp => libcore/asobj/NetConnection_as.cpp
libcore/asobj/NetConnection.h => libcore/asobj/NetConnection_as.h
libcore/asobj/Selection.cpp => libcore/asobj/Selection_as.cpp
libcore/asobj/Selection.h => libcore/asobj/Selection_as.h
modified:
libcore/asobj/ClassHierarchy.cpp
libcore/asobj/Global.cpp
libcore/asobj/Makefile.am
libcore/asobj/NetStream_as.cpp
libcore/asobj/NetStream_as.h
libcore/asobj/Sound.cpp
libcore/asobj/Sound.h
libcore/asobj/NetConnection_as.cpp
libcore/asobj/NetConnection_as.h
libcore/asobj/Selection_as.cpp
=== modified file 'libcore/asobj/ClassHierarchy.cpp'
--- a/libcore/asobj/ClassHierarchy.cpp 2008-12-01 12:21:59 +0000
+++ b/libcore/asobj/ClassHierarchy.cpp 2008-12-05 07:35:49 +0000
@@ -43,9 +43,9 @@
#include "Mouse.h"
#include "MovieClipLoader.h"
#include "movie_definition.h"
-#include "NetConnection.h"
+#include "NetConnection_as.h"
#include "NetStream_as.h"
-#include "Selection.h"
+#include "Selection_as.h"
#include "SharedObject.h"
#include "Sound.h"
#include "Stage_as.h"
=== modified file 'libcore/asobj/Global.cpp'
--- a/libcore/asobj/Global.cpp 2008-12-01 12:21:59 +0000
+++ b/libcore/asobj/Global.cpp 2008-12-05 07:35:49 +0000
@@ -49,9 +49,8 @@
#include "Mouse.h"
#include "MovieClipLoader.h"
#include "movie_definition.h"
-#include "NetConnection.h"
+#include "NetConnection_as.h"
#include "NetStream_as.h"
-#include "Selection.h"
#include "SharedObject.h"
#include "Sound.h"
#include "Stage_as.h"
=== modified file 'libcore/asobj/Makefile.am'
--- a/libcore/asobj/Makefile.am 2008-11-27 08:59:57 +0000
+++ b/libcore/asobj/Makefile.am 2008-12-05 07:35:49 +0000
@@ -59,12 +59,12 @@
Math_as.cpp \
Microphone.cpp \
Mouse.cpp \
- NetConnection.cpp \
+ NetConnection_as.cpp \
NetStream_as.cpp \
Number_as.cpp \
Object.cpp \
PlayHead.cpp \
- Selection.cpp \
+ Selection_as.cpp \
SharedObject.cpp\
Sound.cpp \
Stage_as.cpp \
@@ -125,13 +125,13 @@
Microphone.h \
Mouse.h \
MovieClipLoader.h \
- NetConnection.h \
+ NetConnection_as.h \
NetStream_as.h \
Number_as.h \
Object.h \
PlayHead.h \
prophelper.h \
- Selection.h \
+ Selection_as.h \
SharedObject.h \
Sound.h \
Stage_as.h \
=== renamed file 'libcore/asobj/NetConnection.cpp' =>
'libcore/asobj/NetConnection_as.cpp'
--- a/libcore/asobj/NetConnection.cpp 2008-12-04 12:02:58 +0000
+++ b/libcore/asobj/NetConnection_as.cpp 2008-12-05 07:35:49 +0000
@@ -1,4 +1,4 @@
-// NetConnection.cpp: Open local connections for FLV files or URLs.
+// NetConnection_as.cpp: Open local connections for FLV files or URLs.
//
// Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
//
@@ -33,7 +33,7 @@
#include <arpa/inet.h> // for htons
#endif
-#include "NetConnection.h"
+#include "NetConnection_as.h"
#include "log.h"
#include "GnashException.h"
#include "builtin_function.h"
@@ -44,7 +44,7 @@
#include "URLAccessManager.h"
#include "URL.h"
-// for NetConnection.call()
+// for NetConnection_as.call()
#include "VM.h"
#include "amf.h"
#include "SimpleBuffer.h"
@@ -95,7 +95,7 @@
class AMFQueue {
private:
- NetConnection& _nc;
+ NetConnection_as& _nc;
static const int NCCALLREPLYMAX=200000;
typedef std::map<std::string, boost::intrusive_ptr<as_object> >
@@ -112,7 +112,7 @@
unsigned int ticker;
public:
- AMFQueue(NetConnection& nc, URL url)
+ AMFQueue(NetConnection_as& nc, URL url)
:
_nc(nc),
postdata(),
@@ -193,7 +193,7 @@
// This is just a guess, but is better than sending
// 'undefined'
- _nc.notifyStatus(NetConnection::CALL_FAILED);
+ _nc.notifyStatus(NetConnection_as::CALL_FAILED);
}
else if(_connection->eof() )
{
@@ -390,8 +390,8 @@
static as_value amfqueue_tick_wrapper(const fn_call& fn)
{
- boost::intrusive_ptr<NetConnection> ptr =
- ensureType<NetConnection>(fn.this_ptr);
+ boost::intrusive_ptr<NetConnection_as> ptr =
+ ensureType<NetConnection_as>(fn.this_ptr);
// FIXME check if it's possible for the URL of a NetConnection to
change between call()s
ptr->_callQueue->tick();
return as_value();
@@ -464,7 +464,7 @@
/// \brief Opens a local connection through which you can play
/// back video (FLV) files from an HTTP address or from the local file
/// system, using curl.
-NetConnection::NetConnection()
+NetConnection_as::NetConnection_as()
:
as_object(getNetConnectionInterface()),
_callQueue(0),
@@ -496,13 +496,13 @@
}
// here to have AMFQueue definition available
-NetConnection::~NetConnection()
+NetConnection_as::~NetConnection_as()
{
}
void
-NetConnection::markReachableResources() const
+NetConnection_as::markReachableResources() const
{
if ( _callQueue.get() ) _callQueue->markReachableResources();
markAsObjectReachable();
@@ -510,7 +510,7 @@
std::string
-NetConnection::validateURL() const
+NetConnection_as::validateURL() const
{
const movie_root& mr = _vm.getRoot();
@@ -531,7 +531,7 @@
}
void
-NetConnection::notifyStatus(StatusCode code)
+NetConnection_as::notifyStatus(StatusCode code)
{
std::pair<std::string, std::string> info;
getStatusCodeInfo(code, info);
@@ -549,7 +549,7 @@
}
void
-NetConnection::getStatusCodeInfo(StatusCode code, NetConnectionStatus& info)
+NetConnection_as::getStatusCodeInfo(StatusCode code, NetConnectionStatus& info)
{
/// The Call statuses do exist, but this implementation is a guess.
switch (code)
@@ -593,7 +593,7 @@
void
-NetConnection::connect()
+NetConnection_as::connect()
{
_isConnected = true;
_inError = false;
@@ -602,7 +602,7 @@
void
-NetConnection::connect(const std::string& uri)
+NetConnection_as::connect(const std::string& uri)
{
// FIXME: RTMP URLs should attempt a connection (warning: this seems
@@ -620,7 +620,7 @@
void
-NetConnection::close()
+NetConnection_as::close()
{
/// TODO: what should actually happen here? Should an attached
/// NetStream object be interrupted?
@@ -633,14 +633,14 @@
void
-NetConnection::setURI(const std::string& uri)
+NetConnection_as::setURI(const std::string& uri)
{
init_readonly_property("uri", &netconnection_uri);
_uri = uri;
}
void
-NetConnection::call(as_object* asCallback, const std::string& callNumber,
+NetConnection_as::call(as_object* asCallback, const std::string& callNumber,
const SimpleBuffer& buf)
{
@@ -711,8 +711,8 @@
as_value
netconnection_call(const fn_call& fn)
{
- boost::intrusive_ptr<NetConnection> ptr =
- ensureType<NetConnection>(fn.this_ptr);
+ boost::intrusive_ptr<NetConnection_as> ptr =
+ ensureType<NetConnection_as>(fn.this_ptr);
if (fn.nargs < 1)
{
@@ -809,8 +809,8 @@
as_value
netconnection_close(const fn_call& fn)
{
- boost::intrusive_ptr<NetConnection> ptr =
- ensureType<NetConnection>(fn.this_ptr);
+ boost::intrusive_ptr<NetConnection_as> ptr =
+ ensureType<NetConnection_as>(fn.this_ptr);
ptr->close();
@@ -822,8 +822,8 @@
as_value
netconnection_isConnected(const fn_call& fn)
{
- boost::intrusive_ptr<NetConnection> ptr =
- ensureType<NetConnection>(fn.this_ptr);
+ boost::intrusive_ptr<NetConnection_as> ptr =
+ ensureType<NetConnection_as>(fn.this_ptr);
return as_value(ptr->isConnected());
}
@@ -831,8 +831,8 @@
as_value
netconnection_uri(const fn_call& fn)
{
- boost::intrusive_ptr<NetConnection> ptr =
- ensureType<NetConnection>(fn.this_ptr);
+ boost::intrusive_ptr<NetConnection_as> ptr =
+ ensureType<NetConnection_as>(fn.this_ptr);
return as_value(ptr->getURI());
}
@@ -875,7 +875,7 @@
{
GNASH_REPORT_FUNCTION;
- NetConnection* nc = new NetConnection;
+ NetConnection_as* nc = new NetConnection_as;
return as_value(nc);
}
@@ -897,8 +897,8 @@
netconnection_connect(const fn_call& fn)
{
- boost::intrusive_ptr<NetConnection> ptr =
- ensureType<NetConnection>(fn.this_ptr);
+ boost::intrusive_ptr<NetConnection_as> ptr =
+ ensureType<NetConnection_as>(fn.this_ptr);
if (fn.nargs < 1)
{
@@ -937,8 +937,8 @@
as_value
netconnection_addHeader(const fn_call& fn)
{
- boost::intrusive_ptr<NetConnection> ptr =
- ensureType<NetConnection>(fn.this_ptr);
+ boost::intrusive_ptr<NetConnection_as> ptr =
+ ensureType<NetConnection_as>(fn.this_ptr);
UNUSED(ptr);
log_unimpl("NetConnection.addHeader()");
=== renamed file 'libcore/asobj/NetConnection.h' =>
'libcore/asobj/NetConnection_as.h'
--- a/libcore/asobj/NetConnection.h 2008-12-04 12:02:58 +0000
+++ b/libcore/asobj/NetConnection_as.h 2008-12-05 07:35:49 +0000
@@ -26,7 +26,6 @@
// Forward declarations
namespace gnash {
- //class NetStream_as;
class AMFQueue;
}
@@ -36,7 +35,7 @@
//
/// Provides interfaces to load data from an URL
///
-class NetConnection: public as_object
+class NetConnection_as: public as_object
{
public:
@@ -51,8 +50,8 @@
CALL_BADVERSION
};
- NetConnection();
- ~NetConnection();
+ NetConnection_as();
+ ~NetConnection_as();
/// Make the stored URI into a valid and checked URL.
std::string validateURL() const;
=== modified file 'libcore/asobj/NetStream_as.cpp'
--- a/libcore/asobj/NetStream_as.cpp 2008-12-04 12:02:58 +0000
+++ b/libcore/asobj/NetStream_as.cpp 2008-12-05 07:35:49 +0000
@@ -32,7 +32,7 @@
#include "builtin_function.h"
#include "timers.h" // for registering the advance timer
#include "GnashException.h"
-#include "NetConnection.h"
+#include "NetConnection_as.h"
#include "Object.h" // for getObjectInterface
#include "VM.h"
#include "namedStrings.h"
@@ -54,33 +54,40 @@
//#define GNASH_DEBUG_DECODING
namespace gnash {
-
-static as_value netstream_new(const fn_call& fn);
-static as_value netstream_close(const fn_call& fn);
-static as_value netstream_pause(const fn_call& fn);
-static as_value netstream_play(const fn_call& fn);
-static as_value netstream_seek(const fn_call& fn);
-static as_value netstream_setbuffertime(const fn_call& fn);
-static as_value netstream_time(const fn_call& fn);
-
-static as_value netstream_attachAudio(const fn_call& fn);
-static as_value netstream_attachVideo(const fn_call& fn);
-static as_value netstream_publish(const fn_call& fn);
-static as_value netstream_receiveAudio(const fn_call& fn);
-static as_value netstream_receiveVideo(const fn_call& fn);
-static as_value netstream_send(const fn_call& fn);
-
-static as_object* getNetStreamInterface();
-
+
+namespace {
+
+ as_value netstream_new(const fn_call& fn);
+ as_value netstream_close(const fn_call& fn);
+ as_value netstream_pause(const fn_call& fn);
+ as_value netstream_play(const fn_call& fn);
+ as_value netstream_seek(const fn_call& fn);
+ as_value netstream_setbuffertime(const fn_call& fn);
+ as_value netstream_time(const fn_call& fn);
+
+ as_value netstream_attachAudio(const fn_call& fn);
+ as_value netstream_attachVideo(const fn_call& fn);
+ as_value netstream_publish(const fn_call& fn);
+ as_value netstream_receiveAudio(const fn_call& fn);
+ as_value netstream_receiveVideo(const fn_call& fn);
+ as_value netstream_send(const fn_call& fn);
+
+ as_object* getNetStreamInterface();
+ void attachNetStreamInterface(as_object& o);
+}
+
+/// Contruct a NetStream object.
+//
+/// The default size needed to begin playback (m_bufferTime) of media
+/// is 100 milliseconds.
NetStream_as::NetStream_as()
:
as_object(getNetStreamInterface()),
- _netCon(NULL),
- m_bufferTime(100), // The default size needed to begin playback of media
is 100 miliseconds
+ _netCon(0),
+ m_bufferTime(100),
m_newFrameReady(false),
m_imageframe(),
m_parser(NULL),
- m_isFLV(false),
inputPos(0),
_invalidatedVideoCharacter(0),
_decoding_state(DEC_NONE),
@@ -106,355 +113,6 @@
{
}
-static as_value
-netstream_new(const fn_call& fn)
-{
-
- boost::intrusive_ptr<NetStream_as> netstream_obj;
-
- netstream_obj = new NetStream_as();
-
- if (fn.nargs > 0)
- {
- boost::intrusive_ptr<NetConnection> ns =
boost::dynamic_pointer_cast<NetConnection>(fn.arg(0).to_object());
- if ( ns )
- {
- netstream_obj->setNetCon(ns);
- }
- else
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("First argument "
- "to NetStream constructor "
- "doesn't cast to a NetConnection (%s)"),
- fn.arg(0));
- );
- }
- }
- return as_value(netstream_obj.get());
-
-}
-
-static as_value netstream_close(const fn_call& fn)
-{
- boost::intrusive_ptr<NetStream_as> ns =
ensureType<NetStream_as>(fn.this_ptr);
- ns->close();
- return as_value();
-}
-
-static as_value
-netstream_pause(const fn_call& fn)
-{
- boost::intrusive_ptr<NetStream_as> ns =
- ensureType<NetStream_as>(fn.this_ptr);
-
- // mode: -1 ==> toogle, 0==> pause, 1==> play
- NetStream_as::PauseMode mode = NetStream_as::pauseModeToggle;
- if (fn.nargs > 0)
- {
- mode = fn.arg(0).to_bool() ? NetStream_as::pauseModePause :
- NetStream_as::pauseModeUnPause;
- }
- ns->pause(mode); // toggle mode
- return as_value();
-}
-
-static as_value
-netstream_play(const fn_call& fn)
-{
- boost::intrusive_ptr<NetStream_as> ns =
ensureType<NetStream_as>(fn.this_ptr);
-
- if (fn.nargs < 1)
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("NetStream_as play needs args"));
- );
- return as_value();
- }
-
- if ( ! ns->isConnected() )
- {
- IF_VERBOSE_ASCODING_ERRORS(
- log_aserror(_("NetStream.play(%s): stream is not connected"),
fn.arg(0));
- );
- return as_value();
- }
-
- ns->play(fn.arg(0).to_string());
-
- return as_value();
-}
-
-static as_value netstream_seek(const fn_call& fn) {
- boost::intrusive_ptr<NetStream_as> ns =
ensureType<NetStream_as>(fn.this_ptr);
-
- boost::uint32_t time = 0;
- if (fn.nargs > 0)
- {
- time = static_cast<boost::uint32_t>(fn.arg(0).to_number());
- }
- ns->seek(time);
-
- return as_value();
-}
-
-static as_value netstream_setbuffertime(const fn_call& fn)
-{
-
- //GNASH_REPORT_FUNCTION;
-
- boost::intrusive_ptr<NetStream_as> ns =
ensureType<NetStream_as>(fn.this_ptr);
-
- // TODO: should we do anything if given no args ?
- // are we sure setting bufferTime to 0 is what we have to do ?
- double time = 0;
- if (fn.nargs > 0)
- {
- time = fn.arg(0).to_number();
- }
-
- // TODO: don't allow a limit < 100
-
- ns->setBufferTime(boost::uint32_t(time*1000));
-
- return as_value();
-}
-
-static as_value netstream_attachAudio(const fn_call& fn)
-{
- boost::intrusive_ptr<NetStream_as> ns =
ensureType<NetStream_as>(fn.this_ptr);
- UNUSED(ns);
-
- bool warned = false;
- if ( ! warned ) {
- log_unimpl("NetStream.attachAudio");
- warned = true;
- }
-
- return as_value();
-}
-
-static as_value netstream_attachVideo(const fn_call& fn)
-{
- boost::intrusive_ptr<NetStream_as> ns =
ensureType<NetStream_as>(fn.this_ptr);
- UNUSED(ns);
-
- bool warned = false;
- if ( ! warned ) {
- log_unimpl("NetStream.attachVideo");
- warned = true;
- }
-
- return as_value();
-}
-
-static as_value netstream_publish(const fn_call& fn)
-{
- boost::intrusive_ptr<NetStream_as> ns =
ensureType<NetStream_as>(fn.this_ptr);
- UNUSED(ns);
-
- bool warned = false;
- if ( ! warned ) {
- log_unimpl("NetStream.publish");
- warned = true;
- }
-
- return as_value();
-}
-
-static as_value netstream_receiveAudio(const fn_call& fn)
-{
- boost::intrusive_ptr<NetStream_as> ns =
ensureType<NetStream_as>(fn.this_ptr);
- UNUSED(ns);
-
- bool warned = false;
- if ( ! warned ) {
- log_unimpl("NetStream.receiveAudio");
- warned = true;
- }
-
- return as_value();
-}
-
-static as_value netstream_receiveVideo(const fn_call& fn)
-{
- boost::intrusive_ptr<NetStream_as> ns =
ensureType<NetStream_as>(fn.this_ptr);
- UNUSED(ns);
-
- bool warned = false;
- if ( ! warned ) {
- log_unimpl("NetStream.receiveVideo");
- warned = true;
- }
-
- return as_value();
-}
-
-static as_value netstream_send(const fn_call& fn)
-{
- boost::intrusive_ptr<NetStream_as> ns =
ensureType<NetStream_as>(fn.this_ptr);
- UNUSED(ns);
-
- bool warned = false;
- if ( ! warned ) {
- log_unimpl("NetStream.send");
- warned = true;
- }
-
- return as_value();
-}
-
-// Both a getter and a (do-nothing) setter for time
-static as_value
-netstream_time(const fn_call& fn)
-{
- //GNASH_REPORT_FUNCTION;
-
- boost::intrusive_ptr<NetStream_as> ns =
ensureType<NetStream_as>(fn.this_ptr);
-
- assert(fn.nargs == 0); // we're a getter
- return as_value(double(ns->time()/1000.0));
-}
-
-// Both a getter and a (do-nothing) setter for bytesLoaded
-static as_value
-netstream_bytesloaded(const fn_call& fn)
-{
- boost::intrusive_ptr<NetStream_as> ns =
ensureType<NetStream_as>(fn.this_ptr);
-
- if ( ! ns->isConnected() )
- {
- return as_value();
- }
- long ret = ns->bytesLoaded();
- return as_value(ret);
-}
-
-// Both a getter and a (do-nothing) setter for bytesTotal
-static as_value
-netstream_bytestotal(const fn_call& fn)
-{
- boost::intrusive_ptr<NetStream_as> ns =
ensureType<NetStream_as>(fn.this_ptr);
-
- if ( ! ns->isConnected() )
- {
- return as_value();
- }
- long ret = ns->bytesTotal();
- return as_value(ret);
-}
-
-// Both a getter and a (do-nothing) setter for currentFPS
-static as_value
-netstream_currentFPS(const fn_call& fn)
-{
- boost::intrusive_ptr<NetStream_as> ns =
ensureType<NetStream_as>(fn.this_ptr);
-
- if ( ! ns->isConnected() )
- {
- return as_value();
- }
-
- double fps = ns->getCurrentFPS();
-
-#if 0
- if (fps <= 0) {
- return as_value(); // undef
- }
-#endif
-
- return as_value(fps);
-}
-
-// read-only property bufferLength: amount of time buffered before playback
-static as_value
-netstream_bufferLength(const fn_call& fn)
-{
- boost::intrusive_ptr<NetStream_as> ns =
ensureType<NetStream_as>(fn.this_ptr);
-
- // NetStream_as::bufferLength returns milliseconds, we want
- // to return *fractional* seconds.
- double ret = ns->bufferLength()/1000.0;
- return as_value(ret);
-}
-
-// Both a getter and a (do-nothing) setter for bufferTime
-static as_value
-netstream_bufferTime(const fn_call& fn)
-{
- boost::intrusive_ptr<NetStream_as> ns =
ensureType<NetStream_as>(fn.this_ptr);
-
- // We return bufferTime in seconds
- double ret = ns->bufferTime()/1000.0;
- return as_value(ret);
-}
-
-// Both a getter and a (do-nothing) setter for liveDelay
-static as_value
-netstream_liveDelay(const fn_call& fn)
-{
- boost::intrusive_ptr<NetStream_as> ns =
ensureType<NetStream_as>(fn.this_ptr);
-
- bool warned = false;
- if ( ! warned ) {
- log_unimpl("NetStream.liveDelay getter/setter");
- warned = true;
- }
-
- if ( fn.nargs == 0 ) // getter
- {
- return as_value();
- }
- else // setter
- {
- return as_value();
- }
-}
-
-void
-attachNetStreamInterface(as_object& o)
-{
-
- o.init_member("close", new builtin_function(netstream_close));
- o.init_member("pause", new builtin_function(netstream_pause));
- o.init_member("play", new builtin_function(netstream_play));
- o.init_member("seek", new builtin_function(netstream_seek));
- o.init_member("setBufferTime", new
builtin_function(netstream_setbuffertime));
-
- o.init_member("attachAudio", new builtin_function(netstream_attachAudio));
- o.init_member("attachVideo", new builtin_function(netstream_attachVideo));
- o.init_member("publish", new builtin_function(netstream_publish));
- o.init_member("receiveAudio", new
builtin_function(netstream_receiveAudio));
- o.init_member("receiveVideo", new
builtin_function(netstream_receiveVideo));
- o.init_member("send", new builtin_function(netstream_send));
-
- // Properties
- // TODO: attach to each instance rather then to the class ? check it ..
-
- o.init_readonly_property("time", &netstream_time);
- o.init_readonly_property("bytesLoaded", &netstream_bytesloaded);
- o.init_readonly_property("bytesTotal", &netstream_bytestotal);
- o.init_readonly_property("currentFps", &netstream_currentFPS);
- o.init_readonly_property("bufferLength", &netstream_bufferLength);
- o.init_readonly_property("bufferTime", &netstream_bufferTime);
- o.init_readonly_property("liveDelay", &netstream_liveDelay);
-
-}
-
-static as_object*
-getNetStreamInterface()
-{
-
- static boost::intrusive_ptr<as_object> o;
- if ( o == NULL )
- {
- o = new as_object(getObjectInterface());
- attachNetStreamInterface(*o);
- }
-
- return o.get();
-}
-
// extern (used by Global.cpp)
void netstream_class_init(as_object& global)
{
@@ -1904,5 +1562,351 @@
_audioQueue.clear();
}
-
-} // end of gnash namespace
+namespace {
+
+as_value
+netstream_new(const fn_call& fn)
+{
+
+ boost::intrusive_ptr<NetStream_as> netstream_obj = new NetStream_as;
+
+ if (fn.nargs > 0)
+ {
+ boost::intrusive_ptr<NetConnection_as> ns =
+ boost::dynamic_pointer_cast<NetConnection_as>(
+ fn.arg(0).to_object());
+ if ( ns )
+ {
+ netstream_obj->setNetCon(ns);
+ }
+ else
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("First argument "
+ "to NetStream constructor "
+ "doesn't cast to a NetConnection (%s)"),
+ fn.arg(0));
+ );
+ }
+ }
+ return as_value(netstream_obj.get());
+
+}
+
+as_value
+netstream_close(const fn_call& fn)
+{
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+ ns->close();
+ return as_value();
+}
+
+as_value
+netstream_pause(const fn_call& fn)
+{
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+
+ // mode: -1 ==> toogle, 0==> pause, 1==> play
+ NetStream_as::PauseMode mode = NetStream_as::pauseModeToggle;
+ if (fn.nargs > 0)
+ {
+ mode = fn.arg(0).to_bool() ? NetStream_as::pauseModePause :
+ NetStream_as::pauseModeUnPause;
+ }
+ ns->pause(mode); // toggle mode
+ return as_value();
+}
+
+as_value
+netstream_play(const fn_call& fn)
+{
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+
+ if (!fn.nargs)
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("NetStream_as play needs args"));
+ );
+ return as_value();
+ }
+
+ if ( ! ns->isConnected() )
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror(_("NetStream.play(%s): stream is not connected"),
+ fn.arg(0));
+ );
+ return as_value();
+ }
+
+ ns->play(fn.arg(0).to_string());
+
+ return as_value();
+}
+
+as_value
+netstream_seek(const fn_call& fn)
+{
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+
+ boost::uint32_t time = 0;
+ if (fn.nargs > 0)
+ {
+ time = static_cast<boost::uint32_t>(fn.arg(0).to_number());
+ }
+ ns->seek(time);
+
+ return as_value();
+}
+
+as_value
+netstream_setbuffertime(const fn_call& fn)
+{
+
+ //GNASH_REPORT_FUNCTION;
+
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+
+ // TODO: should we do anything if given no args ?
+ // are we sure setting bufferTime to 0 is what we have to do ?
+ double time = 0;
+ if (fn.nargs > 0)
+ {
+ time = fn.arg(0).to_number();
+ }
+
+ // TODO: don't allow a limit < 100
+
+ ns->setBufferTime(boost::uint32_t(time*1000));
+
+ return as_value();
+}
+
+as_value
+netstream_attachAudio(const fn_call& fn)
+{
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+ UNUSED(ns);
+
+ LOG_ONCE(log_unimpl("NetStream.attachAudio"));;
+
+ return as_value();
+}
+
+as_value
+netstream_attachVideo(const fn_call& fn)
+{
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+ UNUSED(ns);
+
+ LOG_ONCE(log_unimpl("NetStream.attachVideo"));
+
+ return as_value();
+}
+
+as_value
+netstream_publish(const fn_call& fn)
+{
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+ UNUSED(ns);
+
+ LOG_ONCE(log_unimpl("NetStream.publish"));
+
+ return as_value();
+}
+
+as_value
+netstream_receiveAudio(const fn_call& fn)
+{
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+ UNUSED(ns);
+
+ LOG_ONCE(log_unimpl("NetStream.receiveAudio"));
+
+ return as_value();
+}
+
+as_value
+netstream_receiveVideo(const fn_call& fn)
+{
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+ UNUSED(ns);
+
+ LOG_ONCE(log_unimpl("NetStream.receiveVideo"));
+
+ return as_value();
+}
+
+as_value
+netstream_send(const fn_call& fn)
+{
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+ UNUSED(ns);
+
+ LOG_ONCE(log_unimpl("NetStream.send"));
+
+ return as_value();
+}
+
+// Both a getter and a (do-nothing) setter for time
+as_value
+netstream_time(const fn_call& fn)
+{
+ //GNASH_REPORT_FUNCTION;
+
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+
+ assert(fn.nargs == 0); // we're a getter
+ return as_value(double(ns->time()/1000.0));
+}
+
+// Both a getter and a (do-nothing) setter for bytesLoaded
+as_value
+netstream_bytesloaded(const fn_call& fn)
+{
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+
+ if ( ! ns->isConnected() )
+ {
+ return as_value();
+ }
+ long ret = ns->bytesLoaded();
+ return as_value(ret);
+}
+
+// Both a getter and a (do-nothing) setter for bytesTotal
+as_value
+netstream_bytestotal(const fn_call& fn)
+{
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+
+ if ( ! ns->isConnected() )
+ {
+ return as_value();
+ }
+ long ret = ns->bytesTotal();
+ return as_value(ret);
+}
+
+// Both a getter and a (do-nothing) setter for currentFPS
+as_value
+netstream_currentFPS(const fn_call& fn)
+{
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+
+ if ( ! ns->isConnected() )
+ {
+ return as_value();
+ }
+
+ double fps = ns->getCurrentFPS();
+
+ return as_value(fps);
+}
+
+// read-only property bufferLength: amount of time buffered before playback
+as_value
+netstream_bufferLength(const fn_call& fn)
+{
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+
+ // NetStream_as::bufferLength returns milliseconds, we want
+ // to return *fractional* seconds.
+ double ret = ns->bufferLength()/1000.0;
+ return as_value(ret);
+}
+
+// Both a getter and a (do-nothing) setter for bufferTime
+as_value
+netstream_bufferTime(const fn_call& fn)
+{
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+
+ // We return bufferTime in seconds
+ double ret = ns->bufferTime() / 1000.0;
+ return as_value(ret);
+}
+
+// Both a getter and a (do-nothing) setter for liveDelay
+as_value
+netstream_liveDelay(const fn_call& fn)
+{
+ boost::intrusive_ptr<NetStream_as> ns =
+ ensureType<NetStream_as>(fn.this_ptr);
+
+ LOG_ONCE(log_unimpl("NetStream.liveDelay getter/setter"));
+
+ if ( fn.nargs == 0 ) // getter
+ {
+ return as_value();
+ }
+ else // setter
+ {
+ return as_value();
+ }
+}
+
+void
+attachNetStreamInterface(as_object& o)
+{
+
+ o.init_member("close", new builtin_function(netstream_close));
+ o.init_member("pause", new builtin_function(netstream_pause));
+ o.init_member("play", new builtin_function(netstream_play));
+ o.init_member("seek", new builtin_function(netstream_seek));
+ o.init_member("setBufferTime",
+ new builtin_function(netstream_setbuffertime));
+
+ o.init_member("attachAudio", new builtin_function(netstream_attachAudio));
+ o.init_member("attachVideo", new builtin_function(netstream_attachVideo));
+ o.init_member("publish", new builtin_function(netstream_publish));
+ o.init_member("receiveAudio", new
builtin_function(netstream_receiveAudio));
+ o.init_member("receiveVideo", new
builtin_function(netstream_receiveVideo));
+ o.init_member("send", new builtin_function(netstream_send));
+
+ // Properties
+ // TODO: attach to each instance rather then to the class ? check it ..
+
+ o.init_readonly_property("time", &netstream_time);
+ o.init_readonly_property("bytesLoaded", &netstream_bytesloaded);
+ o.init_readonly_property("bytesTotal", &netstream_bytestotal);
+ o.init_readonly_property("currentFps", &netstream_currentFPS);
+ o.init_readonly_property("bufferLength", &netstream_bufferLength);
+ o.init_readonly_property("bufferTime", &netstream_bufferTime);
+ o.init_readonly_property("liveDelay", &netstream_liveDelay);
+
+}
+
+as_object*
+getNetStreamInterface()
+{
+
+ static boost::intrusive_ptr<as_object> o;
+ if ( o == NULL )
+ {
+ o = new as_object(getObjectInterface());
+ attachNetStreamInterface(*o);
+ }
+
+ return o.get();
+}
+
+} // anonymous namespace
+} // gnash namespace
=== modified file 'libcore/asobj/NetStream_as.h'
--- a/libcore/asobj/NetStream_as.h 2008-12-03 11:25:09 +0000
+++ b/libcore/asobj/NetStream_as.h 2008-12-05 07:35:49 +0000
@@ -29,9 +29,9 @@
#include "smart_ptr.h" // GNASH_USE_GC
#include "impl.h"
-#include "NetConnection.h"
#include "MediaParser.h"
#include "as_function.h" // for visibility of destructor by intrusive_ptr
+#include "NetConnection_as.h"
#include "PlayHead.h" // for composition
#include "VideoDecoder.h" // for visibility of dtor
@@ -205,7 +205,7 @@
invalidTime
};
- boost::intrusive_ptr<NetConnection> _netCon;
+ boost::intrusive_ptr<NetConnection_as> _netCon;
boost::scoped_ptr<CharacterProxy> _audioController;
@@ -263,8 +263,6 @@
std::auto_ptr<media::MediaParser> m_parser;
// Are we playing a FLV?
- bool m_isFLV;
-
// The handler which is invoked on status change
boost::intrusive_ptr<as_function> m_statusHandler;
@@ -369,13 +367,12 @@
/// @param nc
/// The NetConnection object to use for network access
///
- void setNetCon(boost::intrusive_ptr<NetConnection> nc)
- {
+ void setNetCon(boost::intrusive_ptr<NetConnection_as> nc) {
_netCon = nc;
}
/// Return true if the NetStream has an associated NetConnection
- bool isConnected() const { return _netCon != 0; }
+ bool isConnected() const { return (_netCon); }
/// Specifies the number of milliseconds to buffer before starting to
display the stream.
//
=== renamed file 'libcore/asobj/Selection.cpp' =>
'libcore/asobj/Selection_as.cpp'
--- a/libcore/asobj/Selection.cpp 2008-12-02 13:28:42 +0000
+++ b/libcore/asobj/Selection_as.cpp 2008-12-05 07:35:49 +0000
@@ -21,7 +21,7 @@
#include "gnashconfig.h"
#endif
-#include "Selection.h"
+#include "Selection_as.h"
#include "as_object.h" // for inheritance
#include "log.h"
#include "fn_call.h"
=== renamed file 'libcore/asobj/Selection.h' => 'libcore/asobj/Selection_as.h'
=== modified file 'libcore/asobj/Sound.cpp'
--- a/libcore/asobj/Sound.cpp 2008-12-02 11:45:42 +0000
+++ b/libcore/asobj/Sound.cpp 2008-12-05 07:35:49 +0000
@@ -69,7 +69,7 @@
Sound::Sound()
:
as_object(getSoundInterface()),
- attachedCharacter(0),
+ _attachedCharacter(0),
soundId(-1),
externalSound(false),
isStreaming(false),
@@ -101,7 +101,7 @@
void
Sound::attachCharacter(character* attachTo)
{
- attachedCharacter.reset(new CharacterProxy(attachTo));
+ _attachedCharacter.reset(new CharacterProxy(attachTo));
}
void
@@ -144,10 +144,10 @@
// have both an attached character *and*
// some other sound...
//
- if ( attachedCharacter )
+ if ( _attachedCharacter )
{
//log_debug("Sound has an attached character");
- character* ch = attachedCharacter->get();
+ character* ch = _attachedCharacter->get();
if ( ! ch )
{
log_debug("Character attached to Sound was unloaded and "
@@ -277,12 +277,13 @@
// have both an attached character *and*
// some other sound...
//
- if ( attachedCharacter )
+ if ( _attachedCharacter )
{
- character* ch = attachedCharacter->get();
+ character* ch = _attachedCharacter->get();
if ( ! ch )
{
- log_debug("Character attached to Sound was unloaded and couldn't
rebind");
+ log_debug("Character attached to Sound was unloaded and "
+ "couldn't rebind");
return;
}
ch->setVolume(volume);
@@ -921,41 +922,56 @@
attachSoundInterface(as_object& o)
{
- int fl_hpc =
as_prop_flags::dontEnum|as_prop_flags::dontDelete|as_prop_flags::readOnly;
+ int flags = as_prop_flags::dontEnum |
+ as_prop_flags::dontDelete |
+ as_prop_flags::readOnly;
o.init_member("attachSound", new builtin_function(sound_attachsound),
- fl_hpc);
- o.init_member("getPan", new builtin_function(sound_getpan), fl_hpc);
- o.init_member("setPan", new builtin_function(sound_setpan), fl_hpc);
- o.init_member("start", new builtin_function(sound_start), fl_hpc);
- o.init_member("stop", new builtin_function(sound_stop), fl_hpc);
+ flags);
+ o.init_member("getPan", new builtin_function(sound_getpan), flags);
+ o.init_member("setPan", new builtin_function(sound_setpan), flags);
+ o.init_member("start", new builtin_function(sound_start), flags);
+ o.init_member("stop", new builtin_function(sound_stop), flags);
o.init_member("getTransform", new builtin_function(sound_gettransform),
- fl_hpc);
+ flags);
o.init_member("setTransform", new builtin_function(sound_settransform),
- fl_hpc);
- o.init_member("getVolume", new builtin_function(sound_getvolume), fl_hpc);
- o.init_member("setVolume", new builtin_function(sound_setvolume), fl_hpc);
-
- int fl_hpcn6 = fl_hpc|as_prop_flags::onlySWF6Up;
-
- o.init_member("getDuration", new builtin_function(sound_getDuration),
fl_hpcn6);
- o.init_member("setDuration", new builtin_function(sound_setDuration),
fl_hpcn6);
- o.init_member("loadSound", new builtin_function(sound_loadsound),
fl_hpcn6);
- o.init_member("getPosition", new builtin_function(sound_getPosition),
fl_hpcn6);
- o.init_member("setPosition", new builtin_function(sound_setPosition),
fl_hpcn6);
- o.init_member("getBytesLoaded", new
builtin_function(sound_getbytesloaded), fl_hpcn6);
- o.init_member("getBytesTotal", new builtin_function(sound_getbytestotal),
fl_hpcn6);
-
- int fl_hpcn9 =
as_prop_flags::dontEnum|as_prop_flags::dontDelete|as_prop_flags::readOnly|as_prop_flags::onlySWF9Up;
- o.init_member("areSoundsInaccessible", new
builtin_function(sound_areSoundsInaccessible), fl_hpcn9);
+ flags);
+ o.init_member("getVolume", new builtin_function(sound_getvolume), flags);
+ o.init_member("setVolume", new builtin_function(sound_setvolume), flags);
+
+ int flagsn6 = flags | as_prop_flags::onlySWF6Up;
+
+ o.init_member("getDuration",
+ new builtin_function(sound_getDuration), flagsn6);
+ o.init_member("setDuration",
+ new builtin_function(sound_setDuration), flagsn6);
+ o.init_member("loadSound", new builtin_function(sound_loadsound), flagsn6);
+ o.init_member("getPosition",
+ new builtin_function(sound_getPosition), flagsn6);
+ o.init_member("setPosition",
+ new builtin_function(sound_setPosition), flagsn6);
+ o.init_member("getBytesLoaded",
+ new builtin_function(sound_getbytesloaded), flagsn6);
+ o.init_member("getBytesTotal",
+ new builtin_function(sound_getbytestotal), flagsn6);
+
+ int flagsn9 = as_prop_flags::dontEnum |
+ as_prop_flags::dontDelete |
+ as_prop_flags::readOnly |
+ as_prop_flags::onlySWF9Up;
+
+ o.init_member("areSoundsInaccessible",
+ new builtin_function(sound_areSoundsInaccessible), flagsn9);
// Properties
//there's no such thing as an ID3 member (swfdec shows)
o.init_readonly_property("duration", &sound_duration);
o.init_readonly_property("position", &sound_position);
- int fl_hp = as_prop_flags::dontEnum|as_prop_flags::dontDelete;
- o.init_property("checkPolicyFile", &checkPolicyFile_getset,
&checkPolicyFile_getset, fl_hp);
+ int fl_hp = as_prop_flags::dontEnum | as_prop_flags::dontDelete;
+
+ o.init_property("checkPolicyFile", &checkPolicyFile_getset,
+ &checkPolicyFile_getset, fl_hp);
}
@@ -1102,8 +1118,7 @@
void
Sound::markReachableResources() const
{
- if ( connection ) connection->setReachable();
- if ( attachedCharacter ) attachedCharacter->setReachable();
+ if ( _attachedCharacter ) _attachedCharacter->setReachable();
markAsObjectReachable();
}
#endif // GNASH_USE_GC
=== modified file 'libcore/asobj/Sound.h'
--- a/libcore/asobj/Sound.h 2008-11-27 09:15:04 +0000
+++ b/libcore/asobj/Sound.h 2008-12-05 07:35:49 +0000
@@ -30,7 +30,6 @@
#include "smart_ptr.h" // GNASH_USE_GC
#include "impl.h"
#include "as_object.h" // for inheritance
-#include "NetConnection.h"
#include "MediaParser.h" // is this really needed for scoped_ptr ?
#include "AudioDecoder.h" // is this really needed for scoped_ptr ?
@@ -106,7 +105,6 @@
/// Mark all reachable resources of a Sound, for the GC
//
/// Reachable resources are:
- /// - associated NetConnection object (connection)
/// - attached character object (attachedCharacter)
///
void markReachableResources() const;
@@ -119,9 +117,7 @@
bool _onComplete;
bool _position;
- boost::intrusive_ptr<NetConnection> connection;
-
- boost::scoped_ptr<CharacterProxy> attachedCharacter;
+ boost::scoped_ptr<CharacterProxy> _attachedCharacter;
int soundId;
bool externalSound;
std::string externalURL;
@@ -145,9 +141,11 @@
boost::uint32_t _leftOverSize;
/// This is a sound_handler::aux_streamer_ptr type.
- static unsigned int getAudioWrapper(void *owner, boost::int16_t* samples,
unsigned int nSamples, bool& etEOF);
+ static unsigned int getAudioWrapper(void *owner, boost::int16_t* samples,
+ unsigned int nSamples, bool& etEOF);
- unsigned int getAudio(boost::int16_t* samples, unsigned int nSamples,
bool& atEOF);
+ unsigned int getAudio(boost::int16_t* samples, unsigned int nSamples,
+ bool& atEOF);
/// The aux streamer for sound handler
sound::InputStream* _inputStream;
@@ -195,6 +193,5 @@
} // end of gnash namespace
-// __SOUND_H__
#endif
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] /srv/bzr/gnash/trunk r10392: Renaming, cleanups.,
Benjamin Wolsey <=