yading@10: /* yading@10: * Audio Frame Queue yading@10: * Copyright (c) 2012 Justin Ruggles yading@10: * yading@10: * This file is part of Libav. yading@10: * yading@10: * Libav is free software; you can redistribute it and/or yading@10: * modify it under the terms of the GNU Lesser General Public yading@10: * License as published by the Free Software Foundation; either yading@10: * version 2.1 of the License, or (at your option) any later version. yading@10: * yading@10: * Libav is distributed in the hope that it will be useful, yading@10: * but WITHOUT ANY WARRANTY; without even the implied warranty of yading@10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU yading@10: * Lesser General Public License for more details. yading@10: * yading@10: * You should have received a copy of the GNU Lesser General Public yading@10: * License along with Libav; if not, write to the Free Software yading@10: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA yading@10: */ yading@10: yading@10: #ifndef AVCODEC_AUDIO_FRAME_QUEUE_H yading@10: #define AVCODEC_AUDIO_FRAME_QUEUE_H yading@10: yading@10: #include "avcodec.h" yading@10: yading@10: typedef struct AudioFrame { yading@10: int64_t pts; yading@10: int duration; yading@10: } AudioFrame; yading@10: yading@10: typedef struct AudioFrameQueue { yading@10: AVCodecContext *avctx; yading@10: int remaining_delay; yading@10: int remaining_samples; yading@10: AudioFrame *frames; yading@10: unsigned frame_count; yading@10: unsigned frame_alloc; yading@10: } AudioFrameQueue; yading@10: yading@10: /** yading@10: * Initialize AudioFrameQueue. yading@10: * yading@10: * @param avctx context to use for time_base and av_log yading@10: * @param afq queue context yading@10: */ yading@10: void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq); yading@10: yading@10: /** yading@10: * Close AudioFrameQueue. yading@10: * yading@10: * Frees memory if needed. yading@10: * yading@10: * @param afq queue context yading@10: */ yading@10: void ff_af_queue_close(AudioFrameQueue *afq); yading@10: yading@10: /** yading@10: * Add a frame to the queue. yading@10: * yading@10: * @param afq queue context yading@10: * @param f frame to add to the queue yading@10: */ yading@10: int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f); yading@10: yading@10: /** yading@10: * Remove frame(s) from the queue. yading@10: * yading@10: * Retrieves the pts of the next available frame, or a generated pts based on yading@10: * the last frame duration if there are no frames left in the queue. The number yading@10: * of requested samples should be the full number of samples represented by the yading@10: * packet that will be output by the encoder. If fewer samples are available yading@10: * in the queue, a smaller value will be used for the output duration. yading@10: * yading@10: * @param afq queue context yading@10: * @param nb_samples number of samples to remove from the queue yading@10: * @param[out] pts output packet pts yading@10: * @param[out] duration output packet duration yading@10: */ yading@10: void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts, yading@10: int *duration); yading@10: yading@10: #endif /* AVCODEC_AUDIO_FRAME_QUEUE_H */