47 #define DEFAULT_ICE_USER "source"
49 #define NOT_EMPTY(s) (s && s[0])
51 #define OFFSET(x) offsetof(IcecastContext, x)
52 #define E AV_OPT_FLAG_ENCODING_PARAM
62 {
"content_type",
"set content-type, MUST be set if not audio/mpeg",
OFFSET(content_type),
AV_OPT_TYPE_STRING, { 0 }, 0, 0,
E },
63 {
"legacy_icecast",
"use legacy SOURCE method, for Icecast < v2.4",
OFFSET(legacy_icecast),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
E },
68 static char *
cat_header(
char buf[],
const char key[],
const char value[])
71 int len = strlen(key) + strlen(value) + 5;
107 char h_url[1024], host[1024], auth[1024], path[1024];
136 &port, path,
sizeof(path), uri);
140 char *sep = strchr(auth,
':');
160 snprintf(auth,
sizeof(auth),
166 if (!path[0] || strcmp(path,
"/") == 0) {
173 ff_url_join(h_url,
sizeof(h_url),
"http", auth, host, port,
"%s", path);
192 static const uint8_t oggs[4] = { 0x4F, 0x67, 0x67, 0x53 };
193 static const uint8_t webm[4] = { 0x1A, 0x45, 0xDF, 0xA3 };
194 static const uint8_t opus[8] = { 0x4F, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64 };
195 if (memcmp(buf, oggs,
sizeof(oggs)) == 0) {
198 }
else if (memcmp(buf, opus,
sizeof(opus)) == 0) {
201 }
else if (memcmp(buf, webm,
sizeof(webm)) == 0) {
226 .priv_data_class = &icecast_context_class,
void av_url_split(char *proto, int proto_size, char *authorization, int authorization_size, char *hostname, int hostname_size, int *port_ptr, char *path, int path_size, const char *url)
Split a URL string into components.
static int icecast_open(URLContext *h, const char *uri, int flags)
#define URL_PROTOCOL_FLAG_NETWORK
#define AV_LOG_WARNING
Something somehow does not look correct.
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h.
#define AVIO_FLAG_READ
read-only
static const AVOption options[]
static int icecast_write(URLContext *h, const uint8_t *buf, int size)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
static char * cat_header(char buf[], const char key[], const char value[])
static int icecast_close(URLContext *h)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
void av_log(void *avcl, int level, const char *fmt,...)
URLProtocol ff_icecast_protocol
int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, int port, const char *fmt,...)
char * av_strdup(const char *s)
Duplicate the string s.
#define AVIO_FLAG_READ_WRITE
read-write pseudo flag
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
static const AVClass icecast_context_class
Describe the class of an AVClass context structure.
size_t av_strlcatf(char *dst, size_t size, const char *fmt,...)
int ffurl_close(URLContext *h)
Close the resource accessed by the URLContext h, and free the memory used by it.
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
int ffurl_open(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create an URLContext for accessing to the resource indicated by url, and open it. ...