update to the codec api, docoder assignment is now handled in the server
multiple reader add-ons are probed to recognize a media file FormatManager does the translation from media_format to media_description git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5667 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -0,0 +1,258 @@
|
||||
#include <MediaFormats.h>
|
||||
#include <Locker.h>
|
||||
#include <Path.h>
|
||||
#include <Entry.h>
|
||||
#include <Directory.h>
|
||||
#include <image.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "AddOnManager.h"
|
||||
#include "FormatManager.h"
|
||||
#include "debug.h"
|
||||
|
||||
extern FormatManager *gFormatManager;
|
||||
extern AddOnManager *gAddOnManager;
|
||||
|
||||
status_t
|
||||
_PublishDecoder(DecoderPlugin *decoderplugin,
|
||||
const char *meta_description,
|
||||
const char *short_name,
|
||||
const char *pretty_name,
|
||||
const char *default_mapping /* = 0 */);
|
||||
|
||||
bool operator==(const media_meta_description & a, const media_meta_description & b);
|
||||
|
||||
AddOnManager::AddOnManager()
|
||||
: fLocker(new BLocker),
|
||||
fReaderList(new List<reader_info>),
|
||||
fWriterList(new List<writer_info>),
|
||||
fDecoderList(new List<decoder_info>),
|
||||
fEncoderList(new List<encoder_info>),
|
||||
fReaderInfo(0),
|
||||
fWriterInfo(0),
|
||||
fDecoderInfo(0),
|
||||
fEncoderInfo(0)
|
||||
{
|
||||
}
|
||||
|
||||
AddOnManager::~AddOnManager()
|
||||
{
|
||||
delete fLocker;
|
||||
delete fReaderList;
|
||||
delete fWriterList;
|
||||
delete fDecoderList;
|
||||
delete fEncoderList;
|
||||
}
|
||||
|
||||
void
|
||||
AddOnManager::LoadState()
|
||||
{
|
||||
RegisterAddOns();
|
||||
}
|
||||
|
||||
void
|
||||
AddOnManager::SaveState()
|
||||
{
|
||||
}
|
||||
|
||||
status_t
|
||||
AddOnManager::GetDecoderForFormat(xfer_entry_ref *out_ref,
|
||||
const media_format &in_format)
|
||||
{
|
||||
media_format_description desc;
|
||||
|
||||
if (B_OK != gFormatManager->GetDescriptionForFormat(&desc, in_format, B_META_FORMAT_FAMILY)) {
|
||||
printf("AddOnManager::GetDecoderForFormat: Error, meta format description unknown\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
fLocker->Lock();
|
||||
decoder_info *info;
|
||||
for (fDecoderList->Rewind(); fDecoderList->GetNext(&info); ) {
|
||||
media_meta_description *meta_desc;
|
||||
for (info->meta_desc.Rewind(); info->meta_desc.GetNext(&meta_desc); ) {
|
||||
if (desc.u.meta == *meta_desc) {
|
||||
printf("AddOnManager::GetDecoderForFormat: found decoder %s for format %s\n", info->ref.name, meta_desc->description);
|
||||
*out_ref = info->ref;
|
||||
fLocker->Unlock();
|
||||
return B_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
fLocker->Unlock();
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
status_t
|
||||
AddOnManager::GetReaders(xfer_entry_ref *out_res, int32 *out_count, int32 max_count)
|
||||
{
|
||||
fLocker->Lock();
|
||||
|
||||
*out_count = 0;
|
||||
|
||||
reader_info *info;
|
||||
for (*out_count = 0, fReaderList->Rewind(); fReaderList->GetNext(&info) && *out_count <= max_count; *out_count += 1)
|
||||
out_res[*out_count] = info->ref;
|
||||
|
||||
fLocker->Unlock();
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
void
|
||||
AddOnManager::RegisterAddOns()
|
||||
{
|
||||
const char *searchdir[] = {
|
||||
"/boot/home/config/add-ons/media/plugins",
|
||||
"/boot/beos/system/add-ons/media/plugins",
|
||||
"/boot/home/develop/openbeos/current/distro/x86.R1/beos/system/add-ons/media/plugins",
|
||||
NULL
|
||||
};
|
||||
|
||||
for (int i = 0; searchdir[i]; i++) {
|
||||
BDirectory dir(searchdir[i]);
|
||||
BEntry e;
|
||||
while (B_OK == dir.GetNextEntry(&e)) {
|
||||
BPath p(&e);
|
||||
entry_ref ref;
|
||||
e.GetRef(&ref);
|
||||
|
||||
printf("AddOnManager: RegisterAddOns trying to load %s\n", p.Path());
|
||||
|
||||
image_id id;
|
||||
id = load_add_on(p.Path());
|
||||
if (id < 0)
|
||||
continue;
|
||||
|
||||
MediaPlugin *(*instantiate_plugin_func)();
|
||||
|
||||
if (get_image_symbol(id, "instantiate_plugin", B_SYMBOL_TYPE_TEXT, (void**)&instantiate_plugin_func) < B_OK) {
|
||||
printf("AddOnManager: Error, RegisterAddOns can't find instantiate_plugin in %s\n", p.Path());
|
||||
unload_add_on(id);
|
||||
continue;
|
||||
}
|
||||
|
||||
MediaPlugin *pl;
|
||||
|
||||
pl = (*instantiate_plugin_func)();
|
||||
if (pl == 0) {
|
||||
printf("AddOnManager: Error, RegisterAddOns instantiate_plugin in %s returned 0\n", p.Path());
|
||||
unload_add_on(id);
|
||||
continue;
|
||||
}
|
||||
|
||||
ReaderPlugin *rp = dynamic_cast<ReaderPlugin *>(pl);
|
||||
if (rp)
|
||||
RegisterReader(rp, ref);
|
||||
|
||||
DecoderPlugin *dp = dynamic_cast<DecoderPlugin *>(pl);
|
||||
if (dp)
|
||||
RegisterDecoder(dp, ref);
|
||||
|
||||
delete pl;
|
||||
unload_add_on(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
AddOnManager::RegisterReader(ReaderPlugin *reader, const entry_ref &ref)
|
||||
{
|
||||
bool already_found;
|
||||
reader_info *pinfo;
|
||||
|
||||
fLocker->Lock();
|
||||
for (already_found = false, fReaderList->Rewind(); fReaderList->GetNext(&pinfo); )
|
||||
if (0 == strcmp(pinfo->ref.name, ref.name)) {
|
||||
already_found = true;
|
||||
break;
|
||||
}
|
||||
fLocker->Unlock();
|
||||
if (already_found)
|
||||
return;
|
||||
|
||||
printf("AddOnManager::RegisterReader, name %s\n", ref.name);
|
||||
|
||||
reader_info info;
|
||||
info.ref = ref;
|
||||
|
||||
if (B_OK != reader->RegisterPlugin())
|
||||
return;
|
||||
|
||||
fLocker->Lock();
|
||||
fReaderList->Insert(info);
|
||||
fLocker->Unlock();
|
||||
}
|
||||
|
||||
void
|
||||
AddOnManager::RegisterDecoder(DecoderPlugin *decoder, const entry_ref &ref)
|
||||
{
|
||||
bool already_found;
|
||||
decoder_info *pinfo;
|
||||
|
||||
fLocker->Lock();
|
||||
for (already_found = false, fDecoderList->Rewind(); fDecoderList->GetNext(&pinfo); )
|
||||
if (0 == strcmp(pinfo->ref.name, ref.name)) {
|
||||
already_found = true;
|
||||
break;
|
||||
}
|
||||
fLocker->Unlock();
|
||||
if (already_found)
|
||||
return;
|
||||
|
||||
printf("AddOnManager::RegisterDecoder, name %s\n", ref.name);
|
||||
|
||||
decoder->Setup((void*)&_PublishDecoder);
|
||||
|
||||
decoder_info info;
|
||||
info.ref = ref;
|
||||
fDecoderInfo = &info;
|
||||
|
||||
if (B_OK != decoder->RegisterPlugin())
|
||||
return;
|
||||
|
||||
fLocker->Lock();
|
||||
fDecoderList->Insert(info);
|
||||
fLocker->Unlock();
|
||||
fDecoderInfo = 0;
|
||||
}
|
||||
|
||||
status_t
|
||||
AddOnManager::PublishDecoderCallback(DecoderPlugin *decoderplugin,
|
||||
const char *meta_description,
|
||||
const char *short_name,
|
||||
const char *pretty_name,
|
||||
const char *default_mapping /* = 0 */)
|
||||
{
|
||||
|
||||
printf("AddOnManager::PublishDecoderCallback: meta_description \"%s\", short_name \"%s\", pretty_name \"%s\", default_mapping \"%s\"\n",
|
||||
meta_description, short_name, pretty_name, default_mapping);
|
||||
|
||||
media_meta_description meta_desc;
|
||||
snprintf(meta_desc.description, sizeof(meta_desc), "%s", meta_description);
|
||||
|
||||
fDecoderInfo->meta_desc.Insert(meta_desc);
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
//typedef status_t *(*publish_func)(DecoderPlugin *, const char *, const char *, const char *, const char *);
|
||||
status_t
|
||||
_PublishDecoder(DecoderPlugin *decoderplugin,
|
||||
const char *meta_description,
|
||||
const char *short_name,
|
||||
const char *pretty_name,
|
||||
const char *default_mapping /* = 0 */)
|
||||
{
|
||||
return gAddOnManager->PublishDecoderCallback(decoderplugin,
|
||||
meta_description,
|
||||
short_name,
|
||||
pretty_name,
|
||||
default_mapping);
|
||||
}
|
||||
|
||||
bool
|
||||
operator==(const media_meta_description & a, const media_meta_description & b)
|
||||
{
|
||||
return 0 == strcmp(a.description, b.description);
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
#ifndef _ADD_ON_MANAGER_H
|
||||
#define _ADD_ON_MANAGER_H
|
||||
|
||||
// Manager for codec add-ons (reader, writer, encoder, decoder)
|
||||
// BMediaAddOn are handled in the NodeManager
|
||||
|
||||
#include "TList.h"
|
||||
#include "ReaderPlugin.h"
|
||||
#include "DecoderPlugin.h"
|
||||
#include "DataExchange.h"
|
||||
|
||||
class AddOnManager
|
||||
{
|
||||
public:
|
||||
AddOnManager();
|
||||
~AddOnManager();
|
||||
|
||||
void LoadState();
|
||||
void SaveState();
|
||||
|
||||
status_t GetDecoderForFormat(xfer_entry_ref *out_ref,
|
||||
const media_format &in_format);
|
||||
|
||||
status_t GetReaders(xfer_entry_ref *out_res, int32 *out_count, int32 max_count);
|
||||
|
||||
status_t PublishDecoderCallback(DecoderPlugin *decoderplugin,
|
||||
const char *meta_description,
|
||||
const char *short_name,
|
||||
const char *pretty_name,
|
||||
const char *default_mapping /* = 0 */);
|
||||
|
||||
private:
|
||||
void RegisterAddOns();
|
||||
void RegisterReader(ReaderPlugin *reader, const entry_ref &ref);
|
||||
void RegisterDecoder(DecoderPlugin *decoder, const entry_ref &ref);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
struct reader_info
|
||||
{
|
||||
entry_ref ref;
|
||||
};
|
||||
struct writer_info
|
||||
{
|
||||
entry_ref ref;
|
||||
};
|
||||
struct decoder_info
|
||||
{
|
||||
entry_ref ref;
|
||||
List<media_meta_description> meta_desc;
|
||||
};
|
||||
struct encoder_info
|
||||
{
|
||||
entry_ref ref;
|
||||
};
|
||||
|
||||
BLocker *fLocker;
|
||||
List<reader_info> *fReaderList;
|
||||
List<writer_info> *fWriterList;
|
||||
List<decoder_info> *fDecoderList;
|
||||
List<encoder_info> *fEncoderList;
|
||||
|
||||
reader_info *fReaderInfo;
|
||||
writer_info *fWriterInfo;
|
||||
decoder_info *fDecoderInfo;
|
||||
encoder_info *fEncoderInfo;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // _ADD_ON_MANAGER_H
|
||||
@@ -0,0 +1,180 @@
|
||||
#include <stdio.h>
|
||||
#include <MediaFormats.h>
|
||||
#include <string.h>
|
||||
#include "FormatManager.h"
|
||||
#include "debug.h"
|
||||
|
||||
const char *family_to_string(media_format_family in_family);
|
||||
const char *string_for_description(const media_format_description &in_description, char *string, size_t length);
|
||||
|
||||
FormatManager::FormatManager()
|
||||
{
|
||||
}
|
||||
|
||||
FormatManager::~FormatManager()
|
||||
{
|
||||
}
|
||||
|
||||
status_t
|
||||
FormatManager::GetFormatForDescription(media_format *out_format,
|
||||
const media_format_description &in_desc)
|
||||
{
|
||||
char s[128];
|
||||
printf("GetFormatForDescription, description: %s\n",
|
||||
string_for_description(in_desc, s, sizeof(s)));
|
||||
|
||||
memset(out_format, 0, sizeof(*out_format));
|
||||
|
||||
if (in_desc.family == B_BEOS_FORMAT_FAMILY && in_desc.u.beos.format == B_BEOS_FORMAT_RAW_AUDIO)
|
||||
out_format->type = B_MEDIA_RAW_AUDIO;
|
||||
else {
|
||||
out_format->type = B_MEDIA_ENCODED_AUDIO;
|
||||
out_format->u.encoded_audio.encoding = (enum media_encoded_audio_format::audio_encoding) in_desc.family;
|
||||
}
|
||||
|
||||
string_for_format(*out_format, s, sizeof(s));
|
||||
printf(" encoding %d, format %s\n", (int)out_format->u.encoded_audio.encoding, s);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
status_t
|
||||
FormatManager::GetDescriptionForFormat(media_format_description *out_description,
|
||||
const media_format &in_format,
|
||||
media_format_family in_family)
|
||||
{
|
||||
printf("GetDescriptionForFormat, requested %s family\n",
|
||||
family_to_string(in_family));
|
||||
char s[128];
|
||||
string_for_format(in_format, s, sizeof(s));
|
||||
printf(" encoding %d, format %s\n", (int)in_format.u.encoded_audio.encoding, s);
|
||||
|
||||
|
||||
if (in_family != B_META_FORMAT_FAMILY)
|
||||
return B_ERROR;
|
||||
|
||||
if (in_format.type == B_MEDIA_RAW_AUDIO) {
|
||||
out_description->family = B_META_FORMAT_FAMILY;
|
||||
strcpy(out_description->u.meta.description, "audiocodec/raw");
|
||||
goto finished;
|
||||
}
|
||||
if (in_format.type == B_MEDIA_RAW_VIDEO) {
|
||||
out_description->family = B_META_FORMAT_FAMILY;
|
||||
strcpy(out_description->u.meta.description, "videocodec/raw");
|
||||
goto finished;
|
||||
}
|
||||
|
||||
out_description->family = B_META_FORMAT_FAMILY;
|
||||
switch (in_format.u.encoded_audio.encoding) {
|
||||
|
||||
case B_MPEG_FORMAT_FAMILY:
|
||||
strcpy(out_description->u.meta.description, "audiocodec/mpeg1layer3");
|
||||
break;
|
||||
|
||||
default:
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
finished:
|
||||
printf(" description: %s\n",
|
||||
string_for_description(*out_description, s, sizeof(s)));
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
void
|
||||
FormatManager::LoadState()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
FormatManager::SaveState()
|
||||
{
|
||||
}
|
||||
|
||||
const char *
|
||||
family_to_string(media_format_family family)
|
||||
{
|
||||
switch (family) {
|
||||
case B_ANY_FORMAT_FAMILY:
|
||||
return "any";
|
||||
case B_BEOS_FORMAT_FAMILY:
|
||||
return "BeOS";
|
||||
case B_QUICKTIME_FORMAT_FAMILY:
|
||||
return "Quicktime";
|
||||
case B_AVI_FORMAT_FAMILY:
|
||||
return "AVI";
|
||||
case B_ASF_FORMAT_FAMILY:
|
||||
return "ASF";
|
||||
case B_MPEG_FORMAT_FAMILY:
|
||||
return "MPEG";
|
||||
case B_WAV_FORMAT_FAMILY:
|
||||
return "WAV";
|
||||
case B_AIFF_FORMAT_FAMILY:
|
||||
return "AIFF";
|
||||
case B_AVR_FORMAT_FAMILY:
|
||||
return "AVR";
|
||||
case B_OGG_FORMAT_FAMILY:
|
||||
return "OGG";
|
||||
case B_MISC_FORMAT_FAMILY:
|
||||
return "misc";
|
||||
case B_META_FORMAT_FAMILY:
|
||||
return "meta";
|
||||
default:
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
||||
const char *
|
||||
string_for_description(const media_format_description &desc, char *string, size_t length)
|
||||
{
|
||||
switch (desc.family) {
|
||||
case B_ANY_FORMAT_FAMILY:
|
||||
snprintf(string, length, "any format");
|
||||
break;
|
||||
case B_BEOS_FORMAT_FAMILY:
|
||||
snprintf(string, length, "BeOS format, format id 0x%lx", desc.u.beos.format);
|
||||
break;
|
||||
case B_QUICKTIME_FORMAT_FAMILY:
|
||||
snprintf(string, length, "Quicktime format, vendor id 0x%lx, codec id 0x%lx", desc.u.quicktime.vendor, desc.u.quicktime.codec);
|
||||
break;
|
||||
case B_AVI_FORMAT_FAMILY:
|
||||
snprintf(string, length, "AVI format, codec id 0x%lx", desc.u.avi.codec);
|
||||
break;
|
||||
case B_ASF_FORMAT_FAMILY:
|
||||
snprintf(string, length, "ASF format, GUID %02x %02x %02x %02x %02x %02x "
|
||||
"%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
|
||||
desc.u.asf.guid.data[0], desc.u.asf.guid.data[1],
|
||||
desc.u.asf.guid.data[2], desc.u.asf.guid.data[3],
|
||||
desc.u.asf.guid.data[4], desc.u.asf.guid.data[5],
|
||||
desc.u.asf.guid.data[6], desc.u.asf.guid.data[7],
|
||||
desc.u.asf.guid.data[8], desc.u.asf.guid.data[9],
|
||||
desc.u.asf.guid.data[10], desc.u.asf.guid.data[11],
|
||||
desc.u.asf.guid.data[12], desc.u.asf.guid.data[13],
|
||||
desc.u.asf.guid.data[14], desc.u.asf.guid.data[15]);
|
||||
break;
|
||||
case B_MPEG_FORMAT_FAMILY:
|
||||
snprintf(string, length, "MPEG format, id 0x%lx", desc.u.mpeg.id);
|
||||
break;
|
||||
case B_WAV_FORMAT_FAMILY:
|
||||
snprintf(string, length, "WAV format, codec id 0x%lx", desc.u.wav.codec);
|
||||
break;
|
||||
case B_AIFF_FORMAT_FAMILY:
|
||||
snprintf(string, length, "AIFF format, codec id 0x%lx", desc.u.aiff.codec);
|
||||
break;
|
||||
case B_AVR_FORMAT_FAMILY:
|
||||
snprintf(string, length, "AVR format, id 0x%lx", desc.u.avr.id);
|
||||
break;
|
||||
case B_OGG_FORMAT_FAMILY:
|
||||
snprintf(string, length, "OGG format");
|
||||
break;
|
||||
case B_MISC_FORMAT_FAMILY:
|
||||
snprintf(string, length, "misc format, file-format id 0x%lx, codec id 0x%lx", desc.u.misc.file_format, desc.u.misc.codec);
|
||||
break;
|
||||
case B_META_FORMAT_FAMILY:
|
||||
snprintf(string, length, "meta format, description %s", desc.u.meta.description);
|
||||
break;
|
||||
default:
|
||||
snprintf(string, length, "unknown format");
|
||||
break;
|
||||
}
|
||||
return string;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
#ifndef _FORMAT_MANAGER_H
|
||||
#define _FORMAT_MANAGER_H
|
||||
|
||||
class FormatManager
|
||||
{
|
||||
public:
|
||||
FormatManager();
|
||||
~FormatManager();
|
||||
|
||||
void LoadState();
|
||||
void SaveState();
|
||||
|
||||
status_t GetFormatForDescription(media_format *out_format,
|
||||
const media_format_description &in_description);
|
||||
|
||||
status_t GetDescriptionForFormat(media_format_description *out_description,
|
||||
const media_format &in_format,
|
||||
media_format_family in_family);
|
||||
};
|
||||
|
||||
#endif // _FORMAT_MANAGER_H
|
||||
@@ -6,9 +6,11 @@ AddResources media_server : media_server.rdef ;
|
||||
|
||||
Server media_server :
|
||||
media_server.cpp
|
||||
AddOnManager.cpp
|
||||
AppManager.cpp
|
||||
BufferManager.cpp
|
||||
DefaultManager.cpp
|
||||
FormatManager.cpp
|
||||
MMediaFilesManager.cpp
|
||||
NodeManager.cpp
|
||||
NotificationManager.cpp
|
||||
|
||||
@@ -118,7 +118,7 @@ MMediaFilesManager::LoadState()
|
||||
}
|
||||
/*if (file.Read(&vol, sizeof(uint32)) < (int32)sizeof(uint32))
|
||||
return B_ERROR;*/
|
||||
TRACE(" %s: %s, volume: %f\n", key, val, *(float *)&vol);
|
||||
//TRACE(" %s: %s, volume: %f\n", key, val, *(float *)&vol);
|
||||
|
||||
entry_ref ref;
|
||||
if(len>1) {
|
||||
|
||||
@@ -43,7 +43,9 @@ char __dont_remove_copyright_from_binary[] = "Copyright (c) 2002, 2003 Marcus Ov
|
||||
#include "DataExchange.h"
|
||||
#include "BufferManager.h"
|
||||
#include "NodeManager.h"
|
||||
#include "AddOnManager.h"
|
||||
#include "AppManager.h"
|
||||
#include "FormatManager.h"
|
||||
#include "MediaMisc.h"
|
||||
#include "media_server.h"
|
||||
#include "debug.h"
|
||||
@@ -55,11 +57,13 @@ char __dont_remove_copyright_from_binary[] = "Copyright (c) 2002, 2003 Marcus Ov
|
||||
*
|
||||
*/
|
||||
|
||||
NotificationManager *gNotificationManager;
|
||||
BufferManager *gBufferManager;
|
||||
AppManager *gAppManager;
|
||||
NodeManager *gNodeManager;
|
||||
MMediaFilesManager *gMMediaFilesManager;
|
||||
AddOnManager * gAddOnManager;
|
||||
AppManager * gAppManager;
|
||||
BufferManager * gBufferManager;
|
||||
FormatManager * gFormatManager;
|
||||
MMediaFilesManager * gMMediaFilesManager;
|
||||
NodeManager * gNodeManager;
|
||||
NotificationManager * gNotificationManager;
|
||||
|
||||
namespace BPrivate { namespace media {
|
||||
extern team_id team;
|
||||
@@ -121,6 +125,8 @@ ServerApp::ServerApp()
|
||||
gAppManager = new AppManager;
|
||||
gNodeManager = new NodeManager;
|
||||
gMMediaFilesManager = new MMediaFilesManager;
|
||||
gFormatManager = new FormatManager;
|
||||
gAddOnManager = new AddOnManager;
|
||||
|
||||
control_port = create_port(64, MEDIA_SERVER_PORT_NAME);
|
||||
control_thread = spawn_thread(controlthread, "media_server control", 105, this);
|
||||
@@ -128,17 +134,21 @@ ServerApp::ServerApp()
|
||||
|
||||
// StartSystemTimeSource();
|
||||
gNodeManager->LoadState();
|
||||
gFormatManager->LoadState();
|
||||
gAddOnManager->LoadState();
|
||||
gAppManager->StartAddonServer();
|
||||
}
|
||||
|
||||
ServerApp::~ServerApp()
|
||||
{
|
||||
TRACE("ServerApp::~ServerApp()\n");
|
||||
delete gAddOnManager;
|
||||
delete gNotificationManager;
|
||||
delete gBufferManager;
|
||||
delete gAppManager;
|
||||
delete gNodeManager;
|
||||
delete gMMediaFilesManager;
|
||||
delete gFormatManager;
|
||||
delete fLocker;
|
||||
delete_port(control_port);
|
||||
status_t err;
|
||||
@@ -173,6 +183,8 @@ ServerApp::QuitRequested()
|
||||
TRACE("ServerApp::QuitRequested()\n");
|
||||
gMMediaFilesManager->SaveState();
|
||||
gNodeManager->SaveState();
|
||||
gFormatManager->SaveState();
|
||||
gAddOnManager->SaveState();
|
||||
gAppManager->TerminateAddonServer();
|
||||
return true;
|
||||
}
|
||||
@@ -671,6 +683,42 @@ ServerApp::HandleMessage(int32 code, void *data, size_t size)
|
||||
break;
|
||||
}
|
||||
|
||||
case SERVER_GET_FORMAT_FOR_DESCRIPTION:
|
||||
{
|
||||
const server_get_format_for_description_request *request = reinterpret_cast<const server_get_format_for_description_request *>(data);
|
||||
server_get_format_for_description_reply reply;
|
||||
rv = gFormatManager->GetFormatForDescription(&reply.format, request->description);
|
||||
request->SendReply(rv, &reply, sizeof(reply));
|
||||
break;
|
||||
}
|
||||
|
||||
case SERVER_GET_DESCRIPTION_FOR_FORMAT:
|
||||
{
|
||||
const server_get_description_for_format_request *request = reinterpret_cast<const server_get_description_for_format_request *>(data);
|
||||
server_get_description_for_format_reply reply;
|
||||
rv = gFormatManager->GetDescriptionForFormat(&reply.description, request->format, request->family);
|
||||
request->SendReply(rv, &reply, sizeof(reply));
|
||||
break;
|
||||
}
|
||||
|
||||
case SERVER_GET_READERS:
|
||||
{
|
||||
const server_get_readers_request *request = reinterpret_cast<const server_get_readers_request *>(data);
|
||||
server_get_readers_reply reply;
|
||||
rv = gAddOnManager->GetReaders(reply.ref, &reply.count, MAX_READERS);
|
||||
request->SendReply(rv, &reply, sizeof(reply));
|
||||
break;
|
||||
}
|
||||
|
||||
case SERVER_GET_DECODER_FOR_FORMAT:
|
||||
{
|
||||
const server_get_decoder_for_format_request *request = reinterpret_cast<const server_get_decoder_for_format_request *>(data);
|
||||
server_get_decoder_for_format_reply reply;
|
||||
rv = gAddOnManager->GetDecoderForFormat(&reply.ref, request->format);
|
||||
request->SendReply(rv, &reply, sizeof(reply));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
printf("media_server: received unknown message code %#08lx\n",code);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user