* Rewrote MediaRoster.h

* Removed appearantly unused satic variables. Hope this does not break
  binary compatibility, going to test.
* There are three more private methods, which could probably be removed
  as well.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24558 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2008-03-24 15:42:58 +00:00
parent a715f908f2
commit 9def3bf783
2 changed files with 339 additions and 396 deletions

View File

@ -1,14 +1,12 @@
/*******************************************************************************
/
/ File: MediaRoster.h
/
/ Description: The BMediaRoster is the main application interface to the Media Kit
/
/ Copyright 1997-98, Be Incorporated, All Rights Reserved
/
*******************************************************************************/
/*
* Copyright (c) 2008 Haiku, Inc. All rights reserved.
* Distributed under the terms of the the MIT licence.
*
*/
#if !defined(_MEDIA_ROSTER_H)
//! The BMediaRoster is the main API to the Media Kit.
#ifndef _MEDIA_ROSTER_H
#define _MEDIA_ROSTER_H
#include <MediaDefs.h>
@ -20,6 +18,7 @@ class BMediaAddOn;
class BMimeType;
class BParameterWeb;
class BString;
struct dormant_flavor_info;
struct entry_ref;
@ -28,367 +27,327 @@ namespace BPrivate { namespace media {
class BMediaRosterEx;
} } // BPrivate::media
class BMediaRoster : public BLooper
{
class BMediaRoster : public BLooper {
public:
status_t GetVideoInput(
media_node * out_node);
status_t GetAudioInput(
media_node * out_node);
status_t GetVideoOutput(
media_node * out_node);
status_t GetAudioMixer(
media_node * out_node);
status_t GetAudioOutput(
media_node * out_node); /* Use the mixer rather than the output for most needs! */
status_t GetAudioOutput(
media_node * out_node,
int32 * out_input_id,
BString * out_input_name);
status_t GetTimeSource(
media_node * out_node);
// Retrieving the global instance of the BMediaRoster:
static BMediaRoster* Roster(status_t* _error = NULL);
// This version will create a roster instance if there isn't
// one already. Thread safe for multiple calls to Roster().
status_t SetVideoInput(
const media_node & producer);
static BMediaRoster* CurrentRoster();
// This version won't create an instance if there isn't one
// already. It is not thread safe if you call Roster() at the
// same time.
// Getting common instances of system nodes:
status_t GetVideoInput(media_node* _node);
status_t GetAudioInput(media_node* _node);
status_t GetVideoOutput(media_node* _node);
status_t GetAudioMixer(media_node* _node);
status_t GetAudioOutput(media_node* _node);
// The output should not be used directly in common use cases.
// Use the mixer node instead.
status_t GetAudioOutput(media_node* _node,
int32* _inputId, BString* _inputName);
status_t GetTimeSource(media_node* _node);
// Setting common system nodes:
status_t SetVideoInput(const media_node& producer);
status_t SetVideoInput(
const dormant_node_info& producer);
status_t SetAudioInput(
const media_node & producer);
status_t SetAudioInput(const media_node& producer);
status_t SetAudioInput(
const dormant_node_info& producer);
status_t SetVideoOutput(
const media_node & consumer);
status_t SetVideoOutput(const media_node& consumer);
status_t SetVideoOutput(
const dormant_node_info& consumer);
status_t SetAudioOutput(
const media_node& consumer);
status_t SetAudioOutput(
const media_input & input_to_output);
const media_input& inputToOutput);
status_t SetAudioOutput(
const dormant_node_info& consumer);
/* Get a media_node from a node ID -- this is how you reference your own nodes! */
status_t GetNodeFor(
media_node_id node,
// Get a media_node from a node ID -- this is how you reference your
// own nodes!
status_t GetNodeFor(media_node_id node,
media_node* clone);
status_t GetSystemTimeSource( /* typically, you want to use GetTimeSource() */
media_node * clone);
status_t ReleaseNode( /* might shut down Node if you're last */
const media_node & node);
status_t GetSystemTimeSource(media_node* clone);
// Typically, you'll want to use GetTimeSource() instead.
status_t ReleaseNode(const media_node& node);
// This method might free the node if there are no
// more references.
BTimeSource* MakeTimeSourceFor(const media_node& for_node);
// Release() the returned object when done!
BTimeSource * MakeTimeSourceFor( /* Release() the object when done */
const media_node & for_node);
/* note that the media_source and media_destination found in */
/* out_output and out_input are the ones actually used; from and to */
/* are only "hints" that the app should not use once a real connection */
/* has been established */
status_t Connect(
const media_source & from,
status_t Connect(const media_source& from,
const media_destination& to,
media_format * io_format,
media_output * out_output,
media_input * out_input);
media_format* _inOutFormat,
media_output* _output,
media_input* _input);
// Note that the media_source and media_destination found in
// _output and _input are the ones actually used. From and to
// are only "hints" that the app should not use once a real
// connection has been established.
enum connect_flags {
B_CONNECT_MUTED = 0x1
};
status_t Connect(
const media_source & from,
status_t Connect(const media_source& from,
const media_destination& to,
media_format * io_format,
media_output * out_output,
media_input * out_input,
uint32 in_flags,
void * _reserved = 0);
media_format* _inOutFormat,
media_output* _output,
media_input* _input,
uint32 flags, void* _reserved = NULL);
status_t Disconnect(
media_node_id source_node,
status_t Disconnect(media_node_id sourceNode,
const media_source& source,
media_node_id destination_node,
media_node_id destinationNode,
const media_destination& destination);
status_t Disconnect( /* Haiku extension, not in R5 */
const media_output &output,
status_t Disconnect(const media_output& output,
const media_input& input);
// NOTE: This is a Haiku extension.
status_t StartNode(
const media_node & node,
bigtime_t at_performance_time);
status_t StopNode(
const media_node & node,
bigtime_t at_performance_time,
bool immediate = false); /* immediate -> at_time is insignificant */
status_t SeekNode(
const media_node & node,
bigtime_t to_media_time,
bigtime_t at_performance_time = 0 /* if running */ );
status_t StartTimeSource(
const media_node & node,
bigtime_t at_real_time);
status_t StopTimeSource(
const media_node & node,
bigtime_t at_real_time,
status_t StartNode(const media_node& node,
bigtime_t atPerformanceTime);
status_t StopNode(const media_node& node,
bigtime_t atPerformanceTime,
bool immediate = false);
status_t SeekTimeSource(
const media_node & node,
bigtime_t to_performance_time,
bigtime_t at_real_time);
// If "immediate" is true, "atPerformanceTime" is ignored.
status_t SeekNode(const media_node& node,
bigtime_t toMediaTime,
bigtime_t atPerformanceTime = 0);
// NOTE: The node needs to be running.
status_t SyncToNode(
const media_node & node,
bigtime_t at_time,
status_t StartTimeSource(const media_node& node,
bigtime_t atRealTime);
status_t StopTimeSource(const media_node& node,
bigtime_t atRealTime,
bool immediate = false);
status_t SeekTimeSource(const media_node& node,
bigtime_t toPerformanceTime,
bigtime_t atRealTime);
status_t SyncToNode(const media_node& node,
bigtime_t atTime,
bigtime_t timeout = B_INFINITE_TIMEOUT);
status_t SetRunModeNode(
const media_node & node,
status_t SetRunModeNode(const media_node& node,
BMediaNode::run_mode mode);
status_t PrerollNode( /* synchronous */
const media_node & node);
status_t RollNode(
const media_node & node,
status_t PrerollNode(const media_node& node);
// NOTE: This method is synchronous.
status_t RollNode(const media_node& node,
bigtime_t startPerformance,
bigtime_t stopPerformance,
bigtime_t atMediaTime = -B_INFINITE_TIMEOUT);
bigtime_t atMediaTime
= -B_INFINITE_TIMEOUT);
status_t SetProducerRunModeDelay( /* should only be used with B_RECORDING */
const media_node & node,
status_t SetProducerRunModeDelay(const media_node& node,
bigtime_t delay,
BMediaNode::run_mode mode = BMediaNode::B_RECORDING);
status_t SetProducerRate( /* not necessarily supported by node */
const media_node & producer,
int32 numer,
int32 denom);
BMediaNode::run_mode mode
= BMediaNode::B_RECORDING);
// NOTE: Should only be used with B_RECORDING
status_t SetProducerRate(const media_node& producer,
int32 numer, int32 denom);
// NOTE: This feature is not necessarily supported by the node.
/* Nodes will have available inputs/outputs as long as they are capable */
/* of accepting more connections. The node may create an additional */
/* output or input as the currently available is taken into usage. */
status_t GetLiveNodeInfo(
const media_node & node,
live_node_info * out_live_info);
status_t GetLiveNodes(
live_node_info * out_live_nodes,
int32 * io_total_count,
const media_format * has_input = NULL,
const media_format * has_output = NULL,
// Retrieving information about available inputs/outputs.
// Nodes will have available inputs/outputs as long as they are capable
// of accepting more connections. The node may create an additional
// output or input as the currently available is taken into usage.
status_t GetLiveNodeInfo(const media_node& node,
live_node_info* _liveInfo);
status_t GetLiveNodes(live_node_info* _liveNodes,
int32* inOutTotalCount,
const media_format* hasInput = NULL,
const media_format* hasOutput = NULL,
const char* name = NULL,
uint64 node_kinds = 0); /* B_BUFFER_PRODUCER etc */
uint64 nodeKinds = 0);
// B_BUFFER_PRODUCER etc.
status_t GetFreeInputsFor(
const media_node & node,
media_input * out_free_inputs,
int32 buf_num_inputs,
int32 * out_total_count,
media_type filter_type = B_MEDIA_UNKNOWN_TYPE);
status_t GetConnectedInputsFor(
const media_node & node,
media_input * out_active_inputs,
int32 buf_num_inputs,
int32 * out_total_count);
status_t GetAllInputsFor(
const media_node & node,
media_input * out_inputs,
int32 buf_num_inputs,
int32 * out_total_count);
status_t GetFreeOutputsFor(
const media_node & node,
media_output * out_free_outputs,
int32 buf_num_outputs,
int32 * out_total_count,
media_type filter_type = B_MEDIA_UNKNOWN_TYPE);
status_t GetConnectedOutputsFor(
const media_node & node,
media_output * out_active_outputs,
int32 buf_num_outputs,
int32 * out_total_count);
status_t GetAllOutputsFor(
const media_node & node,
media_output * out_outputs,
int32 buf_num_outputs,
int32 * out_total_count);
status_t GetFreeInputsFor(const media_node& node,
media_input* _freeInputsBuffer,
int32 bufferCapacity,
int32* _foundCount,
media_type filterType
= B_MEDIA_UNKNOWN_TYPE);
status_t GetConnectedInputsFor(const media_node& node,
media_input* _activeInputsBuffer,
int32 bufferCapacity,
int32* _foundCount);
status_t GetAllInputsFor(const media_node& node,
media_input* _inputsBuffer,
int32 bufferCapacity,
int32* _foundCount);
status_t GetFreeOutputsFor(const media_node& node,
media_output* _freeOutputsBuffer,
int32 bufferCapacity,
int32* _foundCount,
media_type filterType
= B_MEDIA_UNKNOWN_TYPE);
status_t GetConnectedOutputsFor(const media_node& node,
media_output* _activeOutputsBuffer,
int32 bufferCapacity,
int32* _foundCount);
status_t GetAllOutputsFor(const media_node& node,
media_output* _outputsBuffer,
int32 bufferCapacity,
int32* _foundCount);
status_t StartWatching(
const BMessenger & where);
status_t StartWatching(
const BMessenger & where,
// Event notification support:
status_t StartWatching(const BMessenger& target);
status_t StartWatching(const BMessenger& target,
int32 notificationType);
status_t StartWatching(
const BMessenger & where,
status_t StartWatching(const BMessenger& target,
const media_node& node,
int32 notificationType);
status_t StopWatching(
const BMessenger & where);
status_t StopWatching(
const BMessenger & where,
status_t StopWatching(const BMessenger& target);
status_t StopWatching(const BMessenger& target,
int32 notificationType);
status_t StopWatching(
const BMessenger & where,
status_t StopWatching(const BMessenger& target,
const media_node& node,
int32 notificationType);
status_t RegisterNode(
BMediaNode * node);
status_t UnregisterNode(
BMediaNode * node);
status_t RegisterNode(BMediaNode* node);
status_t UnregisterNode(BMediaNode* node);
static BMediaRoster * Roster( // will create if there isn't one
status_t * out_error = NULL); // thread safe for multiple calls to Roster()
static BMediaRoster * CurrentRoster(); // won't create it if there isn't one
// not thread safe if you call Roster() at the same time
status_t SetTimeSourceFor(
media_node_id node,
media_node_id time_source);
status_t SetTimeSourceFor(media_node_id node,
media_node_id timeSource);
status_t GetParameterWebFor(
const media_node & node,
BParameterWeb ** out_web);
status_t StartControlPanel(
const media_node & node,
BMessenger * out_messenger = NULL);
// Building a control GUI for a node:
status_t GetParameterWebFor(const media_node& node,
BParameterWeb** _web);
status_t StartControlPanel(const media_node& node,
BMessenger* _messenger = NULL);
status_t GetDormantNodes(
dormant_node_info * out_info,
int32 * io_count,
const media_format * has_input = NULL,
const media_format * has_output = NULL,
// Information about nodes which are not running, but could
// be instantiated from add-ons:
status_t GetDormantNodes(dormant_node_info* _info,
int32* _inOutCount,
const media_format* _hasInput = NULL,
const media_format* _hasOutput = NULL,
const char* name = NULL,
uint64 require_kinds = 0,
uint64 deny_kinds = 0);
uint64 requireKinds = 0,
uint64 denyKinds = 0);
status_t InstantiateDormantNode(
const dormant_node_info & in_info,
media_node * out_node,
uint32 flags /* currently B_FLAVOR_IS_GLOBAL or B_FLAVOR_IS_LOCAL */ );
const dormant_node_info& info,
media_node* _node,
uint32 flags);
// NOTE: Supported flags are currently B_FLAVOR_IS_GLOBAL
// or B_FLAVOR_IS_LOCAL
status_t InstantiateDormantNode(
const dormant_node_info & in_info,
media_node * out_node);
status_t GetDormantNodeFor(
const media_node & node,
dormant_node_info * out_info);
const dormant_node_info& info,
media_node* _node);
status_t GetDormantNodeFor(const media_node& node,
dormant_node_info* _info);
status_t GetDormantFlavorInfoFor(
const dormant_node_info & in_dormant,
dormant_flavor_info * out_flavor);
const dormant_node_info& info,
dormant_flavor_info* _flavor);
status_t GetLatencyFor(
const media_node & producer,
bigtime_t * out_latency);
// Latency information:
status_t GetLatencyFor(const media_node& producer,
bigtime_t* _latency);
status_t GetInitialLatencyFor(
const media_node& producer,
bigtime_t * out_latency,
uint32 * out_flags = 0);
bigtime_t* _latency,
uint32* _flags = NULL);
status_t GetStartLatencyFor(
const media_node & time_source,
bigtime_t * out_latency);
const media_node& timeSource,
bigtime_t* _latency);
// Finding a suitable node to playback a file:
status_t GetFileFormatsFor(
const media_node & file_interface,
media_file_format * out_formats,
int32 * io_num_infos);
status_t SetRefFor(
const media_node & file_interface,
const media_node& fileInterface,
media_file_format* _formatsBuffer,
int32* _inOutNumInfos);
status_t SetRefFor(const media_node& fileInterface,
const entry_ref& file,
bool create_and_truncate,
bigtime_t * out_length); /* if create is false */
status_t GetRefFor(
const media_node & node,
entry_ref * out_file,
BMimeType * mime_type = NULL);
status_t SniffRefFor(
const media_node & file_interface,
const entry_ref & file,
BMimeType * mime_type,
float * out_capability);
/* This is the generic "here's a file, now can someone please play it" interface */
status_t SniffRef(
const entry_ref & file,
uint64 require_node_kinds, /* if you need an EntityInterface or BufferConsumer or something */
dormant_node_info * out_node,
BMimeType * mime_type = NULL);
status_t GetDormantNodeForType(
const BMimeType & type,
uint64 require_node_kinds,
dormant_node_info * out_node);
bool createAndTruncate,
bigtime_t* _length);
// if create is false
status_t GetRefFor(const media_node& node,
entry_ref* _ref,
BMimeType* mimeType = NULL);
status_t SniffRefFor(const media_node& fileInterface,
const entry_ref& ref, BMimeType* _mimeType,
float* _capability);
// This is the generic "here's a file, now can someone please play it"
// interface:
status_t SniffRef(const entry_ref& ref,
uint64 requireNodeKinds,
// if you need an EntityInterface
// or BufferConsumer or something
dormant_node_info* _node,
BMimeType* _mimeType = NULL);
status_t GetDormantNodeForType(const BMimeType& type,
uint64 requireNodeKinds,
dormant_node_info* _info);
status_t GetReadFileFormatsFor(
const dormant_node_info & in_node,
media_file_format * out_read_formats,
int32 in_read_count,
int32 * out_read_count);
const dormant_node_info& node,
media_file_format* _readFormatsBuffer,
int32 bufferCapacity, int32* _foundCount);
status_t GetWriteFileFormatsFor(
const dormant_node_info & in_node,
media_file_format * out_write_formats,
int32 in_write_count,
int32 * out_write_count);
const dormant_node_info& node,
media_file_format* _writeFormatsBuffer,
int32 bufferCapacity, int32* _foundCount);
status_t GetFormatFor(
const media_output & output,
media_format * io_format,
status_t GetFormatFor(const media_output& output,
media_format* _inOutFormat,
uint32 flags = 0);
status_t GetFormatFor(
const media_input & input,
media_format * io_format,
status_t GetFormatFor(const media_input& input,
media_format* _inOutFormat,
uint32 flags = 0);
status_t GetFormatFor(
const media_node & node,
media_format * io_format,
status_t GetFormatFor(const media_node& node,
media_format* _inOutFormat,
float quality = B_MEDIA_ANY_QUALITY);
ssize_t GetNodeAttributesFor(
const media_node & node,
ssize_t GetNodeAttributesFor(const media_node& node,
media_node_attribute* outArray,
size_t inMaxCount);
media_node_id NodeIDFor(
port_id source_or_destination_port);
status_t GetInstancesFor(
media_addon_id addon,
int32 flavor,
media_node_id * out_id,
int32 * io_count = 0); // default to 1
media_node_id NodeIDFor(port_id sourceOrDestinationPort);
status_t GetInstancesFor(media_addon_id addon,
int32 flavor,media_node_id* _id,
int32* _inOutCount = NULL);
// _inOutCount defaults to 1
// if unspecified (NULL).
// General MediaKit configuration:
status_t SetRealtimeFlags(uint32 enabledFlags);
status_t GetRealtimeFlags(uint32* _enabledFlags);
ssize_t AudioBufferSizeFor(int32 channelCount,
uint32 sampleFormat, float frameRate,
bus_type busType = B_UNKNOWN_BUS);
status_t SetRealtimeFlags(
uint32 in_enabled);
status_t GetRealtimeFlags(
uint32 * out_enabled);
ssize_t AudioBufferSizeFor(
int32 channel_count,
uint32 sample_format,
float frame_rate,
bus_type bus_kind = B_UNKNOWN_BUS);
/* Use MediaFlags to inquire about specific features of the Media Kit. */
/* Returns < 0 for "not present", positive size for output data size. */
/* 0 means that the capability is present, but no data about it. */
static ssize_t MediaFlags(
media_flags cap,
void * buf,
// Use MediaFlags to inquire about specific features of the Media Kit.
// Returns < 0 for "not present", positive size for output data size.
// 0 means that the capability is present, but no data about it.
static ssize_t MediaFlags(media_flags cap, void* buffer,
size_t maxSize);
/* BLooper overrides */
virtual void MessageReceived(
BMessage * message);
// BLooper overrides
virtual void MessageReceived(BMessage* message);
virtual bool QuitRequested();
virtual BHandler * ResolveSpecifier(
BMessage *msg,
int32 index,
BMessage *specifier,
int32 form,
const char *property);
virtual status_t GetSupportedSuites(
BMessage *data);
virtual BHandler* ResolveSpecifier(BMessage* message,
int32 index, BMessage* specifier,
int32 form, const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
~BMediaRoster();
virtual ~BMediaRoster();
private:
// deprecated call
status_t SetOutputBuffersFor(
const media_source & output,
// This method is deprecated:
status_t SetOutputBuffersFor(const media_source& output,
BBufferGroup* group,
bool will_reclaim = false);
bool willReclaim = false);
/* FBC stuffing (Mmmh, Stuffing!) */
// Reserving virtual function slots.
virtual status_t _Reserved_MediaRoster_0(void*);
virtual status_t _Reserved_MediaRoster_1(void*);
virtual status_t _Reserved_MediaRoster_2(void*);
@ -401,36 +360,24 @@ virtual status_t _Reserved_MediaRoster_7(void *);
friend class BPrivate::media::DefaultDeleter;
friend class BPrivate::media::BMediaRosterEx;
static bool _isMediaServer;
// Constructor is private, since you are supposed to use
// Roster() or CurrentRoster().
BMediaRoster();
static port_id _mReplyPort;
static int32 _mReplyPortRes;
static int32 _mReplyPortUnavailCount;
// TODO: Looks like these can be safely removed:
static status_t ParseCommand(BMessage& reply);
uint32 _reserved_media_roster_[67];
static BMediaRoster * _sDefault;
static status_t ParseCommand(
BMessage & reply);
status_t GetDefaultInfo(
media_node_id for_default,
BMessage & out_config);
status_t SetRunningDefault(
media_node_id for_default,
status_t GetDefaultInfo(media_node_id forDefault,
BMessage& _config);
status_t SetRunningDefault(media_node_id forDefault,
const media_node& node);
static port_id checkout_reply_port(
const char * name = NULL);
static void checkin_reply_port(
port_id port);
private:
uint32 _reserved_media_roster_[67];
static BMediaRoster* sDefaultInstance;
};
#endif /* _MEDIA_ROSTER_H */
#endif // _MEDIA_ROSTER_H

View File

@ -67,9 +67,9 @@ namespace BPrivate { namespace media {
public:
~DefaultDeleter()
{
if (BMediaRoster::_sDefault) {
BMediaRoster::_sDefault->Lock();
BMediaRoster::_sDefault->Quit();
if (BMediaRoster::sDefaultInstance) {
BMediaRoster::sDefaultInstance->Lock();
BMediaRoster::sDefaultInstance->Quit();
}
}
};
@ -1951,23 +1951,23 @@ BMediaRoster::Roster(status_t *out_error)
locker.Lock();
if (out_error)
*out_error = B_OK;
if (_sDefault == NULL) {
if (sDefaultInstance == NULL) {
status_t err;
_sDefault = new (std::nothrow) BMediaRosterEx(&err);
if (_sDefault == NULL)
sDefaultInstance = new (std::nothrow) BMediaRosterEx(&err);
if (sDefaultInstance == NULL)
err = B_NO_MEMORY;
else if (err != B_OK) {
if (_sDefault) {
_sDefault->Lock();
_sDefault->Quit();
_sDefault = NULL;
if (sDefaultInstance) {
sDefaultInstance->Lock();
sDefaultInstance->Quit();
sDefaultInstance = NULL;
}
if (out_error)
*out_error = err;
}
}
locker.Unlock();
return _sDefault;
return sDefaultInstance;
}
@ -1976,7 +1976,7 @@ BMediaRoster::Roster(status_t *out_error)
/* static */ BMediaRoster *
BMediaRoster::CurrentRoster()
{
return _sDefault;
return sDefaultInstance;
}
@ -2927,7 +2927,7 @@ BMediaRoster::~BMediaRoster()
// Unset the global instance pointer, the destructor is also called
// if a client app calls Lock(); and Quit(); directly.
_sDefault = NULL;
sDefaultInstance = NULL;
}
@ -2968,6 +2968,7 @@ BMediaRoster::BMediaRoster() :
}
// TODO: Looks like these can be safely removed:
/* static */ status_t
BMediaRoster::ParseCommand(BMessage & reply)
{
@ -2995,13 +2996,8 @@ BMediaRoster::SetRunningDefault(media_node_id for_default,
}
/*************************************************************
* static BMediaRoster variables
*************************************************************/
// #pragma mark - static variables
bool BMediaRoster::_isMediaServer;
port_id BMediaRoster::_mReplyPort;
int32 BMediaRoster::_mReplyPortRes;
int32 BMediaRoster::_mReplyPortUnavailCount;
BMediaRoster * BMediaRoster::_sDefault = NULL;
BMediaRoster* BMediaRoster::sDefaultInstance = NULL;