MediaClientDefs.h revision 6dc7d854
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	const media_source&			_Source() const;
78	const media_destination&	_Destination() const;
79
80	media_node					_Node() const;
81	media_node					_RemoteNode() const;
82
83	media_connection_id			id;
84
85	media_client				client;
86
87	media_node					remote_node;
88
89    media_source				source;
90    media_destination			destination;
91
92    // This format always reflect the most updated format depending
93    // on the connection phase.
94    media_format				format;
95    char						name[B_MEDIA_NAME_LENGTH];
96
97	media_connection_kinds		kinds;
98	uint32						padding[16];
99
100	friend class BMediaClient;
101	friend class BMediaClientNode;
102	friend class BMediaConnection;
103	friend class BMediaInput;
104	friend class BMediaOutput;
105} media_connection;
106
107
108}
109
110}
111
112using namespace BPrivate::media;
113
114#endif
115