3 * Copyright (c) 2012 Justin Ruggles
5 * This file is part of FFmpeg.
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifndef AVCODEC_AUDIO_FRAME_QUEUE_H
23 #define AVCODEC_AUDIO_FRAME_QUEUE_H
27 typedef struct AudioFrame {
32 typedef struct AudioFrameQueue {
33 AVCodecContext *avctx;
35 int remaining_samples;
42 * Initialize AudioFrameQueue.
44 * @param avctx context to use for time_base and av_log
45 * @param afq queue context
47 void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq);
50 * Close AudioFrameQueue.
52 * Frees memory if needed.
54 * @param afq queue context
56 void ff_af_queue_close(AudioFrameQueue *afq);
59 * Add a frame to the queue.
61 * @param afq queue context
62 * @param f frame to add to the queue
64 int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f);
67 * Remove frame(s) from the queue.
69 * Retrieves the pts of the next available frame, or a generated pts based on
70 * the last frame duration if there are no frames left in the queue. The number
71 * of requested samples should be the full number of samples represented by the
72 * packet that will be output by the encoder. If fewer samples are available
73 * in the queue, a smaller value will be used for the output duration.
75 * @param afq queue context
76 * @param nb_samples number of samples to remove from the queue
77 * @param[out] pts output packet pts
78 * @param[out] duration output packet duration
80 void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts,
83 #endif /* AVCODEC_AUDIO_FRAME_QUEUE_H */