1 /* 2 * ESounD media addon for BeOS 3 * 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) 8 * 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: 12 * 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. 18 * 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. 29 * 30 */ 31 #ifndef ESDENDPOINT_H 32 #define ESDENDPOINT_H 33 34 #include "esdproto.h" 35 #include <DataIO.h> 36 #include <String.h> 37 38 //#define ESD_FMT 8 39 #define ESD_FMT 16 40 41 class ESDEndpoint : public BDataIO { 42 public: 43 ESDEndpoint(); 44 ~ESDEndpoint(); 45 46 /* */ 47 void Reset(); 48 status_t SendAuthKey(); 49 status_t Connect(const char *host, uint16 port=ESD_DEFAULT_PORT); 50 status_t Disconnect(); 51 52 /* set the default command and format for BDataIO interface */ 53 status_t SetCommand(esd_command_t cmd=ESD_PROTO_STREAM_PLAY); 54 status_t SetFormat(int bits, int channels, float rate=ESD_DEFAULT_RATE); 55 56 status_t GetServerInfo(); 57 58 /* */ 59 60 bigtime_t GetLatency() const { return fLatency; }; 61 const char *Host() const { return fHost.String(); }; 62 uint16 Port() const { return fPort; }; 63 64 bool CanSend(); 65 66 /* BDataIO */ 67 68 virtual ssize_t Read(void *buffer, size_t size); 69 virtual ssize_t Write(const void *buffer, size_t size); 70 71 status_t SendCommand(esd_command_t cmd, const uint8 *obuf, size_t olen, uint8 *ibuf, size_t ilen); 72 status_t SendDefaultCommand(); 73 private: 74 75 BString fHost; 76 uint16 fPort; 77 int fSocket; 78 esd_key_t fAuthKey; 79 esd_command_t fDefaultCommand; 80 bool fDefaultCommandSent; 81 esd_format_t fDefaultFormat; 82 esd_rate_t fDefaultRate; 83 bigtime_t fLatency; 84 }; 85 86 87 #endif /* ESDENDPOINT_H */ 88