#ifndef _ISMO_IN_H_
#define _ISMO_IN_H_
#include <gpac/constants.h>
#include <gpac/modules/service.h>
#include <gpac/thread.h>
#ifndef GPAC_DISABLE_ISOM
#include <gpac/media_tools.h>
typedef struct
{
GF_InputService *input;
GF_ClientService *service;
GF_List *channels;
GF_ISOFile *mov;
u32 time_scale;
u32 nb_playing;
GF_DownloadSession * dnload;
u64 missing_bytes, last_size;
Bool no_service_desc;
u32 play_only_track_id;
u32 frag_type;
Bool waiting_for_data, reset_frag_state;
GF_Mutex *segment_mutex;
u32 pending_scalable_enhancement_segment_index;
Bool use_memory;
u32 seg_opened;
Bool drop_next_segment;
Bool in_data_flush;
u32 has_pending_segments, nb_force_flush;
Bool clock_discontinuity;
Bool disconnected;
Bool no_order_check;
u64 last_sender_ntp, cts_for_last_sender_ntp;
Double remain_at_buffering_start;
Bool buffering;
} ISOMReader;
typedef struct
{
u32 track, track_id;
u32 base_track;
u32 next_track;
LPNETCHANNEL channel;
ISOMReader *owner;
u64 duration;
Bool wait_for_segment_switch;
GF_ISOSample *sample;
GF_SLHeader current_slh;
GF_Err last_state;
Bool is_pulling;
Bool has_edit_list;
u32 sample_num;
s64 dts_offset;
Bool do_dts_shift_test;
u32 edit_sync_frame;
u64 sample_time, start, end;
Double speed;
u32 time_scale;
Bool to_init, is_playing, has_rap;
u8 streamType;
Bool is_encrypted, is_cenc;
u64 cache_seed_ts;
u32 frame_cts_offset;
u64 prev_dts, max_cts;
GF_ISOSample *cache_sample;
Bool buffering;
u32 buffer_min, buffer_max;
Bool disable_seek;
u32 nalu_extract_mode;
u32 last_sample_desc_index;
} ISOMChannel;
void isor_reset_reader(ISOMChannel *ch);
void isor_reader_get_sample(ISOMChannel *ch);
void isor_reader_release_sample(ISOMChannel *ch);
ISOMChannel *isor_get_channel(ISOMReader *reader, LPNETCHANNEL channel);
GF_InputService *isor_client_load();
void isor_client_del(GF_BaseInterface *bi);
GF_Descriptor *isor_emulate_iod(ISOMReader *read);
void isor_emulate_chapters(GF_ISOFile *file, GF_InitialObjectDescriptor *iod);
void isor_declare_objects(ISOMReader *read);
void send_proxy_command(ISOMReader *read, Bool is_disconnect, Bool is_add_media, GF_Err e, GF_Descriptor *desc, LPNETCHANNEL channel);
void isor_send_cenc_config(ISOMChannel *ch);
void isor_flush_data(ISOMReader *read, Bool check_buffer_level, Bool is_chunk_flush);
#ifndef GPAC_DISABLE_ISOM_WRITE
GF_BaseInterface *isow_load_cache();
void isow_delete_cache(GF_BaseInterface *bi);
#endif
#endif
#endif