20 #ifndef GNASH_NETSTREAM_H
21 #define GNASH_NETSTREAM_H
24 #ifndef __STDC_CONSTANT_MACROS
25 #define __STDC_CONSTANT_MACROS
28 #include <boost/intrusive_ptr.hpp>
30 #include <boost/ptr_container/ptr_deque.hpp>
31 #include <boost/scoped_ptr.hpp>
32 #include <boost/thread/mutex.hpp>
40 class InterruptableVirtualClock;
44 class NetConnection_as;
154 unsigned int fetch(boost::int16_t* samples,
unsigned int nSamples,
158 static unsigned int fetchWrapper(
void* owner, boost::int16_t* samples,
159 unsigned int nSamples,
bool& eof);
238 void seek(boost::uint32_t pos);
244 boost::int32_t
time();
304 std::auto_ptr<image::GnashImage>
get_video();
309 _invalidatedVideoCharacter = ch;
321 static unsigned int audio_streamer(
void *udata, boost::int16_t* samples,
322 unsigned int nSamples,
bool& eof);
364 typedef std::pair<std::string, std::string> NetStreamStatus;
371 void getStatusCodeInfo(StatusCode
code, NetStreamStatus& info);
374 as_object* getStatusObject(StatusCode
code);
380 void initVideoDecoder(
const media::VideoInfo& info);
386 void initAudioDecoder(
const media::AudioInfo& parser);
389 bool startPlayback();
398 void pausePlayback();
408 void unpausePlayback();
424 void refreshVideoFrame(
bool alsoIfPaused =
false);
428 void refreshAudioBuffer();
434 std::auto_ptr<image::GnashImage> decodeNextVideoFrame();
440 BufferedAudioStreamer::CursoredBuffer* decodeNextAudioFrame();
445 void pushDecodedAudioFrames(boost::uint32_t
ts);
457 std::auto_ptr<image::GnashImage> getDecodedVideoFrame(boost::uint32_t
ts);
459 DecodingState decodingStatus(DecodingState newstate = DEC_NONE);
464 void parseNextChunk();
484 void setStatus(StatusCode
code);
496 void processStatusNotifications();
499 void stopAdvanceTimer();
502 void startAdvanceTimer();
504 NetConnection_as* _netCon;
506 boost::scoped_ptr<CharacterProxy> _audioController;
509 boost::uint32_t _bufferTime;
512 boost::mutex image_mutex;
515 std::auto_ptr<image::GnashImage> _imageframe;
521 std::auto_ptr<media::MediaParser> _parser;
527 DisplayObject* _invalidatedVideoCharacter;
529 DecodingState _decoding_state;
533 boost::mutex _state_mutex;
536 std::auto_ptr<media::VideoDecoder> _videoDecoder;
539 bool _videoInfoKnown;
542 std::auto_ptr<media::AudioDecoder> _audioDecoder;
545 bool _audioInfoKnown;
548 boost::scoped_ptr<InterruptableVirtualClock> _playbackClock;
554 sound::sound_handler* _soundHandler;
557 media::MediaHandler* _mediaHandler;
564 std::auto_ptr<IOChannel> _inputStream;
567 BufferedAudioStreamer _audioStreamer;
570 StatusCode _statusCode;
573 boost::mutex _statusMutex;
void detachAuxStreamer()
Detach the aux streamer.
Definition: NetStream_as.cpp:1470
sound::sound_handler * _soundHandler
Definition: NetStream_as.h:123
boost::uint32_t ts
Definition: LocalConnection_as.cpp:152
int videoHeight() const
Get the real height of the video in pixels if the decoder exists.
Definition: NetStream_as.cpp:1190
AudioQueue _audioQueue
Definition: NetStream_as.h:127
~NetStream_as()
Definition: NetStream_as.cpp:305
PlaybackStatus getState() const
Get current playback state.
Definition: PlayHead.h:80
Definition: NetStream_as.h:187
void registerNetStreamNative(as_object &global)
Definition: NetStream_as.cpp:139
void update()
Definition: NetStream_as.cpp:1205
Definition: klash_part.cpp:329
NetStream_as ActionScript class.
Definition: NetStream_as.h:179
boost::uint32_t bufferTime()
Definition: NetStream_as.h:280
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:168
long bufferLength()
Definition: NetStream_as.cpp:196
void attachAuxStreamer()
Attach the aux streamer.
Definition: NetStream_as.cpp:1448
void close()
Definition: NetStream_as.cpp:337
static unsigned int audio_streamer(void *udata, boost::int16_t *samples, unsigned int nSamples, bool &eof)
Callback used by sound_handler to get audio data.
long bytesLoaded()
Returns the number of bytes of the media file that have been buffered.
Definition: NetStream_as.cpp:1412
Sound mixer.
Definition: sound_handler.h:87
~CursoredBuffer()
Definition: NetStream_as.h:100
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
boost::ptr_deque< CursoredBuffer > AudioQueue
Definition: NetStream_as.h:118
bool isConnected() const
Return true if the NetStream has an associated NetConnection.
Definition: NetStream_as.h:265
boost::uint8_t * m_ptr
Cursor into the data.
Definition: NetStream_as.h:115
virtual void markReachableResources() const
Mark any reachable resources other than the owner.
Definition: NetStream_as.cpp:286
The base class for all ActionScript objects.
Definition: as_object.h:161
NetConnection ActionScript class.
Definition: NetConnection_as.h:46
void setNetCon(NetConnection_as *nc)
Sets the NetConnection needed to access external files.
Definition: NetStream_as.h:260
BufferedAudioStreamer(sound::sound_handler *handler)
Definition: NetStream_as.cpp:1493
void cleanAudioQueue()
Definition: NetStream_as.cpp:1571
code
Definition: GnashKey.h:43
void setBufferTime(boost::uint32_t time)
Definition: NetStream_as.cpp:188
static unsigned int fetchWrapper(void *owner, boost::int16_t *samples, unsigned int nSamples, bool &eof)
Fetch samples from the audio queue.
Definition: NetStream_as.cpp:1484
void pause(PauseMode mode)
Pauses/starts the playback of the media played by the current instance.
Definition: NetStream_as.cpp:313
boost::uint8_t * m_data
Actual data.
Definition: NetStream_as.h:112
double getCurrentFPS()
Returns the current framerate in frames per second.
Definition: NetStream_as.h:253
long bytesTotal()
Returns the total number of bytes (size) of the media file.
Definition: NetStream_as.cpp:1423
boost::uint32_t m_size
Number of samples left in buffer starting from cursor.
Definition: NetStream_as.h:106
boost::int32_t time()
Tells where the playhead currently is.
Definition: NetStream_as.cpp:1376
CursoredBuffer()
Definition: NetStream_as.h:93
void setAudioController(DisplayObject *controller)
Make audio controlled by given DisplayObject.
Definition: NetStream_as.cpp:280
as_object & owner() const
Return the as_object that this Relay is attached to.
Definition: Relay.h:108
boost::mutex _audioQueueMutex
Definition: NetStream_as.h:134
void seek(boost::uint32_t pos)
Seek in the media played by the current instance.
Definition: NetStream_as.cpp:724
PauseMode
Definition: NetStream_as.h:184
Definition: NetStream_as.h:186
Buffered AudioStreamer.
Definition: NetStream_as.h:77
int videoWidth() const
Get the real width of the video in pixels if the decoder exists.
Definition: NetStream_as.cpp:1197
void play(const std::string &source)
Starts the playback of the media.
Definition: NetStream_as.cpp:361
PlaybackStatus
Flags for playback state.
Definition: PlayHead.h:39
A buffer with a cursor state.
Definition: NetStream_as.h:90
Definition: NetStream_as.h:185
std::auto_ptr< image::GnashImage > get_video()
Returns the video frame closest to current cursor. See time().
Definition: NetStream_as.cpp:205
void setInvalidatedVideo(DisplayObject *ch)
Register the DisplayObject to invalidate on video updates.
Definition: NetStream_as.h:307
size_t _audioQueueSize
Number of bytes in the audio queue, protected by _audioQueueMutex.
Definition: NetStream_as.h:130
sound::InputStream * _auxStreamer
Definition: NetStream_as.h:137
NetStream_as(as_object *owner)
Contruct a NetStream object.
Definition: NetStream_as.cpp:100
A native type that requires periodic updates from the core (movie_root).
Definition: Relay.h:79
void push(CursoredBuffer *audio)
Push a buffer to the audio queue.
Definition: NetStream_as.cpp:1553
PlayHead::PlaybackStatus playbackState() const
Definition: NetStream_as.h:194
void netstream_class_init(as_object &where, const ObjectURI &uri)
Definition: NetStream_as.cpp:130
unsigned int fetch(boost::int16_t *samples, unsigned int nSamples, bool &eof)
Fetch samples from the audio queue.
Definition: NetStream_as.cpp:1503