1/*
2 * Copyright 2015-2018, Dario Casalinuovo. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5
6#ifndef _MEDIA_CLIENT_DEFS_H
7#define _MEDIA_CLIENT_DEFS_H
8
9#include <MediaDefs.h>
10#include <MediaNode.h>
11
12
13namespace BPrivate { namespace media {
14
15
16typedef int64 media_client_id;
17typedef int64 media_connection_id;
18
19typedef uint64 media_client_kinds;
20typedef uint64 media_connection_kinds;
21
22
23enum media_client_kind {
24	// The client can receive media data.
25	B_MEDIA_RECORDER		= 0x000000001,
26	// The client can send media data to another client.
27	B_MEDIA_PLAYER			= 0x000000002,
28	// The client specify a control GUI which can be used to configure it.
29	B_MEDIA_CONTROLLABLE	= 0x000000004
30};
31
32enum media_connection_kind {
33	B_MEDIA_INPUT = 0,
34	B_MEDIA_OUTPUT = 1
35};
36
37
38typedef struct media_client {
39	media_client_id				Id() const;
40	media_client_kinds			Kinds() const;
41
42	BMessage*					ToMessage();
43
44private:
45	media_client_kinds			kinds;
46
47	media_node					node;
48	uint32						padding[16];
49
50	friend class BMediaClient;
51	friend class BMediaConnection;
52	friend class media_connection;
53} media_client;
54
55
56typedef struct media_connection {
57	media_connection_id			Id() const;
58	media_connection_kinds		Kinds() const;
59
60	const media_client&			Client() const;
61
62	const char*					Name() const;
63
64	bool						IsInput() const;
65	bool						IsOutput() const;
66
67	BMessage*					ToMessage() const;
68
69private:
70	// NOTE: We are doing this on purpose to avoid redundancy we
71	// want to build the input/output on the fly. In pratice, the
72	// only thing that can change is the format which is kept updated
73	// to reflect the current status of this connection.
74	media_input					_BuildMediaInput() const;
75	media_output				_BuildMediaOutput() const;
76
77	media_node					_Node() const;
78
79	media_connection_id			id;
80
81	media_client				client;
82
83	media_node					remote_node;
84
85    media_source				source;
86    media_destination			destination;
87
88    // This format always reflect the most updated format depending
89    // on the connection phase.
90    media_format				format;
91    char						name[B_MEDIA_NAME_LENGTH];
92
93	media_connection_kinds		kinds;
94	uint32						padding[16];
95
96	friend class BMediaClient;
97	friend class BMediaClientNode;
98	friend class BMediaConnection;
99	friend class BMediaInput;
100	friend class BMediaOutput;
101} media_connection;
102
103
104}
105
106}
107
108using namespace BPrivate::media;
109
110#endif
111