[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash ChangeLog server/video_stream_instance.cp...
From: |
Sandro Santilli |
Subject: |
[Gnash-commit] gnash ChangeLog server/video_stream_instance.cp... |
Date: |
Tue, 30 Jan 2007 12:49:04 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Sandro Santilli <strk> 07/01/30 12:49:03
Modified files:
. : ChangeLog
server : video_stream_instance.cpp
video_stream_instance.h
server/asobj : NetConnection.cpp NetConnection.h NetStream.cpp
NetStream.h NetStreamFfmpeg.cpp
NetStreamFfmpeg.h NetStreamGst.cpp
NetStreamGst.h
Log message:
* server/: video_stream_instance.{h,cpp},
server/asobj/: NetConnection.cpp, NetConnection.h,
NetStream.cpp,
NetStream.h, NetStreamFfmpeg.cpp, NetStreamFfmpeg.h,
NetStreamGst.cpp,
NetStreamGst.h:
Refactored NetStream inheritance model, got rid of
netstream_as_object and netconnection_as_object wrappers.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2196&r2=1.2197
http://cvs.savannah.gnu.org/viewcvs/gnash/server/video_stream_instance.cpp?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/server/video_stream_instance.h?cvsroot=gnash&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetConnection.cpp?cvsroot=gnash&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetConnection.h?cvsroot=gnash&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStream.cpp?cvsroot=gnash&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStream.h?cvsroot=gnash&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamFfmpeg.cpp?cvsroot=gnash&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamFfmpeg.h?cvsroot=gnash&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamGst.cpp?cvsroot=gnash&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/NetStreamGst.h?cvsroot=gnash&r1=1.5&r2=1.6
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2196
retrieving revision 1.2197
diff -u -b -r1.2196 -r1.2197
--- ChangeLog 30 Jan 2007 11:05:13 -0000 1.2196
+++ ChangeLog 30 Jan 2007 12:49:03 -0000 1.2197
@@ -1,5 +1,14 @@
2007-01-30 Sandro Santilli <address@hidden>
+ * server/: video_stream_instance.{h,cpp},
+ server/asobj/: NetConnection.cpp, NetConnection.h, NetStream.cpp,
+ NetStream.h, NetStreamFfmpeg.cpp, NetStreamFfmpeg.h, NetStreamGst.cpp,
+ NetStreamGst.h:
+ Refactored NetStream inheritance model, got rid of
+ netstream_as_object and netconnection_as_object wrappers.
+
+2007-01-30 Sandro Santilli <address@hidden>
+
* server/parser/movie_def_impl.cpp (incrementLoadedFrames):
handle malformed SWF containing more SHOWFRAME then expected;
(readHeader): allocate more slots for actions to make malformed
Index: server/video_stream_instance.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/video_stream_instance.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- server/video_stream_instance.cpp 18 Jan 2007 22:53:21 -0000 1.6
+++ server/video_stream_instance.cpp 30 Jan 2007 12:49:03 -0000 1.7
@@ -16,14 +16,16 @@
if (fn.nargs != 1)
{
- log_error("attachVideo needs 1 arg\n");
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("attachVideo needs 1 arg");
+ );
return;
}
-// if (dynamic_cast<netstream_as_object*>(fn.arg(0).to_object()))
- if (video)
+ NetStream* ns = dynamic_cast<NetStream*>(fn.arg(0).to_object());
+ if (ns)
{
- video->m_ns =
static_cast<netstream_as_object*>(fn.arg(0).to_object());
+ video->setStream(ns);
}
}
@@ -33,7 +35,7 @@
character(parent, id),
m_def(def),
m_video_source(NULL),
- m_ns(NULL)
+ _ns(NULL)
// m_source(NULL)
{
assert(m_def);
@@ -48,16 +50,16 @@
void
video_stream_instance::display()
{
- if (m_ns)
+ if (_ns)
{
matrix m = get_world_matrix();
rect bounds(0.0f, 0.0f, PIXELS_TO_TWIPS(m_def->m_width),
PIXELS_TO_TWIPS(m_def->m_height));
- netstream_as_object* nso =
static_cast<netstream_as_object*>(m_ns);
+ NetStream* nso = _ns;
- if (nso->obj.playing())
+ if (nso->playing())
{
- image::image_base* i = nso->obj.get_video();
+ image::image_base* i = nso->get_video();
if (i)
{
gnash::render::drawVideoFrame(i, &m, &bounds);
Index: server/video_stream_instance.h
===================================================================
RCS file: /sources/gnash/gnash/server/video_stream_instance.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- server/video_stream_instance.h 18 Jan 2007 22:53:21 -0000 1.5
+++ server/video_stream_instance.h 30 Jan 2007 12:49:03 -0000 1.6
@@ -4,6 +4,11 @@
#include "character.h" // for inheritance
#include "video_stream_def.h"
+// Forward declarations
+namespace gnash {
+ class NetStream;
+}
+
namespace gnash {
class video_stream_instance : public character
@@ -11,11 +16,11 @@
public:
-// const as_object* m_source;
video_stream_definition* m_def;
// m_video_source - A Camera object that is capturing video data or a
NetStream object.
// To drop the connection to the Video object, pass null for source.
+ // FIXME: don't use as_object, but a more meaningful type
as_object* m_video_source;
video_stream_instance(video_stream_definition* def,
@@ -28,16 +33,16 @@
void get_invalidated_bounds(rect* bounds, bool force);
-// void set_source(const as_object* source)
-// {
-// m_source = source;
-// }
-
- //
- // ActionScript overrides
- //
+ /// Set the input stream for this video
+ void setStream(NetStream* ns)
+ {
+ _ns = ns;
+ }
+
+private:
- as_object* m_ns;
+ // Who owns this ? Should it be an intrusive ptr ?
+ NetStream* _ns;
};
Index: server/asobj/NetConnection.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetConnection.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- server/asobj/NetConnection.cpp 30 Jan 2007 10:52:15 -0000 1.19
+++ server/asobj/NetConnection.cpp 30 Jan 2007 12:49:03 -0000 1.20
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: NetConnection.cpp,v 1.19 2007/01/30 10:52:15 strk Exp $ */
+/* $Id: NetConnection.cpp,v 1.20 2007/01/30 12:49:03 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -159,6 +159,7 @@
}
NetConnection::NetConnection()
:
+ as_object(getNetConnectionInterface()),
_cache(NULL),
_cachefd(0),
_url(),
@@ -187,7 +188,7 @@
/// RTMP. Newer Flash movies have a parameter to connect which is a
/// URL string like rtmp://foobar.com/videos/bar.flv
/*public*/
-bool NetConnection::openConnection(const char* char_url, as_object* ns)
+bool NetConnection::openConnection(const char* char_url, NetStream* ns)
{
netStreamObj = ns;
if (_url.size() > 0) {
@@ -354,22 +355,12 @@
-netconnection_as_object::netconnection_as_object()
- :
- as_object(getNetConnectionInterface())
-{
-}
-
-netconnection_as_object::~netconnection_as_object()
-{
-}
-
// Wrapper around dynamic_cast to implement user warning.
// To be used by builtin properties and methods.
-static netconnection_as_object*
+static NetConnection*
ensure_netconnection(as_object* obj)
{
- netconnection_as_object* ret =
dynamic_cast<netconnection_as_object*>(obj);
+ NetConnection* ret = dynamic_cast<NetConnection*>(obj);
if ( ! ret )
{
throw ActionException("builtin method or gettersetter for
NetConnection objects called against non-NetConnection instance");
@@ -387,7 +378,7 @@
{
GNASH_REPORT_FUNCTION;
- netconnection_as_object *netconnection_obj = new
netconnection_as_object;
+ NetConnection *netconnection_obj = new NetConnection;
fn.result->set_as_object(netconnection_obj);
}
@@ -397,11 +388,10 @@
{
GNASH_REPORT_FUNCTION;
- string filespec;
- netconnection_as_object *ptr = ensure_netconnection(fn.this_ptr);
+ NetConnection *ptr = ensure_netconnection(fn.this_ptr);
if (fn.nargs > 0) {
- ptr->obj.addToURL(fn.arg(0).to_string());
+ ptr->addToURL(fn.arg(0).to_string());
}
}
Index: server/asobj/NetConnection.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetConnection.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- server/asobj/NetConnection.h 27 Jan 2007 16:55:05 -0000 1.14
+++ server/asobj/NetConnection.h 30 Jan 2007 12:49:03 -0000 1.15
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: NetConnection.h,v 1.14 2007/01/27 16:55:05 tgc Exp $ */
+/* $Id: NetConnection.h,v 1.15 2007/01/30 12:49:03 strk Exp $ */
#ifndef __NETCONNECTION_H__
#define __NETCONNECTION_H__
@@ -39,16 +39,21 @@
#include "as_object.h" // for inheritance
#include "fn_call.h"
+// Forward declarations
namespace gnash {
-#ifdef HAVE_CURL_CURL_H
-class NetConnection {
+ class NetStream;
+}
+
+namespace gnash {
+
+class NetConnection: public as_object {
public:
NetConnection();
~NetConnection();
/// Opens the connection to char_url
- bool openConnection(const char* char_url, as_object* ns);
+ bool openConnection(const char* char_url, NetStream* ns);
/// Put read pointer at given position
bool seek(size_t pos);
@@ -107,7 +112,8 @@
bool localFile;
// The NetStream object which handles the video playback
- as_object* netStreamObj;
+ // Watch out for circular dependencies, see NetStream.h
+ NetStream* netStreamObj;
// Total filesize
double totalSize;
@@ -119,27 +125,6 @@
};
-#else
-class NetConnection {
-public:
- NetConnection() {}
- ~NetConnection() {}
- bool openConnection(const char* /*char_url*/, as_object* /*ns*/) {
return false; }
- bool seek(size_t /*pos*/) { return 0; }
- size_t read(void* /*dst*/, size_t /*bytes*/) { return false; }
- void addToURL(const char* /*url*/) {}
-};
-
-#endif // HAVE_CURL_CURL_H
-
-class netconnection_as_object : public as_object
-{
-public:
- netconnection_as_object();
- ~netconnection_as_object();
- NetConnection obj;
-};
-
void netconnection_class_init(as_object& global);
} // end of gnash namespace
Index: server/asobj/NetStream.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStream.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- server/asobj/NetStream.cpp 30 Jan 2007 10:52:15 -0000 1.24
+++ server/asobj/NetStream.cpp 30 Jan 2007 12:49:03 -0000 1.25
@@ -18,17 +18,23 @@
//
//
-/* $Id: NetStream.cpp,v 1.24 2007/01/30 10:52:15 strk Exp $ */
+/* $Id: NetStream.cpp,v 1.25 2007/01/30 12:49:03 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "log.h"
+#ifdef SOUND_GST
+# include "NetStreamGst.h"
+#elif defined(USE_FFMPEG)
+# include "NetStreamFfmpeg.h"
+#endif
#include "NetStream.h"
#include "fn_call.h"
#include "builtin_function.h"
#include "GnashException.h"
+#include "NetConnection.h"
#include "movie_root.h"
@@ -43,14 +49,11 @@
static void netstream_time(const fn_call& fn);
static as_object* getNetStreamInterface();
-netstream_as_object::netstream_as_object()
+NetStream::NetStream()
:
- as_object(getNetStreamInterface())
-{
- obj.set_parent(this);
-}
-
-netstream_as_object::~netstream_as_object()
+ as_object(getNetStreamInterface()),
+ _parent(NULL),
+ _netCon(NULL)
{
}
@@ -58,18 +61,30 @@
netstream_new(const fn_call& fn)
{
- netstream_as_object *netstream_obj = new netstream_as_object;
+ NetStream *netstream_obj;
+
+#ifdef SOUND_GST
+ netstream_obj = new NetStreamGst();
+#elif defined(USE_FFMPEG)
+ netstream_obj = new NetStreamFfmpeg();
+#else
+ netstream_obj = new NetStream();
+#endif
+
if (fn.nargs > 0)
{
- as_object* nc = fn.arg(0).to_object();
- if ( nc ) netstream_obj->obj.setNetCon(nc);
+ NetConnection* ns =
dynamic_cast<NetConnection*>(fn.arg(0).to_object());
+ if ( ns )
+ {
+ netstream_obj->setNetCon(ns);
+ }
else
{
IF_VERBOSE_ASCODING_ERRORS(
log_aserror("First argument "
- "to NetConnection constructor "
- "doesn't cast to an Object (%s)",
+ "to NetStream constructor "
+ "doesn't cast to a NetConnection (%s)",
fn.arg(0).to_string());
);
}
@@ -80,10 +95,10 @@
// Wrapper around dynamic_cast to implement user warning.
// To be used by builtin properties and methods.
-static netstream_as_object*
+static NetStream*
ensure_netstream(as_object* obj)
{
- netstream_as_object* ret = dynamic_cast<netstream_as_object*>(obj);
+ NetStream* ret = dynamic_cast<NetStream*>(obj);
if ( ! ret )
{
throw ActionException("builtin method or gettersetter for
NetStream objects called against non-NetStream instance");
@@ -94,13 +109,13 @@
static void netstream_close(const fn_call& fn)
{
- netstream_as_object* ns = ensure_netstream(fn.this_ptr);
- ns->obj.close();
+ NetStream* ns = ensure_netstream(fn.this_ptr);
+ ns->close();
}
static void netstream_pause(const fn_call& fn)
{
- netstream_as_object* ns = ensure_netstream(fn.this_ptr);
+ NetStream* ns = ensure_netstream(fn.this_ptr);
// mode: -1 ==> toogle, 0==> pause, 1==> play
int mode = -1;
@@ -108,12 +123,12 @@
{
mode = fn.arg(0).to_bool() ? 0 : 1;
}
- ns->obj.pause(mode); // toggle mode
+ ns->pause(mode); // toggle mode
}
static void netstream_play(const fn_call& fn)
{
- netstream_as_object* ns = ensure_netstream(fn.this_ptr);
+ NetStream* ns = ensure_netstream(fn.this_ptr);
if (fn.nargs < 1)
{
@@ -123,25 +138,25 @@
return;
}
- if (ns->obj.play(fn.arg(0).to_string()) != 0)
+ if (ns->play(fn.arg(0).to_string()) != 0)
{
- ns->obj.close();
+ ns->close();
};
}
static void netstream_seek(const fn_call& fn) {
- netstream_as_object* ns = ensure_netstream(fn.this_ptr);
+ NetStream* ns = ensure_netstream(fn.this_ptr);
double time = 0;
if (fn.nargs > 0)
{
time = fn.arg(0).to_number();
}
- ns->obj.seek(time);
+ ns->seek(time);
}
static void netstream_setbuffertime(const fn_call& fn) {
- netstream_as_object* ns = ensure_netstream(fn.this_ptr);
+ NetStream* ns = ensure_netstream(fn.this_ptr);
UNUSED(ns);
log_msg("%s:unimplemented \n", __FUNCTION__);
}
@@ -151,11 +166,11 @@
netstream_time(const fn_call& fn)
{
- netstream_as_object* ns = ensure_netstream(fn.this_ptr);
+ NetStream* ns = ensure_netstream(fn.this_ptr);
if ( fn.nargs == 0 )
{
- fn.result->set_double(ns->obj.time());
+ fn.result->set_double(ns->time());
}
else
{
@@ -219,5 +234,6 @@
global.init_member("NetStream", cl.get());
}
+
} // end of gnash namespace
Index: server/asobj/NetStream.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStream.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- server/asobj/NetStream.h 23 Jan 2007 21:37:16 -0000 1.19
+++ server/asobj/NetStream.h 30 Jan 2007 12:49:03 -0000 1.20
@@ -18,7 +18,7 @@
//
//
-/* $Id: NetStream.h,v 1.19 2007/01/23 21:37:16 tgc Exp $ */
+/* $Id: NetStream.h,v 1.20 2007/01/30 12:49:03 strk Exp $ */
#ifndef __NETSTREAM_H__
#define __NETSTREAM_H__
@@ -31,61 +31,65 @@
#include <pthread.h>
#include "impl.h"
#include "video_stream_instance.h"
-#include "NetStreamFfmpeg.h"
-#include "NetStreamGst.h"
+// Forward declarations
namespace gnash {
+ class NetConnection;
+}
-class netstream_as_object;
+namespace gnash {
-class NetStreamBase {
-public:
- NetStreamBase(){}
- ~NetStreamBase(){}
- void close(){}
- void pause(int /*mode*/){}
- int play(const char* /*source*/){ log_error("FFMPEG or Gstreamer is
needed to play video"); return 0; }
- void seek(double /*pos*/){}
- void setBufferTime(unsigned int /*pos*/){}
- void set_status(const char* /*code*/){}
- void setNetCon(as_object* /*nc*/) {}
- image::image_base* get_video(){ return NULL; }
- int64_t time() { return 0; }
- inline void set_parent(netstream_as_object* /*ns*/)
- {
- }
+class NetStream : public as_object {
- inline bool playing()
- {
- return false;
- }
+protected:
-};
+ // Watch out for circular dependencies, see NetStream.h
+ NetStream* _parent;
+
+ NetConnection* _netCon;
-#ifdef SOUND_GST
-class NetStream : public NetStreamGst {
-#elif defined(USE_FFMPEG)
-class NetStream : public NetStreamFfmpeg {
-#else
-class NetStream : public NetStreamBase {
-#endif
public:
-};
+ NetStream();
+
+ virtual ~NetStream(){}
+
+ virtual void close(){}
+
+ virtual void pause(int /*mode*/){}
-class netstream_as_object : public as_object
-{
- public:
+ virtual int play(const char* /*source*/){ log_error("FFMPEG or
Gstreamer is needed to play video"); return 0; }
- netstream_as_object();
+ virtual void seek(double /*pos*/){}
- ~netstream_as_object();
+ virtual void setBufferTime(unsigned int /*pos*/){}
- NetStream obj;
+ virtual void set_status(const char* /*code*/){}
+
+ virtual void setNetCon(NetConnection* nc)
+ {
+ _netCon = nc;
+ }
+
+ virtual image::image_base* get_video(){ return NULL; }
+
+ virtual int64_t time() { return 0; }
+
+ /// What is supposed to happens if ns is NULL ?
+ void set_parent(NetStream* ns)
+ {
+ _parent = ns;
+ }
+
+ virtual bool playing()
+ {
+ return false;
+ }
};
+
// Initialize the global NetStream class
void netstream_class_init(as_object& global);
Index: server/asobj/NetStreamFfmpeg.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamFfmpeg.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- server/asobj/NetStreamFfmpeg.cpp 27 Jan 2007 16:55:05 -0000 1.10
+++ server/asobj/NetStreamFfmpeg.cpp 30 Jan 2007 12:49:03 -0000 1.11
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: NetStreamFfmpeg.cpp,v 1.10 2007/01/27 16:55:05 tgc Exp $ */
+/* $Id: NetStreamFfmpeg.cpp,v 1.11 2007/01/30 12:49:03 strk Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -71,7 +71,7 @@
// called from avstreamer thread
void NetStreamFfmpeg::set_status(const char* /*code*/)
{
- if (m_netstream_object)
+ if (_parent)
{
//m_netstream_object->init_member("onStatus_Code", code);
//push_video_event(m_netstream_object);
@@ -150,12 +150,13 @@
// ffmpeg callback function
int
-NetStreamFfmpeg::readPacket(void* opaque, uint8_t* buf, int buf_size){
+NetStreamFfmpeg::readPacket(void* opaque, uint8_t* buf, int buf_size)
+{
NetStreamFfmpeg* ns = static_cast<NetStreamFfmpeg*>(opaque);
+ NetConnection* nc = ns->_netCon;
- netconnection_as_object* nc =
static_cast<netconnection_as_object*>(ns->netCon);
- size_t ret = nc->obj.read(static_cast<void*>(buf), buf_size);
+ size_t ret = nc->read(static_cast<void*>(buf), buf_size);
ns->inputPos += ret;
return ret;
@@ -166,24 +167,24 @@
NetStreamFfmpeg::seekMedia(void *opaque, offset_t offset, int whence){
NetStreamFfmpeg* ns = static_cast<NetStreamFfmpeg*>(opaque);
- netconnection_as_object* nc =
static_cast<netconnection_as_object*>(ns->netCon);
+ NetConnection* nc = ns->_netCon;
// Offset is absolute new position in the file
if (whence == SEEK_SET) {
- nc->obj.seek(offset);
+ nc->seek(offset);
ns->inputPos = offset;
// New position is offset + old position
} else if (whence == SEEK_CUR) {
- nc->obj.seek(ns->inputPos + offset);
+ nc->seek(ns->inputPos + offset);
ns->inputPos = ns->inputPos + offset;
// // New position is offset + end of file
} else if (whence == SEEK_END) {
// This is (most likely) a streamed file, so we can't seek to
the end!
// Instead we seek to 50.000 bytes... seems to work fine...
- nc->obj.seek(50000);
+ nc->seek(50000);
ns->inputPos = 50000;
}
@@ -202,6 +203,15 @@
return 0;
}
+ // Does it have an associated NetConnectoin ?
+ if ( ! _netCon )
+ {
+ IF_VERBOSE_ASCODING_ERRORS(
+ log_aserror("No NetConnection associated with this NetStream,
won't play");
+ );
+ return 0;
+ }
+
url += c_url;
// Remove any "mp3:" prefix. Maybe should use this to mark as audio-only
if (url.compare(0, 4, std::string("mp3:")) == 0) {
@@ -224,10 +234,12 @@
NetStreamFfmpeg::startPlayback(NetStreamFfmpeg* ns)
{
- netconnection_as_object* nc =
static_cast<netconnection_as_object*>(ns->netCon);
+ NetConnection* nc = ns->_netCon;
+ assert(nc);
// Pass stuff from/to the NetConnection object.
- if (!nc->obj.openConnection(ns->url.c_str(), ns->m_netstream_object)) {
+ assert(ns); // ns->_parent is ok being NULL
+ if ( !nc->openConnection(ns->url.c_str(), ns->_parent) ) {
log_warning("Gnash could not open movie url: %s",
ns->url.c_str());
return;
}
@@ -252,7 +264,7 @@
AVInputFormat* inputFmt = av_probe_input_format(pd, 1);
// After the format probe, reset to the beginning of the file.
- nc->obj.seek(0);
+ nc->seek(0);
// Setup the filereader/seeker mechanism. 7th argument (NULL) is the
writer function,
// which isn't needed.
@@ -283,7 +295,8 @@
// Find the first video & audio stream
ns->m_video_index = -1;
ns->m_audio_index = -1;
- for (unsigned int i = 0; i < ns->m_FormatCtx->nb_streams; i++)
+ assert(ns->m_FormatCtx->nb_streams >= 0);
+ for (int i = 0; i < ns->m_FormatCtx->nb_streams; i++)
{
AVCodecContext* enc = ns->m_FormatCtx->streams[i]->codec;
@@ -379,11 +392,6 @@
return;
}
-void
-NetStreamFfmpeg::setNetCon(as_object* nc){
- netCon = nc;
-}
-
// decoder thread
void NetStreamFfmpeg::av_streamer(NetStreamFfmpeg* ns)
{
Index: server/asobj/NetStreamFfmpeg.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamFfmpeg.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- server/asobj/NetStreamFfmpeg.h 27 Jan 2007 16:55:05 -0000 1.6
+++ server/asobj/NetStreamFfmpeg.h 30 Jan 2007 12:49:03 -0000 1.7
@@ -14,7 +14,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-/* $Id: NetStreamFfmpeg.h,v 1.6 2007/01/27 16:55:05 tgc Exp $ */
+/* $Id: NetStreamFfmpeg.h,v 1.7 2007/01/30 12:49:03 strk Exp $ */
#ifndef __NETSTREAMFFMPEG_H__
#define __NETSTREAMFFMPEG_H__
@@ -36,6 +36,7 @@
#include <ffmpeg/avformat.h>
#include "image.h"
#include "StreamProvider.h"
+#include "NetStream.h" // for inheritance
namespace gnash {
@@ -148,9 +149,7 @@
std::queue < T > m_queue;
};
-class netstream_as_object;
-
-class NetStreamFfmpeg {
+class NetStreamFfmpeg: public NetStream {
public:
NetStreamFfmpeg();
~NetStreamFfmpeg();
@@ -171,16 +170,11 @@
image::image_base* get_video();
- inline bool playing()
+ bool playing()
{
return m_go;
}
- inline void set_parent(netstream_as_object* ns)
- {
- m_netstream_object = ns;
- }
-
inline double as_double(AVRational time)
{
return time.num / (double) time.den;
@@ -234,10 +228,8 @@
multithread_queue <raw_videodata_t*> m_qvideo;
bool m_pause;
double m_start_clock;
- netstream_as_object* m_netstream_object;
raw_videodata_t* m_unqueued_data;
- as_object* netCon;
ByteIOContext ByteIOCxt;
tu_file* input;
long inputPos;
Index: server/asobj/NetStreamGst.cpp
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamGst.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- server/asobj/NetStreamGst.cpp 30 Jan 2007 09:58:05 -0000 1.8
+++ server/asobj/NetStreamGst.cpp 30 Jan 2007 12:49:03 -0000 1.9
@@ -69,7 +69,7 @@
// called from avstreamer thread
void NetStreamGst::set_status(const char* /*code*/)
{
- if (m_netstream_object)
+ if (_parent)
{
//m_netstream_object->init_member("onStatus_Code", code);
//push_video_event(m_netstream_object);
@@ -240,10 +240,11 @@
NetStreamGst::startPlayback(void* arg)
{
NetStreamGst* ns = static_cast<NetStreamGst*>(arg);
- netconnection_as_object* nc =
static_cast<netconnection_as_object*>(ns->netCon);
+ NetConnection* nc = ns->_netCon;
// Pass stuff from/to the NetConnection object.
- if (!nc->obj.openConnection(ns->url.c_str(), ns->m_netstream_object)) {
+ assert(ns); // ns->_parent being null seems ok
+ if ( !nc->openConnection(ns->url.c_str(), ns->_parent) ) {
log_warning("Gnash could not open movie url: %s",
ns->url.c_str());
return 0;
}
@@ -337,11 +338,6 @@
return 0;
}
-void
-NetStreamGst::setNetCon(as_object* nc){
- netCon = nc;
-}
-
image::image_base* NetStreamGst::get_video()
{
return m_imageframe;
@@ -390,8 +386,8 @@
NetStreamGst* ns = static_cast<NetStreamGst*>(opaque);
- netconnection_as_object* nc =
static_cast<netconnection_as_object*>(ns->netCon);
- size_t ret = nc->obj.read(static_cast<void*>(buf), buf_size);
+ NetConnection* nc = ns->_netCon;
+ size_t ret = nc->read(static_cast<void*>(buf), buf_size);
ns->inputPos += ret;
return ret;
@@ -403,19 +399,19 @@
NetStreamGst::seekMedia(void *opaque, int offset, int whence){
NetStreamGst* ns = static_cast<NetStreamGst*>(opaque);
- netconnection_as_object* nc =
static_cast<netconnection_as_object*>(ns->netCon);
+ NetConnection* nc = ns->_netCon;
bool ret;
// Offset is absolute new position in the file
if (whence == SEEK_SET) {
- ret = nc->obj.seek(offset);
+ ret = nc->seek(offset);
if (!ret) return -1;
ns->inputPos = offset;
// New position is offset + old position
} else if (whence == SEEK_CUR) {
- ret = nc->obj.seek(ns->inputPos + offset);
+ ret = nc->seek(ns->inputPos + offset);
if (!ret) return -1;
ns->inputPos = ns->inputPos + offset;
@@ -423,7 +419,7 @@
} else if (whence == SEEK_END) {
// This is (most likely) a streamed file, so we can't seek to
the end!
// Instead we seek to 50.000 bytes... seems to work fine...
- ret = nc->obj.seek(50000);
+ ret = nc->seek(50000);
ns->inputPos = 50000;
}
return ns->inputPos;
Index: server/asobj/NetStreamGst.h
===================================================================
RCS file: /sources/gnash/gnash/server/asobj/NetStreamGst.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- server/asobj/NetStreamGst.h 23 Jan 2007 21:37:16 -0000 1.5
+++ server/asobj/NetStreamGst.h 30 Jan 2007 12:49:03 -0000 1.6
@@ -30,12 +30,11 @@
#include "video_stream_instance.h"
#include <gst/gst.h>
#include "image.h"
+#include "NetStream.h" // for inheritance
namespace gnash {
-class netstream_as_object;
-
-class NetStreamGst {
+class NetStreamGst: public NetStream {
public:
NetStreamGst();
~NetStreamGst();
@@ -59,11 +58,6 @@
return m_go;
}
- inline void set_parent(netstream_as_object* ns)
- {
- m_netstream_object = ns;
- }
-
static void* startPlayback(void* arg);
static void callback_output (GstElement* /*c*/, GstBuffer *buffer,
GstPad* /*pad*/, gpointer user_data);
static void callback_newpad (GstElement *decodebin, GstPad *pad,
gboolean last, gpointer data);
@@ -96,9 +90,7 @@
pthread_t startThread;
bool m_pause;
- netstream_as_object* m_netstream_object;
- as_object* netCon;
long inputPos;
std::string url;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Gnash-commit] gnash ChangeLog server/video_stream_instance.cp...,
Sandro Santilli <=