mikroSDK Reference Manual
icecast_client.h
Go to the documentation of this file.
1
31#ifndef _ICECAST_CLIENT_H
32#define _ICECAST_CLIENT_H
33
34//Dependencies
35#include "core/net.h"
36#include "core/socket.h"
37
38//Icecast client support
39#ifndef ICECAST_CLIENT_SUPPORT
40 #define ICECAST_CLIENT_SUPPORT DISABLED
41#elif (ICECAST_CLIENT_SUPPORT != ENABLED && ICECAST_CLIENT_SUPPORT != DISABLED)
42 #error ICECAST_CLIENT_SUPPORT parameter is not valid
43#endif
44
45//Stack size required to run the Icecast client
46#ifndef ICECAST_CLIENT_STACK_SIZE
47 #define ICECAST_CLIENT_STACK_SIZE 650
48#elif (ICECAST_CLIENT_STACK_SIZE < 1)
49 #error ICECAST_CLIENT_STACK_SIZE parameter is not valid
50#endif
51
52//Priority at which the Icecast client should run
53#ifndef ICECAST_CLIENT_PRIORITY
54 #define ICECAST_CLIENT_PRIORITY OS_TASK_PRIORITY_NORMAL
55#endif
56
57//Maximum time the Icecast client will wait before closing the connection
58#ifndef ICECAST_CLIENT_TIMEOUT
59 #define ICECAST_CLIENT_TIMEOUT 10000
60#elif (ICECAST_CLIENT_TIMEOUT < 1000)
61 #error ICECAST_CLIENT_TIMEOUT parameter is not valid
62#endif
63
64//Recovery delay
65#ifndef ICECAST_RECOVERY_DELAY
66 #define ICECAST_RECOVERY_DELAY 5000
67#elif (ICECAST_RECOVERY_DELAY < 1000)
68 #error ICECAST_RECOVERY_DELAY parameter is not valid
69#endif
70
71//Maximum length of the server name
72#ifndef ICECAST_SERVER_NAME_MAX_LEN
73 #define ICECAST_SERVER_NAME_MAX_LEN 48
74#elif (ICECAST_SERVER_NAME_MAX_LEN < 1)
75 #error ICECAST_SERVER_NAME_MAX_LEN parameter is not valid
76#endif
77
78//Maxmimum length of the requested resource
79#ifndef ICECAST_RESOURCE_MAX_LEN
80 #define ICECAST_RESOURCE_MAX_LEN 32
81#elif (ICECAST_RESOURCE_MAX_LEN < 1)
82 #error ICECAST_RESOURCE_MAX_LEN parameter is not valid
83#endif
84
85//Maximum size of metadata blocks
86#ifndef ICECAST_CLIENT_METADATA_MAX_SIZE
87 #define ICECAST_CLIENT_METADATA_MAX_SIZE 512
88#elif (ICECAST_CLIENT_METADATA_MAX_SIZE < 128)
89 #error ICECAST_CLIENT_METADATA_MAX_SIZE parameter is not valid
90#endif
91
92//C++ guard
93#ifdef __cplusplus
94extern "C" {
95#endif
96
97
102typedef struct
103{
104 NetInterface *interface;
105 char_t serverName[ICECAST_SERVER_NAME_MAX_LEN];
106 uint16_t serverPort;
107 char_t resource[ICECAST_RESOURCE_MAX_LEN];
108 size_t bufferSize;
110
111
116typedef struct
117{
123#if (OS_STATIC_TASK_SUPPORT == ENABLED)
124 OsTaskTcb taskTcb;
125 OsStackType taskStack[ICECAST_CLIENT_STACK_SIZE];
126#endif
127 Socket *socket;
128 size_t blockSize;
129 uint8_t *streamBuffer;
130 size_t bufferSize;
132 size_t writeIndex;
133 size_t readIndex;
134 size_t totalLength;
135 char_t buffer[ICECAST_CLIENT_METADATA_MAX_SIZE];
136 char_t metadata[ICECAST_CLIENT_METADATA_MAX_SIZE];
139
140
141//Icecast related functions
142void icecastClientGetDefaultSettings(IcecastClientSettings *settings);
143
144error_t icecastClientInit(IcecastClientContext *context,
145 const IcecastClientSettings *settings);
146
147error_t icecastClientStart(IcecastClientContext *context);
148
149error_t icecastClientReadStream(IcecastClientContext *context,
150 uint8_t *data, size_t size, size_t *length, systime_t timeout);
151
152error_t icecastClientReadMetadata(IcecastClientContext *context,
153 char_t *metadata, size_t size, size_t *length);
154
155void icecastClientTask(void *param);
156
157error_t icecastClientConnect(IcecastClientContext *context);
158error_t icecastClientProcessMetadata(IcecastClientContext *context);
159
160//C++ guard
161#ifdef __cplusplus
162}
163#endif
164
165#endif
error_t
Error codes.
Definition error.h:43
TCP/IP stack core.
uint_t OsMutex
Mutex object.
Definition os_port_none.h:118
uint_t OsEvent
Event object.
Definition os_port_none.h:104
uint_t OsTaskId
Task identifier.
Definition os_port_none.h:97
uint32_t systime_t
System time.
Definition os_port_none.h:90
Socket API.
Icecast client context.
Definition icecast_client.h:117
OsEvent writeEvent
This event tells whether the buffer is writable.
Definition icecast_client.h:120
Socket * socket
Underlying socket.
Definition icecast_client.h:127
size_t blockSize
Number of data bytes between subsequent metadata blocks.
Definition icecast_client.h:128
size_t metadataLength
Length of the metadata.
Definition icecast_client.h:137
OsTaskTcb taskTcb
Task control block.
Definition icecast_client.h:124
size_t readIndex
Current read index within the buffer.
Definition icecast_client.h:133
size_t bufferLength
Streaming buffer length.
Definition icecast_client.h:131
OsMutex mutex
Mutex protecting critical sections.
Definition icecast_client.h:119
size_t totalLength
Total number of bytes that have been received.
Definition icecast_client.h:134
IcecastClientSettings settings
User settings.
Definition icecast_client.h:118
size_t writeIndex
Current write index within the buffer.
Definition icecast_client.h:132
uint8_t * streamBuffer
Streaming buffer.
Definition icecast_client.h:129
size_t bufferSize
Streaming buffer size.
Definition icecast_client.h:130
OsEvent readEvent
This event tells whether the buffer is readable.
Definition icecast_client.h:121
OsTaskId taskId
Task identifier.
Definition icecast_client.h:122
Icecast client settings.
Definition icecast_client.h:103
NetInterface * interface
Underlying network interface.
Definition icecast_client.h:104
size_t bufferSize
Streaming buffer size.
Definition icecast_client.h:108
uint16_t serverPort
Icecast server port.
Definition icecast_client.h:106