initial commit
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1032 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
abbf22f13e
commit
8c5a53fbe5
10
src/add-ons/media/media-add-ons/fileproducer/Jamfile
Normal file
10
src/add-ons/media/media-add-ons/fileproducer/Jamfile
Normal file
@ -0,0 +1,10 @@
|
||||
SubDir OBOS_TOP src add-ons media media-add-ons fileproducer ;
|
||||
|
||||
UsePrivateHeaders media ;
|
||||
|
||||
Addon fileproducer.media_addon : media :
|
||||
MediaFileProducer.cpp
|
||||
MediaFileProducerAddOn.cpp
|
||||
;
|
||||
|
||||
LinkSharedOSLibs fileproducer.media_addon : be media ;
|
1353
src/add-ons/media/media-add-ons/fileproducer/MediaFileProducer.cpp
Normal file
1353
src/add-ons/media/media-add-ons/fileproducer/MediaFileProducer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
402
src/add-ons/media/media-add-ons/fileproducer/MediaFileProducer.h
Normal file
402
src/add-ons/media/media-add-ons/fileproducer/MediaFileProducer.h
Normal file
@ -0,0 +1,402 @@
|
||||
// MediaFileProducer.h
|
||||
//
|
||||
// Andrew Bachmann, 2002
|
||||
//
|
||||
// A MediaFileProducer is a node that
|
||||
// implements FileInterface and BBufferProducer.
|
||||
// It reads any file and produces one output,
|
||||
// which is a multistream. It has a rather
|
||||
// unique interpretation of time. Time is
|
||||
// distance in the file. So the duration is the
|
||||
// file length. (in bytes)
|
||||
|
||||
#if !defined(_MEDIA_FILE_PRODUCER_H)
|
||||
#define _MEDIA_FILE_PRODUCER_H
|
||||
|
||||
#include <MediaDefs.h>
|
||||
#include <MediaNode.h>
|
||||
#include <FileInterface.h>
|
||||
#include <BufferProducer.h>
|
||||
#include <Controllable.h>
|
||||
#include <MediaEventLooper.h>
|
||||
#include <File.h>
|
||||
#include <Entry.h>
|
||||
#include <BufferGroup.h>
|
||||
|
||||
class MediaFileProducer :
|
||||
public BFileInterface,
|
||||
public BBufferProducer,
|
||||
public BControllable,
|
||||
public BMediaEventLooper
|
||||
{
|
||||
protected:
|
||||
virtual ~MediaFileProducer(void);
|
||||
|
||||
public:
|
||||
|
||||
explicit MediaFileProducer(
|
||||
size_t defaultChunkSize = 8192, // chunk size = 8 KB
|
||||
float defaultBitRate = 800000, // bit rate = 100.000 KB/sec = 5.85 MB/minute
|
||||
const flavor_info * info = 0, // buffer period = 80 milliseconds
|
||||
BMessage * config = 0,
|
||||
BMediaAddOn * addOn = 0);
|
||||
|
||||
virtual status_t InitCheck(void) const;
|
||||
|
||||
// see BMediaAddOn::GetConfigurationFor
|
||||
virtual status_t GetConfigurationFor(
|
||||
BMessage * into_message);
|
||||
|
||||
/*************************/
|
||||
/* begin from BMediaNode */
|
||||
public:
|
||||
// /* this port is what a media node listens to for commands */
|
||||
// virtual port_id ControlPort(void) const;
|
||||
|
||||
virtual BMediaAddOn* AddOn(
|
||||
int32 * internal_id) const; /* Who instantiated you -- or NULL for app class */
|
||||
|
||||
protected:
|
||||
/* These don't return errors; instead, they use the global error condition reporter. */
|
||||
/* A node is required to have a queue of at least one pending command (plus TimeWarp) */
|
||||
/* and is recommended to allow for at least one pending command of each type. */
|
||||
/* Allowing an arbitrary number of outstanding commands might be nice, but apps */
|
||||
/* cannot depend on that happening. */
|
||||
virtual void Start(
|
||||
bigtime_t performance_time);
|
||||
virtual void Stop(
|
||||
bigtime_t performance_time,
|
||||
bool immediate);
|
||||
virtual void Seek(
|
||||
bigtime_t media_time,
|
||||
bigtime_t performance_time);
|
||||
virtual void SetRunMode(
|
||||
run_mode mode);
|
||||
virtual void TimeWarp(
|
||||
bigtime_t at_real_time,
|
||||
bigtime_t to_performance_time);
|
||||
virtual void Preroll(void);
|
||||
virtual void SetTimeSource(
|
||||
BTimeSource * time_source);
|
||||
|
||||
public:
|
||||
virtual status_t HandleMessage(
|
||||
int32 message,
|
||||
const void * data,
|
||||
size_t size);
|
||||
|
||||
protected:
|
||||
/* Called when requests have completed, or failed. */
|
||||
virtual status_t RequestCompleted( /* reserved 0 */
|
||||
const media_request_info & info);
|
||||
|
||||
protected:
|
||||
virtual status_t DeleteHook(BMediaNode * node); /* reserved 1 */
|
||||
|
||||
virtual void NodeRegistered(void); /* reserved 2 */
|
||||
|
||||
public:
|
||||
|
||||
/* fill out your attributes in the provided array, returning however many you have. */
|
||||
virtual status_t GetNodeAttributes( /* reserved 3 */
|
||||
media_node_attribute * outAttributes,
|
||||
size_t inMaxCount);
|
||||
|
||||
virtual status_t AddTimer(
|
||||
bigtime_t at_performance_time,
|
||||
int32 cookie);
|
||||
|
||||
/* end from BMediaNode */
|
||||
/***********************/
|
||||
|
||||
protected:
|
||||
virtual BParameterWeb * MakeParameterWeb(void);
|
||||
|
||||
/*****************************/
|
||||
/* begin from BFileInterface */
|
||||
protected:
|
||||
//included from BMediaNode
|
||||
//virtual status_t HandleMessage(
|
||||
// int32 message,
|
||||
// const void * data,
|
||||
// size_t size);
|
||||
|
||||
virtual status_t GetNextFileFormat(
|
||||
int32 * cookie,
|
||||
media_file_format * out_format);
|
||||
virtual void DisposeFileFormatCookie(
|
||||
int32 cookie);
|
||||
|
||||
virtual status_t GetDuration(
|
||||
bigtime_t * out_time);
|
||||
|
||||
virtual status_t SniffRef(
|
||||
const entry_ref & file,
|
||||
char * out_mime_type, /* 256 bytes */
|
||||
float * out_quality);
|
||||
|
||||
virtual status_t SetRef(
|
||||
const entry_ref & file,
|
||||
bool create,
|
||||
bigtime_t * out_time);
|
||||
virtual status_t GetRef(
|
||||
entry_ref * out_ref,
|
||||
char * out_mime_type);
|
||||
|
||||
/* end from BFileInterface */
|
||||
/***************************/
|
||||
|
||||
// provided for BMediaFileProducerAddOn
|
||||
public:
|
||||
static status_t StaticSniffRef(
|
||||
const entry_ref & file,
|
||||
char * out_mime_type, /* 256 bytes */
|
||||
float * out_quality);
|
||||
|
||||
/******************************/
|
||||
/* begin from BBufferProducer */
|
||||
protected:
|
||||
/* functionality of BBufferProducer */
|
||||
virtual status_t FormatSuggestionRequested(
|
||||
media_type type,
|
||||
int32 quality,
|
||||
media_format * format);
|
||||
virtual status_t FormatProposal(
|
||||
const media_source & output,
|
||||
media_format * format);
|
||||
/* If the format isn't good, put a good format into *io_format and return error */
|
||||
/* If format has wildcard, specialize to what you can do (and change). */
|
||||
/* If you can change the format, return OK. */
|
||||
/* The request comes from your destination sychronously, so you cannot ask it */
|
||||
/* whether it likes it -- you should assume it will since it asked. */
|
||||
virtual status_t FormatChangeRequested(
|
||||
const media_source & source,
|
||||
const media_destination & destination,
|
||||
media_format * io_format,
|
||||
int32 * _deprecated_);
|
||||
virtual status_t GetNextOutput( /* cookie starts as 0 */
|
||||
int32 * cookie,
|
||||
media_output * out_output);
|
||||
virtual status_t DisposeOutputCookie(
|
||||
int32 cookie);
|
||||
/* In this function, you should either pass on the group to your upstream guy, */
|
||||
/* or delete your current group and hang on to this group. Deleting the previous */
|
||||
/* group (unless you passed it on with the reclaim flag set to false) is very */
|
||||
/* important, else you will 1) leak memory and 2) block someone who may want */
|
||||
/* to reclaim the buffers living in that group. */
|
||||
virtual status_t SetBufferGroup(
|
||||
const media_source & for_source,
|
||||
BBufferGroup * group);
|
||||
/* Format of clipping is (as int16-s): <from line> <npairs> <startclip> <endclip>. */
|
||||
/* Repeat for each line where the clipping is different from the previous line. */
|
||||
/* If <npairs> is negative, use the data from line -<npairs> (there are 0 pairs after */
|
||||
/* a negative <npairs>. Yes, we only support 32k*32k frame buffers for clipping. */
|
||||
/* Any non-0 field of 'display' means that that field changed, and if you don't support */
|
||||
/* that change, you should return an error and ignore the request. Note that the buffer */
|
||||
/* offset values do not have wildcards; 0 (or -1, or whatever) are real values and must */
|
||||
/* be adhered to. */
|
||||
virtual status_t VideoClippingChanged(
|
||||
const media_source & for_source,
|
||||
int16 num_shorts,
|
||||
int16 * clip_data,
|
||||
const media_video_display_info & display,
|
||||
int32 * _deprecated_);
|
||||
/* Iterates over all outputs and maxes the latency found */
|
||||
virtual status_t GetLatency(
|
||||
bigtime_t * out_latency);
|
||||
virtual status_t PrepareToConnect(
|
||||
const media_source & what,
|
||||
const media_destination & where,
|
||||
media_format * format,
|
||||
media_source * out_source,
|
||||
char * out_name);
|
||||
virtual void Connect(
|
||||
status_t error,
|
||||
const media_source & source,
|
||||
const media_destination & destination,
|
||||
const media_format & format,
|
||||
char * io_name);
|
||||
virtual void Disconnect(
|
||||
const media_source & what,
|
||||
const media_destination & where);
|
||||
virtual void LateNoticeReceived(
|
||||
const media_source & what,
|
||||
bigtime_t how_much,
|
||||
bigtime_t performance_time);
|
||||
virtual void EnableOutput(
|
||||
const media_source & what,
|
||||
bool enabled,
|
||||
int32 * _deprecated_);
|
||||
virtual status_t SetPlayRate(
|
||||
int32 numer,
|
||||
int32 denom);
|
||||
|
||||
//included from BMediaNode
|
||||
//virtual status_t HandleMessage( /* call this from the thread that listens to the port */
|
||||
// int32 message,
|
||||
// const void * data,
|
||||
// size_t size);
|
||||
|
||||
virtual void AdditionalBufferRequested( // used to be Reserved 0
|
||||
const media_source & source,
|
||||
media_buffer_id prev_buffer,
|
||||
bigtime_t prev_time,
|
||||
const media_seek_tag * prev_tag); // may be NULL
|
||||
|
||||
virtual void LatencyChanged( // used to be Reserved 1
|
||||
const media_source & source,
|
||||
const media_destination & destination,
|
||||
bigtime_t new_latency,
|
||||
uint32 flags);
|
||||
|
||||
/* end from BBufferProducer */
|
||||
/****************************/
|
||||
|
||||
/****************************/
|
||||
/* begin from BControllable */
|
||||
|
||||
//included from BMediaNode
|
||||
//virtual status_t HandleMessage(
|
||||
// int32 message,
|
||||
// const void * data,
|
||||
// size_t size);
|
||||
public:
|
||||
/* These are alternate methods of accomplishing the same thing as */
|
||||
/* connecting to control information source/destinations would. */
|
||||
virtual status_t GetParameterValue(
|
||||
int32 id,
|
||||
bigtime_t * last_change,
|
||||
void * value,
|
||||
size_t * ioSize);
|
||||
virtual void SetParameterValue(
|
||||
int32 id,
|
||||
bigtime_t when,
|
||||
const void * value,
|
||||
size_t size);
|
||||
virtual status_t StartControlPanel(
|
||||
BMessenger * out_messenger);
|
||||
|
||||
/* end from BControllable */
|
||||
/**************************/
|
||||
|
||||
public:
|
||||
// these three are related:
|
||||
// DEFAULT_CHUNK_SIZE = (DEFAULT_BIT_RATE * 1024) * (DEFAULT_BUFFER_PERIOD / 8000000)
|
||||
static const int32 DEFAULT_CHUNK_SIZE_PARAM; // in bytes
|
||||
static const int32 DEFAULT_BIT_RATE_PARAM; // in 1000*kilobits/sec
|
||||
static const int32 DEFAULT_BUFFER_PERIOD_PARAM; // milliseconds
|
||||
|
||||
private:
|
||||
size_t defaultChunkSizeParam;
|
||||
bigtime_t defaultChunkSizeParamChangeTime;
|
||||
float defaultBitRateParam;
|
||||
bigtime_t defaultBitRateParamChangeTime;
|
||||
bigtime_t defaultBufferPeriodParam;
|
||||
bigtime_t defaultBufferPeriodParamChangeTime;
|
||||
|
||||
// This is used to figure out which parameter to compute
|
||||
// when enforcing the above constraint relating the three params
|
||||
int32 lastUpdatedParameter;
|
||||
int32 leastRecentlyUpdatedParameter;
|
||||
|
||||
/********************************/
|
||||
/* start from BMediaEventLooper */
|
||||
|
||||
protected:
|
||||
/* you must override to handle your events! */
|
||||
/* you should not call HandleEvent directly */
|
||||
virtual void HandleEvent( const media_timed_event *event,
|
||||
bigtime_t lateness,
|
||||
bool realTimeEvent = false);
|
||||
|
||||
/* override to clean up custom events you have added to your queue */
|
||||
virtual void CleanUpEvent(const media_timed_event *event);
|
||||
|
||||
/* called from Offline mode to determine the current time of the node */
|
||||
/* update your internal information whenever it changes */
|
||||
virtual bigtime_t OfflineTime();
|
||||
|
||||
/* override only if you know what you are doing! */
|
||||
/* otherwise much badness could occur */
|
||||
/* the actual control loop function: */
|
||||
/* waits for messages, Pops events off the queue and calls DispatchEvent */
|
||||
virtual void ControlLoop();
|
||||
|
||||
/* end from BMediaEventLooper */
|
||||
/******************************/
|
||||
|
||||
protected:
|
||||
|
||||
virtual status_t HandleBuffer(
|
||||
const media_timed_event *event,
|
||||
bigtime_t lateness,
|
||||
bool realTimeEvent = false);
|
||||
|
||||
virtual status_t HandleParameter(
|
||||
const media_timed_event *event,
|
||||
bigtime_t lateness,
|
||||
bool realTimeEvent = false);
|
||||
|
||||
public:
|
||||
|
||||
static status_t GetFlavor(int32 id, const flavor_info ** out_info);
|
||||
static media_format & GetFormat();
|
||||
static media_file_format & GetFileFormat();
|
||||
|
||||
protected:
|
||||
|
||||
virtual status_t ResetFormat(media_format * format);
|
||||
virtual status_t ResolveWildcards(media_multistream_format * multistream_format);
|
||||
virtual status_t GetFilledBuffer(BBuffer ** outBuffer);
|
||||
virtual status_t FillFileBuffer(BBuffer * buffer);
|
||||
|
||||
private:
|
||||
|
||||
MediaFileProducer( /* private unimplemented */
|
||||
const MediaFileProducer & clone);
|
||||
MediaFileProducer & operator=(
|
||||
const MediaFileProducer & clone);
|
||||
|
||||
status_t initCheckStatus;
|
||||
|
||||
BMediaAddOn * mediaFileProducerAddOn;
|
||||
media_output output;
|
||||
|
||||
BFile * inputFile;
|
||||
entry_ref input_ref;
|
||||
char input_mime_type[B_MIME_TYPE_LENGTH+1];
|
||||
|
||||
BBufferGroup * bufferGroup;
|
||||
|
||||
bigtime_t downstreamLatency;
|
||||
bigtime_t internalLatency;
|
||||
|
||||
bool outputEnabled;
|
||||
|
||||
// this is computed from the real (negotiated) chunk size and bit rate,
|
||||
// not the defaults that are in the parameters
|
||||
bigtime_t bufferPeriod;
|
||||
|
||||
/* Mmmh, stuffing! */
|
||||
virtual status_t _Reserved_MediaFileProducer_0(void *);
|
||||
virtual status_t _Reserved_MediaFileProducer_1(void *);
|
||||
virtual status_t _Reserved_MediaFileProducer_2(void *);
|
||||
virtual status_t _Reserved_MediaFileProducer_3(void *);
|
||||
virtual status_t _Reserved_MediaFileProducer_4(void *);
|
||||
virtual status_t _Reserved_MediaFileProducer_5(void *);
|
||||
virtual status_t _Reserved_MediaFileProducer_6(void *);
|
||||
virtual status_t _Reserved_MediaFileProducer_7(void *);
|
||||
virtual status_t _Reserved_MediaFileProducer_8(void *);
|
||||
virtual status_t _Reserved_MediaFileProducer_9(void *);
|
||||
virtual status_t _Reserved_MediaFileProducer_10(void *);
|
||||
virtual status_t _Reserved_MediaFileProducer_11(void *);
|
||||
virtual status_t _Reserved_MediaFileProducer_12(void *);
|
||||
virtual status_t _Reserved_MediaFileProducer_13(void *);
|
||||
virtual status_t _Reserved_MediaFileProducer_14(void *);
|
||||
virtual status_t _Reserved_MediaFileProducer_15(void *);
|
||||
|
||||
uint32 _reserved_media_file_node_[16];
|
||||
|
||||
};
|
||||
|
||||
#endif /* _MEDIA_FILE_PRODUCER_H */
|
@ -0,0 +1,268 @@
|
||||
// MediaFileProducerAddOn.cpp
|
||||
//
|
||||
// Andrew Bachmann, 2002
|
||||
//
|
||||
// A MediaFileProducerAddOn is an add-on
|
||||
// that can make MediaFileProducer nodes
|
||||
//
|
||||
// MediaFileProducer nodes read a file into a multistream
|
||||
|
||||
|
||||
#include <MediaDefs.h>
|
||||
#include <MediaAddOn.h>
|
||||
#include <Errors.h>
|
||||
#include <Node.h>
|
||||
#include <Mime.h>
|
||||
#include <StorageDefs.h>
|
||||
|
||||
#include "MediaFileProducer.h"
|
||||
#include "MediaFileProducerAddOn.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
// instantiation function
|
||||
extern "C" _EXPORT BMediaAddOn * make_media_addon(image_id image) {
|
||||
return new MediaFileProducerAddOn(image);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------- //
|
||||
// ctor/dtor
|
||||
// -------------------------------------------------------- //
|
||||
|
||||
MediaFileProducerAddOn::~MediaFileProducerAddOn()
|
||||
{
|
||||
}
|
||||
|
||||
MediaFileProducerAddOn::MediaFileProducerAddOn(image_id image) :
|
||||
BMediaAddOn(image)
|
||||
{
|
||||
fprintf(stderr,"MediaFileProducerAddOn::MediaFileProducerAddOn\n");
|
||||
refCount = 0;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------- //
|
||||
// BMediaAddOn impl
|
||||
// -------------------------------------------------------- //
|
||||
|
||||
status_t MediaFileProducerAddOn::InitCheck(
|
||||
const char ** out_failure_text)
|
||||
{
|
||||
fprintf(stderr,"MediaFileProducerAddOn::InitCheck\n");
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
int32 MediaFileProducerAddOn::CountFlavors()
|
||||
{
|
||||
fprintf(stderr,"MediaFileProducerAddOn::CountFlavors\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
status_t MediaFileProducerAddOn::GetFlavorAt(
|
||||
int32 n,
|
||||
const flavor_info ** out_info)
|
||||
{
|
||||
fprintf(stderr,"MediaFileProducerAddOn::GetFlavorAt\n");
|
||||
if (out_info == 0) {
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // we refuse to crash because you were stupid
|
||||
}
|
||||
if (n != 0) {
|
||||
fprintf(stderr,"<- B_BAD_INDEX\n");
|
||||
return B_BAD_INDEX;
|
||||
}
|
||||
return MediaFileProducer::GetFlavor(n,out_info);
|
||||
}
|
||||
|
||||
BMediaNode * MediaFileProducerAddOn::InstantiateNodeFor(
|
||||
const flavor_info * info,
|
||||
BMessage * config,
|
||||
status_t * out_error)
|
||||
{
|
||||
fprintf(stderr,"MediaFileProducerAddOn::InstantiateNodeFor\n");
|
||||
if (out_error == 0) {
|
||||
fprintf(stderr,"<- NULL\n");
|
||||
return 0; // we refuse to crash because you were stupid
|
||||
}
|
||||
size_t defaultChunkSize = size_t(8192); // XXX: read from add-on's attributes
|
||||
float defaultBitRate = 800000;
|
||||
MediaFileProducer * node = new MediaFileProducer(defaultChunkSize,
|
||||
defaultBitRate,
|
||||
info,config,this);
|
||||
if (node == 0) {
|
||||
*out_error = B_NO_MEMORY;
|
||||
fprintf(stderr,"<- B_NO_MEMORY\n");
|
||||
} else {
|
||||
*out_error = node->InitCheck();
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
status_t MediaFileProducerAddOn::GetConfigurationFor(
|
||||
BMediaNode * your_node,
|
||||
BMessage * into_message)
|
||||
{
|
||||
fprintf(stderr,"MediaFileProducerAddOn::GetConfigurationFor\n");
|
||||
if (into_message == 0) {
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // we refuse to crash because you were stupid
|
||||
}
|
||||
MediaFileProducer * node = dynamic_cast<MediaFileProducer*>(your_node);
|
||||
if (node == 0) {
|
||||
fprintf(stderr,"<- B_BAD_TYPE\n");
|
||||
return B_BAD_TYPE;
|
||||
}
|
||||
return node->GetConfigurationFor(into_message);
|
||||
}
|
||||
|
||||
bool MediaFileProducerAddOn::WantsAutoStart()
|
||||
{
|
||||
fprintf(stderr,"MediaFileProducerAddOn::WantsAutoStart\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
status_t MediaFileProducerAddOn::AutoStart(
|
||||
int in_count,
|
||||
BMediaNode ** out_node,
|
||||
int32 * out_internal_id,
|
||||
bool * out_has_more)
|
||||
{
|
||||
fprintf(stderr,"MediaFileProducerAddOn::AutoStart\n");
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------- //
|
||||
// BMediaAddOn impl for B_FILE_INTERFACE nodes
|
||||
// -------------------------------------------------------- //
|
||||
|
||||
status_t MediaFileProducerAddOn::SniffRef(
|
||||
const entry_ref & file,
|
||||
BMimeType * io_mime_type,
|
||||
float * out_quality,
|
||||
int32 * out_internal_id)
|
||||
{
|
||||
fprintf(stderr,"MediaFileProducerAddOn::SniffRef\n");
|
||||
if ((io_mime_type == 0) || (out_quality == 0) || (out_internal_id == 0)) {
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // we refuse to crash because you were stupid
|
||||
}
|
||||
*out_internal_id = 0; // only one flavor
|
||||
char mime_string[B_MIME_TYPE_LENGTH+1];
|
||||
status_t status = MediaFileProducer::StaticSniffRef(file,mime_string,out_quality);
|
||||
io_mime_type->SetTo(mime_string);
|
||||
return status;
|
||||
}
|
||||
|
||||
// even though I implemented SniffTypeKind below and this shouldn't get called,
|
||||
// I am going to implement it anyway. I'll use it later anyhow.
|
||||
status_t MediaFileProducerAddOn::SniffType(
|
||||
const BMimeType & type,
|
||||
float * out_quality,
|
||||
int32 * out_internal_id)
|
||||
{
|
||||
fprintf(stderr,"MediaFileProducerAddOn::SniffType\n");
|
||||
if ((out_quality == 0) || (out_internal_id == 0)) {
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // we refuse to crash because you were stupid
|
||||
}
|
||||
*out_quality = 1.0;
|
||||
*out_internal_id = 0;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
// This function treats null pointers slightly differently than the others.
|
||||
// This is because a program could reasonably call this function with just
|
||||
// about any junk, get the out_read_items and then use that to create an
|
||||
// array of sufficient size to hold the result, and then recall. Also, a
|
||||
// stupid program could not supply an out_read_items, but actually supply
|
||||
// an out_readable_formats and then try to do something useful with it. As
|
||||
// an extreme gesture of nicety we will fill the out_readable_formats with
|
||||
// a valid entry, although they could easily read into garbage after that...
|
||||
status_t MediaFileProducerAddOn::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)
|
||||
{
|
||||
fprintf(stderr,"MediaFileProducerAddOn::GetFileFormatList\n");
|
||||
if (flavor_id != 0) {
|
||||
// this is a sanity check for now
|
||||
fprintf(stderr,"<- B_BAD_INDEX\n");
|
||||
return B_BAD_INDEX;
|
||||
}
|
||||
// see null check comment above
|
||||
if (out_write_items != 0) {
|
||||
*out_write_items = 0;
|
||||
}
|
||||
// see null check comment above
|
||||
if (out_read_items != 0) {
|
||||
*out_read_items = 1;
|
||||
}
|
||||
// see null check comment above
|
||||
if (out_readable_formats != 0) {
|
||||
// don't go off the end
|
||||
if (in_read_items > 0) {
|
||||
out_readable_formats[0] = MediaFileProducer::GetFileFormat();
|
||||
}
|
||||
}
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
status_t MediaFileProducerAddOn::SniffTypeKind(
|
||||
const BMimeType & type,
|
||||
uint64 in_kinds,
|
||||
float * out_quality,
|
||||
int32 * out_internal_id,
|
||||
void * _reserved)
|
||||
{
|
||||
fprintf(stderr,"MediaFileProducerAddOn::SniffTypeKind\n");
|
||||
if ((out_quality == 0) || (out_internal_id == 0)) {
|
||||
fprintf(stderr,"<- B_BAD_VALUE\n");
|
||||
return B_BAD_VALUE; // we refuse to crash because you were stupid
|
||||
}
|
||||
if (in_kinds & (B_BUFFER_PRODUCER | B_FILE_INTERFACE | B_CONTROLLABLE)) {
|
||||
return SniffType(type,out_quality,out_internal_id);
|
||||
} else {
|
||||
// They asked for some kind we don't supply. We set the output
|
||||
// just in case they try to do something with it anyway (!)
|
||||
*out_quality = 0;
|
||||
*out_internal_id = -1;
|
||||
fprintf(stderr,"<- B_BAD_TYPE\n");
|
||||
return B_BAD_TYPE;
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------------------------------- //
|
||||
// stuffing
|
||||
// -------------------------------------------------------- //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// -------------------------------------------------------- //
|
||||
// stuffing
|
||||
// -------------------------------------------------------- //
|
||||
|
||||
status_t MediaFileProducerAddOn::_Reserved_MediaFileProducerAddOn_0(void *) {};
|
||||
status_t MediaFileProducerAddOn::_Reserved_MediaFileProducerAddOn_1(void *) {};
|
||||
status_t MediaFileProducerAddOn::_Reserved_MediaFileProducerAddOn_2(void *) {};
|
||||
status_t MediaFileProducerAddOn::_Reserved_MediaFileProducerAddOn_3(void *) {};
|
||||
status_t MediaFileProducerAddOn::_Reserved_MediaFileProducerAddOn_4(void *) {};
|
||||
status_t MediaFileProducerAddOn::_Reserved_MediaFileProducerAddOn_5(void *) {};
|
||||
status_t MediaFileProducerAddOn::_Reserved_MediaFileProducerAddOn_6(void *) {};
|
||||
status_t MediaFileProducerAddOn::_Reserved_MediaFileProducerAddOn_7(void *) {};
|
||||
status_t MediaFileProducerAddOn::_Reserved_MediaFileProducerAddOn_8(void *) {};
|
||||
status_t MediaFileProducerAddOn::_Reserved_MediaFileProducerAddOn_9(void *) {};
|
||||
status_t MediaFileProducerAddOn::_Reserved_MediaFileProducerAddOn_10(void *) {};
|
||||
status_t MediaFileProducerAddOn::_Reserved_MediaFileProducerAddOn_11(void *) {};
|
||||
status_t MediaFileProducerAddOn::_Reserved_MediaFileProducerAddOn_12(void *) {};
|
||||
status_t MediaFileProducerAddOn::_Reserved_MediaFileProducerAddOn_13(void *) {};
|
||||
status_t MediaFileProducerAddOn::_Reserved_MediaFileProducerAddOn_14(void *) {};
|
||||
status_t MediaFileProducerAddOn::_Reserved_MediaFileProducerAddOn_15(void *) {};
|
@ -0,0 +1,111 @@
|
||||
// MediaFileProducerAddOn.h
|
||||
//
|
||||
// Andrew Bachmann, 2002
|
||||
//
|
||||
// A MediaFileProducerAddOn is an add-on
|
||||
// that can make MediaFileProducer nodes
|
||||
//
|
||||
// MediaFileProducer nodes read a file into a multistream
|
||||
|
||||
#if !defined(_MEDIA_FILE_PRODUCER_ADD_ON_H)
|
||||
#define _MEDIA_FILE_PRODUCER_ADD_ON_H
|
||||
|
||||
#include <MediaDefs.h>
|
||||
#include <MediaAddOn.h>
|
||||
|
||||
class MediaFileProducerAddOn :
|
||||
public BMediaAddOn
|
||||
{
|
||||
public:
|
||||
virtual ~MediaFileProducerAddOn(void);
|
||||
explicit MediaFileProducerAddOn(image_id image);
|
||||
|
||||
/**************************/
|
||||
/* begin from BMediaAddOn */
|
||||
public:
|
||||
virtual status_t InitCheck(
|
||||
const char ** out_failure_text);
|
||||
virtual int32 CountFlavors(void);
|
||||
virtual status_t GetFlavorAt(
|
||||
int32 n,
|
||||
const flavor_info ** out_info);
|
||||
virtual BMediaNode * InstantiateNodeFor(
|
||||
const flavor_info * info,
|
||||
BMessage * config,
|
||||
status_t * out_error);
|
||||
virtual status_t GetConfigurationFor(
|
||||
BMediaNode * your_node,
|
||||
BMessage * into_message);
|
||||
virtual bool WantsAutoStart(void);
|
||||
virtual status_t AutoStart(
|
||||
int in_count,
|
||||
BMediaNode ** out_node,
|
||||
int32 * out_internal_id,
|
||||
bool * out_has_more);
|
||||
|
||||
/* only implement if you have a B_FILE_INTERFACE node */
|
||||
virtual status_t SniffRef(
|
||||
const entry_ref & file,
|
||||
BMimeType * io_mime_type,
|
||||
float * out_quality,
|
||||
int32 * out_internal_id);
|
||||
virtual status_t SniffType( // This is broken if you deal with producers
|
||||
const BMimeType & type, // and consumers both. Use SniffTypeKind instead.
|
||||
float * out_quality, // If you implement SniffTypeKind, this doesn't
|
||||
int32 * out_internal_id); // get called.
|
||||
virtual status_t GetFileFormatList(
|
||||
int32 flavor_id, // for this node flavor (if it matters)
|
||||
media_file_format * out_writable_formats, // don't write here if NULL
|
||||
int32 in_write_items, // this many slots in out_writable_formats
|
||||
int32 * out_write_items, // set this to actual # available, even if bigger than in count
|
||||
media_file_format * out_readable_formats, // don't write here if NULL
|
||||
int32 in_read_items, // this many slots in out_readable_formats
|
||||
int32 * out_read_items, // set this to actual # available, even if bigger than in count
|
||||
void * _reserved); // ignore until further notice
|
||||
virtual status_t SniffTypeKind( // Like SniffType, but for the specific kind(s)
|
||||
const BMimeType & type,
|
||||
uint64 in_kinds,
|
||||
float * out_quality,
|
||||
int32 * out_internal_id,
|
||||
void * _reserved);
|
||||
|
||||
|
||||
/* end from BMediaAddOn */
|
||||
/************************/
|
||||
|
||||
private:
|
||||
|
||||
MediaFileProducerAddOn( /* private unimplemented */
|
||||
const MediaFileProducerAddOn & clone);
|
||||
MediaFileProducerAddOn & operator=(
|
||||
const MediaFileProducerAddOn & clone);
|
||||
|
||||
int32 refCount;
|
||||
|
||||
/* Mmmh, stuffing! */
|
||||
virtual status_t _Reserved_MediaFileProducerAddOn_0(void *);
|
||||
virtual status_t _Reserved_MediaFileProducerAddOn_1(void *);
|
||||
virtual status_t _Reserved_MediaFileProducerAddOn_2(void *);
|
||||
virtual status_t _Reserved_MediaFileProducerAddOn_3(void *);
|
||||
virtual status_t _Reserved_MediaFileProducerAddOn_4(void *);
|
||||
virtual status_t _Reserved_MediaFileProducerAddOn_5(void *);
|
||||
virtual status_t _Reserved_MediaFileProducerAddOn_6(void *);
|
||||
virtual status_t _Reserved_MediaFileProducerAddOn_7(void *);
|
||||
virtual status_t _Reserved_MediaFileProducerAddOn_8(void *);
|
||||
virtual status_t _Reserved_MediaFileProducerAddOn_9(void *);
|
||||
virtual status_t _Reserved_MediaFileProducerAddOn_10(void *);
|
||||
virtual status_t _Reserved_MediaFileProducerAddOn_11(void *);
|
||||
virtual status_t _Reserved_MediaFileProducerAddOn_12(void *);
|
||||
virtual status_t _Reserved_MediaFileProducerAddOn_13(void *);
|
||||
virtual status_t _Reserved_MediaFileProducerAddOn_14(void *);
|
||||
virtual status_t _Reserved_MediaFileProducerAddOn_15(void *);
|
||||
|
||||
uint32 _reserved_media_file_node_[16];
|
||||
|
||||
};
|
||||
|
||||
#if BUILDING_MEDIA_FILE_PRODUCER__ADD_ON
|
||||
extern "C" _EXPORT BMediaAddOn * make_media_file_producer_add_on(image_id you);
|
||||
#endif
|
||||
|
||||
#endif /* _MEDIA_FILE_PRODUCER_ADD_ON_H */
|
Loading…
Reference in New Issue
Block a user