3rdparty/licenseReport: Add seperate LGPL checks
[haiku.git] / src / add-ons / media / media-add-ons / esound_sink / ESDEndpoint.h
blob882de728cdcacc9af0f3fe68ddaee2db4b628bb1
1 /*
2 * ESounD media addon for BeOS
4 * Copyright (c) 2006 François Revol (revol@free.fr)
5 *
6 * Based on Multi Audio addon for Haiku,
7 * Copyright (c) 2002, 2003 Jerome Duval (jerome.duval@free.fr)
9 * All rights reserved.
10 * Redistribution and use in source and binary forms, with or without modification,
11 * are permitted provided that the following conditions are met:
13 * - Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * - Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
23 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
25 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef ESDENDPOINT_H
32 #define ESDENDPOINT_H
34 #include "esdproto.h"
35 #include <DataIO.h>
36 #include <String.h>
38 //#define ESD_FMT 8
39 #define ESD_FMT 16
41 class ESDEndpoint : public BDataIO {
42 public:
43 ESDEndpoint();
44 ~ESDEndpoint();
46 /* */
47 status_t InitCheck() const;
48 void Reset();
49 status_t SendAuthKey();
51 bool Connected() const;
52 status_t Connect(const char *host, uint16 port=ESD_DEFAULT_PORT);
53 status_t WaitForConnect();
54 status_t Disconnect();
56 /* set the default command and format for BDataIO interface */
57 status_t SetCommand(esd_command_t cmd=ESD_PROTO_STREAM_PLAY);
58 status_t SetFormat(int bits, int channels, float rate=ESD_DEFAULT_RATE);
60 status_t GetServerInfo();
62 /* */
64 bigtime_t Latency() const { return fLatency; };
65 const char *Host() const { return fHost.String(); };
66 uint16 Port() const { return fPort; };
67 void GetFriendlyName(BString &name);
69 bool CanSend();
71 /* BDataIO */
73 virtual ssize_t Read(void *buffer, size_t size);
74 virtual ssize_t Write(const void *buffer, size_t size);
76 status_t SendCommand(esd_command_t cmd, const uint8 *obuf, size_t olen, uint8 *ibuf, size_t ilen);
77 status_t SendDefaultCommand();
78 private:
80 static int32 _ConnectThread(void *_arg);
81 int32 ConnectThread(void);
83 status_t fInitStatus;
84 thread_id fConnectThread;
85 BString fHost;
86 uint16 fPort;
87 int fSocket;
88 esd_key_t fAuthKey;
89 esd_command_t fDefaultCommand;
90 bool fDefaultCommandSent;
91 esd_format_t fDefaultFormat;
92 esd_rate_t fDefaultRate;
93 bigtime_t fLatency;
97 #endif /* ESDENDPOINT_H */