本文整理汇总了C++中bstr0函数的典型用法代码示例。如果您正苦于以下问题:C++ bstr0函数的具体用法?C++ bstr0怎么用?C++ bstr0使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了bstr0函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: try_open
static bool try_open(struct MPContext *mpctx, char *filename)
{
struct bstr bfilename = bstr0(filename);
// Avoid trying to open itself or another .cue file. Best would be
// to check the result of demuxer auto-detection, but the demuxer
// API doesn't allow this without opening a full demuxer.
if (bstr_case_endswith(bfilename, bstr0(".cue"))
|| bstrcasecmp(bstr0(mpctx->demuxer->filename), bfilename) == 0)
return false;
struct stream *s = stream_open(filename, mpctx->opts);
if (!s)
return false;
struct demuxer *d = demux_open(s, NULL, NULL, mpctx->opts);
// Since .bin files are raw PCM data with no headers, we have to explicitly
// open them. Also, try to avoid to open files that are most likely not .bin
// files, as that would only play noise. Checking the file extension is
// fragile, but it's about the only way we have.
// TODO: maybe also could check if the .bin file is a multiple of the Audio
// CD sector size (2352 bytes)
if (!d && bstr_case_endswith(bfilename, bstr0(".bin"))) {
mp_msg(MSGT_CPLAYER, MSGL_WARN, "CUE: Opening as BIN file!\n");
d = demux_open(s, "rawaudio", NULL, mpctx->opts);
}
if (d) {
add_source(mpctx, d);
return true;
}
mp_msg(MSGT_CPLAYER, MSGL_ERR, "Could not open source '%s'!\n", filename);
free_stream(s);
return false;
}
开发者ID:CrimsonVoid,项目名称:mpv,代码行数:32,代码来源:tl_cue.c
示例2: try_open
static bool try_open(struct timeline *tl, char *filename)
{
struct bstr bfilename = bstr0(filename);
// Avoid trying to open itself or another .cue file. Best would be
// to check the result of demuxer auto-detection, but the demuxer
// API doesn't allow this without opening a full demuxer.
if (bstr_case_endswith(bfilename, bstr0(".cue"))
|| bstrcasecmp(bstr0(tl->demuxer->filename), bfilename) == 0)
return false;
struct demuxer *d = demux_open_url(filename, NULL, tl->cancel, tl->global);
// Since .bin files are raw PCM data with no headers, we have to explicitly
// open them. Also, try to avoid to open files that are most likely not .bin
// files, as that would only play noise. Checking the file extension is
// fragile, but it's about the only way we have.
// TODO: maybe also could check if the .bin file is a multiple of the Audio
// CD sector size (2352 bytes)
if (!d && bstr_case_endswith(bfilename, bstr0(".bin"))) {
MP_WARN(tl, "CUE: Opening as BIN file!\n");
struct demuxer_params p = {.force_format = "rawaudio"};
d = demux_open_url(filename, &p, tl->cancel, tl->global);
}
if (d) {
add_source(tl, d);
return true;
}
MP_ERR(tl, "Could not open source '%s'!\n", filename);
return false;
}
开发者ID:jmglogow,项目名称:mpv,代码行数:29,代码来源:demux_cue.c
示例3: parse_ref_init
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;
}
开发者ID:2ion,项目名称:mpv,代码行数:31,代码来源:demux_playlist.c
示例4: m_struct_alloc
static stream_t *open_stream_plugin(const stream_info_t *sinfo,
const char *filename,
int mode, struct MPOpts *options,
int *file_format, int *ret,
char **redirected_url)
{
void* arg = NULL;
stream_t* s;
m_struct_t* desc = (m_struct_t*)sinfo->opts;
// Parse options
if(desc) {
arg = m_struct_alloc(desc);
if(sinfo->opts_url) {
m_option_t url_opt =
{ "stream url", arg , CONF_TYPE_CUSTOM_URL, 0, 0 ,0, (void *)sinfo->opts };
if (m_option_parse(&url_opt, bstr0("stream url"), bstr0(filename), arg) < 0) {
mp_tmsg(MSGT_OPEN,MSGL_ERR, "URL parsing failed on url %s\n",filename);
m_struct_free(desc,arg);
return NULL;
}
}
}
s = new_stream(-2,-2);
s->opts = options;
s->url=strdup(filename);
s->flags |= mode;
*ret = sinfo->open(s,mode,arg,file_format);
if((*ret) != STREAM_OK) {
#ifdef CONFIG_NETWORKING
if (*ret == STREAM_REDIRECTED && redirected_url) {
if (s->streaming_ctrl && s->streaming_ctrl->url
&& s->streaming_ctrl->url->url)
*redirected_url = strdup(s->streaming_ctrl->url->url);
else
*redirected_url = NULL;
}
streaming_ctrl_free(s->streaming_ctrl);
#endif
free(s->url);
free(s);
return NULL;
}
if(s->type <= -2)
mp_msg(MSGT_OPEN,MSGL_WARN, "Warning streams need a type !!!!\n");
if(s->flags & MP_STREAM_SEEK && !s->seek)
s->flags &= ~MP_STREAM_SEEK;
if(s->seek && !(s->flags & MP_STREAM_SEEK))
s->flags |= MP_STREAM_SEEK;
s->mode = mode;
mp_msg(MSGT_OPEN,MSGL_V, "STREAM: [%s] %s\n",sinfo->name,filename);
mp_msg(MSGT_OPEN,MSGL_V, "STREAM: Description: %s\n",sinfo->info);
mp_msg(MSGT_OPEN,MSGL_V, "STREAM: Author: %s\n", sinfo->author);
mp_msg(MSGT_OPEN,MSGL_V, "STREAM: Comment: %s\n", sinfo->comment);
return s;
}
开发者ID:divVerent,项目名称:mplayer2,代码行数:59,代码来源:stream.c
示例5: add_new
// Add entry, but only if it's not yet on the list, and if the codec matches.
// If codec == NULL, don't compare codecs.
static void add_new(struct mp_decoder_list *to, struct mp_decoder_entry *entry,
const char *codec)
{
if (!entry || (codec && strcmp(entry->codec, codec) != 0))
return;
if (!find_decoder(to, bstr0(entry->family), bstr0(entry->decoder)))
mp_add_decoder_entry(to, entry);
}
开发者ID:ArcherSeven,项目名称:mpv,代码行数:10,代码来源:codecs.c
示例6: add_indent
static void add_indent(bstr *b, int indent)
{
if (indent < 0)
return;
bstr_xappend(NULL, b, bstr0("\n"));
for (int n = 0; n < indent; n++)
bstr_xappend(NULL, b, bstr0(" "));
}
开发者ID:Akemi,项目名称:mpv,代码行数:8,代码来源:json.c
示例7: talloc_zero
// Select a decoder from the given list for the given codec. The selection
// can be influenced by the selection string, which can specify a priority
// list of preferred decoders.
// This returns a list of decoders to try, with the preferred decoders first.
// The selection string corresponds to --vd/--ad directly, and has the
// following syntax:
// selection = [<entry> ("," <entry>)*]
// entry = <family> ":" <decoder> // prefer decoder
// entry = <family> ":*" // prefer all decoders
// entry = "+" <family> ":" <decoder> // force a decoder
// entry = "-" <family> ":" <decoder> // exclude a decoder
// entry = "-" // don't add fallback decoders
// Forcing a decoder means it's added even if the codec mismatches.
struct mp_decoder_list *mp_select_decoders(struct mp_decoder_list *all,
const char *codec,
const char *selection)
{
struct mp_decoder_list *list = talloc_zero(NULL, struct mp_decoder_list);
struct mp_decoder_list *remove = talloc_zero(NULL, struct mp_decoder_list);
if (!codec)
codec = "unknown";
bool stop = false;
bstr sel = bstr0(selection);
while (sel.len) {
bstr entry;
bstr_split_tok(sel, ",", &entry, &sel);
if (bstr_equals0(entry, "-")) {
stop = true;
break;
}
bool force = bstr_eatstart0(&entry, "+");
bool exclude = !force && bstr_eatstart0(&entry, "-");
struct mp_decoder_list *dest = exclude ? remove : list;
bstr family, decoder;
if (!bstr_split_tok(entry, ":", &family, &decoder)) {
mp_msg(MSGT_CFGPARSER, MSGL_ERR, "Decoders must be specified as "
"'family:decoder' for the --ad/--vd options.\n");
break;
}
if (bstr_equals0(decoder, "*")) {
for (int n = 0; n < all->num_entries; n++) {
struct mp_decoder_entry *cur = &all->entries[n];
if (bstr_equals0(family, cur->family))
add_new(dest, cur, codec);
}
} else {
add_new(dest, find_decoder(all, family, decoder),
force ? NULL : codec);
}
}
if (!stop) {
// Add the remaining codecs which haven't been added yet
for (int n = 0; n < all->num_entries; n++)
add_new(list, &all->entries[n], codec);
}
for (int n = 0; n < remove->num_entries; n++) {
struct mp_decoder_entry *ex = &remove->entries[n];
struct mp_decoder_entry *del =
find_decoder(list, bstr0(ex->family), bstr0(ex->decoder));
if (del) {
int index = del - &list->entries[0];
MP_TARRAY_REMOVE_AT(list->entries, list->num_entries, index);
}
}
talloc_free(remove);
return list;
}
开发者ID:ArcherSeven,项目名称:mpv,代码行数:67,代码来源:codecs.c
示例8: playlist_add_base_path
void playlist_add_base_path(struct playlist *pl, bstr base_path)
{
if (base_path.len == 0 || bstrcmp0(base_path, ".") == 0)
return;
for (struct playlist_entry *e = pl->first; e; e = e->next) {
if (!mp_is_url(bstr0(e->filename))) {
char *new_file = mp_path_join(e, base_path, bstr0(e->filename));
talloc_free(e->filename);
e->filename = new_file;
}
}
}
开发者ID:0x0all,项目名称:mpv,代码行数:12,代码来源:playlist.c
示例9: open_source
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;
}
开发者ID:CrimsonVoid,项目名称:mpv,代码行数:52,代码来源:tl_cue.c
示例10: talloc_zero
// selection is a ","-separated list of decoders, all in the given family.
struct mp_decoder_list *mp_select_decoder_list(struct mp_decoder_list *all,
const char *codec,
const char *family,
const char *selection)
{
struct mp_decoder_list *list = talloc_zero(NULL, struct mp_decoder_list);
bstr sel = bstr0(selection);
while (sel.len) {
bstr decoder;
bstr_split_tok(sel, ",", &decoder, &sel);
add_new(list, find_decoder(all, bstr0(family), decoder), codec);
}
return list;
}
开发者ID:AddictXQ,项目名称:mpv,代码行数:15,代码来源:codecs.c
示例11: talloc_new
char *mp_get_win_config_path(const char *filename)
{
wchar_t w_appdir[MAX_PATH + 1] = {0};
wchar_t w_exedir[MAX_PATH + 1] = {0};
char *res = NULL;
void *tmp = talloc_new(NULL);
#ifndef __CYGWIN__
if (SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA|CSIDL_FLAG_CREATE, NULL,
SHGFP_TYPE_CURRENT, w_appdir) != S_OK)
w_appdir[0] = '\0';
#endif
get_exe_dir(w_exedir);
if (filename && filename[0] && w_exedir[0]) {
char *dir = mp_to_utf8(tmp, w_exedir);
char *temp = mp_path_join(tmp, bstr0(dir), bstr0("mpv"));
res = mp_path_join(NULL, bstr0(temp), bstr0(filename));
if (!mp_path_exists(res) || mp_path_isdir(res)) {
talloc_free(res);
res = NULL;
}
}
if (!res && w_appdir[0]) {
char *dir = mp_to_utf8(tmp, w_appdir);
char *temp = mp_path_join(tmp, bstr0(dir), bstr0("mpv"));
res = mp_path_join(NULL, bstr0(temp), bstr0(filename));
}
talloc_free(tmp);
return res;
}
开发者ID:CrimsonVoid,项目名称:mpv,代码行数:34,代码来源:path-win.c
示例12: open_f
static int open_f(stream_t *stream)
{
stream->fill_buffer = fill_buffer;
stream->seek = seek;
stream->seekable = true;
stream->control = control;
stream->read_chunk = 1024 * 1024;
struct priv *p = talloc_zero(stream, struct priv);
stream->priv = p;
// Initial data
bstr data = bstr0(stream->url);
bool use_hex = bstr_eatstart0(&data, "hex://");
if (!use_hex)
bstr_eatstart0(&data, "memory://");
stream_control(stream, STREAM_CTRL_SET_CONTENTS, &data);
if (use_hex && !bstr_decode_hex(stream, p->data, &p->data)) {
MP_FATAL(stream, "Invalid data.\n");
return STREAM_ERROR;
}
return STREAM_OK;
}
开发者ID:Akemi,项目名称:mpv,代码行数:25,代码来源:stream_memory.c
示例13: fill_plaintext
static void fill_plaintext(struct sd *sd, double pts)
{
struct sd_ass_priv *ctx = sd->priv;
ASS_Track *track = ctx->shadow_track;
ass_flush_events(track);
char *text = get_text(sd, pts);
if (!text)
return;
bstr dst = {0};
while (*text) {
if (*text == '{')
bstr_xappend(NULL, &dst, bstr0("\\"));
bstr_xappend(NULL, &dst, (bstr){text, 1});
// Break ASS escapes with U+2060 WORD JOINER
if (*text == '\\')
mp_append_utf8_bstr(NULL, &dst, 0x2060);
text++;
}
if (!dst.start || !dst.start[0])
return;
int n = ass_alloc_event(track);
ASS_Event *event = track->events + n;
event->Start = 0;
event->Duration = INT_MAX;
event->Style = track->default_style;
event->Text = strdup(dst.start);
if (track->default_style < track->n_styles)
track->styles[track->default_style].Alignment = ctx->on_top ? 6 : 2;
}
开发者ID:sumyungguy,项目名称:mpv,代码行数:35,代码来源:sd_ass.c
示例14: json_append_str
static int json_append_str(char **dst, struct mpv_node *src, int indent)
{
bstr buffer = bstr0(*dst);
int r = json_append(&buffer, src, indent);
*dst = buffer.start;
return r;
}
开发者ID:Akemi,项目名称:mpv,代码行数:7,代码来源:json.c
示例15: init
static int init(struct ao *ao)
{
struct priv *priv = ao->priv;
ao->untimed = priv->untimed;
struct mp_chmap_sel sel = {.tmp = ao};
if (priv->channel_layouts) {
for (int n = 0; priv->channel_layouts[n]; n++) {
struct mp_chmap map = {0};
if (!mp_chmap_from_str(&map, bstr0(priv->channel_layouts[n]))) {
MP_FATAL(ao, "Invalid channel map in option.\n");
return -1;
}
mp_chmap_sel_add_map(&sel, &map);
}
} else {
mp_chmap_sel_add_any(&sel);
}
if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels))
mp_chmap_from_channels(&ao->channels, 2);
priv->latency = priv->latency_sec * ao->samplerate;
// A "buffer" for this many seconds of audio
int bursts = (int)(ao->samplerate * priv->bufferlen + 1) / priv->outburst;
priv->buffersize = priv->outburst * bursts + priv->latency;
priv->last_time = mp_time_sec();
return 0;
}
开发者ID:AddictXQ,项目名称:mpv,代码行数:32,代码来源:ao_null.c
示例16: talloc_zero
struct playlist_entry *playlist_entry_new(const char *filename)
{
struct playlist_entry *e = talloc_zero(NULL, struct playlist_entry);
char *local_filename = mp_file_url_to_filename(e, bstr0(filename));
e->filename = local_filename ? local_filename : talloc_strdup(e, filename);
return e;
}
开发者ID:0x0all,项目名称:mpv,代码行数:7,代码来源:playlist.c
示例17: parse_dir
static int parse_dir(struct pl_parser *p)
{
if (p->real_stream->type != STREAMTYPE_DIR)
return -1;
if (p->probing)
return 0;
char *path = mp_file_get_path(p, bstr0(p->real_stream->url));
char **files = NULL;
int num_files = 0;
struct stat dir_stack[MAX_DIR_STACK];
scan_dir(p, path, dir_stack, 0, &files, &num_files);
if (files)
qsort(files, num_files, sizeof(files[0]), cmp_filename);
for (int n = 0; n < num_files; n++)
playlist_add_file(p->pl, files[n]);
p->add_base = false;
return num_files > 0 ? 0 : -1;
}
开发者ID:2ion,项目名称:mpv,代码行数:25,代码来源:demux_playlist.c
示例18: talloc_zero
struct lavc_conv *lavc_conv_create(struct mp_log *log, const char *codec_name,
char *extradata, int extradata_len)
{
struct lavc_conv *priv = talloc_zero(NULL, struct lavc_conv);
priv->log = log;
priv->cur_list = talloc_array(priv, char*, 0);
priv->codec = talloc_strdup(priv, codec_name);
AVCodecContext *avctx = NULL;
const char *fmt = get_lavc_format(priv->codec);
AVCodec *codec = avcodec_find_decoder(mp_codec_to_av_codec_id(fmt));
if (!codec)
goto error;
avctx = avcodec_alloc_context3(codec);
if (!avctx)
goto error;
avctx->extradata_size = extradata_len;
avctx->extradata = talloc_memdup(priv, extradata, extradata_len);
if (avcodec_open2(avctx, codec, NULL) < 0)
goto error;
// Documented as "set by libavcodec", but there is no other way
avctx->time_base = (AVRational) {1, 1000};
priv->avctx = avctx;
priv->extradata = talloc_strndup(priv, avctx->subtitle_header,
avctx->subtitle_header_size);
disable_styles(bstr0(priv->extradata));
return priv;
error:
MP_FATAL(priv, "Could not open libavcodec subtitle converter\n");
av_free(avctx);
talloc_free(priv);
return NULL;
}
开发者ID:ThreeGe,项目名称:mpv,代码行数:33,代码来源:lavc_conv.c
示例19: parse_mov_rtsptext
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;
}
开发者ID:CrimsonVoid,项目名称:mpv,代码行数:16,代码来源:demux_playlist.c
示例20: json_write
/* Write the contents of *src as JSON, and append the JSON string to *dst.
* This will use strlen() to determine the start offset, and ta_get_size()
* and ta_realloc() to extend the memory allocation of *dst.
* Returns: 0 on success, <0 on failure.
*/
int json_write(char **dst, struct mpv_node *src)
{
bstr buffer = bstr0(*dst);
int r = json_append(&buffer, src);
*dst = buffer.start;
return r;
}
开发者ID:0x0all,项目名称:mpv,代码行数:12,代码来源:json.c
注:本文中的bstr0函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论