changed media kit internal messaging and notification support

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1338 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
beveloper
2002-10-02 01:04:48 +00:00
parent 398e73f23b
commit f492510482
17 changed files with 639 additions and 545 deletions
+81
View File
@@ -0,0 +1,81 @@
/*
* Copyright 2002, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _DATA_EXCHANGE_H
#define _DATA_EXCHANGE_H
#include <MediaDefs.h>
#include <MediaNode.h>
#include <MediaAddOn.h>
#include <Entry.h>
namespace BPrivate {
namespace media {
namespace dataexchange {
struct reply_data;
struct request_data;
// BMessage based data exchange with the media_server
status_t SendToServer(BMessage *msg);
status_t QueryServer(BMessage *request, BMessage *reply);
// BMessage based data exchange with the media_addon_server
status_t SendToAddonServer(BMessage *msg);
// Raw data based data exchange with the media_server
status_t SendToServer(int32 msgcode, void *msg, int size);
status_t QueryServer(int32 msgcode, const request_data *request, int requestsize, reply_data *reply, int replysize);
// Raw data based data exchange with the media_addon_server
status_t SendToAddonServer(int32 msgcode, void *msg, int size);
status_t QueryAddonServer(int32 msgcode, const request_data *request, int requestsize, reply_data *reply, int replysize);
// Raw data based data exchange with the media_server
status_t SendToPort(port_id sendport, int32 msgcode, void *msg, int size);
status_t QueryPort(port_id requestport, int32 msgcode, const request_data *request, int requestsize, reply_data *reply, int replysize);
// The base struct used for all raw requests
struct request_data
{
port_id reply_port;
void SendReply(reply_data *reply, int replysize) const;
};
// The base struct used for all raw replys
struct reply_data
{
status_t result;
};
}; // dataexchange
}; // media
}; // BPrivate
using namespace BPrivate::media::dataexchange;
enum {
// BMediaRoster notification service
MEDIA_SERVER_REQUEST_NOTIFICATIONS = 1000,
MEDIA_SERVER_CANCEL_NOTIFICATIONS,
MEDIA_SERVER_SEND_NOTIFICATIONS
};
struct request_addonserver_instantiate_dormant_node : public request_data
{
dormant_node_info info;
};
struct reply_addonserver_instantiate_dormant_node : public reply_data
{
media_node node;
};
#endif // _DATA_EXCHANGE_H
@@ -1,79 +0,0 @@
/*
* Copyright 2002, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _NOTIFICATION_MANAGER_H
#define _NOTIFICATION_MANAGER_H
namespace BPrivate {
namespace media {
class NotificationManager
{
public:
enum notification_type_mask
{
notification_no_mask = 0,
notification_node_created = (1 << 0),
notification_node_deleted = (1 << 1),
notification_connection_made = (1 << 2),
notification_connection_broken = (1 << 3),
notification_buffer_created = (1 << 4),
notification_buffer_deleted = (1 << 5),
notification_transport_state = (1 << 6),
notification_parameter_changed = (1 << 7),
notification_format_change = (1 << 8),
notification_web_changed = (1 << 9),
notification_default_changed = (1 << 10),
notification_new_parameter_value= (1 << 11),
notification_node_stopped = (1 << 12),
notification_flavors_changed = (1 << 13),
notification_error = (1 << 31), // XXX, um well... always allow error notifications? Handled in the server
notification_basic = (notification_node_created | notification_node_deleted | notification_connection_made | notification_connection_broken),
notification_wildcard = (0xffffffff - notification_error) // exclude error, it is handled in the server
};
public:
NotificationManager();
~NotificationManager();
status_t Register(const BMessenger &notifyHandler, const media_node &node, notification_type_mask mask);
status_t Unregister(const BMessenger &notifyHandler, const media_node &node, notification_type_mask mask);
status_t ReportError(const media_node &node, BMediaNode::node_error what, const BMessage * info);
void NodesCreated(const media_node_id *ids, int32 count);
void NodesDeleted(const media_node_id *ids, int32 count);
void ConnectionMade(const media_input &input, const media_output &output, const media_format &format);
void ConnectionBroken(const media_source &source, const media_destination &destination);
void BuffersCreated(); // XXX fix
void BuffersDeleted(const media_buffer_id *ids, int32 count);
// XXX header file lists: B_MEDIA_TRANSPORT_STATE, /* "state", "location", "realtime" */
void FormatChanged(const media_source &source, const media_destination &destination, const media_format &format);
status_t ParameterChanged(const media_node &node, int32 parameterid);
void WebChanged(const media_node &node); // XXX fix
// XXX header file lists: B_MEDIA_DEFAULT_CHANGED /* "default", "node" -- handled by BMediaRoster */
status_t NewParameterValue(const media_node &node, int32 parameterid, bigtime_t when, const void *param, size_t paramsize);
void FlavorsChanged(media_addon_id addonis, int32 newcount, int32 gonecount);
void NodeStopped(const media_node &node, bigtime_t when); // XXX fix
static bool IsValidNotificationType(int32 notificationType);
static notification_type_mask NotificationType2Mask(int32 notificationType);
private:
status_t SendMessageToMediaServer(BMessage *msg);
private:
BMessenger *fMessenger;
};
}; // namespace media
}; // namespace BPrivate
#define NOTIFICATION_PARAM_WHAT "be:media:internal:what"
#define NOTIFICATION_PARAM_MASK "be:media:internal:mask"
extern BPrivate::media::NotificationManager *_NotificationManager;
#endif // _NOTIFICATION_MANAGER_H
+87
View File
@@ -0,0 +1,87 @@
/*
* Copyright 2002, Marcus Overhagen. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _NOTIFICATIONS_H
#define _NOTIFICATIONS_H
namespace BPrivate {
namespace media {
namespace notifications {
/*
* This are the possible notifications that can be watched.
* The notifications marked with "N" are only send when the
* media_node specific BMediaRoster::StartWatching() is used
* and the notification belongs to the watched node.
*
* In addition, anyone watching a specific node will also receive
* error notifications generated by BMediaNode::ReportError()
*
* B_MEDIA_WILDCARD used to match any notification in Start/StopWatching
* B_MEDIA_NODE_CREATED "media_node_id" (multiple items)
* B_MEDIA_NODE_DELETED "media_node_id" (multiple items)
* B_MEDIA_CONNECTION_MADE "output", "input", "format"
* B_MEDIA_CONNECTION_BROKEN "source", "destination"
* B_MEDIA_BUFFER_CREATED "clone_info" -- handled by BMediaRoster
* B_MEDIA_BUFFER_DELETED "media_buffer_id" -- handled by BMediaRoster
* B_MEDIA_TRANSPORT_STATE "state", "location", "realtime"
* B_MEDIA_PARAMETER_CHANGED N "node", "parameter"
* B_MEDIA_FORMAT_CHANGED N "source", "destination", "format"
* B_MEDIA_WEB_CHANGED N "node"
* B_MEDIA_DEFAULT_CHANGED "default", "node" -- handled by BMediaRoster
* B_MEDIA_NEW_PARAMETER_VALUE N "node", "parameter", "when", "value"
* B_MEDIA_NODE_STOPPED N "node", "when"
* B_MEDIA_FLAVORS_CHANGED "be:addon_id", "be:new_count", "be:gone_count"
*/
// used for BMediaRoster::StartWatching() parameter validation
bool IsValidNotificationRequest(bool node_specific, int32 notification);
// called by BMediaRoster::StartWatching()
status_t Register(const BMessenger &notifyHandler, const media_node &node, int32 notification);
// called by BMediaRoster::StopWatching()
status_t Unregister(const BMessenger &notifyHandler, const media_node &node, int32 notification);
// called by BMediaNode::ReportError()
status_t ReportError(const media_node &node, BMediaNode::node_error what, const BMessage * info);
void NodesCreated(const media_node_id *ids, int32 count);
void NodesDeleted(const media_node_id *ids, int32 count);
void ConnectionMade(const media_input &input, const media_output &output, const media_format &format);
void ConnectionBroken(const media_source &source, const media_destination &destination);
void BuffersCreated(area_info *areas, int32 count);
void BuffersDeleted(const media_buffer_id *ids, int32 count);
// called by BMediaNode::NodeStopped()
void NodeStopped(const media_node &node, bigtime_t when);
// called by BControllable::BroadcastChangedParameter()
status_t ParameterChanged(const media_node &node, int32 parameterid);
// called by BControllable::SetParameterWeb()
void WebChanged(const media_node &node);
// called by BControllable::BroadcastNewParameterValue()
status_t NewParameterValue(const media_node &node, int32 parameterid, bigtime_t when, const void *param, size_t paramsize);
// called by the media_addon_server AFTER a flavor change has been
// handled. NOT CALLED by BMediaAddOn::NotifyFlavorChange()
void FlavorsChanged(media_addon_id addonid, int32 newcount, int32 gonecount);
void FormatChanged(const media_source &source, const media_destination &destination, const media_format &format);
// XXX missing: B_MEDIA_TRANSPORT_STATE /* "state", "location", "realtime" */
// XXX missing: B_MEDIA_DEFAULT_CHANGED /* "default", "node" */
}; // namespace notifications
}; // namespace media
}; // namespace BPrivate
#define NOTIFICATION_PARAM_WHAT "be:media:internal:what"
#define NOTIFICATION_PARAM_TEAM "be:media:internal:team"
#define NOTIFICATION_PARAM_MESSENGER "be:media:internal:messenger"
#endif // _NOTIFICATIONS_H