diff --git a/headers/os/media/MediaEncoder.h b/headers/os/media/MediaEncoder.h
index 834bc73..dc44cbd 100644
--- a/headers/os/media/MediaEncoder.h
+++ b/headers/os/media/MediaEncoder.h
@@ -8,6 +8,17 @@
 
 #include <MediaFormats.h>
 
+namespace BPrivate {
+	class Encoder;
+}
+
+namespace BPrivate {
+	namespace media {
+		class Encoder;
+		class EncoderPlugin;
+	}
+}
+
 
 class BMediaEncoder {
 public:
@@ -65,6 +76,8 @@ private:
 			BMediaEncoder&		operator=(const BMediaEncoder& other);
 
 private:
+			status_t			_AttachToEncoder();
+
 	static	status_t			write_chunk(void* classPtr,
 									const void* buffer, size_t size,
 									media_encode_info* info);
@@ -73,7 +86,7 @@ private:
 			void				ReleaseEncoder();
 
 			uint32				_reserved_was_fEncoderMgr;
-			uint32				_reserved_was_fEncoder;
+			BPrivate::media::Encoder*	fEncoder;
 
 			int32				fEncoderID;
 			bool				fFormatValid;
diff --git a/headers/private/media/EncoderPlugin.h b/headers/private/media/EncoderPlugin.h
index dabcdf1..b5bc8c6 100644
--- a/headers/private/media/EncoderPlugin.h
+++ b/headers/private/media/EncoderPlugin.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2009, Haiku Inc. All rights reserved.
+ * Copyright 2009-2012, Haiku Inc. All rights reserved.
  * Distributed under the terms of the MIT license.
  */
 #ifndef _ENCODER_PLUGIN_H
@@ -122,6 +122,9 @@ public:
 	virtual	Encoder*			NewEncoder(
 									const media_codec_info& codecInfo) = 0;
 
+	virtual	Encoder*			NewEncoder(
+									const media_format& format) = 0;
+
 	virtual	status_t			RegisterNextEncoder(int32* cookie,
 									media_codec_info* codecInfo,
 									media_format_family* formatFamily,
diff --git a/headers/private/media/PluginManager.h b/headers/private/media/PluginManager.h
index d74cba3..5cca4e9 100644
--- a/headers/private/media/PluginManager.h
+++ b/headers/private/media/PluginManager.h
@@ -1,6 +1,7 @@
 /* 
  * Copyright 2004-2007, Marcus Overhagen. All rights reserved.
- * Distributed under the terms of the OpenBeOS License.
+ * Copyright 2012, Fredrik Modéen, firstnam@lastname.se.
+ * Distributed under the terms of the MIT License.
  */
 #ifndef _PLUGIN_MANAGER_H
 #define _PLUGIN_MANAGER_H
@@ -51,6 +52,10 @@ public:
 			status_t			CreateEncoder(Encoder** encoder,
 									const media_codec_info* codecInfo,
 									uint32 flags);
+									
+			status_t			CreateEncoder(Encoder** encoder, 
+									const media_format& format);
+			
 			void				DestroyEncoder(Encoder* encoder);
 	
 private:
diff --git a/headers/private/media/ServerInterface.h b/headers/private/media/ServerInterface.h
index 2c28980..3e423ce 100644
--- a/headers/private/media/ServerInterface.h
+++ b/headers/private/media/ServerInterface.h
@@ -1,6 +1,7 @@
 /*
  * Copyright 2002, Marcus Overhagen. All Rights Reserved.
  * Copyright 2009, Axel Dörfler, axeld@pinc-software.de.
+ * Copyright 2012, Fredrik Modéen, firstnam@lastname.se.
  * Distributed under the terms of the MIT License.
  */
 #ifndef _SERVER_INTERFACE_H_
@@ -78,10 +79,12 @@ enum {
 	SERVER_GET_DESCRIPTION_FOR_FORMAT,
 	SERVER_GET_READERS,
 	SERVER_GET_DECODER_FOR_FORMAT,
+	SERVER_GET_DECODER_FOR_CODEC_INFO,
 	SERVER_GET_WRITER_FOR_FORMAT_FAMILY,
 	SERVER_GET_FILE_FORMAT_FOR_COOKIE,
 	SERVER_GET_CODEC_INFO_FOR_COOKIE,
 	SERVER_GET_ENCODER_FOR_CODEC_INFO,
+	SERVER_GET_ENCODER_FOR_FORMAT,
 	SERVER_REGISTER_ADD_ON,
 	SERVER_UNREGISTER_ADD_ON,
 	SERVER_GET_ADD_ON_REF,
@@ -610,6 +613,15 @@ struct server_get_decoder_for_format_reply : reply_data {
 		// a ref to the decoder
 };
 
+struct server_get_decoder_for_codec_info_request : request_data {
+	int32					id;
+};
+
+struct server_get_decoder_for_codec_info_reply : reply_data {
+	xfer_entry_ref			ref;
+		// a ref to the encoder
+};
+
 struct server_get_encoder_for_codec_info_request : request_data {
 	int32					id;
 };
@@ -619,6 +631,15 @@ struct server_get_encoder_for_codec_info_reply : reply_data {
 		// a ref to the encoder
 };
 
+struct server_get_encoder_for_format_request : request_data {
+	media_format			format;
+};
+
+struct server_get_encoder_for_format_reply : reply_data {
+	xfer_entry_ref			ref;
+		// a ref to the decoder
+};
+
 struct server_get_readers_request : request_data {
 };
 
diff --git a/src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.cpp b/src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.cpp
index b17304b..f779fc1 100644
--- a/src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.cpp
+++ b/src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.cpp
@@ -156,6 +156,19 @@ FFmpegPlugin::NewEncoder(const media_codec_info& codecInfo)
 }
 
 
+Encoder*
+FFmpegPlugin::NewEncoder(const media_format& format)
+{
+/*	for (size_t i = 0; i < gEncoderCount; i++) {
+		if (codecInfo.sub_id == gEncoderTable[i].codec_info.sub_id) {
+			return new(std::nothrow)AVCodecEncoder(codecInfo.sub_id,
+				gEncoderTable[i].bit_rate_scale);
+		}
+	}*/
+	return NULL;
+}
+
+
 status_t
 FFmpegPlugin::RegisterNextEncoder(int32* cookie, media_codec_info* _codecInfo,
 	media_format_family* _formatFamily, media_format* _inputFormat,
diff --git a/src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.h b/src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.h
index ef37a5f..360a857 100644
--- a/src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.h
+++ b/src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.h
@@ -34,6 +34,9 @@ public:
 
 	virtual	Encoder*			NewEncoder(
 									const media_codec_info& codecInfo);
+	
+	virtual	Encoder*			NewEncoder(const media_format& format);
+	
 	virtual	status_t			RegisterNextEncoder(int32* cookie,
 									media_codec_info* codecInfo,
 									media_format_family* formatFamily,
diff --git a/src/kits/media/DataExchange.cpp b/src/kits/media/DataExchange.cpp
index dcf3eeb..a76c91b 100644
--- a/src/kits/media/DataExchange.cpp
+++ b/src/kits/media/DataExchange.cpp
@@ -1,5 +1,6 @@
 /*
  * Copyright 2002-2007, Marcus Overhagen. All rights reserved.
+ * Copyright 2012, Fredrik Modéen, [firstname]@[lastname].se.
  * Distributed under the terms of the MIT License.
  */
 
@@ -39,7 +40,8 @@ find_media_server_port()
 	if (sMediaServerPort < 0) {
 		TRACE("couldn't find sMediaServerPort\n");
 		sMediaServerPort = BAD_MEDIA_SERVER_PORT; // make this a unique number
-	}
+	} else
+		TRACE("Did find sMediaServerPort (%ld)\n", sMediaServerPort);
 }
 
 
@@ -50,7 +52,8 @@ find_media_addon_server_port()
 	if (sMediaAddonServerPort < 0) {
 		TRACE("couldn't find sMediaAddonServerPort\n");
 		sMediaAddonServerPort = BAD_MEDIA_ADDON_SERVER_PORT; // make this a unique number
-	}
+	} else
+		TRACE("Did find MediaAddonServerPort (%ld)\n", sMediaAddonServerPort);
 }
 
 
diff --git a/src/kits/media/MediaEncoder.cpp b/src/kits/media/MediaEncoder.cpp
index 6084920..1ee38d4 100644
--- a/src/kits/media/MediaEncoder.cpp
+++ b/src/kits/media/MediaEncoder.cpp
@@ -1,9 +1,17 @@
-/***********************************************************************
- * AUTHOR: Marcus Overhagen
- *   FILE: MediaEncoder.cpp
- *  DESCR: 
- ***********************************************************************/
+/*
+ * Copyright 2004-2007, Marcus Overhagen. All rights reserved.
+ * Copyright 2010, Oleg Krysenkov, beos344@mail.ru.
+ * Copyright 2012, Fredrik Modéen, [firstname]@[lastname].se.
+ * Distributed under the terms of the MIT License.
+ */
+
+/*TO DO SetTo, SetFormat, Enode Class*/
+
+
 #include <MediaEncoder.h>
+#include <EncoderPlugin.h>
+#include <PluginManager.h>
+#include <new>
 #include "debug.h"
 
 
@@ -12,50 +20,95 @@
  *************************************************************/
 
 BMediaEncoder::BMediaEncoder()
+	:	fEncoder(NULL),
+		fInitStatus(B_NO_INIT)
 {
-	UNIMPLEMENTED();
+
 }
 
 
 BMediaEncoder::BMediaEncoder(const media_format *output_format)
+	:	fEncoder(NULL),
+		fInitStatus(B_NO_INIT)
 {
-	UNIMPLEMENTED();
+	SetTo(output_format);
 }
 
 
 BMediaEncoder::BMediaEncoder(const media_codec_info *mci)
+	:	fEncoder(NULL),
+		fInitStatus(B_NO_INIT)
 {
-	UNIMPLEMENTED();
+	SetTo(mci);
 }
 
 
 /* virtual */
 BMediaEncoder::~BMediaEncoder()
 {
-	UNIMPLEMENTED();
+	gPluginManager.DestroyEncoder(fEncoder);
+	fEncoder = NULL;
 }
 
 
 status_t 
 BMediaEncoder::InitCheck() const
 {
-	UNIMPLEMENTED();
-
-	return B_OK;
+	return fInitStatus;
 }
 
+
 status_t 
 BMediaEncoder::SetTo(const media_format *output_format)
 {
-	UNIMPLEMENTED();
+	gPluginManager.DestroyEncoder(fEncoder);
+	fEncoder = NULL;
+
+	status_t err = gPluginManager.CreateEncoder(&fEncoder, *output_format);
+	if (err < B_OK)
+		goto fail;
+
+	err = _AttachToEncoder();
+	if (err < B_OK)
+		goto fail;
+
+/*	err = SetFormat(NULL, output_format); //Looked at BMediaDecoder
+	if (err < B_OK)
+		goto fail;
+*/
+	fInitStatus = B_OK;
 	return B_OK;
+
+fail:
+	gPluginManager.DestroyEncoder(fEncoder);
+	fEncoder = NULL;
+	fInitStatus = B_NO_INIT;
+	return err;
 }
 
+
 status_t 
 BMediaEncoder::SetTo(const media_codec_info *mci)
 {
-	UNIMPLEMENTED();
+	gPluginManager.DestroyEncoder(fEncoder);
+	fEncoder = NULL;
+
+	status_t err = gPluginManager.CreateEncoder(&fEncoder, mci, 0);
+	if (err < B_OK)
+		goto fail;
+
+	err = _AttachToEncoder();
+	if (err < B_OK)
+		goto fail;
+
+	fInitStatus = B_OK;
 	return B_OK;
+
+fail:
+	gPluginManager.DestroyEncoder(fEncoder);
+	fEncoder = NULL;
+	fInitStatus = B_NO_INIT;
+	return err;
 }
 
 
@@ -64,33 +117,52 @@ BMediaEncoder::SetFormat(media_format *input_format,
 						 media_format *output_format,
 						 media_file_format *mfi)
 {
-	UNIMPLEMENTED();
-	return B_OK;
+	TRACE("BMediaEncoder::SetFormat. Input = %d, Output = %d\n",
+		input_format->type, output_format->type);
+	
+	if (!fEncoder)
+		return B_NO_INIT;
+
+	UNIMPLEMENTED();	
+
+//	media_format in_format = *input_format;
+//	media_format out_format = *output_format;
+	
+//	fEncoder->Setup(input_format, output_format, mfi);
+	
+	return B_OK; 
 }
 
+
 status_t 
 BMediaEncoder::Encode(const void *buffer, 
 					  int64 frame_count,
 					  media_encode_info *info)
 {
-	UNIMPLEMENTED();
-	return B_OK;
+	if (!fEncoder)
+		return B_NO_INIT;
+
+	return fEncoder->Encode(buffer, frame_count, info);
 }
 
 
 status_t 
 BMediaEncoder::GetEncodeParameters(encode_parameters *parameters) const
 {
-	UNIMPLEMENTED();
-	return B_OK;
+	if (fEncoder == NULL)
+		return B_NO_INIT;
+	else 
+		return fEncoder->GetEncodeParameters(parameters);
 }
 
 
 status_t 
 BMediaEncoder::SetEncodeParameters(encode_parameters *parameters)
 {
-	UNIMPLEMENTED();
-	return B_OK;
+	if (fEncoder == NULL)
+		return B_NO_INIT;
+	else 
+		return fEncoder->SetEncodeParameters(parameters);
 }
 
 
@@ -101,8 +173,10 @@ BMediaEncoder::SetEncodeParameters(encode_parameters *parameters)
 /* virtual */ status_t 
 BMediaEncoder::AddTrackInfo(uint32 code, const char *data, size_t size)
 {
-	UNIMPLEMENTED();
-	return B_OK;
+	if (fEncoder == NULL)
+		return B_NO_INIT;
+	else 
+		return fEncoder->AddTrackInfo(code, data, size);
 }
 
 
@@ -140,6 +214,33 @@ BMediaEncoder::ReleaseEncoder()
 	UNIMPLEMENTED();
 }
 
+
+status_t
+BMediaEncoder::_AttachToEncoder()
+{
+	class MediaEncoderChunkWriter : public ChunkWriter {
+	private:
+		BMediaEncoder* fEncoder;
+	public:
+		MediaEncoderChunkWriter(BMediaEncoder* encoder) 
+		{
+			fEncoder = encoder;
+		}
+		virtual status_t WriteChunk(const void* chunkBuffer, size_t chunkSize,
+									media_encode_info* encodeInfo) 
+		{
+			return fEncoder->WriteChunk(chunkBuffer, chunkSize, encodeInfo);
+		}
+	}* writer = new(std::nothrow) MediaEncoderChunkWriter(this);
+	
+	if (!writer)
+		return B_NO_MEMORY;
+	
+	fEncoder->SetChunkWriter(writer);
+	return B_OK;
+}
+
+
 status_t BMediaEncoder::_Reserved_BMediaEncoder_0(int32 arg, ...) { return B_ERROR; }
 status_t BMediaEncoder::_Reserved_BMediaEncoder_1(int32 arg, ...) { return B_ERROR; }
 status_t BMediaEncoder::_Reserved_BMediaEncoder_2(int32 arg, ...) { return B_ERROR; }
@@ -162,20 +263,26 @@ status_t BMediaEncoder::_Reserved_BMediaEncoder_15(int32 arg, ...) { return B_ER
  *************************************************************/
 
 BMediaBufferEncoder::BMediaBufferEncoder()
+	:	BMediaEncoder(),
+		fBuffer(NULL)
 {
-	UNIMPLEMENTED();
+
 }
 
 
 BMediaBufferEncoder::BMediaBufferEncoder(const media_format *output_format)
+	:	BMediaEncoder(output_format), 
+		fBuffer(NULL)
 {
-	UNIMPLEMENTED();
+
 }
 
 
 BMediaBufferEncoder::BMediaBufferEncoder(const media_codec_info *mci)
+	:	BMediaEncoder(mci), 
+		fBuffer(NULL)
 {
-	UNIMPLEMENTED();
+
 }
 
 
@@ -186,9 +293,17 @@ BMediaBufferEncoder::EncodeToBuffer(void *output_buffer,
 									int64 frame_count,
 									media_encode_info *info)
 {
-	UNIMPLEMENTED();
-
-	return B_ERROR;
+	status_t error;
+	fBuffer = output_buffer;
+	fBufferSize = *output_size;
+	error = Encode(input_buffer, frame_count, info);
+	if (fBuffer) {
+		fBuffer = NULL;
+		*output_size = 0;
+	} else {
+		*output_size = fBufferSize;
+	}
+	return error;
 }
 
 
@@ -201,9 +316,20 @@ BMediaBufferEncoder::WriteChunk(const void *chunk_data,
 								size_t chunk_len,
 								media_encode_info *info)
 {
-	UNIMPLEMENTED();
-
-	return B_ERROR;
+	if (fBuffer == NULL)
+		return B_ENTRY_NOT_FOUND;
+	
+	if ((ssize_t)chunk_len < 0)
+		return B_ERROR;
+	
+	if (chunk_len > (size_t)fBufferSize) {
+		memcpy(fBuffer, chunk_data, fBufferSize);
+		fBuffer = NULL;
+		return B_DEVICE_FULL;
+	}
+	
+	memcpy(fBuffer, chunk_data, chunk_len);
+	fBufferSize = chunk_len;
+	fBuffer = NULL;
+	return B_NO_ERROR;
 }
-
-
diff --git a/src/kits/media/PluginManager.cpp b/src/kits/media/PluginManager.cpp
index ffb816d..5dea9a0 100644
--- a/src/kits/media/PluginManager.cpp
+++ b/src/kits/media/PluginManager.cpp
@@ -1,6 +1,7 @@
 /* 
  * Copyright 2004-2010, Marcus Overhagen. All rights reserved.
- * Distributed under the terms of the OpenBeOS License.
+ * Copyright 2012, Fredrik Modéen, [firstname]@[lastname].se.
+ * Distributed under the terms of the MIT License.
  */
 
 #include <Path.h>
@@ -26,7 +27,7 @@ PluginManager::CreateReader(Reader** reader, int32* streamCount,
 
 	BPositionIO *seekable_source = dynamic_cast<BPositionIO *>(source);
 	if (seekable_source == 0) {
-		printf("PluginManager::CreateReader: non-seekable sources not "
+		ERROR("PluginManager::CreateReader: non-seekable sources not "
 			"supported yet\n");
 		return B_ERROR;
 	}
@@ -37,7 +38,7 @@ PluginManager::CreateReader(Reader** reader, int32* streamCount,
 	status_t ret = QueryServer(SERVER_GET_READERS, &request, sizeof(request),
 		&reply, sizeof(reply));
 	if (ret != B_OK) {
-		printf("PluginManager::CreateReader: can't get list of readers: %s\n",
+		ERROR("PluginManager::CreateReader: can't get list of readers: %s\n",
 			strerror(ret));
 		return ret;
 	}
@@ -47,20 +48,20 @@ PluginManager::CreateReader(Reader** reader, int32* streamCount,
 		entry_ref ref = reply.ref[i];
 		MediaPlugin* plugin = GetPlugin(ref);
 		if (plugin == NULL) {
-			printf("PluginManager::CreateReader: GetPlugin failed\n");
+			ERROR("PluginManager::CreateReader: GetPlugin failed\n");
 			return B_ERROR;
 		}
 
 		ReaderPlugin* readerPlugin = dynamic_cast<ReaderPlugin*>(plugin);
 		if (readerPlugin == NULL) {
-			printf("PluginManager::CreateReader: dynamic_cast failed\n");
+			ERROR("PluginManager::CreateReader: dynamic_cast failed\n");
 			PutPlugin(plugin);
 			return B_ERROR;
 		}
 
 		*reader = readerPlugin->NewReader();
 		if (*reader == NULL) {
-			printf("PluginManager::CreateReader: NewReader failed\n");
+			ERROR("PluginManager::CreateReader: NewReader failed\n");
 			PutPlugin(plugin);
 			return B_ERROR;
 		}
@@ -113,20 +114,20 @@ PluginManager::CreateDecoder(Decoder** _decoder, const media_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: "
+		ERROR("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");
+		ERROR("PluginManager::CreateDecoder: GetPlugin failed\n");
 		return B_ERROR;
 	}
 	
 	DecoderPlugin* decoderPlugin = dynamic_cast<DecoderPlugin*>(plugin);
 	if (decoderPlugin == NULL) {
-		printf("PluginManager::CreateDecoder: dynamic_cast failed\n");
+		ERROR("PluginManager::CreateDecoder: dynamic_cast failed\n");
 		PutPlugin(plugin);
 		return B_ERROR;
 	}
@@ -135,7 +136,7 @@ PluginManager::CreateDecoder(Decoder** _decoder, const media_format& format)
 	// but this is not yet handled (passing "0" as index/ID).
 	*_decoder = decoderPlugin->NewDecoder(0);
 	if (*_decoder == NULL) {
-		printf("PluginManager::CreateDecoder: NewDecoder() failed\n");
+		ERROR("PluginManager::CreateDecoder: NewDecoder() failed\n");
 		PutPlugin(plugin);
 		return B_ERROR;
 	}
@@ -151,9 +152,50 @@ PluginManager::CreateDecoder(Decoder** _decoder, const media_format& format)
 status_t
 PluginManager::CreateDecoder(Decoder** decoder, const media_codec_info& mci)
 {
-	// TODO
+	TRACE("PluginManager::CreateDecoder enter\n");
+
+	// get decoder for this format from the server
+	server_get_decoder_for_codec_info_request request;
+	server_get_decoder_for_codec_info_reply reply;
+	request.id = mci.id;
+	status_t ret = QueryServer(SERVER_GET_DECODER_FOR_CODEC_INFO, &request,
+		sizeof(request), &reply, sizeof(reply));
+	if (ret != B_OK) {
+		ERROR("PluginManager::CreateDecoder: can't get decoder for format: "
+			"%s\n", strerror(ret));
+		return ret;
+	}
+
+	MediaPlugin* plugin = GetPlugin(reply.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;
+/*	// TODO
 	debugger("not implemented");
-	return B_ERROR;
+	return B_ERROR;*/
 }
 
 
@@ -203,27 +245,27 @@ PluginManager::CreateWriter(Writer** writer, const media_file_format& mff,
 	status_t ret = QueryServer(SERVER_GET_WRITER_FOR_FORMAT_FAMILY, &request,
 		sizeof(request), &reply, sizeof(reply));
 	if (ret != B_OK) {
-		printf("PluginManager::CreateWriter: can't get writer for file "
+		ERROR("PluginManager::CreateWriter: can't get writer for file "
 			"family: %s\n", strerror(ret));
 		return ret;
 	}
 
 	MediaPlugin* plugin = GetPlugin(reply.ref);
 	if (plugin == NULL) {
-		printf("PluginManager::CreateWriter: GetPlugin failed\n");
+		ERROR("PluginManager::CreateWriter: GetPlugin failed\n");
 		return B_ERROR;
 	}
 
 	WriterPlugin* writerPlugin = dynamic_cast<WriterPlugin*>(plugin);
 	if (writerPlugin == NULL) {
-		printf("PluginManager::CreateWriter: dynamic_cast failed\n");
+		ERROR("PluginManager::CreateWriter: dynamic_cast failed\n");
 		PutPlugin(plugin);
 		return B_ERROR;
 	}
 
 	*writer = writerPlugin->NewWriter();
 	if (*writer == NULL) {
-		printf("PluginManager::CreateWriter: NewWriter failed\n");
+		ERROR("PluginManager::CreateWriter: NewWriter failed\n");
 		PutPlugin(plugin);
 		return B_ERROR;
 	}
@@ -253,7 +295,7 @@ PluginManager::DestroyWriter(Writer* writer)
 
 
 status_t
-PluginManager::CreateEncoder(Encoder** _encoder,
+PluginManager::CreateEncoder(Encoder** encoder,
 	const media_codec_info* codecInfo, uint32 flags)
 {
 	TRACE("PluginManager::CreateEncoder enter\n");
@@ -265,32 +307,32 @@ PluginManager::CreateEncoder(Encoder** _encoder,
 	status_t ret = QueryServer(SERVER_GET_ENCODER_FOR_CODEC_INFO, &request,
 		sizeof(request), &reply, sizeof(reply));
 	if (ret != B_OK) {
-		printf("PluginManager::CreateEncoder: can't get encoder for codec %s: "
+		ERROR("PluginManager::CreateEncoder: can't get encoder for codec %s: "
 			"%s\n", codecInfo->pretty_name, strerror(ret));
 		return ret;
 	}
 
 	MediaPlugin* plugin = GetPlugin(reply.ref);
 	if (!plugin) {
-		printf("PluginManager::CreateEncoder: GetPlugin failed\n");
+		ERROR("PluginManager::CreateEncoder: GetPlugin failed\n");
 		return B_ERROR;
 	}
 	
 	EncoderPlugin* encoderPlugin = dynamic_cast<EncoderPlugin*>(plugin);
 	if (encoderPlugin == NULL) {
-		printf("PluginManager::CreateEncoder: dynamic_cast failed\n");
+		ERROR("PluginManager::CreateEncoder: dynamic_cast failed\n");
 		PutPlugin(plugin);
 		return B_ERROR;
 	}
 
-	*_encoder = encoderPlugin->NewEncoder(*codecInfo);
-	if (*_encoder == NULL) {
-		printf("PluginManager::CreateEncoder: NewEncoder() failed\n");
+	*encoder = encoderPlugin->NewEncoder(*codecInfo);
+	if (*encoder == NULL) {
+		ERROR("PluginManager::CreateEncoder: NewEncoder() failed\n");
 		PutPlugin(plugin);
 		return B_ERROR;
 	}
-	TRACE("  created encoder: %p\n", *_encoder);
-	(*_encoder)->fMediaPlugin = plugin;
+	TRACE("  created encoder: %p\n", *encoder);
+	(*encoder)->fMediaPlugin = plugin;
 
 	TRACE("PluginManager::CreateEncoder leave\n");
 
@@ -298,6 +340,51 @@ PluginManager::CreateEncoder(Encoder** _encoder,
 }
 
 
+status_t
+PluginManager::CreateEncoder(Encoder** encoder, const media_format& format)
+{
+	TRACE("PluginManager::CreateEncoder enter nr2\n");
+	// Get encoder for this codec info from the server
+	server_get_encoder_for_format_request request;
+	server_get_encoder_for_format_reply reply;
+	request.format = format;
+	status_t ret = QueryServer(SERVER_GET_ENCODER_FOR_FORMAT, &request,
+		sizeof(request), &reply, sizeof(reply));
+	if (ret != B_OK) {
+		ERROR("PluginManager::CreateEncoder: can't get decoder for format: "
+			"%s\n", strerror(ret));
+		return ret;
+	}
+
+	MediaPlugin* plugin = GetPlugin(reply.ref);
+	if (plugin == NULL) {
+		ERROR("PluginManager::CreateEncoder: GetPlugin failed\n");
+		return B_ERROR;
+	}
+	
+	EncoderPlugin* encoderPlugin = dynamic_cast<EncoderPlugin*>(plugin);
+	if (encoderPlugin == NULL) {
+		ERROR("PluginManager::CreateEncoder: dynamic_cast failed\n");
+		PutPlugin(plugin);
+		return B_ERROR;
+	}
+
+	
+	*encoder = encoderPlugin->NewEncoder(format);
+	if (*encoder == NULL) {
+		ERROR("PluginManager::CreateEncoder: NewEncoder() failed\n");
+		PutPlugin(plugin);
+		return B_ERROR;
+	}
+	TRACE("  created encoder: %p\n", *encoder);
+	(*encoder)->fMediaPlugin = plugin;
+	
+	TRACE("PluginManager::CreateEncoder leave nr2\n");
+
+	return B_OK;
+}
+
+
 void
 PluginManager::DestroyEncoder(Encoder* encoder)
 {
@@ -332,7 +419,7 @@ PluginManager::~PluginManager()
 	for (int i = fPluginList.CountItems() - 1; i >= 0; i--) {
 		plugin_info* info = NULL;
 		fPluginList.Get(i, &info);
-		printf("PluginManager: Error, unloading PlugIn %s with usecount "
+		ERROR("PluginManager: Error, unloading PlugIn %s with usecount "
 			"%d\n", info->name, info->usecount);
 		delete info->plugin;
 		unload_add_on(info->image);
@@ -361,7 +448,7 @@ PluginManager::GetPlugin(const entry_ref& ref)
 	}
 
 	if (_LoadPlugin(ref, &info.plugin, &info.image) < B_OK) {
-		printf("PluginManager: Error, loading PlugIn %s failed\n", ref.name);
+		ERROR("PluginManager: Error, loading PlugIn %s failed\n", ref.name);
 		fLocker.Unlock();
 		return NULL;
 	}
@@ -403,7 +490,7 @@ PluginManager::PutPlugin(MediaPlugin* plugin)
 		}
 	}
 	
-	printf("PluginManager: Error, can't put PlugIn %p\n", plugin);
+	ERROR("PluginManager: Error, can't put PlugIn %p\n", plugin);
 	
 	fLocker.Unlock();
 }
@@ -420,7 +507,7 @@ PluginManager::_LoadPlugin(const entry_ref& ref, MediaPlugin** plugin,
 	image_id id;
 	id = load_add_on(p.Path());
 	if (id < 0) {
-		printf("PluginManager: Error, load_add_on(): %s\n", strerror(id));
+		ERROR("PluginManager: Error, load_add_on(): %s\n", strerror(id));
 		return B_ERROR;
 	}
 		
@@ -428,7 +515,7 @@ PluginManager::_LoadPlugin(const entry_ref& ref, MediaPlugin** plugin,
 	
 	if (get_image_symbol(id, "instantiate_plugin", B_SYMBOL_TYPE_TEXT,
 			(void**)&instantiate_plugin_func) < B_OK) {
-		printf("PluginManager: Error, _LoadPlugin can't find "
+		ERROR("PluginManager: Error, _LoadPlugin can't find "
 			"instantiate_plugin in %s\n", p.Path());
 		unload_add_on(id);
 		return B_ERROR;
@@ -438,7 +525,7 @@ PluginManager::_LoadPlugin(const entry_ref& ref, MediaPlugin** plugin,
 	
 	pl = (*instantiate_plugin_func)();
 	if (pl == NULL) {
-		printf("PluginManager: Error, _LoadPlugin instantiate_plugin in %s "
+		ERROR("PluginManager: Error, _LoadPlugin instantiate_plugin in %s "
 			"returned NULL\n", p.Path());
 		unload_add_on(id);
 		return B_ERROR;
diff --git a/src/servers/media/media_server.cpp b/src/servers/media/media_server.cpp
index fd51cf77..80dbaab 100644
--- a/src/servers/media/media_server.cpp
+++ b/src/servers/media/media_server.cpp
@@ -896,6 +896,18 @@ ServerApp::_HandleMessage(int32 code, const void* data, size_t size)
 			request.SendReply(status, &reply, sizeof(reply));
 			break;
 		}
+		
+		case SERVER_GET_DECODER_FOR_CODEC_INFO:
+		{
+			const server_get_decoder_for_codec_info_request& request
+				= *static_cast<
+					const server_get_decoder_for_codec_info_request*>(data);
+			server_get_decoder_for_codec_info_reply reply;
+			
+			status_t status = gAddOnManager->GetEncoder(&reply.ref, request.id);
+			request.SendReply(status, &reply, sizeof(reply));
+			break;
+		}
 
 		case SERVER_GET_DECODER_FOR_FORMAT:
 		{
@@ -946,6 +958,19 @@ ServerApp::_HandleMessage(int32 code, const void* data, size_t size)
 			request.SendReply(status, &reply, sizeof(reply));
 			break;
 		}
+		
+		case SERVER_GET_ENCODER_FOR_FORMAT:
+		{
+			const server_get_encoder_for_format_request& request
+				= *static_cast<
+					const server_get_encoder_for_format_request*>(data);
+			server_get_encoder_for_format_reply reply;
+
+			status_t status = gAddOnManager->GetDecoderForFormat(&reply.ref,
+				request.format);
+			request.SendReply(status, &reply, sizeof(reply));
+			break;
+		}
 
 		case SERVER_GET_ENCODER_FOR_CODEC_INFO:
 		{
@@ -953,6 +978,7 @@ ServerApp::_HandleMessage(int32 code, const void* data, size_t size)
 				= *static_cast<
 					const server_get_encoder_for_codec_info_request*>(data);
 			server_get_encoder_for_codec_info_reply reply;
+			
 			status_t status = gAddOnManager->GetEncoder(&reply.ref, request.id);
 			request.SendReply(status, &reply, sizeof(reply));
 			break;
