From 156f40773fae82ec9fe8b5c7ad2615d8fa60c22e Mon Sep 17 00:00:00 2001 From: Comment Date: Sun, 17 Mar 2013 19:17:29 +0000 Subject: implementing decoder --- rotord/rotor.h | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) (limited to 'rotord/rotor.h') diff --git a/rotord/rotor.h b/rotord/rotor.h index 18b1f19..c7d25b2 100755 --- a/rotord/rotor.h +++ b/rotord/rotor.h @@ -7,6 +7,8 @@ we traverse the graph as recursive function calls until we satisfy all dependenc NO NODE HAS MORE THAN ONE OUTPUT WE DON'T LINK TO AN OUTPUT OBJECT WE LINK TO THE NODE - GET_OUTPUT IS THE RENDER FUNCTION +MORE THAN ONE NODE CAN LINK THE SAME OUTPUT +NODES CACHE AT LEAST ONE FRAME ??the only node with more than 1 output is audio? ??lets rethink this @@ -104,6 +106,33 @@ namespace Rotor { //forward declaration class Node; class Signal_node; + + //http://blog.tomaka17.com/2012/03/libavcodeclibavformat-tutorial/ + struct Packet { + explicit Packet(AVFormatContext* ctxt = nullptr) { + av_init_packet(&packet); + packet.data = nullptr; + if (ctxt) reset(ctxt); + } + + Packet(Packet&& other) : packet(std::move(other.packet)) { + other.packet.data = nullptr; + } + + ~Packet() { + if (packet.data) + av_free_packet(&packet); + } + + void reset(AVFormatContext* ctxt) { + if (packet.data) + av_free_packet(&packet); + if (av_read_frame(ctxt, &packet) < 0) + packet.data = nullptr; + } + + AVPacket packet; + }; class Render_status{ @@ -304,14 +333,14 @@ namespace Rotor { base_audio_processor(); base_audio_processor(int _channels,int _bits); virtual bool process_chunk(char *data,int num_samples); + void init(int _channels,int _bits) { + channels=_channels; + bits=_bits; + }; int channels,bits; }; class audio_thumbnailer: public base_audio_processor { public: - audio_thumbnailer(int _channels,int _bits) { - channels=_channels; - bits=_bits; - }; }; class Render_context: public Poco::Task { //Poco task object //manages a 'patchbay' -- cgit v1.2.3