MediaClient: Introduce media_client and media_connection
* Those structs are provided as replacement for the classic media_kit ones. They provide better encapsulation of the data and the resulting code is heavily simplified. It's planned to introduce BMediaRoster functions to provide conversion from media_node and media_input/media_output to media_client and media_connection.
This commit is contained in:
parent
a9d53d9e7e
commit
23d5326e2b
103
headers/private/media/MediaClientDefs.h
Normal file
103
headers/private/media/MediaClientDefs.h
Normal file
@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright 2015, Haiku, Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#ifndef _MEDIA_CLIENT_DEFS_H
|
||||
#define _MEDIA_CLIENT_DEFS_H
|
||||
|
||||
#include <MediaDefs.h>
|
||||
#include <MediaNode.h>
|
||||
|
||||
|
||||
namespace BPrivate { namespace media {
|
||||
|
||||
|
||||
typedef int32 media_client_id;
|
||||
typedef int32 media_client_kind;
|
||||
typedef int32 media_connection_id;
|
||||
|
||||
|
||||
enum media_client_kinds {
|
||||
// The client can receive media data.
|
||||
B_MEDIA_RECORDER = 0x000000001,
|
||||
// The client can send media data to another client.
|
||||
B_MEDIA_PLAYER = 0x000000002,
|
||||
// The client specify a control GUI which can be used to configure it.
|
||||
B_MEDIA_CONTROLLABLE = 0x000000004
|
||||
};
|
||||
|
||||
enum media_connection_kind {
|
||||
B_MEDIA_INPUT = 0,
|
||||
B_MEDIA_OUTPUT = 1
|
||||
};
|
||||
|
||||
|
||||
typedef struct media_client {
|
||||
media_client_id Id() const;
|
||||
media_client_kind Kind() const;
|
||||
|
||||
BMessage* ToMessage();
|
||||
|
||||
private:
|
||||
media_client_kind kind;
|
||||
|
||||
media_node node;
|
||||
uint32 padding[16];
|
||||
|
||||
friend class BMediaClient;
|
||||
friend class BMediaConnection;
|
||||
friend class media_connection;
|
||||
} media_client;
|
||||
|
||||
|
||||
typedef struct media_connection {
|
||||
media_connection_id Id() const;
|
||||
media_connection_kind Kind() const;
|
||||
|
||||
media_client Client() const;
|
||||
|
||||
const char* Name() const;
|
||||
|
||||
bool IsInput() const;
|
||||
bool IsOutput() const;
|
||||
|
||||
BMessage* ToMessage() const;
|
||||
|
||||
private:
|
||||
media_input MediaInput() const;
|
||||
media_output MediaOutput() const;
|
||||
|
||||
const media_source& Source() const;
|
||||
const media_destination& Destination() const;
|
||||
|
||||
media_node RemoteNode() const;
|
||||
|
||||
private:
|
||||
media_connection_id id;
|
||||
|
||||
media_client client;
|
||||
// TODO really needed?
|
||||
media_client remote_client;
|
||||
|
||||
media_source source;
|
||||
media_destination destination;
|
||||
media_format format;
|
||||
char name[B_MEDIA_NAME_LENGTH];
|
||||
|
||||
media_connection_kind kind;
|
||||
uint32 padding[16];
|
||||
|
||||
friend class BMediaClient;
|
||||
friend class BMediaConnection;
|
||||
friend class BMediaClientNode;
|
||||
} media_connection;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
using namespace BPrivate::media;
|
||||
|
||||
#endif
|
89
src/kits/media/MediaClientDefs.cpp
Normal file
89
src/kits/media/MediaClientDefs.cpp
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
* Copyright 2015, Dario Casalinuovo. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
#include <MediaClient.h>
|
||||
#include <MediaConnection.h>
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
media_client_id
|
||||
media_client::Id() const
|
||||
{
|
||||
return node.node;
|
||||
}
|
||||
|
||||
|
||||
media_connection_id
|
||||
media_connection::Id() const
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
media_connection_kind
|
||||
media_connection::Kind() const
|
||||
{
|
||||
return kind;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
media_connection::IsInput() const
|
||||
{
|
||||
return Kind() == B_MEDIA_INPUT;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
media_connection::IsOutput() const
|
||||
{
|
||||
return Kind() == B_MEDIA_OUTPUT;
|
||||
}
|
||||
|
||||
|
||||
media_input
|
||||
media_connection::MediaInput() const
|
||||
{
|
||||
media_input input;
|
||||
input.node = client.node;
|
||||
input.source = source;
|
||||
input.destination = destination;
|
||||
input.format = format;
|
||||
return input;
|
||||
}
|
||||
|
||||
|
||||
media_output
|
||||
media_connection::MediaOutput() const
|
||||
{
|
||||
media_output output;
|
||||
output.node = client.node;
|
||||
output.source = source;
|
||||
output.destination = destination;
|
||||
output.format = format;
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
const media_source&
|
||||
media_connection::Source() const
|
||||
{
|
||||
return source;
|
||||
}
|
||||
|
||||
|
||||
const media_destination&
|
||||
media_connection::Destination() const
|
||||
{
|
||||
return destination;
|
||||
}
|
||||
|
||||
|
||||
media_node
|
||||
media_connection::RemoteNode() const
|
||||
{
|
||||
return remote_client.node;
|
||||
}
|
Loading…
Reference in New Issue
Block a user