Ticket #2970: media.2.diff
File media.2.diff, 25.8 KB (added by , 12 years ago) |
---|
-
headers/os/media/MediaEncoder.h
diff --git a/headers/os/media/MediaEncoder.h b/headers/os/media/MediaEncoder.h index 834bc73..dc44cbd 100644
a b 8 8 9 9 #include <MediaFormats.h> 10 10 11 namespace BPrivate { 12 class Encoder; 13 } 14 15 namespace BPrivate { 16 namespace media { 17 class Encoder; 18 class EncoderPlugin; 19 } 20 } 21 11 22 12 23 class BMediaEncoder { 13 24 public: … … private: 65 76 BMediaEncoder& operator=(const BMediaEncoder& other); 66 77 67 78 private: 79 status_t _AttachToEncoder(); 80 68 81 static status_t write_chunk(void* classPtr, 69 82 const void* buffer, size_t size, 70 83 media_encode_info* info); … … private: 73 86 void ReleaseEncoder(); 74 87 75 88 uint32 _reserved_was_fEncoderMgr; 76 uint32 _reserved_was_fEncoder;89 BPrivate::media::Encoder* fEncoder; 77 90 78 91 int32 fEncoderID; 79 92 bool fFormatValid; -
headers/private/media/EncoderPlugin.h
diff --git a/headers/private/media/EncoderPlugin.h b/headers/private/media/EncoderPlugin.h index dabcdf1..b5bc8c6 100644
a b 1 1 /* 2 * Copyright 2009 , Haiku Inc. All rights reserved.2 * Copyright 2009-2012, Haiku Inc. All rights reserved. 3 3 * Distributed under the terms of the MIT license. 4 4 */ 5 5 #ifndef _ENCODER_PLUGIN_H … … public: 122 122 virtual Encoder* NewEncoder( 123 123 const media_codec_info& codecInfo) = 0; 124 124 125 virtual Encoder* NewEncoder( 126 const media_format& format) = 0; 127 125 128 virtual status_t RegisterNextEncoder(int32* cookie, 126 129 media_codec_info* codecInfo, 127 130 media_format_family* formatFamily, -
headers/private/media/PluginManager.h
diff --git a/headers/private/media/PluginManager.h b/headers/private/media/PluginManager.h index d74cba3..5cca4e9 100644
a b 1 1 /* 2 2 * Copyright 2004-2007, Marcus Overhagen. All rights reserved. 3 * Distributed under the terms of the OpenBeOS License. 3 * Copyright 2012, Fredrik Modéen, firstnam@lastname.se. 4 * Distributed under the terms of the MIT License. 4 5 */ 5 6 #ifndef _PLUGIN_MANAGER_H 6 7 #define _PLUGIN_MANAGER_H … … public: 51 52 status_t CreateEncoder(Encoder** encoder, 52 53 const media_codec_info* codecInfo, 53 54 uint32 flags); 55 56 status_t CreateEncoder(Encoder** encoder, 57 const media_format& format); 58 54 59 void DestroyEncoder(Encoder* encoder); 55 60 56 61 private: -
headers/private/media/ServerInterface.h
diff --git a/headers/private/media/ServerInterface.h b/headers/private/media/ServerInterface.h index 2c28980..3e423ce 100644
a b 1 1 /* 2 2 * Copyright 2002, Marcus Overhagen. All Rights Reserved. 3 3 * Copyright 2009, Axel Dörfler, axeld@pinc-software.de. 4 * Copyright 2012, Fredrik Modéen, firstnam@lastname.se. 4 5 * Distributed under the terms of the MIT License. 5 6 */ 6 7 #ifndef _SERVER_INTERFACE_H_ … … enum { 78 79 SERVER_GET_DESCRIPTION_FOR_FORMAT, 79 80 SERVER_GET_READERS, 80 81 SERVER_GET_DECODER_FOR_FORMAT, 82 SERVER_GET_DECODER_FOR_CODEC_INFO, 81 83 SERVER_GET_WRITER_FOR_FORMAT_FAMILY, 82 84 SERVER_GET_FILE_FORMAT_FOR_COOKIE, 83 85 SERVER_GET_CODEC_INFO_FOR_COOKIE, 84 86 SERVER_GET_ENCODER_FOR_CODEC_INFO, 87 SERVER_GET_ENCODER_FOR_FORMAT, 85 88 SERVER_REGISTER_ADD_ON, 86 89 SERVER_UNREGISTER_ADD_ON, 87 90 SERVER_GET_ADD_ON_REF, … … struct server_get_decoder_for_format_reply : reply_data { 610 613 // a ref to the decoder 611 614 }; 612 615 616 struct server_get_decoder_for_codec_info_request : request_data { 617 int32 id; 618 }; 619 620 struct server_get_decoder_for_codec_info_reply : reply_data { 621 xfer_entry_ref ref; 622 // a ref to the encoder 623 }; 624 613 625 struct server_get_encoder_for_codec_info_request : request_data { 614 626 int32 id; 615 627 }; … … struct server_get_encoder_for_codec_info_reply : reply_data { 619 631 // a ref to the encoder 620 632 }; 621 633 634 struct server_get_encoder_for_format_request : request_data { 635 media_format format; 636 }; 637 638 struct server_get_encoder_for_format_reply : reply_data { 639 xfer_entry_ref ref; 640 // a ref to the decoder 641 }; 642 622 643 struct server_get_readers_request : request_data { 623 644 }; 624 645 -
src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.cpp
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 b FFmpegPlugin::NewEncoder(const media_codec_info& codecInfo) 156 156 } 157 157 158 158 159 Encoder* 160 FFmpegPlugin::NewEncoder(const media_format& format) 161 { 162 /* for (size_t i = 0; i < gEncoderCount; i++) { 163 if (codecInfo.sub_id == gEncoderTable[i].codec_info.sub_id) { 164 return new(std::nothrow)AVCodecEncoder(codecInfo.sub_id, 165 gEncoderTable[i].bit_rate_scale); 166 } 167 }*/ 168 return NULL; 169 } 170 171 159 172 status_t 160 173 FFmpegPlugin::RegisterNextEncoder(int32* cookie, media_codec_info* _codecInfo, 161 174 media_format_family* _formatFamily, media_format* _inputFormat, -
src/add-ons/media/plugins/ffmpeg/FFmpegPlugin.h
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 b public: 34 34 35 35 virtual Encoder* NewEncoder( 36 36 const media_codec_info& codecInfo); 37 38 virtual Encoder* NewEncoder(const media_format& format); 39 37 40 virtual status_t RegisterNextEncoder(int32* cookie, 38 41 media_codec_info* codecInfo, 39 42 media_format_family* formatFamily, -
src/kits/media/DataExchange.cpp
diff --git a/src/kits/media/DataExchange.cpp b/src/kits/media/DataExchange.cpp index dcf3eeb..a76c91b 100644
a b 1 1 /* 2 2 * Copyright 2002-2007, Marcus Overhagen. All rights reserved. 3 * Copyright 2012, Fredrik Modéen, [firstname]@[lastname].se. 3 4 * Distributed under the terms of the MIT License. 4 5 */ 5 6 … … find_media_server_port() 39 40 if (sMediaServerPort < 0) { 40 41 TRACE("couldn't find sMediaServerPort\n"); 41 42 sMediaServerPort = BAD_MEDIA_SERVER_PORT; // make this a unique number 42 } 43 } else 44 TRACE("Did find sMediaServerPort (%ld)\n", sMediaServerPort); 43 45 } 44 46 45 47 … … find_media_addon_server_port() 50 52 if (sMediaAddonServerPort < 0) { 51 53 TRACE("couldn't find sMediaAddonServerPort\n"); 52 54 sMediaAddonServerPort = BAD_MEDIA_ADDON_SERVER_PORT; // make this a unique number 53 } 55 } else 56 TRACE("Did find MediaAddonServerPort (%ld)\n", sMediaAddonServerPort); 54 57 } 55 58 56 59 -
src/kits/media/MediaEncoder.cpp
diff --git a/src/kits/media/MediaEncoder.cpp b/src/kits/media/MediaEncoder.cpp index 6084920..1ee38d4 100644
a b 1 /*********************************************************************** 2 * AUTHOR: Marcus Overhagen 3 * FILE: MediaEncoder.cpp 4 * DESCR: 5 ***********************************************************************/ 1 /* 2 * Copyright 2004-2007, Marcus Overhagen. All rights reserved. 3 * Copyright 2010, Oleg Krysenkov, beos344@mail.ru. 4 * Copyright 2012, Fredrik Modéen, [firstname]@[lastname].se. 5 * Distributed under the terms of the MIT License. 6 */ 7 8 /*TO DO SetTo, SetFormat, Enode Class*/ 9 10 6 11 #include <MediaEncoder.h> 12 #include <EncoderPlugin.h> 13 #include <PluginManager.h> 14 #include <new> 7 15 #include "debug.h" 8 16 9 17 … … 12 20 *************************************************************/ 13 21 14 22 BMediaEncoder::BMediaEncoder() 23 : fEncoder(NULL), 24 fInitStatus(B_NO_INIT) 15 25 { 16 UNIMPLEMENTED(); 26 17 27 } 18 28 19 29 20 30 BMediaEncoder::BMediaEncoder(const media_format *output_format) 31 : fEncoder(NULL), 32 fInitStatus(B_NO_INIT) 21 33 { 22 UNIMPLEMENTED();34 SetTo(output_format); 23 35 } 24 36 25 37 26 38 BMediaEncoder::BMediaEncoder(const media_codec_info *mci) 39 : fEncoder(NULL), 40 fInitStatus(B_NO_INIT) 27 41 { 28 UNIMPLEMENTED();42 SetTo(mci); 29 43 } 30 44 31 45 32 46 /* virtual */ 33 47 BMediaEncoder::~BMediaEncoder() 34 48 { 35 UNIMPLEMENTED(); 49 gPluginManager.DestroyEncoder(fEncoder); 50 fEncoder = NULL; 36 51 } 37 52 38 53 39 54 status_t 40 55 BMediaEncoder::InitCheck() const 41 56 { 42 UNIMPLEMENTED(); 43 44 return B_OK; 57 return fInitStatus; 45 58 } 46 59 60 47 61 status_t 48 62 BMediaEncoder::SetTo(const media_format *output_format) 49 63 { 50 UNIMPLEMENTED(); 64 gPluginManager.DestroyEncoder(fEncoder); 65 fEncoder = NULL; 66 67 status_t err = gPluginManager.CreateEncoder(&fEncoder, *output_format); 68 if (err < B_OK) 69 goto fail; 70 71 err = _AttachToEncoder(); 72 if (err < B_OK) 73 goto fail; 74 75 /* err = SetFormat(NULL, output_format); //Looked at BMediaDecoder 76 if (err < B_OK) 77 goto fail; 78 */ 79 fInitStatus = B_OK; 51 80 return B_OK; 81 82 fail: 83 gPluginManager.DestroyEncoder(fEncoder); 84 fEncoder = NULL; 85 fInitStatus = B_NO_INIT; 86 return err; 52 87 } 53 88 89 54 90 status_t 55 91 BMediaEncoder::SetTo(const media_codec_info *mci) 56 92 { 57 UNIMPLEMENTED(); 93 gPluginManager.DestroyEncoder(fEncoder); 94 fEncoder = NULL; 95 96 status_t err = gPluginManager.CreateEncoder(&fEncoder, mci, 0); 97 if (err < B_OK) 98 goto fail; 99 100 err = _AttachToEncoder(); 101 if (err < B_OK) 102 goto fail; 103 104 fInitStatus = B_OK; 58 105 return B_OK; 106 107 fail: 108 gPluginManager.DestroyEncoder(fEncoder); 109 fEncoder = NULL; 110 fInitStatus = B_NO_INIT; 111 return err; 59 112 } 60 113 61 114 … … BMediaEncoder::SetFormat(media_format *input_format, 64 117 media_format *output_format, 65 118 media_file_format *mfi) 66 119 { 67 UNIMPLEMENTED(); 68 return B_OK; 120 TRACE("BMediaEncoder::SetFormat. Input = %d, Output = %d\n", 121 input_format->type, output_format->type); 122 123 if (!fEncoder) 124 return B_NO_INIT; 125 126 UNIMPLEMENTED(); 127 128 // media_format in_format = *input_format; 129 // media_format out_format = *output_format; 130 131 // fEncoder->Setup(input_format, output_format, mfi); 132 133 return B_OK; 69 134 } 70 135 136 71 137 status_t 72 138 BMediaEncoder::Encode(const void *buffer, 73 139 int64 frame_count, 74 140 media_encode_info *info) 75 141 { 76 UNIMPLEMENTED(); 77 return B_OK; 142 if (!fEncoder) 143 return B_NO_INIT; 144 145 return fEncoder->Encode(buffer, frame_count, info); 78 146 } 79 147 80 148 81 149 status_t 82 150 BMediaEncoder::GetEncodeParameters(encode_parameters *parameters) const 83 151 { 84 UNIMPLEMENTED(); 85 return B_OK; 152 if (fEncoder == NULL) 153 return B_NO_INIT; 154 else 155 return fEncoder->GetEncodeParameters(parameters); 86 156 } 87 157 88 158 89 159 status_t 90 160 BMediaEncoder::SetEncodeParameters(encode_parameters *parameters) 91 161 { 92 UNIMPLEMENTED(); 93 return B_OK; 162 if (fEncoder == NULL) 163 return B_NO_INIT; 164 else 165 return fEncoder->SetEncodeParameters(parameters); 94 166 } 95 167 96 168 … … BMediaEncoder::SetEncodeParameters(encode_parameters *parameters) 101 173 /* virtual */ status_t 102 174 BMediaEncoder::AddTrackInfo(uint32 code, const char *data, size_t size) 103 175 { 104 UNIMPLEMENTED(); 105 return B_OK; 176 if (fEncoder == NULL) 177 return B_NO_INIT; 178 else 179 return fEncoder->AddTrackInfo(code, data, size); 106 180 } 107 181 108 182 … … BMediaEncoder::ReleaseEncoder() 140 214 UNIMPLEMENTED(); 141 215 } 142 216 217 218 status_t 219 BMediaEncoder::_AttachToEncoder() 220 { 221 class MediaEncoderChunkWriter : public ChunkWriter { 222 private: 223 BMediaEncoder* fEncoder; 224 public: 225 MediaEncoderChunkWriter(BMediaEncoder* encoder) 226 { 227 fEncoder = encoder; 228 } 229 virtual status_t WriteChunk(const void* chunkBuffer, size_t chunkSize, 230 media_encode_info* encodeInfo) 231 { 232 return fEncoder->WriteChunk(chunkBuffer, chunkSize, encodeInfo); 233 } 234 }* writer = new(std::nothrow) MediaEncoderChunkWriter(this); 235 236 if (!writer) 237 return B_NO_MEMORY; 238 239 fEncoder->SetChunkWriter(writer); 240 return B_OK; 241 } 242 243 143 244 status_t BMediaEncoder::_Reserved_BMediaEncoder_0(int32 arg, ...) { return B_ERROR; } 144 245 status_t BMediaEncoder::_Reserved_BMediaEncoder_1(int32 arg, ...) { return B_ERROR; } 145 246 status_t BMediaEncoder::_Reserved_BMediaEncoder_2(int32 arg, ...) { return B_ERROR; } … … status_t BMediaEncoder::_Reserved_BMediaEncoder_15(int32 arg, ...) { return B_ER 162 263 *************************************************************/ 163 264 164 265 BMediaBufferEncoder::BMediaBufferEncoder() 266 : BMediaEncoder(), 267 fBuffer(NULL) 165 268 { 166 UNIMPLEMENTED(); 269 167 270 } 168 271 169 272 170 273 BMediaBufferEncoder::BMediaBufferEncoder(const media_format *output_format) 274 : BMediaEncoder(output_format), 275 fBuffer(NULL) 171 276 { 172 UNIMPLEMENTED(); 277 173 278 } 174 279 175 280 176 281 BMediaBufferEncoder::BMediaBufferEncoder(const media_codec_info *mci) 282 : BMediaEncoder(mci), 283 fBuffer(NULL) 177 284 { 178 UNIMPLEMENTED(); 285 179 286 } 180 287 181 288 … … BMediaBufferEncoder::EncodeToBuffer(void *output_buffer, 186 293 int64 frame_count, 187 294 media_encode_info *info) 188 295 { 189 UNIMPLEMENTED(); 190 191 return B_ERROR; 296 status_t error; 297 fBuffer = output_buffer; 298 fBufferSize = *output_size; 299 error = Encode(input_buffer, frame_count, info); 300 if (fBuffer) { 301 fBuffer = NULL; 302 *output_size = 0; 303 } else { 304 *output_size = fBufferSize; 305 } 306 return error; 192 307 } 193 308 194 309 … … BMediaBufferEncoder::WriteChunk(const void *chunk_data, 201 316 size_t chunk_len, 202 317 media_encode_info *info) 203 318 { 204 UNIMPLEMENTED(); 205 206 return B_ERROR; 319 if (fBuffer == NULL) 320 return B_ENTRY_NOT_FOUND; 321 322 if ((ssize_t)chunk_len < 0) 323 return B_ERROR; 324 325 if (chunk_len > (size_t)fBufferSize) { 326 memcpy(fBuffer, chunk_data, fBufferSize); 327 fBuffer = NULL; 328 return B_DEVICE_FULL; 329 } 330 331 memcpy(fBuffer, chunk_data, chunk_len); 332 fBufferSize = chunk_len; 333 fBuffer = NULL; 334 return B_NO_ERROR; 207 335 } 208 209 -
src/kits/media/PluginManager.cpp
diff --git a/src/kits/media/PluginManager.cpp b/src/kits/media/PluginManager.cpp index ffb816d..5dea9a0 100644
a b 1 1 /* 2 2 * Copyright 2004-2010, Marcus Overhagen. All rights reserved. 3 * Distributed under the terms of the OpenBeOS License. 3 * Copyright 2012, Fredrik Modéen, [firstname]@[lastname].se. 4 * Distributed under the terms of the MIT License. 4 5 */ 5 6 6 7 #include <Path.h> … … PluginManager::CreateReader(Reader** reader, int32* streamCount, 26 27 27 28 BPositionIO *seekable_source = dynamic_cast<BPositionIO *>(source); 28 29 if (seekable_source == 0) { 29 printf("PluginManager::CreateReader: non-seekable sources not "30 ERROR("PluginManager::CreateReader: non-seekable sources not " 30 31 "supported yet\n"); 31 32 return B_ERROR; 32 33 } … … PluginManager::CreateReader(Reader** reader, int32* streamCount, 37 38 status_t ret = QueryServer(SERVER_GET_READERS, &request, sizeof(request), 38 39 &reply, sizeof(reply)); 39 40 if (ret != B_OK) { 40 printf("PluginManager::CreateReader: can't get list of readers: %s\n",41 ERROR("PluginManager::CreateReader: can't get list of readers: %s\n", 41 42 strerror(ret)); 42 43 return ret; 43 44 } … … PluginManager::CreateReader(Reader** reader, int32* streamCount, 47 48 entry_ref ref = reply.ref[i]; 48 49 MediaPlugin* plugin = GetPlugin(ref); 49 50 if (plugin == NULL) { 50 printf("PluginManager::CreateReader: GetPlugin failed\n");51 ERROR("PluginManager::CreateReader: GetPlugin failed\n"); 51 52 return B_ERROR; 52 53 } 53 54 54 55 ReaderPlugin* readerPlugin = dynamic_cast<ReaderPlugin*>(plugin); 55 56 if (readerPlugin == NULL) { 56 printf("PluginManager::CreateReader: dynamic_cast failed\n");57 ERROR("PluginManager::CreateReader: dynamic_cast failed\n"); 57 58 PutPlugin(plugin); 58 59 return B_ERROR; 59 60 } 60 61 61 62 *reader = readerPlugin->NewReader(); 62 63 if (*reader == NULL) { 63 printf("PluginManager::CreateReader: NewReader failed\n");64 ERROR("PluginManager::CreateReader: NewReader failed\n"); 64 65 PutPlugin(plugin); 65 66 return B_ERROR; 66 67 } … … PluginManager::CreateDecoder(Decoder** _decoder, const media_format& format) 113 114 status_t ret = QueryServer(SERVER_GET_DECODER_FOR_FORMAT, &request, 114 115 sizeof(request), &reply, sizeof(reply)); 115 116 if (ret != B_OK) { 116 printf("PluginManager::CreateDecoder: can't get decoder for format: "117 ERROR("PluginManager::CreateDecoder: can't get decoder for format: " 117 118 "%s\n", strerror(ret)); 118 119 return ret; 119 120 } 120 121 121 122 MediaPlugin* plugin = GetPlugin(reply.ref); 122 123 if (plugin == NULL) { 123 printf("PluginManager::CreateDecoder: GetPlugin failed\n");124 ERROR("PluginManager::CreateDecoder: GetPlugin failed\n"); 124 125 return B_ERROR; 125 126 } 126 127 127 128 DecoderPlugin* decoderPlugin = dynamic_cast<DecoderPlugin*>(plugin); 128 129 if (decoderPlugin == NULL) { 129 printf("PluginManager::CreateDecoder: dynamic_cast failed\n");130 ERROR("PluginManager::CreateDecoder: dynamic_cast failed\n"); 130 131 PutPlugin(plugin); 131 132 return B_ERROR; 132 133 } … … PluginManager::CreateDecoder(Decoder** _decoder, const media_format& format) 135 136 // but this is not yet handled (passing "0" as index/ID). 136 137 *_decoder = decoderPlugin->NewDecoder(0); 137 138 if (*_decoder == NULL) { 138 printf("PluginManager::CreateDecoder: NewDecoder() failed\n");139 ERROR("PluginManager::CreateDecoder: NewDecoder() failed\n"); 139 140 PutPlugin(plugin); 140 141 return B_ERROR; 141 142 } … … PluginManager::CreateDecoder(Decoder** _decoder, const media_format& format) 151 152 status_t 152 153 PluginManager::CreateDecoder(Decoder** decoder, const media_codec_info& mci) 153 154 { 154 // TODO 155 TRACE("PluginManager::CreateDecoder enter\n"); 156 157 // get decoder for this format from the server 158 server_get_decoder_for_codec_info_request request; 159 server_get_decoder_for_codec_info_reply reply; 160 request.id = mci.id; 161 status_t ret = QueryServer(SERVER_GET_DECODER_FOR_CODEC_INFO, &request, 162 sizeof(request), &reply, sizeof(reply)); 163 if (ret != B_OK) { 164 ERROR("PluginManager::CreateDecoder: can't get decoder for format: " 165 "%s\n", strerror(ret)); 166 return ret; 167 } 168 169 MediaPlugin* plugin = GetPlugin(reply.ref); 170 if (plugin == NULL) { 171 ERROR("PluginManager::CreateDecoder: GetPlugin failed\n"); 172 return B_ERROR; 173 } 174 175 DecoderPlugin* decoderPlugin = dynamic_cast<DecoderPlugin*>(plugin); 176 if (decoderPlugin == NULL) { 177 ERROR("PluginManager::CreateDecoder: dynamic_cast failed\n"); 178 PutPlugin(plugin); 179 return B_ERROR; 180 } 181 182 // TODO: In theory, one DecoderPlugin could support multiple Decoders, 183 // but this is not yet handled (passing "0" as index/ID). 184 *decoder = decoderPlugin->NewDecoder(0); 185 if (*decoder == NULL) { 186 ERROR("PluginManager::CreateDecoder: NewDecoder() failed\n"); 187 PutPlugin(plugin); 188 return B_ERROR; 189 } 190 TRACE(" created decoder: %p\n", *decoder); 191 (*decoder)->fMediaPlugin = plugin; 192 193 TRACE("PluginManager::CreateDecoder leave\n"); 194 195 return B_OK; 196 /* // TODO 155 197 debugger("not implemented"); 156 return B_ERROR; 198 return B_ERROR;*/ 157 199 } 158 200 159 201 … … PluginManager::CreateWriter(Writer** writer, const media_file_format& mff, 203 245 status_t ret = QueryServer(SERVER_GET_WRITER_FOR_FORMAT_FAMILY, &request, 204 246 sizeof(request), &reply, sizeof(reply)); 205 247 if (ret != B_OK) { 206 printf("PluginManager::CreateWriter: can't get writer for file "248 ERROR("PluginManager::CreateWriter: can't get writer for file " 207 249 "family: %s\n", strerror(ret)); 208 250 return ret; 209 251 } 210 252 211 253 MediaPlugin* plugin = GetPlugin(reply.ref); 212 254 if (plugin == NULL) { 213 printf("PluginManager::CreateWriter: GetPlugin failed\n");255 ERROR("PluginManager::CreateWriter: GetPlugin failed\n"); 214 256 return B_ERROR; 215 257 } 216 258 217 259 WriterPlugin* writerPlugin = dynamic_cast<WriterPlugin*>(plugin); 218 260 if (writerPlugin == NULL) { 219 printf("PluginManager::CreateWriter: dynamic_cast failed\n");261 ERROR("PluginManager::CreateWriter: dynamic_cast failed\n"); 220 262 PutPlugin(plugin); 221 263 return B_ERROR; 222 264 } 223 265 224 266 *writer = writerPlugin->NewWriter(); 225 267 if (*writer == NULL) { 226 printf("PluginManager::CreateWriter: NewWriter failed\n");268 ERROR("PluginManager::CreateWriter: NewWriter failed\n"); 227 269 PutPlugin(plugin); 228 270 return B_ERROR; 229 271 } … … PluginManager::DestroyWriter(Writer* writer) 253 295 254 296 255 297 status_t 256 PluginManager::CreateEncoder(Encoder** _encoder,298 PluginManager::CreateEncoder(Encoder** encoder, 257 299 const media_codec_info* codecInfo, uint32 flags) 258 300 { 259 301 TRACE("PluginManager::CreateEncoder enter\n"); … … PluginManager::CreateEncoder(Encoder** _encoder, 265 307 status_t ret = QueryServer(SERVER_GET_ENCODER_FOR_CODEC_INFO, &request, 266 308 sizeof(request), &reply, sizeof(reply)); 267 309 if (ret != B_OK) { 268 printf("PluginManager::CreateEncoder: can't get encoder for codec %s: "310 ERROR("PluginManager::CreateEncoder: can't get encoder for codec %s: " 269 311 "%s\n", codecInfo->pretty_name, strerror(ret)); 270 312 return ret; 271 313 } 272 314 273 315 MediaPlugin* plugin = GetPlugin(reply.ref); 274 316 if (!plugin) { 275 printf("PluginManager::CreateEncoder: GetPlugin failed\n");317 ERROR("PluginManager::CreateEncoder: GetPlugin failed\n"); 276 318 return B_ERROR; 277 319 } 278 320 279 321 EncoderPlugin* encoderPlugin = dynamic_cast<EncoderPlugin*>(plugin); 280 322 if (encoderPlugin == NULL) { 281 printf("PluginManager::CreateEncoder: dynamic_cast failed\n");323 ERROR("PluginManager::CreateEncoder: dynamic_cast failed\n"); 282 324 PutPlugin(plugin); 283 325 return B_ERROR; 284 326 } 285 327 286 * _encoder = encoderPlugin->NewEncoder(*codecInfo);287 if (* _encoder == NULL) {288 printf("PluginManager::CreateEncoder: NewEncoder() failed\n");328 *encoder = encoderPlugin->NewEncoder(*codecInfo); 329 if (*encoder == NULL) { 330 ERROR("PluginManager::CreateEncoder: NewEncoder() failed\n"); 289 331 PutPlugin(plugin); 290 332 return B_ERROR; 291 333 } 292 TRACE(" created encoder: %p\n", * _encoder);293 (* _encoder)->fMediaPlugin = plugin;334 TRACE(" created encoder: %p\n", *encoder); 335 (*encoder)->fMediaPlugin = plugin; 294 336 295 337 TRACE("PluginManager::CreateEncoder leave\n"); 296 338 … … PluginManager::CreateEncoder(Encoder** _encoder, 298 340 } 299 341 300 342 343 status_t 344 PluginManager::CreateEncoder(Encoder** encoder, const media_format& format) 345 { 346 TRACE("PluginManager::CreateEncoder enter nr2\n"); 347 // Get encoder for this codec info from the server 348 server_get_encoder_for_format_request request; 349 server_get_encoder_for_format_reply reply; 350 request.format = format; 351 status_t ret = QueryServer(SERVER_GET_ENCODER_FOR_FORMAT, &request, 352 sizeof(request), &reply, sizeof(reply)); 353 if (ret != B_OK) { 354 ERROR("PluginManager::CreateEncoder: can't get decoder for format: " 355 "%s\n", strerror(ret)); 356 return ret; 357 } 358 359 MediaPlugin* plugin = GetPlugin(reply.ref); 360 if (plugin == NULL) { 361 ERROR("PluginManager::CreateEncoder: GetPlugin failed\n"); 362 return B_ERROR; 363 } 364 365 EncoderPlugin* encoderPlugin = dynamic_cast<EncoderPlugin*>(plugin); 366 if (encoderPlugin == NULL) { 367 ERROR("PluginManager::CreateEncoder: dynamic_cast failed\n"); 368 PutPlugin(plugin); 369 return B_ERROR; 370 } 371 372 373 *encoder = encoderPlugin->NewEncoder(format); 374 if (*encoder == NULL) { 375 ERROR("PluginManager::CreateEncoder: NewEncoder() failed\n"); 376 PutPlugin(plugin); 377 return B_ERROR; 378 } 379 TRACE(" created encoder: %p\n", *encoder); 380 (*encoder)->fMediaPlugin = plugin; 381 382 TRACE("PluginManager::CreateEncoder leave nr2\n"); 383 384 return B_OK; 385 } 386 387 301 388 void 302 389 PluginManager::DestroyEncoder(Encoder* encoder) 303 390 { … … PluginManager::~PluginManager() 332 419 for (int i = fPluginList.CountItems() - 1; i >= 0; i--) { 333 420 plugin_info* info = NULL; 334 421 fPluginList.Get(i, &info); 335 printf("PluginManager: Error, unloading PlugIn %s with usecount "422 ERROR("PluginManager: Error, unloading PlugIn %s with usecount " 336 423 "%d\n", info->name, info->usecount); 337 424 delete info->plugin; 338 425 unload_add_on(info->image); … … PluginManager::GetPlugin(const entry_ref& ref) 361 448 } 362 449 363 450 if (_LoadPlugin(ref, &info.plugin, &info.image) < B_OK) { 364 printf("PluginManager: Error, loading PlugIn %s failed\n", ref.name);451 ERROR("PluginManager: Error, loading PlugIn %s failed\n", ref.name); 365 452 fLocker.Unlock(); 366 453 return NULL; 367 454 } … … PluginManager::PutPlugin(MediaPlugin* plugin) 403 490 } 404 491 } 405 492 406 printf("PluginManager: Error, can't put PlugIn %p\n", plugin);493 ERROR("PluginManager: Error, can't put PlugIn %p\n", plugin); 407 494 408 495 fLocker.Unlock(); 409 496 } … … PluginManager::_LoadPlugin(const entry_ref& ref, MediaPlugin** plugin, 420 507 image_id id; 421 508 id = load_add_on(p.Path()); 422 509 if (id < 0) { 423 printf("PluginManager: Error, load_add_on(): %s\n", strerror(id));510 ERROR("PluginManager: Error, load_add_on(): %s\n", strerror(id)); 424 511 return B_ERROR; 425 512 } 426 513 … … PluginManager::_LoadPlugin(const entry_ref& ref, MediaPlugin** plugin, 428 515 429 516 if (get_image_symbol(id, "instantiate_plugin", B_SYMBOL_TYPE_TEXT, 430 517 (void**)&instantiate_plugin_func) < B_OK) { 431 printf("PluginManager: Error, _LoadPlugin can't find "518 ERROR("PluginManager: Error, _LoadPlugin can't find " 432 519 "instantiate_plugin in %s\n", p.Path()); 433 520 unload_add_on(id); 434 521 return B_ERROR; … … PluginManager::_LoadPlugin(const entry_ref& ref, MediaPlugin** plugin, 438 525 439 526 pl = (*instantiate_plugin_func)(); 440 527 if (pl == NULL) { 441 printf("PluginManager: Error, _LoadPlugin instantiate_plugin in %s "528 ERROR("PluginManager: Error, _LoadPlugin instantiate_plugin in %s " 442 529 "returned NULL\n", p.Path()); 443 530 unload_add_on(id); 444 531 return B_ERROR; -
src/servers/media/media_server.cpp
diff --git a/src/servers/media/media_server.cpp b/src/servers/media/media_server.cpp index fd51cf77..80dbaab 100644
a b ServerApp::_HandleMessage(int32 code, const void* data, size_t size) 896 896 request.SendReply(status, &reply, sizeof(reply)); 897 897 break; 898 898 } 899 900 case SERVER_GET_DECODER_FOR_CODEC_INFO: 901 { 902 const server_get_decoder_for_codec_info_request& request 903 = *static_cast< 904 const server_get_decoder_for_codec_info_request*>(data); 905 server_get_decoder_for_codec_info_reply reply; 906 907 status_t status = gAddOnManager->GetEncoder(&reply.ref, request.id); 908 request.SendReply(status, &reply, sizeof(reply)); 909 break; 910 } 899 911 900 912 case SERVER_GET_DECODER_FOR_FORMAT: 901 913 { … … ServerApp::_HandleMessage(int32 code, const void* data, size_t size) 946 958 request.SendReply(status, &reply, sizeof(reply)); 947 959 break; 948 960 } 961 962 case SERVER_GET_ENCODER_FOR_FORMAT: 963 { 964 const server_get_encoder_for_format_request& request 965 = *static_cast< 966 const server_get_encoder_for_format_request*>(data); 967 server_get_encoder_for_format_reply reply; 968 969 status_t status = gAddOnManager->GetDecoderForFormat(&reply.ref, 970 request.format); 971 request.SendReply(status, &reply, sizeof(reply)); 972 break; 973 } 949 974 950 975 case SERVER_GET_ENCODER_FOR_CODEC_INFO: 951 976 { … … ServerApp::_HandleMessage(int32 code, const void* data, size_t size) 953 978 = *static_cast< 954 979 const server_get_encoder_for_codec_info_request*>(data); 955 980 server_get_encoder_for_codec_info_reply reply; 981 956 982 status_t status = gAddOnManager->GetEncoder(&reply.ref, request.id); 957 983 request.SendReply(status, &reply, sizeof(reply)); 958 984 break;