MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / open_input_stream

Function open_input_stream

ffserver.c:2130–2202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2128}
2129
2130static int open_input_stream(HTTPContext *c, const char *info)
2131{
2132 char buf[128];
2133 char input_filename[1024];
2134 AVFormatContext *s;
2135 int buf_size, i, ret;
2136 int64_t stream_pos;
2137
2138 /* find file name */
2139 if (c->stream->feed) {
2140 strcpy(input_filename, c->stream->feed->feed_filename);
2141 buf_size = FFM_PACKET_SIZE;
2142 /* compute position (absolute time) */
2143 if (find_info_tag(buf, sizeof(buf), "date", info)) {
2144 stream_pos = parse_date(buf, 0);
2145 if (stream_pos == INT64_MIN)
2146 return -1;
2147 } else if (find_info_tag(buf, sizeof(buf), "buffer", info)) {
2148 int prebuffer = strtol(buf, 0, 10);
2149 stream_pos = av_gettime() - prebuffer * (int64_t)1000000;
2150 } else
2151 stream_pos = av_gettime() - c->stream->prebuffer * (int64_t)1000;
2152 } else {
2153 strcpy(input_filename, c->stream->feed_filename);
2154 buf_size = 0;
2155 /* compute position (relative time) */
2156 if (find_info_tag(buf, sizeof(buf), "date", info)) {
2157 stream_pos = parse_date(buf, 1);
2158 if (stream_pos == INT64_MIN)
2159 return -1;
2160 } else
2161 stream_pos = 0;
2162 }
2163 if (input_filename[0] == '\0')
2164 return -1;
2165
2166 /* open stream */
2167 if ((ret = av_open_input_file(&s, input_filename, c->stream->ifmt,
2168 buf_size, c->stream->ap_in)) < 0) {
2169 http_log("could not open %s: %d\n", input_filename, ret);
2170 return -1;
2171 }
2172 s->flags |= AVFMT_FLAG_GENPTS;
2173 c->fmt_in = s;
2174 if (strcmp(s->iformat->name, "ffm") && av_find_stream_info(c->fmt_in) < 0) {
2175 http_log("Could not find stream info '%s'\n", input_filename);
2176 av_close_input_file(s);
2177 return -1;
2178 }
2179
2180 /* open each parser */
2181 for(i=0;i<s->nb_streams;i++)
2182 open_parser(s, i);
2183
2184 /* choose stream as clock source (we favorize video stream if
2185 present) for packet sending */
2186 c->pts_stream_index = 0;
2187 for(i=0;i<c->stream->nb_streams;i++) {

Callers 4

start_multicastFunction · 0.85
http_parse_requestFunction · 0.85
http_prepare_dataFunction · 0.85
rtsp_cmd_setupFunction · 0.85

Calls 9

find_info_tagFunction · 0.85
parse_dateFunction · 0.85
av_gettimeFunction · 0.85
av_open_input_fileFunction · 0.85
http_logFunction · 0.85
av_find_stream_infoFunction · 0.85
av_close_input_fileFunction · 0.85
open_parserFunction · 0.85
av_seek_frameFunction · 0.85

Tested by

no test coverage detected