/*
 *  FFMPEGEncoder.h
 *  live555 Test
 *
 *  Created by Severin Schoepke on 05.06.07.
 *  Copyright 2007 Neotrivium AG. All rights reserved.
 *
 */

#ifndef FFMPEG_ENCODER_H
#define FFMPEG_ENCODER_H

#include <ffmpeg/avformat.h>

class Benchmark;

class FFMPEGEncoder
{
public:
    FFMPEGEncoder(const char *format, 
                    const char *vcodec, 
                    const char *acodec, 
                    int width, 
                    int height, 
                    int videoBitRate, 
                    int audioBitRate, 
                    int sampleRate, 
                    int numChannels);
    virtual         ~FFMPEGEncoder();
    
    int encodeVideo(void *output, void *input, unsigned int input_size);
    int encodeAudio(void *output, void *input, unsigned int input_size);
    
    PixelFormat pixelFormat();
    int         width();
    int         height();
    int         frameRate();
    int         videoBitRate();
    int         audioBitRate();
    int         audioFrameSize();
    int         sampleRate();
    int         numChannels();
    
private:
    
    AVOutputFormat  *_fmt;
    AVFormatContext *_oc;
    
    AVStream        *_audio_st; 
    AVStream        *_video_st;
    
    int64_t         _audio_pts;
    int64_t         _video_pts;
    
    uint8_t         *_audio_outbuf;
    unsigned int    _audio_outbuf_size;
    
    uint8_t         *_video_outbuf;
    unsigned int    _video_outbuf_size;
    AVFrame         *_tmp_frame;
    
    Benchmark       *_benchmark;
};
#endif