Пример #1
0
static u_char* 
mp4_builder_write_audio_trun_atom(u_char* p, media_sequence_t* sequence, uint32_t first_frame_offset)
{
	media_clip_filtered_t* cur_clip;
	input_frame_t* cur_frame;
	input_frame_t* last_frame;
	size_t atom_size;

	atom_size = ATOM_HEADER_SIZE + sizeof(trun_atom_t) + sequence->total_frame_count * 2 * sizeof(uint32_t);

	write_atom_header(p, atom_size, 't', 'r', 'u', 'n');
	write_be32(p, 0x301);								// flags = data offset, duration, size
	write_be32(p, sequence->total_frame_count);
	write_be32(p, first_frame_offset);	// first frame offset relative to moof start offset

	for (cur_clip = sequence->filtered_clips; cur_clip < sequence->filtered_clips_end; cur_clip++)
	{
		cur_frame = cur_clip->first_track->first_frame;
		last_frame = cur_clip->first_track->last_frame;
		for (; cur_frame < last_frame; cur_frame++)
		{
			write_be32(p, cur_frame->duration);
			write_be32(p, cur_frame->size);
		}
	}
	return p;
}
Пример #2
0
static u_char*
edash_packager_passthrough_write_encryption_atoms(void* ctx, u_char* p, size_t mdat_atom_start)
{
	mp4_encrypt_passthrough_context_t* context = ctx;
	media_clip_filtered_t* cur_clip;
	media_sequence_t* sequence = context->sequence;
	media_track_t* cur_track;
	size_t senc_atom_size;
	uint32_t flags;

	// saiz / saio
	p = mp4_encrypt_passthrough_write_saiz_saio(ctx, p, mdat_atom_start - context->auxiliary_info_size);

	// senc
	senc_atom_size = ATOM_HEADER_SIZE + sizeof(senc_atom_t) + context->auxiliary_info_size;
	write_atom_header(p, senc_atom_size, 's', 'e', 'n', 'c');
	flags = context->use_subsamples ? 0x2 : 0x0;
	write_be32(p, flags);		// flags
	write_be32(p, sequence->total_frame_count);
	for (cur_clip = sequence->filtered_clips; cur_clip < sequence->filtered_clips_end; cur_clip++)
	{
		cur_track = cur_clip->first_track;
		p = vod_copy(p, 
			cur_track->encryption_info.auxiliary_info, 
			cur_track->encryption_info.auxiliary_info_end - cur_track->encryption_info.auxiliary_info);
	}

	return p;
}
Пример #3
0
static u_char*
hds_write_afra_atom_header(u_char* p, size_t atom_size, uint32_t video_key_frame_count)
{
	write_atom_header(p, atom_size, 'a', 'f', 'r', 'a');
	write_be32(p, 0);
	*p++ = 0xC0;								// LongIDs | LongOffsets
	write_be32(p, HDS_TIMESCALE);				// timescale
	write_be32(p, video_key_frame_count);		// entries
	return p;
}
Пример #4
0
u_char*
mp4_builder_write_mfhd_atom(u_char* p, uint32_t segment_index)
{
	size_t atom_size = ATOM_HEADER_SIZE + sizeof(mfhd_atom_t);

	write_atom_header(p, atom_size, 'm', 'f', 'h', 'd');
	write_be32(p, 0);
	write_be32(p, segment_index);
	return p;
}
Пример #5
0
static u_char*
mss_write_tfhd_atom(u_char* p, uint32_t track_id, uint32_t flags)
{
	size_t atom_size = ATOM_HEADER_SIZE + sizeof(tfhd_atom_t);

	write_atom_header(p, atom_size, 't', 'f', 'h', 'd');
	write_be32(p, 0x20);		// default sample flags
	write_be32(p, track_id);
	write_be32(p, flags);
	return p;
}
Пример #6
0
static u_char*
mss_playready_video_write_uuid_piff_atom(u_char* p, mp4_encrypt_video_state_t* state, media_sequence_t* sequence, size_t atom_size)
{
	write_atom_header(p, atom_size, 'u', 'u', 'i', 'd');
	p = vod_copy(p, piff_uuid, sizeof(piff_uuid));
	write_be32(p, 2);
	write_be32(p, sequence->total_frame_count);
	p = vod_copy(p, state->auxiliary_data.start, state->auxiliary_data.pos - state->auxiliary_data.start);

	return p;
}
Пример #7
0
static u_char*
hds_write_tfhd_atom(u_char* p, uint32_t track_id, uint64_t base_data_offset)
{
	size_t atom_size = ATOM_HEADER_SIZE + sizeof(tfhd_atom_t);

	write_atom_header(p, atom_size, 't', 'f', 'h', 'd');
	write_be32(p, 3);							// flags - base data offset | sample description
	write_be32(p, track_id);
	write_be64(p, base_data_offset);
	write_be32(p, 1);							// sample_desc_index
	return p;
}
static u_char*
edash_packager_write_pssh(u_char* p, drm_system_info_t* cur_info)
{
	size_t pssh_atom_size;

	pssh_atom_size = ATOM_HEADER_SIZE + sizeof(pssh_atom_t) + cur_info->data.len;

	write_atom_header(p, pssh_atom_size, 'p', 's', 's', 'h');
	write_be32(p, 0);						// version + flags
	p = vod_copy(p, cur_info->system_id, DRM_SYSTEM_ID_SIZE);	// system id
	write_be32(p, cur_info->data.len);		// data size
	p = vod_copy(p, cur_info->data.data, cur_info->data.len);
	return p;
}
Пример #9
0
void		Key_file::store (std::ostream& out) const
{
	out.write("\0GITCRYPTKEY", 12);
	write_be32(out, FORMAT_VERSION);
	if (!key_name.empty()) {
		write_be32(out, HEADER_FIELD_KEY_NAME);
		write_be32(out, key_name.size());
		out.write(key_name.data(), key_name.size());
	}
	write_be32(out, HEADER_FIELD_END);
	for (Map::const_iterator it(entries.begin()); it != entries.end(); ++it) {
		it->second.store(out);
	}
}
Пример #10
0
static u_char*
hds_write_single_audio_frame_trun_atom(u_char* p, input_frame_t* frame, uint32_t offset)
{
	size_t atom_size;

	atom_size = TRUN_SIZE_SINGLE_AUDIO_FRAME;

	write_atom_header(p, atom_size, 't', 'r', 'u', 'n');
	write_be32(p, 0x301);				// flags = data offset, duration, size
	write_be32(p, 1);					// frame count
	write_be32(p, offset);				// offset from mdat start to frame raw data (excluding the tag)
	write_be32(p, frame->duration);
	write_be32(p, frame->size);
	return p;
}
Пример #11
0
static vod_status_t
mp4_encrypt_video_snpf_build_auxiliary_data(mp4_encrypt_video_state_t* state)
{
	u_char iv[MP4_AES_CTR_IV_SIZE];
	uint32_t bytes_of_encrypted_data;
	uint16_t bytes_of_clear_data;
	bool_t init_track;
	u_char* p;

	state->default_auxiliary_sample_size = sizeof(cenc_sample_auxiliary_data_t) + sizeof(cenc_sample_auxiliary_data_subsample_t);
	state->saiz_sample_count = state->base.sequence->total_frame_count;

	p = vod_alloc(
		state->base.request_context->pool, 
		state->default_auxiliary_sample_size * state->base.sequence->total_frame_count);
	if (p == NULL)
	{
		vod_log_debug0(VOD_LOG_DEBUG_LEVEL, state->base.request_context->log, 0,
			"mp4_encrypt_video_snpf_build_auxiliary_data: vod_alloc failed");
		return VOD_ALLOC_FAILED;
	}

	state->auxiliary_data.start = p;

	bytes_of_clear_data = state->base.cur_clip->first_track->media_info.u.video.nal_packet_size_length + 1;
	vod_memcpy(iv, state->base.iv, sizeof(iv));

	for (;;)
	{
		if (!mp4_encrypt_move_to_next_frame(&state->base, &init_track))
		{
			break;
		}

		if (init_track)
		{
			bytes_of_clear_data = state->base.cur_clip->first_track->media_info.u.video.nal_packet_size_length + 1;
		}

		// cenc_sample_auxiliary_data_t
		p = vod_copy(p, iv, sizeof(iv));
		mp4_aes_ctr_increment_be64(iv);
		write_be16(p, 1);		// subsample count

		// cenc_sample_auxiliary_data_subsample_t
		bytes_of_encrypted_data = state->base.cur_frame->size - bytes_of_clear_data;
		write_be16(p, bytes_of_clear_data);
		write_be32(p, bytes_of_encrypted_data);

		state->base.cur_frame++;
	}

	state->auxiliary_data.pos = p;

	// reset the state
	state->base.cur_clip = state->base.sequence->filtered_clips;
	mp4_encrypt_init_track(&state->base, state->base.cur_clip->first_track);

	return VOD_OK;
}
Пример #12
0
static u_char*
mss_write_uuid_tfrf_atom(u_char* p, segment_timing_info_t* timing_info)
{
	size_t atom_size = TFRF_ATOM_SIZE;
	uint64_t timestamp;
	uint64_t duration;
	int i;

	timestamp = timing_info->timestamp;
	duration = timing_info->duration;

	write_atom_header(p, atom_size, 'u', 'u', 'i', 'd');
	p = vod_copy(p, tfrf_uuid, sizeof(tfrf_uuid));
	write_be32(p, 0x01000000);		// version / flags
	*p++ = MSS_LOOK_AHEAD_COUNT;

	for (i = 0; i < MSS_LOOK_AHEAD_COUNT; i++)
	{
		timestamp += duration;
		write_be64(p, timestamp);
		write_be64(p, duration);
	}

	return p;
}
Пример #13
0
static u_char*
edash_packager_video_write_encryption_atoms(void* context, u_char* p, size_t mdat_atom_start)
{
	mp4_encrypt_video_state_t* state = (mp4_encrypt_video_state_t*)context;
	size_t senc_data_size = state->auxiliary_data.pos - state->auxiliary_data.start;
	size_t senc_atom_size = ATOM_HEADER_SIZE + sizeof(senc_atom_t) + senc_data_size;

	// saiz / saio
	p = mp4_encrypt_video_write_saiz_saio(state, p, mdat_atom_start - senc_data_size);

	// senc
	write_atom_header(p, senc_atom_size, 's', 'e', 'n', 'c');
	write_be32(p, 0x2);		// flags
	write_be32(p, state->base.sequence->total_frame_count);
	p = vod_copy(p, state->auxiliary_data.start, senc_data_size);

	return p;
}
Пример #14
0
static u_char*
edash_packager_audio_write_encryption_atoms(void* context, u_char* p, size_t mdat_atom_start)
{
	mp4_encrypt_state_t* state = (mp4_encrypt_state_t*)context;
	size_t senc_data_size = MP4_AES_CTR_IV_SIZE * state->sequence->total_frame_count;
	size_t senc_atom_size = ATOM_HEADER_SIZE + sizeof(senc_atom_t) + senc_data_size;

	// saiz / saio
	p = mp4_encrypt_audio_write_saiz_saio(state, p, mdat_atom_start - senc_data_size);

	// senc
	write_atom_header(p, senc_atom_size, 's', 'e', 'n', 'c');
	write_be32(p, 0x0);		// flags
	write_be32(p, state->sequence->total_frame_count);
	p = mp4_encrypt_audio_write_auxiliary_data(state, p);

	return p;
}
Пример #15
0
static void
sparc64_fixup_plt (DSO *dso, GElf_Rela *rela, GElf_Addr value)
{
  Elf64_Sxword disp = value - rela->r_offset;

  if (rela->r_addend)
    {
      /* .plt[32768+]  */
      write_be64 (dso, rela->r_offset, value);
    }
  else if (disp >= -0x800000 && disp < 0x800000)
    {
      /* b,a value
	  nop
	 nop  */
      write_be32 (dso, rela->r_offset, 0x30800000 | ((disp >> 2) & 0x3fffff));
      write_be32 (dso, rela->r_offset + 4, 0x01000000);
      write_be32 (dso, rela->r_offset + 8, 0x01000000);
    }
Пример #16
0
u_char*
mp4_encrypt_audio_write_saiz_saio(mp4_encrypt_state_t* state, u_char* p, size_t auxiliary_data_offset)
{
	size_t saiz_atom_size = ATOM_HEADER_SIZE + sizeof(saiz_atom_t);
	size_t saio_atom_size = ATOM_HEADER_SIZE + sizeof(saio_atom_t);

	// moof.traf.saiz
	write_atom_header(p, saiz_atom_size, 's', 'a', 'i', 'z');
	write_be32(p, 0);			// version, flags
	*p++ = MP4_AES_CTR_IV_SIZE;				// default auxiliary sample size
	write_be32(p, state->sequence->total_frame_count);

	// moof.traf.saio
	write_atom_header(p, saio_atom_size, 's', 'a', 'i', 'o');
	write_be32(p, 0);			// version, flags
	write_be32(p, 1);			// entry count
	write_be32(p, auxiliary_data_offset);

	return p;
}
Пример #17
0
static u_char*
edash_packager_write_pssh(void* context, u_char* p)
{
	drm_system_info_array_t* pssh_array = (drm_system_info_array_t*)context;
	drm_system_info_t* cur_info;
	size_t pssh_atom_size;

	for (cur_info = pssh_array->first; cur_info < pssh_array->last; cur_info++)
	{
		pssh_atom_size = ATOM_HEADER_SIZE + sizeof(pssh_atom_t) + cur_info->data.len;

		write_atom_header(p, pssh_atom_size, 'p', 's', 's', 'h');
		write_be32(p, 0);						// version + flags
		p = vod_copy(p, cur_info->system_id, DRM_SYSTEM_ID_SIZE);	// system id
		write_be32(p, cur_info->data.len);		// data size
		p = vod_copy(p, cur_info->data.data, cur_info->data.len);
	}

	return p;
}
Пример #18
0
u_char*
mp4_encrypt_video_write_saiz_saio(mp4_encrypt_video_state_t* state, u_char* p, size_t auxiliary_data_offset)
{
	// moof.traf.saiz
	write_atom_header(p, state->base.saiz_atom_size, 's', 'a', 'i', 'z');
	write_be32(p, 0);			// version, flags
	*p++ = state->default_auxiliary_sample_size;
	write_be32(p, state->saiz_sample_count);
	if (state->default_auxiliary_sample_size == 0)
	{
		p = vod_copy(p, state->auxiliary_sample_sizes, state->saiz_sample_count);
	}

	// moof.traf.saio
	write_atom_header(p, state->base.saio_atom_size, 's', 'a', 'i', 'o');
	write_be32(p, 0);			// version, flags
	write_be32(p, 1);			// entry count
	write_be32(p, auxiliary_data_offset);

	return p;
}
Пример #19
0
static u_char*
mss_write_uuid_tfxd_atom(u_char* p, segment_timing_info_t* timing_info)
{
	size_t atom_size = ATOM_HEADER_SIZE + sizeof(uuid_tfxd_atom_t);

	write_atom_header(p, atom_size, 'u', 'u', 'i', 'd');
	p = vod_copy(p, tfxd_uuid, sizeof(tfxd_uuid));
	write_be32(p, 0x01000000);		// version / flags
	write_be64(p, timing_info->timestamp);
	write_be64(p, timing_info->duration);
	return p;
}
Пример #20
0
static void vh_calc_checksum(struct volume_header *vh)
{
	uint32_t newsum = 0;
	unsigned char *buffer = (unsigned char *)vh;
	unsigned int i;

	vh->vh_csum = 0;

	for(i = 0; i < sizeof(struct volume_header); i += 4)
        newsum -= read_be32(&buffer[i]);

    write_be32(newsum, (unsigned char *)&vh->vh_csum);
}
Пример #21
0
static u_char* 
mp4_builder_write_video_trun_atom(u_char* p, media_sequence_t* sequence, uint32_t first_frame_offset)
{
	media_clip_filtered_t* cur_clip;
	frame_list_part_t* part;
	input_frame_t* cur_frame;
	input_frame_t* last_frame;
	size_t atom_size;

	atom_size = ATOM_HEADER_SIZE + sizeof(trun_atom_t) + sequence->total_frame_count * 4 * sizeof(uint32_t);

	write_atom_header(p, atom_size, 't', 'r', 'u', 'n');
	write_be32(p, 0xF01);								// flags = data offset, duration, size, key, delay
	write_be32(p, sequence->total_frame_count);
	write_be32(p, first_frame_offset);	// first frame offset relative to moof start offset

	for (cur_clip = sequence->filtered_clips; cur_clip < sequence->filtered_clips_end; cur_clip++)
	{
		part = &cur_clip->first_track->frames;
		last_frame = part->last_frame;
		for (cur_frame = part->first_frame;; cur_frame++)
		{
			if (cur_frame >= last_frame)
			{
				if (part->next == NULL)
				{
					break;
				}
				part = part->next;
				cur_frame = part->first_frame;
				last_frame = part->last_frame;
			}

			write_be32(p, cur_frame->duration);
			write_be32(p, cur_frame->size);
			if (cur_frame->key_frame)
			{
				write_be32(p, 0x00000000);
			}
			else
			{
				write_be32(p, 0x00010000);
			}
			write_be32(p, cur_frame->pts_delay);
		}
	}
	return p;
}
Пример #22
0
static u_char*
dash_packager_write_sidx_atom(
	u_char* p,
	sidx_params_t* sidx_params,
	uint32_t reference_size)
{
	size_t atom_size = ATOM_HEADER_SIZE + sizeof(sidx_atom_t);

	write_atom_header(p, atom_size, 's', 'i', 'd', 'x');
	write_be32(p, 0);					// version + flags
	write_be32(p, 1);					// reference id
	write_be32(p, sidx_params->timescale);			// timescale
	write_be32(p, sidx_params->earliest_pres_time);	// earliest presentation time
	write_be32(p, 0);					// first offset
	write_be32(p, 1);					// reserved + reference count
	write_be32(p, reference_size);		// referenced size
	write_be32(p, sidx_params->total_frames_duration);		// subsegment duration
	write_be32(p, 0x90000000);			// starts with SAP / SAP type
	return p;
}
Пример #23
0
static u_char*
edash_packager_write_stsd(void* ctx, u_char* p)
{
	stsd_writer_context_t* context = (stsd_writer_context_t*)ctx;
	u_char format_by_media_type[MEDIA_TYPE_COUNT] = { 'v', 'a' };

	// stsd
	write_atom_header(p, context->stsd_atom_size, 's', 't', 's', 'd');
	write_be32(p, 0);								// version + flags
	write_be32(p, context->has_clear_lead ? 2 : 1);	// entries

	// stsd encrypted entry
	write_be32(p, context->encrypted_stsd_entry_size);		// size
	write_atom_name(p, 'e', 'n', 'c', format_by_media_type[context->media_type]);	// format
	p = vod_copy(p, context->original_stsd_entry + 1, context->original_stsd_entry_size - sizeof(stsd_entry_header_t));

	// sinf
	write_atom_header(p, context->sinf_atom_size, 's', 'i', 'n', 'f');
	
	// sinf.frma
	write_atom_header(p, context->frma_atom_size, 'f', 'r', 'm', 'a');
	write_be32(p, context->original_stsd_entry_format);

	// sinf.schm
	write_atom_header(p, context->schm_atom_size, 's', 'c', 'h', 'm');
	write_be32(p, 0);							// version + flags
	write_atom_name(p, 'c', 'e', 'n', 'c');		// scheme type
	write_be32(p, 0x10000);						// scheme version

	// sinf.schi
	write_atom_header(p, context->schi_atom_size, 's', 'c', 'h', 'i');

	// sinf.schi.tenc
	write_atom_header(p, context->tenc_atom_size, 't', 'e', 'n', 'c');
	write_be32(p, 0);							// version + flags
	write_be32(p, 0x108);						// default is encrypted (1) + iv size (8)
	p = vod_copy(p, context->default_kid, DRM_KID_SIZE);			// default key id

	// clear entry
	if (context->has_clear_lead)
	{
		p = vod_copy(p, context->original_stsd_entry, context->original_stsd_entry_size);
	}

	return p;
}
Пример #24
0
static u_char*
mss_playready_passthrough_write_encryption_atoms(void* ctx, u_char* p, size_t mdat_atom_start)
{
	mp4_encrypt_passthrough_context_t* context = ctx;
	media_clip_filtered_t* cur_clip;
	media_sequence_t* sequence = context->sequence;
	media_track_t* cur_track;
	size_t auxiliary_data_offset;
	size_t uuid_atom_size;
	uint32_t flags;

	// uuid piff
	uuid_atom_size = ATOM_HEADER_SIZE + sizeof(uuid_piff_atom_t) + context->auxiliary_info_size;
	write_atom_header(p, uuid_atom_size, 'u', 'u', 'i', 'd');
	p = vod_copy(p, piff_uuid, sizeof(piff_uuid));
	flags = context->use_subsamples ? 0x2 : 0x0;
	write_be32(p, flags);		// flags
	write_be32(p, sequence->total_frame_count);
	for (cur_clip = sequence->filtered_clips; cur_clip < sequence->filtered_clips_end; cur_clip++)
	{
		cur_track = cur_clip->first_track;
		p = vod_copy(p,
			cur_track->encryption_info.auxiliary_info,
			cur_track->encryption_info.auxiliary_info_end - cur_track->encryption_info.auxiliary_info);
	}

	// saiz / saio
	auxiliary_data_offset = mdat_atom_start -
		(context->auxiliary_info_size +
		context->saiz_atom_size +
		context->saio_atom_size);

	p = mp4_encrypt_passthrough_write_saiz_saio(ctx, p, auxiliary_data_offset);

	return p;
}
Пример #25
0
static vod_status_t
mp4_encrypt_video_add_subsample(mp4_encrypt_video_state_t* state, uint16_t bytes_of_clear_data, uint32_t bytes_of_encrypted_data)
{
	vod_status_t rc;

	rc = vod_dynamic_buf_reserve(&state->auxiliary_data, sizeof(cenc_sample_auxiliary_data_subsample_t));
	if (rc != VOD_OK)
	{
		vod_log_debug1(VOD_LOG_DEBUG_LEVEL, state->base.request_context->log, 0,
			"mp4_encrypt_video_add_subsample: vod_dynamic_buf_reserve failed %i", rc);
		return rc;
	}
	write_be16(state->auxiliary_data.pos, bytes_of_clear_data);
	write_be32(state->auxiliary_data.pos, bytes_of_encrypted_data);
	state->subsample_count++;

	return VOD_OK;
}
Пример #26
0
void		Key_file::Entry::store (std::ostream& out) const
{
	// Version
	write_be32(out, KEY_FIELD_VERSION);
	write_be32(out, 4);
	write_be32(out, version);

	// AES key
	write_be32(out, KEY_FIELD_AES_KEY);
	write_be32(out, AES_KEY_LEN);
	out.write(reinterpret_cast<const char*>(aes_key), AES_KEY_LEN);

	// HMAC key
	write_be32(out, KEY_FIELD_HMAC_KEY);
	write_be32(out, HMAC_KEY_LEN);
	out.write(reinterpret_cast<const char*>(hmac_key), HMAC_KEY_LEN);

	// End
	write_be32(out, KEY_FIELD_END);
}
Пример #27
0
static vod_status_t
hds_muxer_end_frame(hds_muxer_state_t* state)
{
	uint32_t packet_size = state->frame_header_size + state->cur_frame->size;
	vod_status_t rc;
	u_char* p;

	// write the frame size
	rc = write_buffer_get_bytes(&state->write_buffer_state, sizeof(uint32_t), NULL, &p);
	if (rc != VOD_OK)
	{
		vod_log_debug1(VOD_LOG_DEBUG_LEVEL, state->request_context->log, 0,
			"hds_muxer_end_frame: write_buffer_get_bytes failed %i", rc);
		return rc;
	}
	write_be32(p, packet_size);

	return VOD_OK;
}
Пример #28
0
static u_char*
hds_muxer_write_codec_config(u_char* p, hds_muxer_state_t* state, uint64_t cur_frame_dts)
{
	media_track_t* cur_track;
	hds_muxer_stream_state_t* cur_stream;
	uint32_t packet_size;
	u_char* packet_start;

	for (cur_stream = state->first_stream; cur_stream < state->last_stream; cur_stream++)
	{
		cur_track = cur_stream->track;
		packet_start = p;
		switch (cur_track->media_info.media_type)
		{
		case MEDIA_TYPE_VIDEO:
			p = hds_write_video_tag_header(
				p,
				cur_track->media_info.extra_data_size,
				cur_frame_dts,
				FRAME_TYPE_KEY_FRAME,
				AVC_PACKET_TYPE_SEQUENCE_HEADER,
				0);
			break;

		case MEDIA_TYPE_AUDIO:
			p = hds_write_audio_tag_header(
				p,
				cur_track->media_info.extra_data_size,
				cur_frame_dts,
				cur_stream->sound_info,
				AAC_PACKET_TYPE_SEQUENCE_HEADER);
			break;
		}
		p = vod_copy(p, cur_track->media_info.extra_data, cur_track->media_info.extra_data_size);
		packet_size = p - packet_start;
		write_be32(p, packet_size);
	}
	return p;
}
Пример #29
0
static u_char*
hds_write_single_video_frame_trun_atom(u_char* p, input_frame_t* frame, uint32_t offset)
{
	size_t atom_size;

	atom_size = TRUN_SIZE_SINGLE_VIDEO_FRAME;

	write_atom_header(p, atom_size, 't', 'r', 'u', 'n');
	write_be32(p, 0xF01);				// flags = data offset, duration, size, key, delay
	write_be32(p, 1);					// frame count
	write_be32(p, offset);				// offset from mdat start to frame raw data (excluding the tag)
	write_be32(p, frame->duration);
	write_be32(p, frame->size);
	if (frame->key_frame)
	{
		write_be32(p, 0x02000000);		// I-frame
	}
	else
	{
		write_be32(p, 0x01010000);		// not I-frame + non key sample
	}
	write_be32(p, frame->pts_delay);
	return p;
}
Пример #30
0
static int boot_mips_write(FILE *outfile)
{
	struct directory_entry	*boot_file;	/* Boot file we need to search for */
    unsigned long length = 0;
    unsigned long extent = 0;
	int i;
	struct volume_header vh;
    unsigned long long iso_size = 0;
    char *filename = NULL;

	memset(&vh, 0, sizeof(vh));

    iso_size = last_extent * 2048;

    write_be32(VHMAGIC, (unsigned char *)&vh.vh_magic);

	/* Values from an IRIX cd */
    write_be16(BYTES_PER_SECTOR, (unsigned char *)&vh.vh_dp.dp_secbytes);
    write_be16(SECTORS_PER_TRACK, (unsigned char *)&vh.vh_dp.dp_secs);
    write_be32(DP_RESEEK|DP_IGNOREERRORS|DP_TRKFWD, (unsigned char *)&vh.vh_dp.dp_flags);
    write_be16(1, (unsigned char *)&vh.vh_dp.dp_trks0);

    write_be16((iso_size + BYTES_PER_SECTOR - 1) / (SECTORS_PER_TRACK * BYTES_PER_SECTOR),
               (unsigned char *)&vh.vh_dp.dp_cyls);

	for(i = 0; i < boot_mips_num_files; i++)
    {
        boot_file = search_tree_file(root, boot_mips_filename[i]);
        
        if (!boot_file) {
#ifdef	USE_LIBSCHILY
            comerrno(EX_BAD, "Uh oh, I cant find the MIPS boot file '%s'!\n",
                     boot_mips_filename[i]);
#else
            fprintf(stderr, "Uh oh, I cant find the MIPS boot file '%s'!\n",
                    boot_mips_filename[i]);
            exit(1);
#endif
        }

        extent = get_733(boot_file->isorec.extent) * 4;
        length = ((get_733(boot_file->isorec.size) + 2047) / 2048) * 2048;
        filename = file_base_name(boot_mips_filename[i]);

        strncpy((char *)vh.vh_vd[i].vd_name, filename, MIN(VDNAMESIZE, strlen(filename)));
        write_be32(extent, (unsigned char *)&vh.vh_vd[i].vd_lbn);
        write_be32(length, (unsigned char *)&vh.vh_vd[i].vd_nbytes);
        
        fprintf(stderr, "Found mips boot image %s, using extent %lu (0x%lX), #blocks %lu (0x%lX)\n",
                filename, extent, extent, length, length);
	}

	/* Create volume partition on whole cd iso */
    write_be32((iso_size + (BYTES_PER_SECTOR - 1))/ BYTES_PER_SECTOR, (unsigned char *)&vh.vh_pt[10].pt_nblks);
    write_be32(0, (unsigned char *)&vh.vh_pt[10].pt_firstlbn);
    write_be32(PTYPE_VOLUME, (unsigned char *)&vh.vh_pt[10].pt_type);

	/* Create volume header partition, also on WHOLE cd iso */
    write_be32((iso_size + (BYTES_PER_SECTOR - 1))/ BYTES_PER_SECTOR, (unsigned char *)&vh.vh_pt[8].pt_nblks);
    write_be32(0, (unsigned char *)&vh.vh_pt[8].pt_firstlbn);
    write_be32(PTYPE_VOLHDR, (unsigned char *)&vh.vh_pt[8].pt_type);

	/* Create checksum */
	vh_calc_checksum(&vh);

    jtwrite(&vh, sizeof(vh), 1, 0, FALSE);
    xfwrite(&vh, sizeof(vh), 1, outfile, 0, FALSE);
    last_extent_written++;

	return 0;
}