Exemple #1
0
int dc_audio_muxer_write(AudioOutputFile * p_aoutf, int i_frame_nb) {

	//GF_Err ret;
	switch (p_aoutf->muxer_type) {

	case FFMPEG_AUDIO_MUXER:
		return dc_ffmpeg_audio_muxer_write(p_aoutf);
	case GPAC_AUDIO_MUXER:
	case GPAC_INIT_AUDIO_MUXER:
		if (i_frame_nb % p_aoutf->i_frame_per_frag == 0) {
			gf_isom_start_fragment(p_aoutf->p_isof, 1);

			gf_isom_set_traf_base_media_decode_time(p_aoutf->p_isof, 1,
					p_aoutf->i_first_dts * p_aoutf->i_frame_size);
			p_aoutf->i_first_dts += p_aoutf->i_frame_per_frag;
		}
		dc_gpac_audio_isom_write(p_aoutf);
		if (i_frame_nb % p_aoutf->i_frame_per_frag
				== p_aoutf->i_frame_per_frag - 1) {
			gf_isom_flush_fragments(p_aoutf->p_isof, 1);
		}
		if(i_frame_nb + 1 == p_aoutf->i_frame_per_seg)
			return 1;
		return 0;
	default:
		return GF_BAD_PARAM;
	};

	return GF_BAD_PARAM;
}
Exemple #2
0
int dc_audio_muxer_write(AudioOutputFile *audio_output_file, int frame_nb, Bool insert_ntp)
{
	switch (audio_output_file->muxer_type) {
	case FFMPEG_AUDIO_MUXER:
		return dc_ffmpeg_audio_muxer_write(audio_output_file);
#ifndef GPAC_DISABLE_ISOM
	case GPAC_AUDIO_MUXER:
	case GPAC_INIT_AUDIO_MUXER:
		if (frame_nb % audio_output_file->frame_per_frag == 0) {
			gf_isom_start_fragment(audio_output_file->isof, 1);
			
			if (insert_ntp) {
				gf_isom_set_fragment_reference_time(audio_output_file->isof, 1, audio_output_file->frame_ntp, audio_output_file->first_dts * audio_output_file->codec_ctx->frame_size);
			}

			gf_isom_set_traf_base_media_decode_time(audio_output_file->isof, 1, audio_output_file->first_dts * audio_output_file->codec_ctx->frame_size);
			audio_output_file->first_dts += audio_output_file->frame_per_frag;
			GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[DashCast] Audio start fragment first DTS %d at "LLU"\n", audio_output_file->first_dts, gf_net_get_utc() ));
		}
		dc_gpac_audio_isom_write(audio_output_file);
		if (frame_nb % audio_output_file->frame_per_frag == audio_output_file->frame_per_frag - 1) {
			gf_isom_flush_fragments(audio_output_file->isof, 1);
			GF_LOG(GF_LOG_DEBUG, GF_LOG_DASH, ("[DashCast] Audio flush fragment first DTS %d at "LLU"\n", audio_output_file->first_dts, gf_net_get_utc() ));
		}
		//TODO - do same as video, flush based on time in case of losses
		if (frame_nb + 1 == audio_output_file->frame_per_seg) {
			return 1;
		}

		return 0;
#endif

	default:
		return GF_BAD_PARAM;
	}
	return GF_BAD_PARAM;
}