From 2b7aa6e5084441cdd82a2c7060e510ea423c0381 Mon Sep 17 00:00:00 2001 From: Comment Date: Mon, 18 Mar 2013 23:46:24 +0000 Subject: figuring out codec context --- rotord/rotor.cpp | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) (limited to 'rotord/rotor.cpp') diff --git a/rotord/rotor.cpp b/rotord/rotor.cpp index 281671e..931bfa9 100644 --- a/rotord/rotor.cpp +++ b/rotord/rotor.cpp @@ -263,38 +263,12 @@ Command_response Render_context::session_command(const std::vector& return response; } -//how to do this? -//aim - load nodes from xml -//easily maintain the xml tree -//be able to save it or print it -//--if the list of nodes is a flat vector - don't need to store ID with the node - just refer to the index # of the node while loading? -//--if instead it refers to the index# in the unordered map - can handle deletion etc - have to check if a node exists when linking -//--also can a node link to one 'later' ? it may have to? in which case there's a 2 step process - 1 load the nodes - 2 link them -//maybe -// a generic way to create a named node- each node is an object- will be loadable from .so -// eventually need to figure out to load .sos and enumerate classes -// in the short term either -// - hand logic that recognises nodes and creates inputs etc -// - not sure how else? - -//its a factory? -//http://stackoverflow.com/questions/4007382/how-to-create-class-objects-dynamically -//http://www.codeproject.com/Articles/3734/Different-ways-of-implementing-factories -//http://stackoverflow.com/questions/13292856/create-derived-class-in-base-class-based-on-parameter -//http://en.wikipedia.org/wiki/Factory_method_pattern - -//what is a good way to pass parameters to objects? -//get all attributes of node and pass them as creation parameters? -//could just pass them all as strings, let the object choose what to do itself? -//YES //http://blog.tomaka17.com/2012/03/libavcodeclibavformat-tutorial/ //great to use c++11 features - - bool Render_context::load_audio(string &filename,vector processors){ //load audio data from file //what's the best way to use this? the model is background processing, and we want to update a progress bar @@ -336,12 +310,13 @@ bool Render_context::load_audio(string &filename,vector p } // getting the required codec structure - const auto codec = avcodec_find_decoder(stream->codec->codec_id); + const auto codec = avcodec_find_decoder(stream->codec->codec_id); //returns AVCodec* if (codec == nullptr) { cerr <<"Rotor: Audio codec not available"<< endl; return false; } - + + //AVCodecContext?? avFormat->streams[i]->codec // allocating a structure std::shared_ptr audioCodec(avcodec_alloc_context3(codec), [](AVCodecContext* c) { avcodec_close(c); av_free(c); }); @@ -360,6 +335,10 @@ bool Render_context::load_audio(string &filename,vector p } */ + //avcodec.h line 1026 + + cerr << "audio codec context - sample rate: "<< audioCodec->sample_rate <<" ,channels: "<channels<<" ,sample format: "<sample_fmt< p std::shared_ptr avFrame(avcodec_alloc_frame(), &av_free); // the current packet of data - Packet packet; + //Packet packet; // data in the packet of data already processed size_t offsetInData = 0; + + + /* // the decoding loop, running until EOF while (true) { // reading a packet using libavformat @@ -414,6 +396,7 @@ bool Render_context::load_audio(string &filename,vector p std::this_thread::sleep(std::chrono::milliseconds(msToWait)); } } + */ return true; } -- cgit v1.2.3