Commit 4bb04098 authored by Marton Balint's avatar Marton Balint

avdevice: migrate to AVFormatContext->url

Signed-off-by: 's avatarMarton Balint <cus@passwd.hu>
parent 25a2d269
......@@ -177,8 +177,8 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode,
snd_pcm_uframes_t buffer_size, period_size;
uint64_t layout = ctx->streams[0]->codecpar->channel_layout;
if (ctx->filename[0] == 0) audio_device = "default";
else audio_device = ctx->filename;
if (ctx->url[0] == 0) audio_device = "default";
else audio_device = ctx->url;
if (*codec_id == AV_CODEC_ID_NONE)
*codec_id = DEFAULT_CODEC_ID;
......
......@@ -259,7 +259,7 @@ static void destroy_context(AVFContext* ctx)
static void parse_device_name(AVFormatContext *s)
{
AVFContext *ctx = (AVFContext*)s->priv_data;
char *tmp = av_strdup(s->filename);
char *tmp = av_strdup(s->url);
char *save;
if (tmp[0] != ':') {
......
......@@ -294,7 +294,7 @@ static int grab_read_header(AVFormatContext *s1)
st->codecpar->height = s->height;
st->avg_frame_rate = framerate;
if (bktr_init(s1->filename, s->width, s->height, s->standard,
if (bktr_init(s1->url, s->width, s->height, s->standard,
&s->video_fd, &s->tuner_fd, -1, 0.0) < 0) {
ret = AVERROR(EIO);
goto out;
......
......@@ -178,7 +178,7 @@ static int caca_write_header(AVFormatContext *s)
}
if (!c->window_title)
c->window_title = av_strdup(s->filename);
c->window_title = av_strdup(s->url);
caca_set_display_title(c->display, c->window_title);
caca_set_display_time(c->display, av_rescale_q(1, st->codec->time_base, AV_TIME_BASE_Q));
......
......@@ -404,7 +404,7 @@ int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direct
}
av_log(avctx, AV_LOG_INFO, "Supported formats for '%s':\n\tformat_code\tdescription",
avctx->filename);
avctx->url);
while (itermode->Next(&mode) == S_OK) {
BMDTimeValue tb_num, tb_den;
mode->GetFrameRate(&tb_num, &tb_den);
......
......@@ -951,7 +951,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
cctx->raw_format = MKBETAG('v','2','1','0');
}
strcpy (fname, avctx->filename);
av_strlcpy(fname, avctx->url, sizeof(fname));
tmp=strchr (fname, '@');
if (tmp != NULL) {
av_log(avctx, AV_LOG_WARNING, "The @mode syntax is deprecated and will be removed. Please use the -format_code option.\n");
......@@ -966,7 +966,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx)
/* Get input device. */
if (ctx->dl->QueryInterface(IID_IDeckLinkInput, (void **) &ctx->dli) != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not open input device from '%s'\n",
avctx->filename);
avctx->url);
ret = AVERROR(EIO);
goto error;
}
......
......@@ -400,14 +400,14 @@ av_cold int ff_decklink_write_header(AVFormatContext *avctx)
return AVERROR_EXIT;
}
ret = ff_decklink_init_device(avctx, avctx->filename);
ret = ff_decklink_init_device(avctx, avctx->url);
if (ret < 0)
return ret;
/* Get output device. */
if (ctx->dl->QueryInterface(IID_IDeckLinkOutput, (void **) &ctx->dlo) != S_OK) {
av_log(avctx, AV_LOG_ERROR, "Could not open output device from '%s'\n",
avctx->filename);
avctx->url);
ret = AVERROR(EIO);
goto error;
}
......
......@@ -1033,7 +1033,7 @@ static int parse_device_name(AVFormatContext *avctx)
{
struct dshow_ctx *ctx = avctx->priv_data;
char **device_name = ctx->device_name;
char *name = av_strdup(avctx->filename);
char *name = av_strdup(avctx->url);
char *tmp = name;
int ret = 1;
char *type;
......
......@@ -78,8 +78,8 @@ static av_cold int fbdev_read_header(AVFormatContext *avctx)
if (avctx->flags & AVFMT_FLAG_NONBLOCK)
flags |= O_NONBLOCK;
if (avctx->filename[0])
device = avctx->filename;
if (avctx->url[0])
device = avctx->url;
else
device = ff_fbdev_default_device();
......
......@@ -53,8 +53,8 @@ static av_cold int fbdev_write_header(AVFormatContext *h)
return AVERROR(EINVAL);
}
if (h->filename[0])
device = h->filename;
if (h->url[0])
device = h->url;
else
device = ff_fbdev_default_device();
......
......@@ -230,7 +230,7 @@ gdigrab_read_header(AVFormatContext *s1)
HBITMAP hbmp = NULL;
void *buffer = NULL;
const char *filename = s1->filename;
const char *filename = s1->url;
const char *name = NULL;
AVStream *st = NULL;
......
......@@ -259,14 +259,14 @@ static int iec61883_read_header(AVFormatContext *context)
goto fail;
}
inport = strtol(context->filename, &endptr, 10);
if (endptr != context->filename && *endptr == '\0') {
inport = strtol(context->url, &endptr, 10);
if (endptr != context->url && *endptr == '\0') {
av_log(context, AV_LOG_INFO, "Selecting IEEE1394 port: %d\n", inport);
j = inport;
nb_ports = inport + 1;
} else if (strcmp(context->filename, "auto")) {
} else if (strcmp(context->url, "auto")) {
av_log(context, AV_LOG_ERROR, "Invalid input \"%s\", you should specify "
"\"auto\" for auto-detection, or the port number.\n", context->filename);
"\"auto\" for auto-detection, or the port number.\n", context->url);
goto fail;
}
......
......@@ -150,8 +150,8 @@ static int start_jack(AVFormatContext *context)
jack_status_t status;
int i, test;
/* Register as a JACK client, using the context filename as client name. */
self->client = jack_client_open(context->filename, JackNullOption, &status);
/* Register as a JACK client, using the context url as client name. */
self->client = jack_client_open(context->url, JackNullOption, &status);
if (!self->client) {
av_log(context, AV_LOG_ERROR, "Unable to register as a JACK client\n");
return AVERROR(EIO);
......@@ -174,7 +174,7 @@ static int start_jack(AVFormatContext *context)
JackPortIsInput, 0);
if (!self->ports[i]) {
av_log(context, AV_LOG_ERROR, "Unable to register port %s:%s\n",
context->filename, str);
context->url, str);
jack_client_close(self->client);
return AVERROR(EIO);
}
......
......@@ -166,7 +166,7 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
}
if (!lavfi->graph_str)
lavfi->graph_str = av_strdup(avctx->filename);
lavfi->graph_str = av_strdup(avctx->url);
/* parse the graph, create a stream for each open output */
if (!(lavfi->graph = avfilter_graph_alloc()))
......
......@@ -60,9 +60,9 @@ static av_cold int read_header(AVFormatContext *ctx)
if (!(st = avformat_new_stream(ctx, NULL)))
return AVERROR(ENOMEM);
s->drive = cdio_cddap_identify(ctx->filename, CDDA_MESSAGE_LOGIT, &err);
s->drive = cdio_cddap_identify(ctx->url, CDDA_MESSAGE_LOGIT, &err);
if (!s->drive) {
av_log(ctx, AV_LOG_ERROR, "Could not open drive %s.\n", ctx->filename);
av_log(ctx, AV_LOG_ERROR, "Could not open drive %s.\n", ctx->url);
return AVERROR(EINVAL);
}
if (err) {
......@@ -70,7 +70,7 @@ static av_cold int read_header(AVFormatContext *ctx)
free(err);
}
if ((ret = cdio_cddap_open(s->drive)) < 0 || !s->drive->opened) {
av_log(ctx, AV_LOG_ERROR, "Could not open disk in drive %s.\n", ctx->filename);
av_log(ctx, AV_LOG_ERROR, "Could not open disk in drive %s.\n", ctx->url);
return AVERROR(EINVAL);
}
......
......@@ -149,7 +149,7 @@ static int ndi_read_header(AVFormatContext *avctx)
}
/* Find available sources. */
ret = ndi_find_sources(avctx, avctx->filename, &recv_create_desc.source_to_connect_to);
ret = ndi_find_sources(avctx, avctx->url, &recv_create_desc.source_to_connect_to);
if (ctx->find_sources) {
return AVERROR_EXIT;
}
......
......@@ -233,7 +233,7 @@ static int ndi_write_header(AVFormatContext *avctx)
int ret = 0;
unsigned int n;
struct NDIContext *ctx = avctx->priv_data;
const NDIlib_send_create_t ndi_send_desc = { .p_ndi_name = avctx->filename,
const NDIlib_send_create_t ndi_send_desc = { .p_ndi_name = avctx->url,
.p_groups = NULL, .clock_video = ctx->clock_video, .clock_audio = ctx->clock_audio };
if (!NDIlib_initialize()) {
......@@ -260,7 +260,7 @@ static int ndi_write_header(AVFormatContext *avctx)
ctx->ndi_send = NDIlib_send_create(&ndi_send_desc);
if (!ctx->ndi_send) {
av_log(avctx, AV_LOG_ERROR, "Failed to create NDI output %s\n", avctx->filename);
av_log(avctx, AV_LOG_ERROR, "Failed to create NDI output %s\n", avctx->url);
ret = AVERROR_EXTERNAL;
}
......
......@@ -139,7 +139,7 @@ static int read_header(AVFormatContext *ctx)
/* Open device for capture */
ad->device =
alcCaptureOpenDevice(ctx->filename[0] ? ctx->filename : NULL,
alcCaptureOpenDevice(ctx->url[0] ? ctx->url : NULL,
ad->sample_rate,
ad->sample_format,
ad->sample_rate); /* Maximum 1 second of sample data to be read at once */
......
......@@ -1070,7 +1070,7 @@ static av_cold int opengl_write_header(AVFormatContext *h)
opengl->window_height = opengl->height;
if (!opengl->window_title && !opengl->no_window)
opengl->window_title = av_strdup(h->filename);
opengl->window_title = av_strdup(h->url);
if ((ret = opengl_create_window(h)))
goto fail;
......
......@@ -52,7 +52,7 @@ static int audio_read_header(AVFormatContext *s1)
return AVERROR(ENOMEM);
}
ret = ff_oss_audio_open(s1, 0, s1->filename);
ret = ff_oss_audio_open(s1, 0, s1->url);
if (ret < 0) {
return AVERROR(EIO);
}
......
......@@ -46,7 +46,7 @@ static int audio_write_header(AVFormatContext *s1)
st = s1->streams[0];
s->sample_rate = st->codecpar->sample_rate;
s->channels = st->codecpar->channels;
ret = ff_oss_audio_open(s1, 1, s1->filename);
ret = ff_oss_audio_open(s1, 1, s1->url);
if (ret < 0) {
return AVERROR(EIO);
} else {
......
......@@ -158,8 +158,8 @@ static av_cold int pulse_read_header(AVFormatContext *s)
attr.fragsize = pd->fragment_size;
if (s->filename[0] != '\0' && strcmp(s->filename, "default"))
device = s->filename;
if (s->url[0] != '\0' && strcmp(s->url, "default"))
device = s->url;
if (!(pd->mainloop = pa_threaded_mainloop_new())) {
pulse_close(s);
......
......@@ -459,8 +459,8 @@ static av_cold int pulse_write_header(AVFormatContext *h)
st = h->streams[0];
if (!stream_name) {
if (h->filename[0])
stream_name = h->filename;
if (h->url[0])
stream_name = h->url;
else
stream_name = "Playback";
}
......
......@@ -165,7 +165,7 @@ static int sdl2_write_header(AVFormatContext *s)
int flags = 0;
if (!sdl->window_title)
sdl->window_title = av_strdup(s->filename);
sdl->window_title = av_strdup(s->url);
if (SDL_WasInit(SDL_INIT_VIDEO)) {
av_log(s, AV_LOG_WARNING,
......
......@@ -41,7 +41,7 @@ static av_cold int audio_read_header(AVFormatContext *s1)
if (!st)
return AVERROR(ENOMEM);
ret = ff_sndio_open(s1, 0, s1->filename);
ret = ff_sndio_open(s1, 0, s1->url);
if (ret < 0)
return ret;
......
......@@ -38,7 +38,7 @@ static av_cold int audio_write_header(AVFormatContext *s1)
s->sample_rate = st->codecpar->sample_rate;
s->channels = st->codecpar->channels;
ret = ff_sndio_open(s1, 1, s1->filename);
ret = ff_sndio_open(s1, 1, s1->url);
return ret;
}
......
......@@ -106,7 +106,7 @@ struct buff_data {
int index;
};
static int device_open(AVFormatContext *ctx)
static int device_open(AVFormatContext *ctx, const char* device_path)
{
struct video_data *s = ctx->priv_data;
struct v4l2_capability cap;
......@@ -147,11 +147,11 @@ static int device_open(AVFormatContext *ctx)
flags |= O_NONBLOCK;
}
fd = v4l2_open(ctx->filename, flags, 0);
fd = v4l2_open(device_path, flags, 0);
if (fd < 0) {
err = AVERROR(errno);
av_log(ctx, AV_LOG_ERROR, "Cannot open video device %s: %s\n",
ctx->filename, av_err2str(err));
device_path, av_err2str(err));
return err;
}
......@@ -840,7 +840,7 @@ static int v4l2_read_header(AVFormatContext *ctx)
v4l2_log_file = fopen("/dev/null", "w");
#endif
s->fd = device_open(ctx);
s->fd = device_open(ctx, ctx->url);
if (s->fd < 0)
return s->fd;
......@@ -1042,11 +1042,13 @@ static int v4l2_get_device_list(AVFormatContext *ctx, AVDeviceInfoList *device_l
return ret;
}
while ((entry = readdir(dir))) {
char device_name[256];
if (!v4l2_is_v4l_dev(entry->d_name))
continue;
snprintf(ctx->filename, sizeof(ctx->filename), "/dev/%s", entry->d_name);
if ((s->fd = device_open(ctx)) < 0)
snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name);
if ((s->fd = device_open(ctx, device_name)) < 0)
continue;
if (v4l2_ioctl(s->fd, VIDIOC_QUERYCAP, &cap) < 0) {
......@@ -1060,7 +1062,7 @@ static int v4l2_get_device_list(AVFormatContext *ctx, AVDeviceInfoList *device_l
ret = AVERROR(ENOMEM);
goto fail;
}
device->device_name = av_strdup(ctx->filename);
device->device_name = av_strdup(device_name);
device->device_description = av_strdup(cap.card);
if (!device->device_name || !device->device_description) {
ret = AVERROR(ENOMEM);
......
......@@ -39,10 +39,10 @@ static av_cold int write_header(AVFormatContext *s1)
if (s1->flags & AVFMT_FLAG_NONBLOCK)
flags |= O_NONBLOCK;
s->fd = open(s1->filename, flags);
s->fd = open(s1->url, flags);
if (s->fd < 0) {
res = AVERROR(errno);
av_log(s1, AV_LOG_ERROR, "Unable to open V4L2 device '%s'\n", s1->filename);
av_log(s1, AV_LOG_ERROR, "Unable to open V4L2 device '%s'\n", s1->url);
return res;
}
......
......@@ -256,7 +256,7 @@ static int vfw_read_header(AVFormatContext *s)
int ret;
AVRational framerate_q;
if (!strcmp(s->filename, "list")) {
if (!strcmp(s->url, "list")) {
for (devnum = 0; devnum <= 9; devnum++) {
char driver_name[256];
char driver_ver[256];
......@@ -279,7 +279,7 @@ static int vfw_read_header(AVFormatContext *s)
}
/* If atoi fails, devnum==0 and the default device is used */
devnum = atoi(s->filename);
devnum = atoi(s->url);
ret = SendMessage(ctx->hwnd, WM_CAP_DRIVER_CONNECT, devnum, 0);
if(!ret) {
......
......@@ -629,14 +629,14 @@ static av_cold int xcbgrab_read_header(AVFormatContext *s)
XCBGrabContext *c = s->priv_data;
int screen_num, ret;
const xcb_setup_t *setup;
char *display_name = av_strdup(s->filename);
char *display_name = av_strdup(s->url);
if (!display_name)
return AVERROR(ENOMEM);
if (!sscanf(s->filename, "%[^+]+%d,%d", display_name, &c->x, &c->y)) {
if (!sscanf(s->url, "%[^+]+%d,%d", display_name, &c->x, &c->y)) {
*display_name = 0;
sscanf(s->filename, "+%d,%d", &c->x, &c->y);
sscanf(s->url, "+%d,%d", &c->x, &c->y);
}
c->conn = xcb_connect(display_name[0] ? display_name : NULL, &screen_num);
......@@ -644,7 +644,7 @@ static av_cold int xcbgrab_read_header(AVFormatContext *s)
if ((ret = xcb_connection_has_error(c->conn))) {
av_log(s, AV_LOG_ERROR, "Cannot open display %s, error %d.\n",
s->filename[0] ? s->filename : "default", ret);
s->url[0] ? s->url : "default", ret);
return AVERROR(EIO);
}
......
......@@ -151,7 +151,7 @@ static int xv_write_header(AVFormatContext *s)
xv->window_width, xv->window_height,
0, 0, 0);
if (!xv->window_title) {
if (!(xv->window_title = av_strdup(s->filename))) {
if (!(xv->window_title = av_strdup(s->url))) {
ret = AVERROR(ENOMEM);
goto fail;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment