예제 #1
0
vod_status_t
edash_packager_build_init_mp4(
	request_context_t* request_context,
	media_set_t* media_set,
	bool_t has_clear_lead,
	bool_t size_only,
	vod_str_t* result)
{
	media_track_t* first_track = media_set->sequences[0].filtered_clips[0].first_track;
	mp4_encrypt_info_t* drm_info = (mp4_encrypt_info_t*)media_set->sequences[0].drm_info;
	stsd_writer_context_t stsd_writer_context;
	atom_writer_t pssh_atom_writer;
	atom_writer_t stsd_atom_writer;
	mp4_encrypt_system_info_t* cur_info;
	vod_status_t rc;

	rc = edash_packager_init_stsd_writer_context(
		request_context,
		first_track->media_info.media_type,
		&first_track->raw_atoms[RTA_STSD],
		has_clear_lead,
		drm_info->key_id,
		&stsd_writer_context);
	if (rc != VOD_OK)
	{
		vod_log_debug1(VOD_LOG_DEBUG_LEVEL, request_context->log, 0,
			"edash_packager_build_init_mp4: edash_packager_init_stsd_writer_context failed %i", rc);
		return rc;
	}

	// build the pssh writer
	pssh_atom_writer.atom_size = 0;
	for (cur_info = drm_info->pssh_array.first; cur_info < drm_info->pssh_array.last; cur_info++)
	{
		pssh_atom_writer.atom_size += ATOM_HEADER_SIZE + sizeof(pssh_atom_t) + cur_info->data.len;
	}
	pssh_atom_writer.write = edash_packager_write_pssh;
	pssh_atom_writer.context = &drm_info->pssh_array;

	// build the stsd writer
	stsd_atom_writer.atom_size = stsd_writer_context.stsd_atom_size;
	stsd_atom_writer.write = edash_packager_write_stsd;
	stsd_atom_writer.context = &stsd_writer_context;

	rc = dash_packager_build_init_mp4(
		request_context,
		media_set,
		size_only,
		&pssh_atom_writer,
		&stsd_atom_writer,
		result);
	if (rc != VOD_OK)
	{
		vod_log_debug1(VOD_LOG_DEBUG_LEVEL, request_context->log, 0,
			"edash_packager_build_init_mp4: dash_packager_build_init_mp4 failed %i", rc);
		return rc;
	}

	return VOD_OK;
}
예제 #2
0
static ngx_int_t
ngx_http_vod_dash_handle_init_segment(
	ngx_http_vod_submodule_context_t* submodule_context,
	ngx_str_t* response,
	ngx_str_t* content_type)
{
	vod_status_t rc;

	if (submodule_context->conf->drm_enabled)
	{
		rc = edash_packager_build_init_mp4(
			&submodule_context->request_context,
			&submodule_context->media_set,
			submodule_context->conf->drm_clear_lead_segment_count > 0,
			ngx_http_vod_submodule_size_only(submodule_context),
			response);
	}
	else
	{
		rc = dash_packager_build_init_mp4(
			&submodule_context->request_context,
			&submodule_context->media_set,
			ngx_http_vod_submodule_size_only(submodule_context),
			NULL,
			NULL,
			response);
	}

	if (rc != VOD_OK)
	{
		ngx_log_debug1(NGX_LOG_DEBUG_HTTP, submodule_context->request_context.log, 0,
			"ngx_http_vod_dash_handle_init_segment: (e)dash_packager_build_init_mp4 failed %i", rc);
		return ngx_http_vod_status_to_ngx_error(rc);
	}

	if (submodule_context->media_set.track_count[MEDIA_TYPE_VIDEO] != 0)
	{
		content_type->data = mp4_video_content_type;
		content_type->len = sizeof(mp4_video_content_type) - 1;
	}
	else
	{
		content_type->data = mp4_audio_content_type;
		content_type->len = sizeof(mp4_audio_content_type) - 1;
	}

	return NGX_OK;
}