#ifndef VIDEO_MUXER_H_
#define VIDEO_MUXER_H_
#include "../../modules/ffmpeg_in/ffmpeg_in.h"
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
#include "libavutil/mathematics.h"
#include <gpac/isomedia.h>
#include <gpac/internal/media_dev.h>
#include "video_scaler.h"
typedef enum {
FFMPEG_VIDEO_MUXER,
RAW_VIDEO_H264,
GPAC_VIDEO_MUXER,
GPAC_INIT_VIDEO_MUXER_AVC1,
GPAC_INIT_VIDEO_MUXER_AVC3
} VideoMuxerType;
typedef struct {
VideoDataConf *video_data_conf;
VideoMuxerType muxer_type;
AVFormatContext *av_fmt_ctx;
AVCodecContext *codec_ctx;
AVCodec *codec;
FILE *file;
#ifndef GPAC_DISABLE_ISOM
GF_ISOFile *isof;
GF_ISOSample *sample;
#endif
u32 trackID;
int vstream_idx;
Consumer consumer;
uint8_t *vbuf;
int vbuf_size;
int encoded_frame_size;
int frame_per_fragment;
int frame_per_segment;
int seg_dur;
int frag_dur;
u64 first_dts_in_fragment;
u64 ntp_at_first_dts;
u32 seg_marker;
int gop_size;
int gdr;
Bool use_source_timing;
u64 pts_at_segment_start, pts_at_first_segment;
u64 last_pts, last_dts;
u64 frame_dur;
u32 timescale;
u32 nb_segments;
Bool fragment_started, segment_started;
const char *rep_id;
u64 frame_ntp, frame_utc;
} VideoOutputFile;
int dc_video_muxer_init(VideoOutputFile *video_output_file, VideoDataConf *video_data_conf, VideoMuxerType muxer_type, int frame_per_segment, int frame_per_fragment, u32 seg_marker, int gdr, int seg_dur, int frag_dur, int frame_dur, int gop_size, int video_cb_size);
int dc_video_muxer_free(VideoOutputFile *video_output_file);
int dc_video_muxer_open(VideoOutputFile *video_output_file, char *directory, char *id_name, int seg);
int dc_video_muxer_write(VideoOutputFile *video_output_file, int frame_nb, Bool insert_ntp_timestamp);
int dc_video_muxer_close(VideoOutputFile *video_output_file);
#endif