* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavutil/opt.h"
#include "libavcodec/flac.h"
#include "avformat.h"
#include "flacenc.h"
#include "libavcodec/bytestream.h"
+typedef struct FlacMuxerContext {
+ const AVClass *class;
+ int write_header;
+} FlacMuxerContext;
+
static int flac_write_block_padding(AVIOContext *pb, unsigned int n_padding_bytes,
int last_block)
{
{
int ret;
AVCodecContext *codec = s->streams[0]->codec;
+ FlacMuxerContext *c = s->priv_data;
+
+ if (!c->write_header)
+ return 0;
ret = ff_flac_write_header(s->pb, codec, 0);
if (ret)
uint8_t *streaminfo;
enum FLACExtradataFormat format;
int64_t file_size;
+ FlacMuxerContext *c = s->priv_data;
+
+ if (!c->write_header)
+ return 0;
if (!avpriv_flac_is_extradata_valid(s->streams[0]->codec, &format, &streaminfo))
return -1;
return 0;
}
+static const AVOption flacenc_options[] = {
+ { "write_header", "Write the file header", offsetof(FlacMuxerContext, write_header), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM },
+ { NULL },
+};
+
+static const AVClass flac_muxer_class = {
+ .class_name = "flac muxer",
+ .item_name = av_default_item_name,
+ .option = flacenc_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVOutputFormat ff_flac_muxer = {
.name = "flac",
.long_name = NULL_IF_CONFIG_SMALL("raw FLAC"),
+ .priv_data_size = sizeof(FlacMuxerContext),
.mime_type = "audio/x-flac",
.extensions = "flac",
.audio_codec = AV_CODEC_ID_FLAC,
.write_packet = flac_write_packet,
.write_trailer = flac_write_trailer,
.flags = AVFMT_NOTIMESTAMPS,
+ .priv_class = &flac_muxer_class,
};