Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
icecast_client.h
00001 /** 00002 * @file icecast_client.h 00003 * @brief Icecast client 00004 * 00005 * @section License 00006 * 00007 * Copyright (C) 2010-2017 Oryx Embedded SARL. All rights reserved. 00008 * 00009 * This file is part of CycloneTCP Open. 00010 * 00011 * This program is free software; you can redistribute it and/or 00012 * modify it under the terms of the GNU General Public License 00013 * as published by the Free Software Foundation; either version 2 00014 * of the License, or (at your option) any later version. 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU General Public License 00022 * along with this program; if not, write to the Free Software Foundation, 00023 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00024 * 00025 * @author Oryx Embedded SARL (www.oryx-embedded.com) 00026 * @version 1.7.6 00027 **/ 00028 00029 #ifndef _ICECAST_CLIENT_H 00030 #define _ICECAST_CLIENT_H 00031 00032 //Dependencies 00033 #include "core/net.h" 00034 #include "core/socket.h" 00035 00036 //Icecast client support 00037 #ifndef ICECAST_CLIENT_SUPPORT 00038 #define ICECAST_CLIENT_SUPPORT ENABLED 00039 #elif (ICECAST_CLIENT_SUPPORT != ENABLED && ICECAST_CLIENT_SUPPORT != DISABLED) 00040 #error ICECAST_CLIENT_SUPPORT parameter is not valid 00041 #endif 00042 00043 //Stack size required to run the Icecast client 00044 #ifndef ICECAST_CLIENT_STACK_SIZE 00045 #define ICECAST_CLIENT_STACK_SIZE 650 00046 #elif (ICECAST_CLIENT_STACK_SIZE < 1) 00047 #error ICECAST_CLIENT_STACK_SIZE parameter is not valid 00048 #endif 00049 00050 //Priority at which the Icecast client should run 00051 #ifndef ICECAST_CLIENT_PRIORITY 00052 #define ICECAST_CLIENT_PRIORITY OS_TASK_PRIORITY_NORMAL 00053 #endif 00054 00055 //Maximum time the Icecast client will wait before closing the connection 00056 #ifndef ICECAST_CLIENT_TIMEOUT 00057 #define ICECAST_CLIENT_TIMEOUT 10000 00058 #elif (ICECAST_CLIENT_TIMEOUT < 1000) 00059 #error ICECAST_CLIENT_TIMEOUT parameter is not valid 00060 #endif 00061 00062 //Recovery delay 00063 #ifndef ICECAST_RECOVERY_DELAY 00064 #define ICECAST_RECOVERY_DELAY 5000 00065 #elif (ICECAST_RECOVERY_DELAY < 1000) 00066 #error ICECAST_RECOVERY_DELAY parameter is not valid 00067 #endif 00068 00069 //Maximum length of the server name 00070 #ifndef ICECAST_SERVER_NAME_MAX_LEN 00071 #define ICECAST_SERVER_NAME_MAX_LEN 48 00072 #elif (ICECAST_SERVER_NAME_MAX_LEN < 1) 00073 #error ICECAST_SERVER_NAME_MAX_LEN parameter is not valid 00074 #endif 00075 00076 //Maxmimum length of the requested resource 00077 #ifndef ICECAST_RESOURCE_MAX_LEN 00078 #define ICECAST_RESOURCE_MAX_LEN 32 00079 #elif (ICECAST_RESOURCE_MAX_LEN < 1) 00080 #error ICECAST_RESOURCE_MAX_LEN parameter is not valid 00081 #endif 00082 00083 //Maximum size of metadata blocks 00084 #ifndef ICECAST_CLIENT_METADATA_MAX_SIZE 00085 #define ICECAST_CLIENT_METADATA_MAX_SIZE 512 00086 #elif (ICECAST_CLIENT_METADATA_MAX_SIZE < 128) 00087 #error ICECAST_CLIENT_METADATA_MAX_SIZE parameter is not valid 00088 #endif 00089 00090 00091 /** 00092 * @brief Icecast client settings 00093 **/ 00094 00095 typedef struct 00096 { 00097 NetInterface *interface; ///<Underlying network interface 00098 char_t serverName[ICECAST_SERVER_NAME_MAX_LEN]; ///<Icecast server name 00099 uint16_t serverPort; ///<Icecast server port 00100 char_t resource[ICECAST_RESOURCE_MAX_LEN]; ///<Requested resource 00101 size_t bufferSize; ///<Streaming buffer size 00102 } IcecastClientSettings; 00103 00104 00105 /** 00106 * @brief Icecast client context 00107 **/ 00108 00109 typedef struct 00110 { 00111 IcecastClientSettings settings; ///<User settings 00112 OsMutex mutex; ///<Mutex protecting critical sections 00113 OsEvent writeEvent; ///<This event tells whether the buffer is writable 00114 OsEvent readEvent; ///<This event tells whether the buffer is readable 00115 Socket *socket; ///<Underlying socket 00116 size_t blockSize; ///<Number of data bytes between subsequent metadata blocks 00117 uint8_t *streamBuffer; ///<Streaming buffer 00118 size_t bufferSize; ///<Streaming buffer size 00119 size_t bufferLength; ///<Streaming buffer length 00120 size_t writeIndex; ///<Current write index within the buffer 00121 size_t readIndex; ///<Current read index within the buffer 00122 size_t totalLength; ///<Total number of bytes that have been received 00123 char_t buffer[ICECAST_CLIENT_METADATA_MAX_SIZE]; ///<Memory buffer for input/output operations 00124 char_t metadata[ICECAST_CLIENT_METADATA_MAX_SIZE]; ///<Metadata information 00125 size_t metadataLength; ///<Length of the metadata 00126 } IcecastClientContext; 00127 00128 00129 //Icecast related functions 00130 void icecastClientGetDefaultSettings(IcecastClientSettings *settings); 00131 00132 error_t icecastClientInit(IcecastClientContext *context, 00133 const IcecastClientSettings *settings); 00134 00135 error_t icecastClientStart(IcecastClientContext *context); 00136 00137 error_t icecastClientReadStream(IcecastClientContext *context, 00138 uint8_t *data, size_t size, size_t *length, systime_t timeout); 00139 00140 error_t icecastClientReadMetadata(IcecastClientContext *context, 00141 char_t *metadata, size_t size, size_t *length); 00142 00143 void icecastClientTask(void *param); 00144 00145 error_t icecastClientConnect(IcecastClientContext *context); 00146 error_t icecastClientProcessMetadata(IcecastClientContext *context); 00147 00148 #endif 00149
Generated on Tue Jul 12 2022 17:10:13 by
1.7.2