Move media plug-in support to application side.
The media server tried to use node monitoring to dynamically add and remove plug-ins, but it isn't that useful: * When a plug-in is added, applications would have to query the media server to get an up to date list of available formats. For example MediaConvert populates its format menus on startup. * When removing a plugin, if an app already had it loaded, there is not much that can be done to keep it working. * The list of plugins was not sorted by directories (user vs system add-ons), so the directories were re-scanned to make sure user add-ons were returned first, rendering the node monitoring less interesting. Now, the format handling is done by each application. The node monitoring is removed, instead the apps will scan the plugin directory when first using the media kit classes. Restarting the application is needed to update the media formats list.
This commit is contained in:
parent
1c69e1c306
commit
2feaa37f24
@ -25,9 +25,6 @@ enum {
|
||||
MEDIA_SERVER_CANCEL_NOTIFICATIONS,
|
||||
MEDIA_SERVER_SEND_NOTIFICATIONS,
|
||||
|
||||
MEDIA_SERVER_GET_FORMATS,
|
||||
MEDIA_SERVER_MAKE_FORMAT_FOR,
|
||||
|
||||
// add_system_beep_event()
|
||||
MEDIA_SERVER_ADD_SYSTEM_BEEP_EVENT,
|
||||
|
||||
@ -76,12 +73,6 @@ enum {
|
||||
SERVER_SET_ITEM_AUDIO_GAIN,
|
||||
SERVER_GET_FORMAT_FOR_DESCRIPTION,
|
||||
SERVER_GET_DESCRIPTION_FOR_FORMAT,
|
||||
SERVER_GET_READERS,
|
||||
SERVER_GET_DECODER_FOR_FORMAT,
|
||||
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_REGISTER_ADD_ON,
|
||||
SERVER_UNREGISTER_ADD_ON,
|
||||
SERVER_GET_ADD_ON_REF,
|
||||
@ -601,62 +592,6 @@ struct server_set_item_audio_gain_request : request_data {
|
||||
struct server_set_item_audio_gain_reply : reply_data {
|
||||
};
|
||||
|
||||
struct server_get_decoder_for_format_request : request_data {
|
||||
media_format format;
|
||||
};
|
||||
|
||||
struct server_get_decoder_for_format_reply : reply_data {
|
||||
xfer_entry_ref ref;
|
||||
// a ref to the decoder
|
||||
};
|
||||
|
||||
struct server_get_encoder_for_codec_info_request : request_data {
|
||||
int32 id;
|
||||
};
|
||||
|
||||
struct server_get_encoder_for_codec_info_reply : reply_data {
|
||||
xfer_entry_ref ref;
|
||||
// a ref to the encoder
|
||||
};
|
||||
|
||||
struct server_get_readers_request : request_data {
|
||||
};
|
||||
|
||||
struct server_get_readers_reply : reply_data {
|
||||
xfer_entry_ref ref[MAX_READERS];
|
||||
// a list of refs to the reader
|
||||
int32 count;
|
||||
};
|
||||
|
||||
struct server_get_writer_request : request_data {
|
||||
uint32 internal_id;
|
||||
};
|
||||
|
||||
struct server_get_writer_reply : reply_data {
|
||||
xfer_entry_ref ref;
|
||||
// a ref to the writer
|
||||
};
|
||||
|
||||
struct server_get_file_format_request : request_data {
|
||||
int32 cookie;
|
||||
};
|
||||
|
||||
struct server_get_file_format_reply : reply_data {
|
||||
media_file_format file_format;
|
||||
// the file format matching the cookie
|
||||
};
|
||||
|
||||
struct server_get_codec_info_request : request_data {
|
||||
int32 cookie;
|
||||
};
|
||||
|
||||
struct server_get_codec_info_reply : reply_data {
|
||||
media_codec_info codec_info;
|
||||
media_format_family format_family;
|
||||
media_format input_format;
|
||||
media_format output_format;
|
||||
// the codec info matching the cookie
|
||||
};
|
||||
|
||||
struct server_get_dormant_flavor_info_request : request_data {
|
||||
media_addon_id add_on_id;
|
||||
|
@ -51,10 +51,12 @@ for architectureObject in [ MultiArchSubDirSetup ] {
|
||||
TimeSource.cpp
|
||||
|
||||
# Internal Functionality
|
||||
AddOnManager.cpp
|
||||
BufferCache.cpp
|
||||
DataExchange.cpp
|
||||
DefaultMediaTheme.cpp
|
||||
DormantNodeManager.cpp
|
||||
FormatManager.cpp
|
||||
Notifications.cpp
|
||||
request_data.cpp
|
||||
SharedBufferList.cpp
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
#include "AddOnManager.h"
|
||||
#include "DataExchange.h"
|
||||
#include "MediaMisc.h"
|
||||
|
||||
@ -1191,17 +1192,11 @@ get_next_file_format(int32* cookie, media_file_format* mff)
|
||||
if (cookie == NULL || mff == NULL)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
// get list of available readers from the server
|
||||
server_get_file_format_request request;
|
||||
request.cookie = *cookie;
|
||||
server_get_file_format_reply reply;
|
||||
status_t ret = QueryServer(SERVER_GET_FILE_FORMAT_FOR_COOKIE, &request,
|
||||
sizeof(request), &reply, sizeof(reply));
|
||||
status_t ret = AddOnManager::GetInstance()->GetFileFormat(mff, *cookie);
|
||||
if (ret != B_OK)
|
||||
return ret;
|
||||
|
||||
*cookie = *cookie + 1;
|
||||
*mff = reply.file_format;
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <image.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "AddOnManager.h"
|
||||
#include "PluginManager.h"
|
||||
#include "DataExchange.h"
|
||||
#include "debug.h"
|
||||
@ -32,10 +33,11 @@ PluginManager::CreateReader(Reader** reader, int32* streamCount,
|
||||
}
|
||||
|
||||
// get list of available readers from the server
|
||||
server_get_readers_request request;
|
||||
server_get_readers_reply reply;
|
||||
status_t ret = QueryServer(SERVER_GET_READERS, &request, sizeof(request),
|
||||
&reply, sizeof(reply));
|
||||
entry_ref refs[MAX_READERS];
|
||||
int32 count;
|
||||
|
||||
status_t ret = AddOnManager::GetInstance()->GetReaders(refs, &count,
|
||||
MAX_READERS);
|
||||
if (ret != B_OK) {
|
||||
printf("PluginManager::CreateReader: can't get list of readers: %s\n",
|
||||
strerror(ret));
|
||||
@ -43,8 +45,8 @@ PluginManager::CreateReader(Reader** reader, int32* streamCount,
|
||||
}
|
||||
|
||||
// try each reader by calling it's Sniff function...
|
||||
for (int32 i = 0; i < reply.count; i++) {
|
||||
entry_ref ref = reply.ref[i];
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
entry_ref ref = refs[i];
|
||||
MediaPlugin* plugin = GetPlugin(ref);
|
||||
if (plugin == NULL) {
|
||||
printf("PluginManager::CreateReader: GetPlugin failed\n");
|
||||
@ -106,19 +108,17 @@ 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));
|
||||
// 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(reply.ref);
|
||||
MediaPlugin* plugin = GetPlugin(ref);
|
||||
if (plugin == NULL) {
|
||||
printf("PluginManager::CreateDecoder: GetPlugin failed\n");
|
||||
return B_ERROR;
|
||||
@ -197,18 +197,16 @@ PluginManager::CreateWriter(Writer** writer, const media_file_format& mff,
|
||||
TRACE("PluginManager::CreateWriter enter\n");
|
||||
|
||||
// Get the Writer responsible for this media_file_format from the server.
|
||||
server_get_writer_request request;
|
||||
request.internal_id = mff.id.internal_id;
|
||||
server_get_writer_reply reply;
|
||||
status_t ret = QueryServer(SERVER_GET_WRITER_FOR_FORMAT_FAMILY, &request,
|
||||
sizeof(request), &reply, sizeof(reply));
|
||||
entry_ref ref;
|
||||
status_t ret = AddOnManager::GetInstance()->GetWriter(&ref,
|
||||
mff.id.internal_id);
|
||||
if (ret != B_OK) {
|
||||
printf("PluginManager::CreateWriter: can't get writer for file "
|
||||
"family: %s\n", strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
MediaPlugin* plugin = GetPlugin(reply.ref);
|
||||
MediaPlugin* plugin = GetPlugin(ref);
|
||||
if (plugin == NULL) {
|
||||
printf("PluginManager::CreateWriter: GetPlugin failed\n");
|
||||
return B_ERROR;
|
||||
@ -259,18 +257,16 @@ PluginManager::CreateEncoder(Encoder** _encoder,
|
||||
TRACE("PluginManager::CreateEncoder enter\n");
|
||||
|
||||
// Get encoder for this codec info from the server
|
||||
server_get_encoder_for_codec_info_request request;
|
||||
server_get_encoder_for_codec_info_reply reply;
|
||||
request.id = codecInfo->id;
|
||||
status_t ret = QueryServer(SERVER_GET_ENCODER_FOR_CODEC_INFO, &request,
|
||||
sizeof(request), &reply, sizeof(reply));
|
||||
entry_ref ref;
|
||||
status_t ret = AddOnManager::GetInstance()->GetEncoder(&ref,
|
||||
codecInfo->id);
|
||||
if (ret != B_OK) {
|
||||
printf("PluginManager::CreateEncoder: can't get encoder for codec %s: "
|
||||
"%s\n", codecInfo->pretty_name, strerror(ret));
|
||||
return ret;
|
||||
}
|
||||
|
||||
MediaPlugin* plugin = GetPlugin(reply.ref);
|
||||
MediaPlugin* plugin = GetPlugin(ref);
|
||||
if (!plugin) {
|
||||
printf("PluginManager::CreateEncoder: GetPlugin failed\n");
|
||||
return B_ERROR;
|
||||
|
@ -9,11 +9,9 @@ AddResources media_server : media_server.rdef ;
|
||||
|
||||
Server media_server :
|
||||
media_server.cpp
|
||||
AddOnManager.cpp
|
||||
AppManager.cpp
|
||||
BufferManager.cpp
|
||||
DefaultManager.cpp
|
||||
FormatManager.cpp
|
||||
MediaFilesManager.cpp
|
||||
NodeManager.cpp
|
||||
NotificationManager.cpp
|
||||
|
@ -47,11 +47,9 @@ char __dont_remove_copyright_from_binary[] = "Copyright (c) 2002, 2003 "
|
||||
|
||||
#include <syscalls.h>
|
||||
|
||||
#include "AddOnManager.h"
|
||||
#include "AppManager.h"
|
||||
#include "BufferManager.h"
|
||||
#include "DataExchange.h"
|
||||
#include "FormatManager.h"
|
||||
#include "MediaMisc.h"
|
||||
#include "MediaFilesManager.h"
|
||||
#include "NodeManager.h"
|
||||
@ -61,10 +59,8 @@ char __dont_remove_copyright_from_binary[] = "Copyright (c) 2002, 2003 "
|
||||
#include "media_server.h"
|
||||
|
||||
|
||||
AddOnManager* gAddOnManager;
|
||||
AppManager* gAppManager;
|
||||
BufferManager* gBufferManager;
|
||||
FormatManager* gFormatManager;
|
||||
MediaFilesManager* gMediaFilesManager;
|
||||
NodeManager* gNodeManager;
|
||||
NotificationManager* gNotificationManager;
|
||||
@ -111,8 +107,6 @@ ServerApp::ServerApp()
|
||||
gAppManager = new AppManager;
|
||||
gNodeManager = new NodeManager;
|
||||
gMediaFilesManager = new MediaFilesManager;
|
||||
gFormatManager = new FormatManager;
|
||||
gAddOnManager = new AddOnManager;
|
||||
|
||||
fControlPort = create_port(64, MEDIA_SERVER_PORT_NAME);
|
||||
fControlThread = spawn_thread(_ControlThread, "media_server control", 105,
|
||||
@ -128,13 +122,11 @@ ServerApp::~ServerApp()
|
||||
delete_port(fControlPort);
|
||||
wait_for_thread(fControlThread, NULL);
|
||||
|
||||
delete gAddOnManager;
|
||||
delete gNotificationManager;
|
||||
delete gBufferManager;
|
||||
delete gAppManager;
|
||||
delete gNodeManager;
|
||||
delete gMediaFilesManager;
|
||||
delete gFormatManager;
|
||||
}
|
||||
|
||||
|
||||
@ -142,14 +134,12 @@ void
|
||||
ServerApp::ReadyToRun()
|
||||
{
|
||||
gNodeManager->LoadState();
|
||||
gFormatManager->LoadState();
|
||||
|
||||
// make sure any previous media_addon_server is gone
|
||||
_QuitAddOnServer();
|
||||
// and start a new one
|
||||
_LaunchAddOnServer();
|
||||
|
||||
gAddOnManager->LoadState();
|
||||
}
|
||||
|
||||
|
||||
@ -159,8 +149,6 @@ ServerApp::QuitRequested()
|
||||
TRACE("ServerApp::QuitRequested()\n");
|
||||
gMediaFilesManager->SaveState();
|
||||
gNodeManager->SaveState();
|
||||
gFormatManager->SaveState();
|
||||
gAddOnManager->SaveState();
|
||||
|
||||
_QuitAddOnServer();
|
||||
|
||||
@ -887,79 +875,6 @@ ServerApp::_HandleMessage(int32 code, const void* data, size_t size)
|
||||
break;
|
||||
}
|
||||
|
||||
case SERVER_GET_READERS:
|
||||
{
|
||||
const server_get_readers_request& request
|
||||
= *static_cast<const server_get_readers_request*>(data);
|
||||
server_get_readers_reply reply;
|
||||
|
||||
status_t status = gAddOnManager->GetReaders(reply.ref, &reply.count,
|
||||
MAX_READERS);
|
||||
request.SendReply(status, &reply, sizeof(reply));
|
||||
break;
|
||||
}
|
||||
|
||||
case SERVER_GET_DECODER_FOR_FORMAT:
|
||||
{
|
||||
const server_get_decoder_for_format_request& request
|
||||
= *static_cast<
|
||||
const server_get_decoder_for_format_request*>(data);
|
||||
server_get_decoder_for_format_reply reply;
|
||||
|
||||
status_t status = gAddOnManager->GetDecoderForFormat(&reply.ref,
|
||||
request.format);
|
||||
request.SendReply(status, &reply, sizeof(reply));
|
||||
break;
|
||||
}
|
||||
|
||||
case SERVER_GET_WRITER_FOR_FORMAT_FAMILY:
|
||||
{
|
||||
const server_get_writer_request& request
|
||||
= *static_cast<const server_get_writer_request*>(data);
|
||||
server_get_writer_reply reply;
|
||||
|
||||
status_t status = gAddOnManager->GetWriter(&reply.ref,
|
||||
request.internal_id);
|
||||
request.SendReply(status, &reply, sizeof(reply));
|
||||
break;
|
||||
}
|
||||
|
||||
case SERVER_GET_FILE_FORMAT_FOR_COOKIE:
|
||||
{
|
||||
const server_get_file_format_request& request
|
||||
= *static_cast<const server_get_file_format_request*>(data);
|
||||
server_get_file_format_reply reply;
|
||||
|
||||
status_t status = gAddOnManager->GetFileFormat(&reply.file_format,
|
||||
request.cookie);
|
||||
request.SendReply(status, &reply, sizeof(reply));
|
||||
break;
|
||||
}
|
||||
|
||||
case SERVER_GET_CODEC_INFO_FOR_COOKIE:
|
||||
{
|
||||
const server_get_codec_info_request& request
|
||||
= *static_cast<const server_get_codec_info_request*>(data);
|
||||
server_get_codec_info_reply reply;
|
||||
|
||||
status_t status = gAddOnManager->GetCodecInfo(&reply.codec_info,
|
||||
&reply.format_family, &reply.input_format,
|
||||
&reply.output_format, request.cookie);
|
||||
request.SendReply(status, &reply, sizeof(reply));
|
||||
break;
|
||||
}
|
||||
|
||||
case SERVER_GET_ENCODER_FOR_CODEC_INFO:
|
||||
{
|
||||
const server_get_encoder_for_codec_info_request& request
|
||||
= *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;
|
||||
}
|
||||
|
||||
default:
|
||||
printf("media_server: received unknown message code %#08" B_PRIx32
|
||||
"\n", code);
|
||||
@ -1000,14 +915,6 @@ ServerApp::MessageReceived(BMessage* msg)
|
||||
gMediaFilesManager->TimerMessage();
|
||||
break;
|
||||
|
||||
case MEDIA_SERVER_GET_FORMATS:
|
||||
gFormatManager->GetFormats(*msg);
|
||||
break;
|
||||
|
||||
case MEDIA_SERVER_MAKE_FORMAT_FOR:
|
||||
gFormatManager->MakeFormatFor(*msg);
|
||||
break;
|
||||
|
||||
case MEDIA_SERVER_ADD_SYSTEM_BEEP_EVENT:
|
||||
gMediaFilesManager->HandleAddSystemBeepEvent(msg);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user