49 #define DEFAULT_ICE_USER "source"
51 #define NOT_EMPTY(s) (s && s[0])
53 #define OFFSET(x) offsetof(IcecastContext, x)
54 #define E AV_OPT_FLAG_ENCODING_PARAM
65 {
"legacy_icecast",
"use legacy SOURCE method, for Icecast < v2.4",
OFFSET(legacy_icecast),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
E },
92 char h_url[1024], host[1024], auth[1024], path[1024];
93 char *headers, *user =
NULL;
104 cat_header(&bp,
"Ice-Description",
s->description);
107 cat_header(&bp,
"Ice-Public",
s->public ?
"1" :
"0");
116 av_dict_set(&opt_dict,
"method",
s->legacy_icecast ?
"SOURCE" :
"PUT", 0);
120 av_dict_set(&opt_dict,
"send_expect_100",
s->legacy_icecast ?
"-1" :
"1", 0);
122 av_dict_set(&opt_dict,
"content_type",
s->content_type, 0);
124 av_dict_set(&opt_dict,
"content_type",
"audio/mpeg", 0);
130 &port, path,
sizeof(path), uri);
134 char *sep = strchr(auth,
':');
157 s->pass ?
s->pass :
"");
160 if (!path[0] || strcmp(path,
"/") == 0) {
168 s->tls ?
"https" :
"http",
169 auth, host, port,
"%s", path);
172 &opt_dict,
h->protocol_whitelist,
h->protocol_blacklist,
h);
184 if (!
s->send_started) {
186 if (!
s->content_type &&
size >= 8) {
187 static const uint8_t oggs[4] = { 0x4F, 0x67, 0x67, 0x53 };
188 static const uint8_t webm[4] = { 0x1A, 0x45, 0xDF, 0xA3 };
189 static const uint8_t opus[8] = { 0x4F, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64 };
190 if (memcmp(buf, oggs,
sizeof(oggs)) == 0) {
193 }
else if (memcmp(buf, opus,
sizeof(opus)) == 0) {
196 }
else if (memcmp(buf, webm,
sizeof(webm)) == 0) {
int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist, URLContext *parent)
Create an URLContext for accessing to the resource indicated by url, and open it.
int ffurl_closep(URLContext **hh)
Close the resource accessed by the URLContext h, and free the memory used by it.
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
#define AVIO_FLAG_READ_WRITE
read-write pseudo flag
void av_bprintf(AVBPrint *buf, const char *fmt,...)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
#define AV_BPRINT_SIZE_AUTOMATIC
#define flags(name, subs,...)
static av_cold void cleanup(FlashSV2Context *s)
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.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
char * av_strdup(const char *s)
Duplicate a string.
#define LIBAVUTIL_VERSION_INT
static const AVOption options[]
static int icecast_write(URLContext *h, const uint8_t *buf, int size)
static void cat_header(AVBPrint *bp, const char key[], const char value[])
static int icecast_open(URLContext *h, const char *uri, int flags)
static const AVClass icecast_context_class
static int icecast_close(URLContext *h)
const URLProtocol ff_icecast_protocol
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, int port, const char *fmt,...)
#define URL_PROTOCOL_FLAG_NETWORK