src/atsc3_mmt_mpu_utils.c
void mpu_push_to_output_buffer_no_locking(pipe_ffplay_buffer_t* pipe_ffplay_buffer, mmtp_payload_fragments_union_t* mmtp_payload) {

	__MMT_MPU_DEBUG("payload of size: %d payload type: 0x%x", mmtp_payload->mmtp_mpu_type_packet_header.mpu_data_unit_payload->i_pos, mmtp_payload->mmtp_mpu_type_packet_header.mpu_fragment_type);

	//discard if we are not a mpu payload
	if(mmtp_payload->mmtp_mpu_type_packet_header.mmtp_payload_type != 0x0) {
		__MMT_MPU_WARN("Incorrect payload type: 0x%x", mmtp_payload->mmtp_mpu_type_packet_header.mmtp_payload_type);
		goto cleanup;

	}

	//if we have not written our init box, mpu_fragment_type == 0x0, then discard until we see our first mpu_fragment_type == 0x0
	if(!pipe_ffplay_buffer->has_written_init_box) {
		if(mmtp_payload->mmtp_mpu_type_packet_header.mpu_fragment_type != 0x0) {
			goto cleanup;
		}

		pipe_buffer_unsafe_push_block(pipe_ffplay_buffer, mmtp_payload->mmtp_mpu_type_packet_header.mpu_data_unit_payload->p_buffer, mmtp_payload->mmtp_mpu_type_packet_header.mpu_data_unit_payload->i_pos);
		pipe_ffplay_buffer->last_mpu_sequence_number = mmtp_payload->mmtp_mpu_type_packet_header.mpu_sequence_number;
		pipe_ffplay_buffer->has_written_init_box = true;

		__MMT_MPU_DEBUG("pushing init fragment for %d fragment_type: 0", mmtp_payload->mmtp_mpu_type_packet_header.mpu_sequence_number);

		goto cleanup;

	} else {
		//ignore our init box after we've sent it the first time
		if(mmtp_payload->mmtp_mpu_type_packet_header.mpu_fragment_type == 0x0) {
			goto cleanup;
		}

		__MMT_MPU_DEBUG("pushing payload fragment for %d fragment_type: %d", mmtp_payload->mmtp_mpu_type_packet_header.mpu_sequence_number, mmtp_payload->mmtp_mpu_type_packet_header.mpu_fragment_type);

		pipe_buffer_unsafe_push_block(pipe_ffplay_buffer, mmtp_payload->mmtp_mpu_type_packet_header.mpu_data_unit_payload->p_buffer, mmtp_payload->mmtp_mpu_type_packet_header.mpu_data_unit_payload->i_pos);

		pipe_ffplay_buffer->last_mpu_sequence_number = mmtp_payload->mmtp_mpu_type_packet_header.mpu_sequence_number;
	}

cleanup:
	return;
}
/*
 * only use this if you will manage the mutex externally
 *
 * callee is responsible for freeing mpu_data_unit_payload
 */
only use this if you will manage the mutex externally
callee is responsible for freeing mpu_data_unit_payload
only use this if you will manage the mutex externally callee is responsible for freeing mpu_data_unit_payload
void mpu_push_to_output_buffer_no_locking(pipe_ffplay_buffer_t* pipe_ffplay_buffer, mmtp_payload_fragments_union_t* mmtp_payload) {
	__MMT_MPU_DEBUG("payload of size: %d payload type: 0x%x", mmtp_payload->mmtp_mpu_type_packet_header.mpu_data_unit_payload->i_pos, mmtp_payload->mmtp_mpu_type_packet_header.mpu_fragment_type);
	if(mmtp_payload->mmtp_mpu_type_packet_header.mmtp_payload_type != 0x0) {
		__MMT_MPU_WARN("Incorrect payload type: 0x%x", mmtp_payload->mmtp_mpu_type_packet_header.mmtp_payload_type);
		goto cleanup;
	}
	if(!pipe_ffplay_buffer->has_written_init_box) {
		if(mmtp_payload->mmtp_mpu_type_packet_header.mpu_fragment_type != 0x0) {
			goto cleanup;
		}
		pipe_buffer_unsafe_push_block(pipe_ffplay_buffer, mmtp_payload->mmtp_mpu_type_packet_header.mpu_data_unit_payload->p_buffer, mmtp_payload->mmtp_mpu_type_packet_header.mpu_data_unit_payload->i_pos);
		pipe_ffplay_buffer->last_mpu_sequence_number = mmtp_payload->mmtp_mpu_type_packet_header.mpu_sequence_number;
		pipe_ffplay_buffer->has_written_init_box = true;
		__MMT_MPU_DEBUG("pushing init fragment for %d fragment_type: 0", mmtp_payload->mmtp_mpu_type_packet_header.mpu_sequence_number);
		goto cleanup;
	} else {
		if(mmtp_payload->mmtp_mpu_type_packet_header.mpu_fragment_type == 0x0) {
			goto cleanup;
		}
		__MMT_MPU_DEBUG("pushing payload fragment for %d fragment_type: %d", mmtp_payload->mmtp_mpu_type_packet_header.mpu_sequence_number, mmtp_payload->mmtp_mpu_type_packet_header.mpu_fragment_type);
		pipe_buffer_unsafe_push_block(pipe_ffplay_buffer, mmtp_payload->mmtp_mpu_type_packet_header.mpu_data_unit_payload->p_buffer, mmtp_payload->mmtp_mpu_type_packet_header.mpu_data_unit_payload->i_pos);
		pipe_ffplay_buffer->last_mpu_sequence_number = mmtp_payload->mmtp_mpu_type_packet_header.mpu_sequence_number;
	}
cleanup:
	return;
}
void mpu_push_to_output_buffer_no_locking ( pipe_ffplay_buffer_t * pipe_ffplay_buffer , mmtp_payload_fragments_union_t * mmtp_payload ) { __MMT_MPU_DEBUG ( " " , mmtp_payload -> mmtp_mpu_type_packet_header . mpu_data_unit_payload -> i_pos , mmtp_payload -> mmtp_mpu_type_packet_header . mpu_fragment_type ) ; if ( mmtp_payload -> mmtp_mpu_type_packet_header . mmtp_payload_type != 0x0 ) { __MMT_MPU_WARN ( " " , mmtp_payload -> mmtp_mpu_type_packet_header . mmtp_payload_type ) ; goto cleanup ; } if ( ! pipe_ffplay_buffer -> has_written_init_box ) { if ( mmtp_payload -> mmtp_mpu_type_packet_header . mpu_fragment_type != 0x0 ) { goto cleanup ; } pipe_buffer_unsafe_push_block ( pipe_ffplay_buffer , mmtp_payload -> mmtp_mpu_type_packet_header . mpu_data_unit_payload -> p_buffer , mmtp_payload -> mmtp_mpu_type_packet_header . mpu_data_unit_payload -> i_pos ) ; pipe_ffplay_buffer -> last_mpu_sequence_number = mmtp_payload -> mmtp_mpu_type_packet_header . mpu_sequence_number ; pipe_ffplay_buffer -> has_written_init_box = true ; __MMT_MPU_DEBUG ( " " , mmtp_payload -> mmtp_mpu_type_packet_header . mpu_sequence_number ) ; goto cleanup ; } else { if ( mmtp_payload -> mmtp_mpu_type_packet_header . mpu_fragment_type == 0x0 ) { goto cleanup ; } __MMT_MPU_DEBUG ( " " , mmtp_payload -> mmtp_mpu_type_packet_header . mpu_sequence_number , mmtp_payload -> mmtp_mpu_type_packet_header . mpu_fragment_type ) ; pipe_buffer_unsafe_push_block ( pipe_ffplay_buffer , mmtp_payload -> mmtp_mpu_type_packet_header . mpu_data_unit_payload -> p_buffer , mmtp_payload -> mmtp_mpu_type_packet_header . mpu_data_unit_payload -> i_pos ) ; pipe_ffplay_buffer -> last_mpu_sequence_number = mmtp_payload -> mmtp_mpu_type_packet_header . mpu_sequence_number ; } cleanup : return ; }
only use this if you will manage the mutex externally
 callee is responsible for freeing mpu_data_unit_payload
only use this if you will manage the mutex externally callee is responsible for freeing mpu_data_unit_payload
//discard if we are not a mpu payload //if we have not written our init box, mpu_fragment_type == 0x0, then discard until we see our first mpu_fragment_type == 0x0 //ignore our init box after we've sent it the first time