Example #1
0
status_t
PluginManager::CreateDecoder(Decoder** _decoder, const media_format& format)
{
	TRACE("PluginManager::CreateDecoder enter\n");

	// get decoder for this format from the server
	server_get_decoder_for_format_request request;
	server_get_decoder_for_format_reply reply;
	request.format = format;
	status_t ret = QueryServer(SERVER_GET_DECODER_FOR_FORMAT, &request,
		sizeof(request), &reply, sizeof(reply));
	if (ret != B_OK) {
		printf("PluginManager::CreateDecoder: can't get decoder for format: "
			"%s\n", strerror(ret));
		return ret;
	}

	MediaPlugin* plugin = GetPlugin(reply.ref);
	if (plugin == NULL) {
		printf("PluginManager::CreateDecoder: GetPlugin failed\n");
		return B_ERROR;
	}
	
	DecoderPlugin* decoderPlugin = dynamic_cast<DecoderPlugin*>(plugin);
	if (decoderPlugin == NULL) {
		printf("PluginManager::CreateDecoder: dynamic_cast failed\n");
		PutPlugin(plugin);
		return B_ERROR;
	}
	
	// TODO: In theory, one DecoderPlugin could support multiple Decoders,
	// but this is not yet handled (passing "0" as index/ID).
	*_decoder = decoderPlugin->NewDecoder(0);
	if (*_decoder == NULL) {
		printf("PluginManager::CreateDecoder: NewDecoder() failed\n");
		PutPlugin(plugin);
		return B_ERROR;
	}
	TRACE("  created decoder: %p\n", *_decoder);
	(*_decoder)->fMediaPlugin = plugin;

	TRACE("PluginManager::CreateDecoder leave\n");

	return B_OK;
}
Example #2
0
status_t
PluginManager::CreateDecoder(Decoder** _decoder, const media_format& format)
{
	TRACE("PluginManager::CreateDecoder enter\n");

	// get decoder for this format
	entry_ref ref;
	status_t ret = AddOnManager::GetInstance()->GetDecoderForFormat(
		&ref, format);
	if (ret != B_OK) {
		printf("PluginManager::CreateDecoder: can't get decoder for format: "
			"%s\n", strerror(ret));
		return ret;
	}

	MediaPlugin* plugin = GetPlugin(ref);
	if (plugin == NULL) {
		printf("PluginManager::CreateDecoder: GetPlugin failed\n");
		return B_ERROR;
	}
	
	DecoderPlugin* decoderPlugin = dynamic_cast<DecoderPlugin*>(plugin);
	if (decoderPlugin == NULL) {
		printf("PluginManager::CreateDecoder: dynamic_cast failed\n");
		PutPlugin(plugin);
		return B_ERROR;
	}
	
	// TODO: In theory, one DecoderPlugin could support multiple Decoders,
	// but this is not yet handled (passing "0" as index/ID).
	*_decoder = decoderPlugin->NewDecoder(0);
	if (*_decoder == NULL) {
		printf("PluginManager::CreateDecoder: NewDecoder() failed\n");
		PutPlugin(plugin);
		return B_ERROR;
	}
	TRACE("  created decoder: %p\n", *_decoder);
	(*_decoder)->fMediaPlugin = plugin;

	TRACE("PluginManager::CreateDecoder leave\n");

	return B_OK;
}
Example #3
0
// ask the server for a good decoder for the arguments
// GETS THE CODEC for mci->id, mci->sub_id
// fails if the mci->id = 0
status_t 
BMediaDecoder::SetTo(const media_codec_info *mci)
{
	fInitStatus = B_NO_INIT;
	delete fDecoder;
	DecoderPlugin * plugin = GetDecoderPlugin(mci->id);
	if (plugin == NULL) {
		return fInitStatus = B_ERROR;
	}
	Decoder * decoder = plugin->NewDecoder(0);
	if (decoder == NULL) {
		return fInitStatus = B_ERROR;
	}
	fDecoder = decoder;
	fDecoderID = mci->sub_id;
	if ((fInitStatus = AttachToDecoder()) != B_OK) {
		return fInitStatus;
	}
	return fInitStatus;
}
Example #4
0
status_t
PluginManager::CreateDecoder(Decoder** decoder, const media_codec_info& mci)
{
	TRACE("PluginManager::CreateDecoder enter\n");
	entry_ref ref;
	status_t status = AddOnManager::GetInstance()->GetEncoder(&ref, mci.id);
	if (status != B_OK)
		return status;

	MediaPlugin* plugin = GetPlugin(ref);
	if (plugin == NULL) {
		ERROR("PluginManager::CreateDecoder: GetPlugin failed\n");
		return B_ERROR;
	}

	DecoderPlugin* decoderPlugin = dynamic_cast<DecoderPlugin*>(plugin);
	if (decoderPlugin == NULL) {
		ERROR("PluginManager::CreateDecoder: dynamic_cast failed\n");
		PutPlugin(plugin);
		return B_ERROR;
	}

	// TODO: In theory, one DecoderPlugin could support multiple Decoders,
	// but this is not yet handled (passing "0" as index/ID).
	*decoder = decoderPlugin->NewDecoder(0);
	if (*decoder == NULL) {
		ERROR("PluginManager::CreateDecoder: NewDecoder() failed\n");
		PutPlugin(plugin);
		return B_ERROR;
	}
	TRACE("  created decoder: %p\n", *decoder);
	(*decoder)->fMediaPlugin = plugin;

	TRACE("PluginManager::CreateDecoder leave\n");

	return B_OK;

}
Example #5
0
// ask the server for a good decoder for the arguments
// GETS THE CODEC for in_format->type + in_format->u.x.encoding
status_t 
BMediaDecoder::SetTo(const media_format *in_format,
					 const void *info,
					 size_t info_size)
{
	fNeedsInit = false;
	fInitStatus = B_NO_INIT;
	delete fDecoder;
	DecoderPlugin * plugin = GetDecoderPlugin(in_format);
	if (plugin == NULL) {
		return fInitStatus = B_ERROR;
	}
	Decoder * decoder = plugin->NewDecoder(0);
	if (decoder == NULL) {
		return fInitStatus = B_ERROR;
	}
	fDecoder = decoder;
//	fDecoderID = mci->sub_id;
	if ((fInitStatus = AttachToDecoder()) != B_OK) {
		return fInitStatus;
	}
	fInitStatus = SetInputFormat(in_format,info,info_size);
	return fInitStatus;
}