76 char host[1024], path[1024], url[1024], announce_addr[50] =
"";
78 int port = 9875, base_port = 5004, i, pos = 0, same_port = 0, ttl = 255;
82 socklen_t addrlen =
sizeof(localaddr);
96 option_list = strrchr(path,
'?');
100 port = strtol(buf,
NULL, 10);
103 same_port = strtol(buf,
NULL, 10);
106 ttl = strtol(buf,
NULL, 10);
109 av_strlcpy(announce_addr, buf,
sizeof(announce_addr));
113 if (!announce_addr[0]) {
121 if (ai->ai_family == AF_INET) {
123 av_strlcpy(announce_addr,
"224.2.127.254",
sizeof(announce_addr));
124 #if HAVE_STRUCT_SOCKADDR_IN6 125 }
else if (ai->ai_family == AF_INET6) {
129 av_strlcpy(announce_addr,
"ff0e::2:7ffe",
sizeof(announce_addr));
134 "address family\n", host);
173 av_strlcpy(contexts[i]->filename, url,
sizeof(contexts[i]->filename));
180 "?ttl=%d&connect=1", ttl);
189 if (getsockname(udp_fd, (
struct sockaddr*) &localaddr, &addrlen)) {
193 if (localaddr.ss_family != AF_INET
195 && localaddr.ss_family != AF_INET6
208 sap->
ann[pos] = (1 << 5);
209 #if HAVE_STRUCT_SOCKADDR_IN6 210 if (localaddr.ss_family == AF_INET6)
211 sap->
ann[pos] |= 0x10;
217 if (localaddr.ss_family == AF_INET) {
218 memcpy(&sap->
ann[pos], &((
struct sockaddr_in*)&localaddr)->sin_addr,
219 sizeof(
struct in_addr));
220 pos +=
sizeof(
struct in_addr);
221 #if HAVE_STRUCT_SOCKADDR_IN6 223 memcpy(&sap->
ann[pos], &((
struct sockaddr_in6*)&localaddr)->sin6_addr,
224 sizeof(
struct in6_addr));
225 pos +=
sizeof(
struct in6_addr);
230 pos += strlen(&sap->
ann[pos]) + 1;
239 pos += strlen(&sap->
ann[pos]);
265 if (ret < 0 && ret !=
AVERROR(ECONNREFUSED))
276 .priv_data_size =
sizeof(
struct SAPState),
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.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t start_time_realtime
Start time of the stream in real world time, in microseconds since the Unix epoch (00:00 1st January ...
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
Write size bytes from buf to the resource accessed by h.
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
#define AVIO_FLAG_WRITE
write-only
void ff_network_close(void)
AVOutputFormat ff_sap_muxer
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int sap_write_packet(AVFormatContext *s, AVPacket *pkt)
int ff_network_init(void)
miscellaneous OS support macros and functions.
AVStream ** streams
A list of all streams in the file.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
char * protocol_whitelist
A comma-separated list of protocol names that can be used internally by libavformat.
#define AV_LOG_VERBOSE
Detailed information.
int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
Generate an SDP for an RTP session.
int av_find_info_tag(char *arg, int arg_size, const char *tag1, const char *info)
Attempt to find a specific tag in a URL.
int ffurl_open(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const URLProtocol **protocols, URLContext *parent)
Create an URLContext for accessing to the resource indicated by url, and open it. ...
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVDictionary * metadata
Metadata that applies to the whole file.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
#define HAVE_STRUCT_SOCKADDR_IN6
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
char filename[1024]
input or output filename
static int sap_write_close(AVFormatContext *s)
int ffurl_get_file_handle(URLContext *h)
Return the file descriptor associated with this URL.
int64_t av_gettime(void)
Get the current time in microseconds.
int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, int port, const char *fmt,...)
static int sap_write_header(AVFormatContext *s)
const URLProtocol ** protocols
AVIOContext * pb
I/O context.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
int ffurl_close(URLContext *h)
Close the resource accessed by the URLContext h, and free the memory used by it.
int ff_rtp_chain_mux_open(AVFormatContext **out, AVFormatContext *s, AVStream *st, URLContext *handle, int packet_size, int idx)
void * priv_data
Format private data.
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
char * protocol_blacklist
A comma-separated list of protocol names that will not be used internally by libavformat.
int max_packet_size
if non zero, the stream is packetized with this max packet size
unbuffered private I/O API
uint32_t av_get_random_seed(void)
Get random data.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
const URLProtocol ** ffurl_get_protocols(const char *whitelist, const char *blacklist)
Construct a list of protocols matching a given whitelist and/or blacklist.
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...