~ubuntu-branches/ubuntu/vivid/mpv/vivid

« back to all changes in this revision

Viewing changes to stream/stream_lavf.c

  • Committer: Package Import Robot
  • Author(s): Artur Rona
  • Date: 2015-02-08 11:38:05 UTC
  • mfrom: (28.1.4 vivid-proposed)
  • Revision ID: package-import@ubuntu.com-20150208113805-hb7kk68170y002es
Tags: 0.7.3-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - debian/rules:
    + Disable altivec on ppc64el again, as it FTBFS with it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include <libavformat/avio.h>
21
21
#include <libavutil/opt.h>
22
22
 
23
 
#include "config.h"
24
23
#include "options/options.h"
25
24
#include "options/path.h"
26
25
#include "common/msg.h"
34
33
#include "misc/bstr.h"
35
34
#include "talloc.h"
36
35
 
37
 
struct stream_lavf_params *stream_lavf_opts;
38
 
 
39
36
#define OPT_BASE_STRUCT struct stream_lavf_params
40
37
struct stream_lavf_params {
41
38
    char **avopts;
49
46
    .size = sizeof(struct stream_lavf_params),
50
47
};
51
48
 
 
49
static const char *const http_like[];
 
50
 
52
51
static int open_f(stream_t *stream);
53
52
static struct mp_tags *read_icy(stream_t *stream);
54
53
 
188
187
    talloc_free(temp);
189
188
}
190
189
 
 
190
// Escape http URLs with unescaped, invalid characters in them.
 
191
// libavformat's http protocol does not do this, and a patch to add this
 
192
// in a 100% safe case (spaces only) was rejected.
 
193
static char *normalize_url(void *ta_parent, const char *filename)
 
194
{
 
195
    bstr proto = mp_split_proto(bstr0(filename), NULL);
 
196
    for (int n = 0; http_like[n]; n++) {
 
197
        if (bstr_equals0(proto, http_like[n]))
 
198
            // Escape everything but reserved characters.
 
199
            // Also don't double-scape, so include '%'.
 
200
            return mp_url_escape(ta_parent, filename, ":/?#[]@!$&'()*+,;=%");
 
201
    }
 
202
    return (char *)filename;
 
203
}
 
204
 
191
205
static int open_f(stream_t *stream)
192
206
{
193
207
    struct MPOpts *opts = stream->opts;
238
252
        .opaque = stream,
239
253
    };
240
254
 
 
255
    filename = normalize_url(stream, filename);
 
256
 
241
257
    int err = avio_open2(&avio, filename, flags, &cb, &dict);
242
258
    if (err < 0) {
243
259
        if (err == AVERROR_PROTOCOL_NOT_FOUND)
335
351
    return res;
336
352
}
337
353
 
 
354
static const char *const http_like[] =
 
355
    {"http", "https", "mmsh", "mmshttp", "httproxy", NULL};
 
356
 
338
357
const stream_info_t stream_info_ffmpeg = {
339
358
  .name = "ffmpeg",
340
359
  .open = open_f,