20 #ifndef GNASH_NETSTREAM_H
21 #define GNASH_NETSTREAM_H
24 #ifndef __STDC_CONSTANT_MACROS
25 #define __STDC_CONSTANT_MACROS
33 #include <boost/intrusive_ptr.hpp>
34 #include <boost/ptr_container/ptr_deque.hpp>
42 class InterruptableVirtualClock;
46 class NetConnection_as;
156 unsigned int fetch(std::int16_t* samples,
unsigned int nSamples,
160 static unsigned int fetchWrapper(
void* owner, std::int16_t* samples,
161 unsigned int nSamples,
bool& eof);
240 void seek(std::uint32_t pos);
306 std::unique_ptr<image::GnashImage>
get_video();
311 _invalidatedVideoCharacter = ch;
323 static unsigned int audio_streamer(
void *udata, std::int16_t* samples,
324 unsigned int nSamples,
bool& eof);
366 typedef std::pair<std::string, std::string> NetStreamStatus;
373 void getStatusCodeInfo(StatusCode
code, NetStreamStatus& info);
376 as_object* getStatusObject(StatusCode
code);
382 void initVideoDecoder(
const media::VideoInfo& info);
388 void initAudioDecoder(
const media::AudioInfo& parser);
391 bool startPlayback();
400 void pausePlayback();
410 void unpausePlayback();
426 void refreshVideoFrame(
bool alsoIfPaused =
false);
430 void refreshAudioBuffer();
436 std::unique_ptr<image::GnashImage> decodeNextVideoFrame();
442 BufferedAudioStreamer::CursoredBuffer* decodeNextAudioFrame();
447 void pushDecodedAudioFrames(std::uint32_t
ts);
459 std::unique_ptr<image::GnashImage> getDecodedVideoFrame(std::uint32_t
ts);
461 DecodingState decodingStatus(DecodingState newstate = DEC_NONE);
466 void parseNextChunk();
486 void setStatus(StatusCode
code);
498 void processStatusNotifications();
501 void stopAdvanceTimer();
504 void startAdvanceTimer();
506 NetConnection_as* _netCon;
508 std::unique_ptr<CharacterProxy> _audioController;
511 std::uint32_t _bufferTime;
514 std::mutex image_mutex;
517 std::unique_ptr<image::GnashImage> _imageframe;
523 std::unique_ptr<media::MediaParser> _parser;
529 DisplayObject* _invalidatedVideoCharacter;
532 std::atomic<int> _decoding_state;
535 std::unique_ptr<media::VideoDecoder> _videoDecoder;
538 bool _videoInfoKnown;
541 std::unique_ptr<media::AudioDecoder> _audioDecoder;
544 bool _audioInfoKnown;
547 std::unique_ptr<InterruptableVirtualClock> _playbackClock;
553 sound::sound_handler* _soundHandler;
556 media::MediaHandler* _mediaHandler;
563 std::unique_ptr<IOChannel> _inputStream;
566 BufferedAudioStreamer _audioStreamer;
571 std::atomic<int> _statusCode;
void detachAuxStreamer()
Detach the aux streamer.
Definition: NetStream_as.cpp:1465
sound::sound_handler * _soundHandler
Definition: NetStream_as.h:125
int videoHeight() const
Get the real height of the video in pixels if the decoder exists.
Definition: NetStream_as.cpp:1186
AudioQueue _audioQueue
Definition: NetStream_as.h:129
~NetStream_as()
Definition: NetStream_as.cpp:301
PlaybackStatus getState() const
Get current playback state.
Definition: PlayHead.h:80
Definition: NetStream_as.h:189
void registerNetStreamNative(as_object &global)
Definition: NetStream_as.cpp:139
void update()
Definition: NetStream_as.cpp:1201
Definition: klash_part.cpp:329
NetStream_as ActionScript class.
Definition: NetStream_as.h:181
DisplayObject is the base class for all DisplayList objects.
Definition: DisplayObject.h:168
std::mutex _audioQueueMutex
Definition: NetStream_as.h:136
std::uint32_t bufferTime()
Definition: NetStream_as.h:282
long bufferLength()
Definition: NetStream_as.cpp:192
void attachAuxStreamer()
Attach the aux streamer.
Definition: NetStream_as.cpp:1443
std::unique_ptr< image::GnashImage > get_video()
Returns the video frame closest to current cursor. See time().
Definition: NetStream_as.cpp:201
void close()
Definition: NetStream_as.cpp:333
std::uint32_t ts
Definition: LocalConnection_as.cpp:150
long bytesLoaded()
Returns the number of bytes of the media file that have been buffered.
Definition: NetStream_as.cpp:1409
Sound mixer.
Definition: sound_handler.h:87
~CursoredBuffer()
Definition: NetStream_as.h:102
Anonymous namespace for callbacks, local functions, event handlers etc.
Definition: dbus_ext.cpp:40
boost::ptr_deque< CursoredBuffer > AudioQueue
Definition: NetStream_as.h:120
bool isConnected() const
Return true if the NetStream has an associated NetConnection.
Definition: NetStream_as.h:267
virtual void markReachableResources() const
Mark any reachable resources other than the owner.
Definition: NetStream_as.cpp:282
unsigned int fetch(std::int16_t *samples, unsigned int nSamples, bool &eof)
Fetch samples from the audio queue.
Definition: NetStream_as.cpp:1498
void setBufferTime(std::uint32_t time)
Definition: NetStream_as.cpp:184
The base class for all ActionScript objects.
Definition: as_object.h:161
NetConnection ActionScript class.
Definition: NetConnection_as.h:45
void setNetCon(NetConnection_as *nc)
Sets the NetConnection needed to access external files.
Definition: NetStream_as.h:262
BufferedAudioStreamer(sound::sound_handler *handler)
Definition: NetStream_as.cpp:1488
void cleanAudioQueue()
Definition: NetStream_as.cpp:1566
code
Definition: GnashKey.h:43
void pause(PauseMode mode)
Pauses/starts the playback of the media played by the current instance.
Definition: NetStream_as.cpp:309
double getCurrentFPS()
Returns the current framerate in frames per second.
Definition: NetStream_as.h:255
static unsigned int audio_streamer(void *udata, std::int16_t *samples, unsigned int nSamples, bool &eof)
Callback used by sound_handler to get audio data.
long bytesTotal()
Returns the total number of bytes (size) of the media file.
Definition: NetStream_as.cpp:1420
std::uint8_t * m_data
Actual data.
Definition: NetStream_as.h:114
CursoredBuffer()
Definition: NetStream_as.h:95
std::uint32_t m_size
Number of samples left in buffer starting from cursor.
Definition: NetStream_as.h:108
void seek(std::uint32_t pos)
Seek in the media played by the current instance.
Definition: NetStream_as.cpp:720
void setAudioController(DisplayObject *controller)
Make audio controlled by given DisplayObject.
Definition: NetStream_as.cpp:276
as_object & owner() const
Return the as_object that this Relay is attached to.
Definition: Relay.h:108
std::uint8_t * m_ptr
Cursor into the data.
Definition: NetStream_as.h:117
PauseMode
Definition: NetStream_as.h:186
Definition: NetStream_as.h:188
Buffered AudioStreamer.
Definition: NetStream_as.h:79
int videoWidth() const
Get the real width of the video in pixels if the decoder exists.
Definition: NetStream_as.cpp:1193
void play(const std::string &source)
Starts the playback of the media.
Definition: NetStream_as.cpp:357
PlaybackStatus
Flags for playback state.
Definition: PlayHead.h:39
A buffer with a cursor state.
Definition: NetStream_as.h:92
Definition: NetStream_as.h:187
void setInvalidatedVideo(DisplayObject *ch)
Register the DisplayObject to invalidate on video updates.
Definition: NetStream_as.h:309
size_t _audioQueueSize
Number of bytes in the audio queue, protected by _audioQueueMutex.
Definition: NetStream_as.h:132
sound::InputStream * _auxStreamer
Definition: NetStream_as.h:139
std::int32_t time()
Tells where the playhead currently is.
Definition: NetStream_as.cpp:1373
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:1548
static unsigned int fetchWrapper(void *owner, std::int16_t *samples, unsigned int nSamples, bool &eof)
Fetch samples from the audio queue.
Definition: NetStream_as.cpp:1479
PlayHead::PlaybackStatus playbackState() const
Definition: NetStream_as.h:196
void netstream_class_init(as_object &where, const ObjectURI &uri)
Definition: NetStream_as.cpp:130