2003-04-15 03:31:32 +04:00
|
|
|
/*
|
2008-03-12 02:24:40 +03:00
|
|
|
* Copyright (c) 2002, 2003, 2008 Marcus Overhagen <Marcus@Overhagen.de>
|
2003-04-15 03:31:32 +04:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files or portions
|
|
|
|
* thereof (the "Software"), to deal in the Software without restriction,
|
|
|
|
* including without limitation the rights to use, copy, modify, merge,
|
|
|
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
|
|
* and to permit persons to whom the Software is furnished to do so, subject
|
|
|
|
* to the following conditions:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright notice
|
|
|
|
* in the binary, as well as this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials provided with
|
|
|
|
* the distribution.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
#include <MediaAddOn.h>
|
|
|
|
#include <string.h>
|
2007-10-30 20:32:27 +03:00
|
|
|
#include <stdlib.h>
|
2008-03-12 02:24:40 +03:00
|
|
|
#include <new>
|
2002-07-09 16:24:59 +04:00
|
|
|
#include "debug.h"
|
2002-11-03 19:03:23 +03:00
|
|
|
#include "DataExchange.h"
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* some little helper function
|
|
|
|
*/
|
|
|
|
|
2008-03-12 02:24:40 +03:00
|
|
|
static inline char *_newstrdup(const char *str);
|
|
|
|
char *_newstrdup(const char *str)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
if (str == NULL)
|
|
|
|
return NULL;
|
|
|
|
int len = strlen(str) + 1;
|
2008-03-12 02:24:40 +03:00
|
|
|
char *p = new(std::nothrow) char[len];
|
|
|
|
if (p)
|
|
|
|
memcpy(p, str, len);
|
2002-07-09 16:24:59 +04:00
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
2008-03-12 02:24:40 +03:00
|
|
|
#define MAX_FLAVOR_IN_FORMAT_COUNT 300
|
|
|
|
#define MAX_FLAVOR_OUT_FORMAT_COUNT 300
|
|
|
|
|
2002-07-09 16:24:59 +04:00
|
|
|
#define FLATTEN_MAGIC 'CODE'
|
|
|
|
#define FLATTEN_TYPECODE 'DFIT'
|
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
* public dormant_node_info
|
|
|
|
*************************************************************/
|
|
|
|
|
|
|
|
// final & verified
|
|
|
|
dormant_node_info::dormant_node_info()
|
|
|
|
: addon(-1),
|
|
|
|
flavor_id(-1)
|
|
|
|
{
|
|
|
|
name[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
// final
|
|
|
|
dormant_node_info::~dormant_node_info()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
* private flavor_info
|
|
|
|
*************************************************************/
|
|
|
|
|
|
|
|
/* DO NOT IMPLEMENT */
|
|
|
|
/*
|
|
|
|
flavor_info &flavor_info::operator=(const flavor_info &other)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
* public dormant_flavor_info
|
|
|
|
*************************************************************/
|
|
|
|
|
|
|
|
// final & verified
|
|
|
|
dormant_flavor_info::dormant_flavor_info()
|
|
|
|
{
|
|
|
|
name = 0;
|
|
|
|
info = 0;
|
|
|
|
kinds = 0;
|
|
|
|
flavor_flags = 0;
|
|
|
|
internal_id = 0;
|
|
|
|
possible_count = 0;
|
|
|
|
in_format_count = 0;
|
|
|
|
in_format_flags = 0;
|
|
|
|
in_formats = 0;
|
|
|
|
out_format_count = 0;
|
|
|
|
out_format_flags = 0;
|
|
|
|
out_formats = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */
|
|
|
|
dormant_flavor_info::~dormant_flavor_info()
|
|
|
|
{
|
|
|
|
delete [] name;
|
|
|
|
delete [] info;
|
|
|
|
delete [] in_formats;
|
|
|
|
delete [] out_formats;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dormant_flavor_info::dormant_flavor_info(const dormant_flavor_info &clone)
|
|
|
|
{
|
|
|
|
*this = clone;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dormant_flavor_info &
|
|
|
|
dormant_flavor_info::operator=(const dormant_flavor_info &clone)
|
|
|
|
{
|
2002-07-15 04:33:52 +04:00
|
|
|
// call operator=(const flavor_info &clone) to copy the flavor_info base class
|
|
|
|
*this = static_cast<const flavor_info>(clone);
|
|
|
|
// copy the dormant_node_info member variable
|
2002-07-09 16:24:59 +04:00
|
|
|
node_info = clone.node_info;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dormant_flavor_info &
|
|
|
|
dormant_flavor_info::operator=(const flavor_info &clone)
|
|
|
|
{
|
|
|
|
kinds = clone.kinds;
|
|
|
|
flavor_flags = clone.flavor_flags;
|
|
|
|
internal_id = clone.internal_id;
|
|
|
|
possible_count = clone.possible_count;
|
|
|
|
|
2008-03-12 02:24:40 +03:00
|
|
|
delete [] info;
|
|
|
|
info = _newstrdup(clone.info);
|
|
|
|
|
|
|
|
delete [] name;
|
|
|
|
name = _newstrdup(clone.name);
|
|
|
|
|
|
|
|
delete [] in_formats;
|
|
|
|
in_formats = 0;
|
|
|
|
in_format_count = 0;
|
2002-07-09 16:24:59 +04:00
|
|
|
in_format_flags = clone.in_format_flags;
|
2008-03-12 02:24:40 +03:00
|
|
|
if (kinds & B_BUFFER_CONSUMER) {
|
|
|
|
if (clone.in_format_count >= 0 && clone.in_format_count <= MAX_FLAVOR_IN_FORMAT_COUNT) {
|
|
|
|
in_formats = new(std::nothrow) media_format[clone.in_format_count];
|
|
|
|
if (in_formats != NULL && clone.in_formats != NULL) {
|
|
|
|
in_format_count = clone.in_format_count;
|
|
|
|
for (int i = 0; i < in_format_count; i++)
|
|
|
|
const_cast<media_format &>(in_formats[i]) = clone.in_formats[i];
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
fprintf(stderr, "error: dormant_flavor_info::operator= clone.in_format_count is invalid\n");
|
|
|
|
} else if (clone.in_format_count)
|
|
|
|
fprintf(stderr, "warning: dormant_flavor_info::operator= not B_BUFFER_CONSUMER and clone.in_format_count is != 0\n");
|
|
|
|
|
|
|
|
delete [] out_formats;
|
|
|
|
out_formats = 0;
|
|
|
|
out_format_count = 0;
|
2002-07-09 16:24:59 +04:00
|
|
|
out_format_flags = clone.out_format_flags;
|
2008-03-12 02:24:40 +03:00
|
|
|
if (kinds & B_BUFFER_PRODUCER) {
|
|
|
|
if (clone.out_format_count >= 0 && clone.out_format_count <= MAX_FLAVOR_OUT_FORMAT_COUNT) {
|
|
|
|
out_formats = new(std::nothrow) media_format[clone.out_format_count];
|
|
|
|
if (out_formats != NULL && clone.out_formats != NULL) {
|
|
|
|
out_format_count = clone.out_format_count;
|
|
|
|
for (int i = 0; i < out_format_count; i++)
|
|
|
|
const_cast<media_format &>(out_formats[i]) = clone.out_formats[i];
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
fprintf(stderr, "error dormant_flavor_info::operator= clone.out_format_count is invalid\n");
|
2008-03-13 02:19:52 +03:00
|
|
|
} else if (clone.out_format_count)
|
2008-03-12 02:24:40 +03:00
|
|
|
fprintf(stderr, "warning: dormant_flavor_info::operator= not B_BUFFER_PRODUCER and clone.out_format_count is != 0\n");
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2002-07-15 04:33:52 +04:00
|
|
|
// initialize node_info with default values from dormant_node_info constructor
|
2008-03-12 02:24:40 +03:00
|
|
|
dormant_node_info defaultValues;
|
|
|
|
node_info = defaultValues;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
dormant_flavor_info::set_name(const char *in_name)
|
|
|
|
{
|
|
|
|
delete [] name;
|
2008-03-12 02:24:40 +03:00
|
|
|
name = _newstrdup(in_name);
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
dormant_flavor_info::set_info(const char *in_info)
|
|
|
|
{
|
|
|
|
delete [] info;
|
2008-03-12 02:24:40 +03:00
|
|
|
info = _newstrdup(in_info);
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
dormant_flavor_info::add_in_format(const media_format &in_format)
|
|
|
|
{
|
2008-03-12 02:24:40 +03:00
|
|
|
media_format *p = new(std::nothrow) media_format[in_format_count + 1];
|
|
|
|
if (p) {
|
|
|
|
for (int i = 0; i < in_format_count; i++)
|
|
|
|
p[i] = in_formats[i];
|
|
|
|
p[in_format_count] = in_format;
|
|
|
|
delete [] in_formats;
|
|
|
|
in_formats = p;
|
|
|
|
in_format_count += 1;
|
|
|
|
}
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
dormant_flavor_info::add_out_format(const media_format &out_format)
|
|
|
|
{
|
2008-03-12 02:24:40 +03:00
|
|
|
media_format *p = new(std::nothrow) media_format[out_format_count + 1];
|
|
|
|
if (p) {
|
|
|
|
for (int i = 0; i < out_format_count; i++)
|
|
|
|
p[i] = out_formats[i];
|
|
|
|
p[out_format_count] = out_format;
|
|
|
|
delete [] out_formats;
|
|
|
|
out_formats = p;
|
|
|
|
out_format_count += 1;
|
|
|
|
}
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */ bool
|
|
|
|
dormant_flavor_info::IsFixedSize() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */ type_code
|
|
|
|
dormant_flavor_info::TypeCode() const
|
|
|
|
{
|
|
|
|
return FLATTEN_TYPECODE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */ ssize_t
|
|
|
|
dormant_flavor_info::FlattenedSize() const
|
|
|
|
{
|
|
|
|
ssize_t size = 0;
|
|
|
|
// magic
|
|
|
|
size += sizeof(int32);
|
|
|
|
// size
|
|
|
|
size += sizeof(int32);
|
|
|
|
// struct flavor_info
|
|
|
|
size += sizeof(int32) + strlen(name);
|
|
|
|
size += sizeof(int32) + strlen(info);
|
|
|
|
size += sizeof(kinds);
|
|
|
|
size += sizeof(flavor_flags);
|
|
|
|
size += sizeof(internal_id);
|
|
|
|
size += sizeof(possible_count);
|
|
|
|
size += sizeof(in_format_count);
|
|
|
|
size += sizeof(in_format_flags);
|
2008-03-12 02:24:40 +03:00
|
|
|
if (in_format_count > 0 && in_format_count <= MAX_FLAVOR_IN_FORMAT_COUNT && in_formats != NULL)
|
|
|
|
size += in_format_count * sizeof(media_format);
|
2002-07-09 16:24:59 +04:00
|
|
|
size += sizeof(out_format_count);
|
|
|
|
size += sizeof(out_format_flags);
|
2008-03-12 02:24:40 +03:00
|
|
|
if (out_format_count > 0 && out_format_count <= MAX_FLAVOR_OUT_FORMAT_COUNT && out_formats != NULL)
|
|
|
|
size += out_format_count * sizeof(media_format);
|
2002-07-09 16:24:59 +04:00
|
|
|
// struct dormant_node_info node_info
|
|
|
|
size += sizeof(node_info);
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */ status_t
|
|
|
|
dormant_flavor_info::Flatten(void *buffer,
|
|
|
|
ssize_t size) const
|
|
|
|
{
|
|
|
|
if (size < FlattenedSize())
|
|
|
|
return B_ERROR;
|
|
|
|
|
|
|
|
char *buf = (char *)buffer;
|
2008-03-12 02:24:40 +03:00
|
|
|
int32 nameLength = name ? (int32)strlen(name) : -1;
|
|
|
|
int32 infoLength = info ? (int32)strlen(info) : -1;
|
|
|
|
int32 inFormatCount = 0;
|
|
|
|
size_t inFormatSize = 0;
|
|
|
|
int32 outFormatCount = 0;
|
|
|
|
size_t outFormatSize = 0;
|
|
|
|
|
|
|
|
if ((kinds & B_BUFFER_CONSUMER) && in_format_count > 0 && in_formats != NULL) {
|
|
|
|
if (in_format_count <= MAX_FLAVOR_IN_FORMAT_COUNT) {
|
|
|
|
inFormatCount = in_format_count;
|
|
|
|
inFormatSize = in_format_count * sizeof(media_format);
|
|
|
|
} else {
|
|
|
|
fprintf(stderr, "error dormant_flavor_info::Flatten: in_format_count is too large\n");
|
|
|
|
return B_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((kinds & B_BUFFER_PRODUCER) && out_format_count > 0 && out_formats != NULL) {
|
|
|
|
if (out_format_count <= MAX_FLAVOR_OUT_FORMAT_COUNT) {
|
|
|
|
outFormatCount = out_format_count;
|
|
|
|
outFormatSize = out_format_count * sizeof(media_format);
|
|
|
|
} else {
|
|
|
|
fprintf(stderr, "error dormant_flavor_info::Flatten: out_format_count is too large\n");
|
|
|
|
return B_ERROR;
|
|
|
|
}
|
|
|
|
}
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// magic
|
|
|
|
*(int32*)buf = FLATTEN_MAGIC; buf += sizeof(int32);
|
|
|
|
|
|
|
|
// size
|
|
|
|
*(int32*)buf = FlattenedSize(); buf += sizeof(int32);
|
|
|
|
|
|
|
|
// struct flavor_info
|
2008-03-12 02:24:40 +03:00
|
|
|
*(int32*)buf = nameLength; buf += sizeof(int32);
|
|
|
|
if (nameLength > 0) {
|
|
|
|
memcpy(buf, name, nameLength);
|
|
|
|
buf += nameLength;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
2008-03-12 02:24:40 +03:00
|
|
|
*(int32*)buf = infoLength; buf += sizeof(int32);
|
|
|
|
if (infoLength > 0) {
|
|
|
|
memcpy(buf, info, infoLength);
|
|
|
|
buf += infoLength;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
*(uint64*)buf = kinds; buf += sizeof(uint64);
|
|
|
|
*(uint32*)buf = flavor_flags; buf += sizeof(uint32);
|
|
|
|
*(int32*)buf = internal_id; buf += sizeof(int32);
|
|
|
|
*(int32*)buf = possible_count; buf += sizeof(int32);
|
2008-03-12 02:24:40 +03:00
|
|
|
*(int32*)buf = inFormatCount; buf += sizeof(int32);
|
2002-07-09 16:24:59 +04:00
|
|
|
*(uint32*)buf = in_format_flags; buf += sizeof(uint32);
|
|
|
|
|
|
|
|
// XXX FIXME! we should not!!! make flat copies of media_format
|
2008-03-12 02:24:40 +03:00
|
|
|
memcpy(buf, in_formats, inFormatSize); buf += inFormatSize;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2008-03-12 02:24:40 +03:00
|
|
|
*(int32*)buf = outFormatCount; buf += sizeof(int32);
|
2002-07-09 16:24:59 +04:00
|
|
|
*(uint32*)buf = out_format_flags; buf += sizeof(uint32);
|
|
|
|
|
|
|
|
// XXX FIXME! we should not!!! make flat copies of media_format
|
2008-03-12 02:24:40 +03:00
|
|
|
memcpy(buf, out_formats, outFormatSize); buf += outFormatSize;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
*(dormant_node_info*)buf = node_info; buf += sizeof(dormant_node_info);
|
|
|
|
|
|
|
|
return B_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */ status_t
|
|
|
|
dormant_flavor_info::Unflatten(type_code c,
|
|
|
|
const void *buffer,
|
|
|
|
ssize_t size)
|
|
|
|
{
|
|
|
|
if (c != FLATTEN_TYPECODE)
|
|
|
|
return B_ERROR;
|
|
|
|
if (size < 8)
|
|
|
|
return B_ERROR;
|
|
|
|
|
|
|
|
const char *buf = (const char *)buffer;
|
2008-03-12 02:24:40 +03:00
|
|
|
int32 nameLength;
|
|
|
|
int32 infoLength;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
2008-03-12 02:24:40 +03:00
|
|
|
// check magic
|
2002-07-09 16:24:59 +04:00
|
|
|
if (*(int32*)buf != FLATTEN_MAGIC)
|
|
|
|
return B_ERROR;
|
|
|
|
buf += sizeof(int32);
|
|
|
|
|
2008-03-12 02:24:40 +03:00
|
|
|
// check size
|
|
|
|
if (*(uint32*)buf > (uint32)size)
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_ERROR;
|
|
|
|
buf += sizeof(int32);
|
|
|
|
|
|
|
|
delete [] name;
|
2008-03-12 02:24:40 +03:00
|
|
|
name = NULL;
|
2002-07-09 16:24:59 +04:00
|
|
|
delete [] info;
|
2008-03-12 02:24:40 +03:00
|
|
|
info = NULL;
|
2002-07-09 16:24:59 +04:00
|
|
|
delete [] in_formats;
|
2008-03-12 02:24:40 +03:00
|
|
|
in_formats = NULL;
|
|
|
|
in_format_count = 0;
|
2002-07-09 16:24:59 +04:00
|
|
|
delete [] out_formats;
|
2008-03-12 02:24:40 +03:00
|
|
|
out_formats = NULL;
|
|
|
|
out_format_count = 0;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
// struct flavor_info
|
2008-03-12 02:24:40 +03:00
|
|
|
nameLength = *(int32*)buf; buf += sizeof(int32);
|
|
|
|
if (nameLength >= 0) { // if nameLength is -1, we leave name = 0
|
|
|
|
name = new(std::nothrow) char [nameLength + 1];
|
|
|
|
if (name) {
|
|
|
|
memcpy(name, buf, nameLength);
|
|
|
|
name[nameLength] = 0;
|
|
|
|
buf += nameLength; // XXX not save
|
|
|
|
}
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2008-03-12 02:24:40 +03:00
|
|
|
infoLength = *(int32*)buf; buf += sizeof(int32);
|
|
|
|
if (infoLength >= 0) { // if infoLength is -1, we leave info = 0
|
|
|
|
info = new(std::nothrow) char [infoLength + 1];
|
|
|
|
if (info) {
|
|
|
|
memcpy(info, buf, infoLength);
|
|
|
|
info[infoLength] = 0;
|
|
|
|
buf += infoLength; // XXX not save
|
|
|
|
}
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
2008-03-12 02:24:40 +03:00
|
|
|
|
|
|
|
int32 count;
|
2002-07-09 16:24:59 +04:00
|
|
|
|
|
|
|
kinds = *(uint64*)buf; buf += sizeof(uint64);
|
|
|
|
flavor_flags = *(uint32*)buf; buf += sizeof(uint32);
|
|
|
|
internal_id = *(int32*)buf; buf += sizeof(int32);
|
|
|
|
possible_count = *(int32*)buf; buf += sizeof(int32);
|
2008-03-12 02:24:40 +03:00
|
|
|
count = *(int32*)buf; buf += sizeof(int32);
|
2002-07-09 16:24:59 +04:00
|
|
|
in_format_flags = *(uint32*)buf; buf += sizeof(uint32);
|
|
|
|
|
2008-03-12 02:24:40 +03:00
|
|
|
if (count > 0) {
|
|
|
|
if (count <= MAX_FLAVOR_IN_FORMAT_COUNT) {
|
|
|
|
in_formats = new(std::nothrow) media_format[count];
|
|
|
|
if (!in_formats)
|
|
|
|
return B_NO_MEMORY;
|
|
|
|
// XXX FIXME! we should not!!! make flat copies of media_format
|
|
|
|
memcpy(const_cast<media_format *>(in_formats), buf, count * sizeof(media_format));
|
|
|
|
in_format_count = count;
|
|
|
|
}
|
|
|
|
buf += count * sizeof(media_format); // XXX not save
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
2008-03-12 02:24:40 +03:00
|
|
|
count = *(int32*)buf; buf += sizeof(int32);
|
2002-07-09 16:24:59 +04:00
|
|
|
out_format_flags = *(uint32*)buf; buf += sizeof(uint32);
|
|
|
|
|
2008-03-12 02:24:40 +03:00
|
|
|
if (count > 0) {
|
|
|
|
if (count <= MAX_FLAVOR_OUT_FORMAT_COUNT) {
|
|
|
|
out_formats = new(std::nothrow) media_format[count];
|
|
|
|
if (!out_formats)
|
|
|
|
return B_NO_MEMORY;
|
|
|
|
// XXX FIXME! we should not!!! make flat copies of media_format
|
|
|
|
memcpy(const_cast<media_format *>(out_formats), buf, count * sizeof(media_format));
|
|
|
|
out_format_count = count;
|
|
|
|
}
|
|
|
|
buf += count * sizeof(media_format); // XXX not save
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
node_info = *(dormant_node_info*)buf; buf += sizeof(dormant_node_info);
|
|
|
|
|
|
|
|
return B_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
* public BMediaAddOn
|
|
|
|
*************************************************************/
|
|
|
|
|
|
|
|
/* explicit */
|
|
|
|
BMediaAddOn::BMediaAddOn(image_id image) :
|
2002-08-12 23:38:19 +04:00
|
|
|
fImage(image),
|
|
|
|
fAddon(0)
|
2002-07-09 16:24:59 +04:00
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */
|
|
|
|
BMediaAddOn::~BMediaAddOn()
|
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */ status_t
|
|
|
|
BMediaAddOn::InitCheck(const char **out_failure_text)
|
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
// only to be implemented by derived classes
|
|
|
|
*out_failure_text = "no error";
|
|
|
|
return B_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */ int32
|
|
|
|
BMediaAddOn::CountFlavors()
|
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
// only to be implemented by derived classes
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */ status_t
|
|
|
|
BMediaAddOn::GetFlavorAt(int32 n,
|
|
|
|
const flavor_info **out_info)
|
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
// only to be implemented by derived classes
|
|
|
|
return B_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */ BMediaNode *
|
|
|
|
BMediaAddOn::InstantiateNodeFor(const flavor_info *info,
|
|
|
|
BMessage *config,
|
|
|
|
status_t *out_error)
|
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
// only to be implemented by derived classes
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */ status_t
|
|
|
|
BMediaAddOn::GetConfigurationFor(BMediaNode *your_node,
|
|
|
|
BMessage *into_message)
|
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
// only to be implemented by derived classes
|
|
|
|
return B_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */ bool
|
|
|
|
BMediaAddOn::WantsAutoStart()
|
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
// only to be implemented by derived classes
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */ status_t
|
|
|
|
BMediaAddOn::AutoStart(int in_count,
|
|
|
|
BMediaNode **out_node,
|
|
|
|
int32 *out_internal_id,
|
|
|
|
bool *out_has_more)
|
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
// only to be implemented by derived classes
|
|
|
|
return B_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */ status_t
|
|
|
|
BMediaAddOn::SniffRef(const entry_ref &file,
|
|
|
|
BMimeType *io_mime_type,
|
|
|
|
float *out_quality,
|
|
|
|
int32 *out_internal_id)
|
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
// only to be implemented by BFileInterface derived classes
|
|
|
|
return B_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */ status_t
|
|
|
|
BMediaAddOn::SniffType(const BMimeType &type,
|
|
|
|
float *out_quality,
|
|
|
|
int32 *out_internal_id)
|
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
// only to be implemented by BFileInterface derived classes
|
|
|
|
return B_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */ status_t
|
|
|
|
BMediaAddOn::GetFileFormatList(int32 flavor_id,
|
|
|
|
media_file_format *out_writable_formats,
|
|
|
|
int32 in_write_items,
|
|
|
|
int32 *out_write_items,
|
|
|
|
media_file_format *out_readable_formats,
|
|
|
|
int32 in_read_items,
|
|
|
|
int32 *out_read_items,
|
|
|
|
void *_reserved)
|
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
// only to be implemented by BFileInterface derived classes
|
|
|
|
return B_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */ status_t
|
|
|
|
BMediaAddOn::SniffTypeKind(const BMimeType &type,
|
|
|
|
uint64 in_kinds,
|
|
|
|
float *out_quality,
|
|
|
|
int32 *out_internal_id,
|
|
|
|
void *_reserved)
|
|
|
|
{
|
|
|
|
CALLED();
|
|
|
|
// only to be implemented by BFileInterface derived classes
|
|
|
|
return B_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
image_id
|
|
|
|
BMediaAddOn::ImageID()
|
|
|
|
{
|
2002-08-12 23:38:19 +04:00
|
|
|
return fImage;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
media_addon_id
|
|
|
|
BMediaAddOn::AddonID()
|
|
|
|
{
|
2002-08-12 23:38:19 +04:00
|
|
|
return fAddon;
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
* protected BMediaAddOn
|
|
|
|
*************************************************************/
|
|
|
|
|
|
|
|
status_t
|
|
|
|
BMediaAddOn::NotifyFlavorChange()
|
|
|
|
{
|
2002-08-13 19:21:32 +04:00
|
|
|
CALLED();
|
2002-08-12 23:38:19 +04:00
|
|
|
if (fAddon == 0)
|
2002-07-09 16:24:59 +04:00
|
|
|
return B_ERROR;
|
|
|
|
|
2002-11-20 04:28:23 +03:00
|
|
|
addonserver_rescan_mediaaddon_flavors_command command;
|
|
|
|
command.addonid = fAddon;
|
|
|
|
return SendToAddonServer(ADDONSERVER_RESCAN_MEDIAADDON_FLAVORS, &command, sizeof(command));
|
2002-07-09 16:24:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
* private BMediaAddOn
|
|
|
|
*************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
unimplemented:
|
|
|
|
BMediaAddOn::BMediaAddOn()
|
|
|
|
BMediaAddOn::BMediaAddOn(const BMediaAddOn &clone)
|
|
|
|
BMediaAddOn & BMediaAddOn::operator=(const BMediaAddOn &clone)
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************
|
|
|
|
* private BMediaAddOn
|
|
|
|
*************************************************************/
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
// declared here to remove them from the class header file
|
|
|
|
status_t _Reserved_MediaAddOn_0__11BMediaAddOnPv(void *, void *); /* now used for BMediaAddOn::GetFileFormatList */
|
|
|
|
status_t _Reserved_MediaAddOn_1__11BMediaAddOnPv(void *, void *); /* now used for BMediaAddOn::SniffTypeKind */
|
|
|
|
status_t _Reserved_MediaAddOn_0__11BMediaAddOnPv(void *, void *) { return B_ERROR; }
|
|
|
|
status_t _Reserved_MediaAddOn_1__11BMediaAddOnPv(void *, void *) { return B_ERROR; }
|
|
|
|
};
|
|
|
|
|
|
|
|
status_t BMediaAddOn::_Reserved_MediaAddOn_2(void *) { return B_ERROR; }
|
|
|
|
status_t BMediaAddOn::_Reserved_MediaAddOn_3(void *) { return B_ERROR; }
|
|
|
|
status_t BMediaAddOn::_Reserved_MediaAddOn_4(void *) { return B_ERROR; }
|
|
|
|
status_t BMediaAddOn::_Reserved_MediaAddOn_5(void *) { return B_ERROR; }
|
|
|
|
status_t BMediaAddOn::_Reserved_MediaAddOn_6(void *) { return B_ERROR; }
|
|
|
|
status_t BMediaAddOn::_Reserved_MediaAddOn_7(void *) { return B_ERROR; }
|
|
|
|
|