static int parse_ref_init(struct pl_parser *p) { bstr line = bstr_strip(pl_get_line(p)); if (!bstr_equals0(line, "[Reference]")) return -1; // ASF http streaming redirection - this is needed because ffmpeg http:// // and mmsh:// can not automatically switch automatically between each // others. Both protocols use http - MMSH requires special http headers // to "activate" it, and will in other cases return this playlist. static const char *const mmsh_types[] = {"audio/x-ms-wax", "audio/x-ms-wma", "video/x-ms-asf", "video/x-ms-afs", "video/x-ms-wmv", "video/x-ms-wma", "application/x-mms-framed", "application/vnd.ms.wms-hdr.asfv1", NULL}; bstr burl = bstr0(p->s->url); if (bstr_eatstart0(&burl, "http://") && check_mimetype(p->s, mmsh_types)) { MP_INFO(p, "Redirecting to mmsh://\n"); playlist_add_file(p->pl, talloc_asprintf(p, "mmsh://%.*s", BSTR_P(burl))); return 0; } while (!pl_eof(p)) { line = bstr_strip(pl_get_line(p)); if (bstr_case_startswith(line, bstr0("Ref"))) { bstr_split_tok(line, "=", &(bstr){0}, &line); if (line.len) pl_add(p, line); } } return 0; }
static bool open_source(struct MPContext *mpctx, struct bstr filename) { void *ctx = talloc_new(NULL); bool res = false; struct bstr dirname = mp_dirname(mpctx->demuxer->filename); struct bstr base_filename = bstr0(mp_basename(bstrdup0(ctx, filename))); if (!base_filename.len) { mp_msg(MSGT_CPLAYER, MSGL_WARN, "CUE: Invalid audio filename in .cue file!\n"); } else { char *fullname = mp_path_join(ctx, dirname, base_filename); if (try_open(mpctx, fullname)) { res = true; goto out; } } // Try an audio file with the same name as the .cue file (but different // extension). // Rationale: this situation happens easily if the audio file or both files // are renamed. struct bstr cuefile = bstr_strip_ext(bstr0(mp_basename(mpctx->demuxer->filename))); DIR *d = opendir(bstrdup0(ctx, dirname)); if (!d) goto out; struct dirent *de; while ((de = readdir(d))) { char *dename0 = de->d_name; struct bstr dename = bstr0(dename0); if (bstr_case_startswith(dename, cuefile)) { mp_msg(MSGT_CPLAYER, MSGL_WARN, "CUE: No useful audio filename " "in .cue file found, trying with '%s' instead!\n", dename0); if (try_open(mpctx, mp_path_join(ctx, dirname, dename))) { res = true; break; } } } closedir(d); out: talloc_free(ctx); if (!res) mp_msg(MSGT_CPLAYER, MSGL_ERR, "CUE: Could not open audio file!\n"); return res; }
static int parse_ref_init(struct pl_parser *p) { bstr line = bstr_strip(pl_get_line(p)); if (!bstr_equals0(line, "[Reference]")) return -1; while (!pl_eof(p)) { line = bstr_strip(pl_get_line(p)); if (bstr_case_startswith(line, bstr0("Ref"))) { bstr_split_tok(line, "=", &(bstr){0}, &line); if (line.len) pl_add(p, line); } } return 0; }
static int parse_mov_rtsptext(struct pl_parser *p) { bstr line = pl_get_line(p); if (!bstr_eatstart(&line, bstr0("RTSPtext"))) return -1; if (p->probing) return 0; line = bstr_strip(line); do { if (bstr_case_startswith(line, bstr0("rtsp://"))) { pl_add(p, line); return 0; } } while (!pl_eof(p) && (line = bstr_strip(pl_get_line(p))).len); return -1; }
static int parse_pls(struct pl_parser *p) { bstr line = {0}; while (!line.len && !pl_eof(p)) line = bstr_strip(pl_get_line(p)); if (bstrcasecmp0(line, "[playlist]") != 0) return -1; if (p->probing) return 0; while (!pl_eof(p)) { line = bstr_strip(pl_get_line(p)); bstr key, value; if (bstr_split_tok(line, "=", &key, &value) && bstr_case_startswith(key, bstr0("File"))) { pl_add(p, value); } } return 0; }