ICodec: fix free avcodec in destructor

* Close and free avcodec in destructor only if AVCodecContext and AVCodec
are not NULL.
* Generator Video / Audio: get a pointer to an ICodec, because we set its codec from the outside (method setVideoCodec / setAudioCodec). And this codec outside will be free elsewhere.
StreamTranscoder: clean constructor in case of generator essence

* Cast only one time (for video or audio cases).
* Use reference when cast (it was not the case for video).