FFmpeg: libavformat/sapdec.c Source File
Go to the documentation of this file. 1 /*
2 * Session Announcement Protocol (RFC 2974) demuxer
3 * Copyright (c) 2010 Martin Storsjo
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
32 #if HAVE_POLL_H
33 #include <poll.h>
34 #endif
35
43 };
44
46 {
49 return 0;
50 }
51
53 {
60 return 0;
61 }
62
64 {
66 char host[1024], path[1024], url[1024];
68 int port;
71
74
76 path,
sizeof(path),
s->url);
77 if (port < 0)
78 port = 9875;
79
80 if (!host[0]) {
81 /* Listen for announcements on sap.mcast.net if no host was specified */
82 av_strlcpy(host,
"224.2.127.254",
sizeof(host));
83 }
84
86 port);
88 &
s->interrupt_callback,
NULL,
89 s->protocol_whitelist,
s->protocol_blacklist,
NULL);
92
93 while (1) {
94 int addr_type, auth_len;
96
99 continue;
102 recvbuf[
ret] =
'0円';
/* Null terminate for easier parsing */
105 continue;
106 }
107
108 if ((recvbuf[0] & 0xe0) != 0x20) {
110 "received\n");
111 continue;
112 }
113
114 if (recvbuf[0] & 0x04) {
116 "announcement\n");
117 continue;
118 }
119 addr_type = recvbuf[0] & 0x10;
120 auth_len = recvbuf[1];
123 if (addr_type)
124 pos += 16;
/* IPv6 */
125 else
130 continue;
131 }
132 #define MIME "application/sdp"
133 if (strcmp(&recvbuf[
pos],
MIME) == 0) {
135 }
else if (strncmp(&recvbuf[
pos],
"v=0\r\n", 5) == 0) {
136 // Direct SDP without a mime type
137 } else {
140 continue;
141 }
142
147 }
148 break;
149 }
150
154
156 if (!infmt)
162 }
166
169
177 if (!st) {
180 }
184 }
185
186 return 0;
187
191 }
192
194 {
198 struct pollfd p = {fd, POLLIN, 0};
200
203
204 while (1) {
205 n = poll(&p, 1, 0);
206 if (n <= 0 || !(p.revents & POLLIN))
207 break;
211 /* Should ideally check the source IP address, too */
212 if (recvbuf[0] & 0x04 &&
hash == sap->
hash) {
213 /* Stream deletion */
216 }
217 }
218 }
224 int i =
s->nb_streams;
226 if (!st) {
228 }
232 }
233 }
235 }
236
240 .priv_data_size =
sizeof(
struct SAPState),
246 };
#define AV_LOG_WARNING
Something somehow does not look correct.
static int sap_read_header(AVFormatContext *s)
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
#define AVERROR_EOF
End of file.
AVStream ** streams
A list of all streams in the file.
#define AV_LOG_VERBOSE
Detailed information.
void ff_network_close(void)
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
static int sap_read_close(AVFormatContext *s)
int ff_network_init(void)
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
int ctx_flags
Flags signalling stream properties.
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.
AVInputFormat ff_sap_demuxer
int ff_url_join(char *str, int size, const char *proto, const char *authorization, const char *hostname, int port, const char *fmt,...)
AVCodecParameters * codecpar
Codec parameters associated with this stream.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
AVIOContext * pb
I/O context.
This structure contains the data a format has to probe a file.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
int ffio_init_context(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
AVFormatContext * sdp_ctx
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
ff_const59 AVInputFormat * av_find_input_format(const char *short_name)
Find AVInputFormat based on the short name of the input format.
int avformat_open_input(AVFormatContext **ps, const char *url, ff_const59 AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
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.
int ffurl_closep(URLContext **hh)
Close the resource accessed by the URLContext h, and free the memory used by it.
static int sap_probe(const AVProbeData *p)
int id
Format-specific stream ID.
#define RTP_MAX_PACKET_LENGTH
static int sap_fetch_packet(AVFormatContext *s, AVPacket *pkt)
int ffurl_read(URLContext *h, unsigned char *buf, int size)
Read up to size bytes from the resource accessed by h, and store the read bytes in buf.
#define AVIO_FLAG_READ
read-only
char * av_strdup(const char *s)
Duplicate a string.
This structure stores compressed data.
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.
int ffurl_get_file_handle(URLContext *h)
Return the file descriptor associated with this URL.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
Generated on Wed Aug 24 2022 21:34:46 for FFmpeg by
doxygen
1.8.17