History

avdevice: migrate to AVFormatContext->url

Marton Balint committed 8 years ago

Commit 4bb04091 parent 25a2d2631 files · +59 −57Browse files

Unified · Split

31 files
  1. libavdevice/alsa.c +2 −2
  2. libavdevice/avfoundation.m +1 −1
  3. libavdevice/bktr.c +1 −1
  4. libavdevice/caca.c +1 −1
  5. libavdevice/decklink_common.cpp +1 −1
  6. libavdevice/decklink_dec.cpp +2 −2
  7. libavdevice/decklink_enc.cpp +2 −2
  8. libavdevice/dshow.c +1 −1
  9. libavdevice/fbdev_dec.c +2 −2
  10. libavdevice/fbdev_enc.c +2 −2
  11. libavdevice/gdigrab.c +1 −1
  12. libavdevice/iec61883.c +4 −4
  13. libavdevice/jack.c +3 −3
  14. libavdevice/lavfi.c +1 −1
  15. libavdevice/libcdio.c +3 −3
  16. libavdevice/libndi_newtek_dec.c +1 −1
  17. libavdevice/libndi_newtek_enc.c +2 −2
  18. libavdevice/openal-dec.c +1 −1
  19. libavdevice/opengl_enc.c +1 −1
  20. libavdevice/oss_dec.c +1 −1
  21. libavdevice/oss_enc.c +1 −1
  22. libavdevice/pulse_audio_dec.c +2 −2
  23. libavdevice/pulse_audio_enc.c +2 −2
  24. libavdevice/sdl2.c +1 −1
  25. libavdevice/sndio_dec.c +1 −1
  26. libavdevice/sndio_enc.c +1 −1
  27. libavdevice/v4l2.c +9 −7
  28. libavdevice/v4l2enc.c +2 −2
  29. libavdevice/vfwcap.c +2 −2
  30. libavdevice/xcbgrab.c +4 −4
  31. libavdevice/xv.c +1 −1
libavdevice/alsa.c+2−2
@@ -177,8 +177,8 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode, · 176 unmodified lines
177177 snd_pcm_uframes_t buffer_size, period_size;
178178 uint64_t layout = ctx->streams[0]->codecpar->channel_layout;
179179
180− if (ctx->filename[0] == 0) audio_device = "default";
181− else audio_device = ctx->filename;
180+ if (ctx->url[0] == 0) audio_device = "default";
181+ else audio_device = ctx->url;
182182
183183 if (*codec_id == AV_CODEC_ID_NONE)
184184 *codec_id = DEFAULT_CODEC_ID;
libavdevice/avfoundation.m+1−1
@@ -259,7 +259,7 @@ static void destroy_context(AVFContext* ctx) · 258 unmodified lines
259259 static void parse_device_name(AVFormatContext *s)
260260 {
261261 AVFContext *ctx = (AVFContext*)s->priv_data;
262− char *tmp = av_strdup(s->filename);
262+ char *tmp = av_strdup(s->url);
263263 char *save;
264264
265265 if (tmp[0] != ':') {
libavdevice/bktr.c+1−1
@@ -294,7 +294,7 @@ static int grab_read_header(AVFormatContext *s1) · 293 unmodified lines
294294 st->codecpar->height = s->height;
295295 st->avg_frame_rate = framerate;
296296
297− if (bktr_init(s1->filename, s->width, s->height, s->standard,
297+ if (bktr_init(s1->url, s->width, s->height, s->standard,
298298 &s->video_fd, &s->tuner_fd, -1, 0.0) < 0) {
299299 ret = AVERROR(EIO);
300300 goto out;
libavdevice/caca.c+1−1
@@ -178,7 +178,7 @@ static int caca_write_header(AVFormatContext *s) · 177 unmodified lines
178178 }
179179
180180 if (!c->window_title)
181− c->window_title = av_strdup(s->filename);
181+ c->window_title = av_strdup(s->url);
182182 caca_set_display_title(c->display, c->window_title);
183183 caca_set_display_time(c->display, av_rescale_q(1, st->codec->time_base, AV_TIME_BASE_Q));
184184
libavdevice/decklink_common.cpp+1−1
@@ -404,7 +404,7 @@ int ff_decklink_list_formats(AVFormatContext *avctx, decklink_direction_t direct · 403 unmodified lines
404404 }
405405
406406 av_log(avctx, AV_LOG_INFO, "Supported formats for '%s':\n\tformat_code\tdescription",
407− avctx->filename);
407+ avctx->url);
408408 while (itermode->Next(&mode) == S_OK) {
409409 BMDTimeValue tb_num, tb_den;
410410 mode->GetFrameRate(&tb_num, &tb_den);
libavdevice/decklink_dec.cpp+2−2
@@ -951,7 +951,7 @@ av_cold int ff_decklink_read_header(AVFormatContext *avctx) · 950 unmodified lines
951951 cctx->raw_format = MKBETAG('v','2','1','0');
952952 }
953953
954− strcpy (fname, avctx->filename);
954+ av_strlcpy(fname, avctx->url, sizeof(fname));
955955 tmp=strchr (fname, '@');
956956 if (tmp != NULL) {
957957 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) · 8 unmodified lines
966966 /* Get input device. */
967967 if (ctx->dl->QueryInterface(IID_IDeckLinkInput, (void **) &ctx->dli) != S_OK) {
968968 av_log(avctx, AV_LOG_ERROR, "Could not open input device from '%s'\n",
969− avctx->filename);
969+ avctx->url);
970970 ret = AVERROR(EIO);
971971 goto error;
972972 }
libavdevice/decklink_enc.cpp+2−2
@@ -400,14 +400,14 @@ av_cold int ff_decklink_write_header(AVFormatContext *avctx) · 399 unmodified lines
400400 return AVERROR_EXIT;
401401 }
402402
403− ret = ff_decklink_init_device(avctx, avctx->filename);
403+ ret = ff_decklink_init_device(avctx, avctx->url);
404404 if (ret < 0)
405405 return ret;
406406
407407 /* Get output device. */
408408 if (ctx->dl->QueryInterface(IID_IDeckLinkOutput, (void **) &ctx->dlo) != S_OK) {
409409 av_log(avctx, AV_LOG_ERROR, "Could not open output device from '%s'\n",
410− avctx->filename);
410+ avctx->url);
411411 ret = AVERROR(EIO);
412412 goto error;
413413 }
libavdevice/dshow.c+1−1
@@ -1033,7 +1033,7 @@ static int parse_device_name(AVFormatContext *avctx) · 1032 unmodified lines
10331033 {
10341034 struct dshow_ctx *ctx = avctx->priv_data;
10351035 char **device_name = ctx->device_name;
1036− char *name = av_strdup(avctx->filename);
1036+ char *name = av_strdup(avctx->url);
10371037 char *tmp = name;
10381038 int ret = 1;
10391039 char *type;
libavdevice/fbdev_dec.c+2−2
@@ -78,8 +78,8 @@ static av_cold int fbdev_read_header(AVFormatContext *avctx) · 77 unmodified lines
7878 if (avctx->flags & AVFMT_FLAG_NONBLOCK)
7979 flags |= O_NONBLOCK;
8080
81− if (avctx->filename[0])
82− device = avctx->filename;
81+ if (avctx->url[0])
82+ device = avctx->url;
8383 else
8484 device = ff_fbdev_default_device();
8585
libavdevice/fbdev_enc.c+2−2
@@ -53,8 +53,8 @@ static av_cold int fbdev_write_header(AVFormatContext *h) · 52 unmodified lines
5353 return AVERROR(EINVAL);
5454 }
5555
56− if (h->filename[0])
57− device = h->filename;
56+ if (h->url[0])
57+ device = h->url;
5858 else
5959 device = ff_fbdev_default_device();
6060
libavdevice/gdigrab.c+1−1
@@ -230,7 +230,7 @@ gdigrab_read_header(AVFormatContext *s1) · 229 unmodified lines
230230 HBITMAP hbmp = NULL;
231231 void *buffer = NULL;
232232
233− const char *filename = s1->filename;
233+ const char *filename = s1->url;
234234 const char *name = NULL;
235235 AVStream *st = NULL;
236236
libavdevice/iec61883.c+4−4
@@ -259,14 +259,14 @@ static int iec61883_read_header(AVFormatContext *context) · 258 unmodified lines
259259 goto fail;
260260 }
261261
262− inport = strtol(context->filename, &endptr, 10);
263− if (endptr != context->filename && *endptr == '\0') {
262+ inport = strtol(context->url, &endptr, 10);
263+ if (endptr != context->url && *endptr == '\0') {
264264 av_log(context, AV_LOG_INFO, "Selecting IEEE1394 port: %d\n", inport);
265265 j = inport;
266266 nb_ports = inport + 1;
267− } else if (strcmp(context->filename, "auto")) {
267+ } else if (strcmp(context->url, "auto")) {
268268 av_log(context, AV_LOG_ERROR, "Invalid input \"%s\", you should specify "
269− "\"auto\" for auto-detection, or the port number.\n", context->filename);
269+ "\"auto\" for auto-detection, or the port number.\n", context->url);
270270 goto fail;
271271 }
272272
libavdevice/jack.c+3−3
@@ -150,8 +150,8 @@ static int start_jack(AVFormatContext *context) · 149 unmodified lines
150150 jack_status_t status;
151151 int i, test;
152152
153− /* Register as a JACK client, using the context filename as client name. */
154− self->client = jack_client_open(context->filename, JackNullOption, &status);
153+ /* Register as a JACK client, using the context url as client name. */
154+ self->client = jack_client_open(context->url, JackNullOption, &status);
155155 if (!self->client) {
156156 av_log(context, AV_LOG_ERROR, "Unable to register as a JACK client\n");
157157 return AVERROR(EIO);
@@ -174,7 +174,7 @@ static int start_jack(AVFormatContext *context) · 16 unmodified lines
174174 JackPortIsInput, 0);
175175 if (!self->ports[i]) {
176176 av_log(context, AV_LOG_ERROR, "Unable to register port %s:%s\n",
177− context->filename, str);
177+ context->url, str);
178178 jack_client_close(self->client);
179179 return AVERROR(EIO);
180180 }
libavdevice/lavfi.c+1−1
@@ -166,7 +166,7 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx) · 165 unmodified lines
166166 }
167167
168168 if (!lavfi->graph_str)
169− lavfi->graph_str = av_strdup(avctx->filename);
169+ lavfi->graph_str = av_strdup(avctx->url);
170170
171171 /* parse the graph, create a stream for each open output */
172172 if (!(lavfi->graph = avfilter_graph_alloc()))
libavdevice/libcdio.c+3−3
@@ -60,9 +60,9 @@ static av_cold int read_header(AVFormatContext *ctx) · 59 unmodified lines
6060
6161 if (!(st = avformat_new_stream(ctx, NULL)))
6262 return AVERROR(ENOMEM);
63− s->drive = cdio_cddap_identify(ctx->filename, CDDA_MESSAGE_LOGIT, &err);
63+ s->drive = cdio_cddap_identify(ctx->url, CDDA_MESSAGE_LOGIT, &err);
6464 if (!s->drive) {
65− av_log(ctx, AV_LOG_ERROR, "Could not open drive %s.\n", ctx->filename);
65+ av_log(ctx, AV_LOG_ERROR, "Could not open drive %s.\n", ctx->url);
6666 return AVERROR(EINVAL);
6767 }
6868 if (err) {
@@ -70,7 +70,7 @@ static av_cold int read_header(AVFormatContext *ctx) · 1 unmodified line
7070 free(err);
7171 }
7272 if ((ret = cdio_cddap_open(s->drive)) < 0 || !s->drive->opened) {
73− av_log(ctx, AV_LOG_ERROR, "Could not open disk in drive %s.\n", ctx->filename);
73+ av_log(ctx, AV_LOG_ERROR, "Could not open disk in drive %s.\n", ctx->url);
7474 return AVERROR(EINVAL);
7575 }
7676
libavdevice/libndi_newtek_dec.c+1−1
@@ -149,7 +149,7 @@ static int ndi_read_header(AVFormatContext *avctx) · 148 unmodified lines
149149 }
150150
151151 /* Find available sources. */
152− ret = ndi_find_sources(avctx, avctx->filename, &recv_create_desc.source_to_connect_to);
152+ ret = ndi_find_sources(avctx, avctx->url, &recv_create_desc.source_to_connect_to);
153153 if (ctx->find_sources) {
154154 return AVERROR_EXIT;
155155 }
libavdevice/libndi_newtek_enc.c+2−2
@@ -233,7 +233,7 @@ static int ndi_write_header(AVFormatContext *avctx) · 232 unmodified lines
233233 int ret = 0;
234234 unsigned int n;
235235 struct NDIContext *ctx = avctx->priv_data;
236− const NDIlib_send_create_t ndi_send_desc = { .p_ndi_name = avctx->filename,
236+ const NDIlib_send_create_t ndi_send_desc = { .p_ndi_name = avctx->url,
237237 .p_groups = NULL, .clock_video = ctx->clock_video, .clock_audio = ctx->clock_audio };
238238
239239 if (!NDIlib_initialize()) {
@@ -260,7 +260,7 @@ static int ndi_write_header(AVFormatContext *avctx) · 20 unmodified lines
260260
261261 ctx->ndi_send = NDIlib_send_create(&ndi_send_desc);
262262 if (!ctx->ndi_send) {
263− av_log(avctx, AV_LOG_ERROR, "Failed to create NDI output %s\n", avctx->filename);
263+ av_log(avctx, AV_LOG_ERROR, "Failed to create NDI output %s\n", avctx->url);
264264 ret = AVERROR_EXTERNAL;
265265 }
266266
libavdevice/openal-dec.c+1−1
@@ -139,7 +139,7 @@ static int read_header(AVFormatContext *ctx) · 138 unmodified lines
139139
140140 /* Open device for capture */
141141 ad->device =
142− alcCaptureOpenDevice(ctx->filename[0] ? ctx->filename : NULL,
142+ alcCaptureOpenDevice(ctx->url[0] ? ctx->url : NULL,
143143 ad->sample_rate,
144144 ad->sample_format,
145145 ad->sample_rate); /* Maximum 1 second of sample data to be read at once */
libavdevice/opengl_enc.c+1−1
@@ -1070,7 +1070,7 @@ static av_cold int opengl_write_header(AVFormatContext *h) · 1069 unmodified lines
10701070 opengl->window_height = opengl->height;
10711071
10721072 if (!opengl->window_title && !opengl->no_window)
1073− opengl->window_title = av_strdup(h->filename);
1073+ opengl->window_title = av_strdup(h->url);
10741074
10751075 if ((ret = opengl_create_window(h)))
10761076 goto fail;
libavdevice/oss_dec.c+1−1
@@ -52,7 +52,7 @@ static int audio_read_header(AVFormatContext *s1) · 51 unmodified lines
5252 return AVERROR(ENOMEM);
5353 }
5454
55− ret = ff_oss_audio_open(s1, 0, s1->filename);
55+ ret = ff_oss_audio_open(s1, 0, s1->url);
5656 if (ret < 0) {
5757 return AVERROR(EIO);
5858 }
libavdevice/oss_enc.c+1−1
@@ -46,7 +46,7 @@ static int audio_write_header(AVFormatContext *s1) · 45 unmodified lines
4646 st = s1->streams[0];
4747 s->sample_rate = st->codecpar->sample_rate;
4848 s->channels = st->codecpar->channels;
49− ret = ff_oss_audio_open(s1, 1, s1->filename);
49+ ret = ff_oss_audio_open(s1, 1, s1->url);
5050 if (ret < 0) {
5151 return AVERROR(EIO);
5252 } else {
libavdevice/pulse_audio_dec.c+2−2
@@ -158,8 +158,8 @@ static av_cold int pulse_read_header(AVFormatContext *s) · 157 unmodified lines
158158
159159 attr.fragsize = pd->fragment_size;
160160
161− if (s->filename[0] != '\0' && strcmp(s->filename, "default"))
162− device = s->filename;
161+ if (s->url[0] != '\0' && strcmp(s->url, "default"))
162+ device = s->url;
163163
164164 if (!(pd->mainloop = pa_threaded_mainloop_new())) {
165165 pulse_close(s);
libavdevice/pulse_audio_enc.c+2−2
@@ -459,8 +459,8 @@ static av_cold int pulse_write_header(AVFormatContext *h) · 458 unmodified lines
459459 st = h->streams[0];
460460
461461 if (!stream_name) {
462− if (h->filename[0])
463− stream_name = h->filename;
462+ if (h->url[0])
463+ stream_name = h->url;
464464 else
465465 stream_name = "Playback";
466466 }
libavdevice/sdl2.c+1−1
@@ -165,7 +165,7 @@ static int sdl2_write_header(AVFormatContext *s) · 164 unmodified lines
165165 int flags = 0;
166166
167167 if (!sdl->window_title)
168− sdl->window_title = av_strdup(s->filename);
168+ sdl->window_title = av_strdup(s->url);
169169
170170 if (SDL_WasInit(SDL_INIT_VIDEO)) {
171171 av_log(s, AV_LOG_WARNING,
libavdevice/sndio_dec.c+1−1
@@ -41,7 +41,7 @@ static av_cold int audio_read_header(AVFormatContext *s1) · 40 unmodified lines
4141 if (!st)
4242 return AVERROR(ENOMEM);
4343
44− ret = ff_sndio_open(s1, 0, s1->filename);
44+ ret = ff_sndio_open(s1, 0, s1->url);
4545 if (ret < 0)
4646 return ret;
4747
libavdevice/sndio_enc.c+1−1
@@ -38,7 +38,7 @@ static av_cold int audio_write_header(AVFormatContext *s1) · 37 unmodified lines
3838 s->sample_rate = st->codecpar->sample_rate;
3939 s->channels = st->codecpar->channels;
4040
41− ret = ff_sndio_open(s1, 1, s1->filename);
41+ ret = ff_sndio_open(s1, 1, s1->url);
4242
4343 return ret;
4444 }
libavdevice/v4l2.c+9−7
@@ -106,7 +106,7 @@ struct buff_data { · 105 unmodified lines
106106 int index;
107107 };
108108
109−static int device_open(AVFormatContext *ctx)
109+static int device_open(AVFormatContext *ctx, const char* device_path)
110110 {
111111 struct video_data *s = ctx->priv_data;
112112 struct v4l2_capability cap;
@@ -147,11 +147,11 @@ static int device_open(AVFormatContext *ctx) · 34 unmodified lines
147147 flags |= O_NONBLOCK;
148148 }
149149
150− fd = v4l2_open(ctx->filename, flags, 0);
150+ fd = v4l2_open(device_path, flags, 0);
151151 if (fd < 0) {
152152 err = AVERROR(errno);
153153 av_log(ctx, AV_LOG_ERROR, "Cannot open video device %s: %s\n",
154− ctx->filename, av_err2str(err));
154+ device_path, av_err2str(err));
155155 return err;
156156 }
157157
@@ -840,7 +840,7 @@ static int v4l2_read_header(AVFormatContext *ctx) · 682 unmodified lines
840840 v4l2_log_file = fopen("/dev/null", "w");
841841 #endif
842842
843− s->fd = device_open(ctx);
843+ s->fd = device_open(ctx, ctx->url);
844844 if (s->fd < 0)
845845 return s->fd;
846846
@@ -1042,11 +1042,13 @@ static int v4l2_get_device_list(AVFormatContext *ctx, AVDeviceInfoList *device_l · 195 unmodified lines
10421042 return ret;
10431043 }
10441044 while ((entry = readdir(dir))) {
1045+ char device_name[256];
1046+
10451047 if (!v4l2_is_v4l_dev(entry->d_name))
10461048 continue;
10471049
1048− snprintf(ctx->filename, sizeof(ctx->filename), "/dev/%s", entry->d_name);
1049− if ((s->fd = device_open(ctx)) < 0)
1050+ snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name);
1051+ if ((s->fd = device_open(ctx, device_name)) < 0)
10501052 continue;
10511053
10521054 if (v4l2_ioctl(s->fd, VIDIOC_QUERYCAP, &cap) < 0) {
@@ -1060,7 +1062,7 @@ static int v4l2_get_device_list(AVFormatContext *ctx, AVDeviceInfoList *device_l · 7 unmodified lines
10601062 ret = AVERROR(ENOMEM);
10611063 goto fail;
10621064 }
1063− device->device_name = av_strdup(ctx->filename);
1065+ device->device_name = av_strdup(device_name);
10641066 device->device_description = av_strdup(cap.card);
10651067 if (!device->device_name || !device->device_description) {
10661068 ret = AVERROR(ENOMEM);
libavdevice/v4l2enc.c+2−2
@@ -39,10 +39,10 @@ static av_cold int write_header(AVFormatContext *s1) · 38 unmodified lines
3939 if (s1->flags & AVFMT_FLAG_NONBLOCK)
4040 flags |= O_NONBLOCK;
4141
42− s->fd = open(s1->filename, flags);
42+ s->fd = open(s1->url, flags);
4343 if (s->fd < 0) {
4444 res = AVERROR(errno);
45− av_log(s1, AV_LOG_ERROR, "Unable to open V4L2 device '%s'\n", s1->filename);
45+ av_log(s1, AV_LOG_ERROR, "Unable to open V4L2 device '%s'\n", s1->url);
4646 return res;
4747 }
4848
libavdevice/vfwcap.c+2−2
@@ -256,7 +256,7 @@ static int vfw_read_header(AVFormatContext *s) · 255 unmodified lines
256256 int ret;
257257 AVRational framerate_q;
258258
259− if (!strcmp(s->filename, "list")) {
259+ if (!strcmp(s->url, "list")) {
260260 for (devnum = 0; devnum <= 9; devnum++) {
261261 char driver_name[256];
262262 char driver_ver[256];
@@ -279,7 +279,7 @@ static int vfw_read_header(AVFormatContext *s) · 16 unmodified lines
279279 }
280280
281281 /* If atoi fails, devnum==0 and the default device is used */
282− devnum = atoi(s->filename);
282+ devnum = atoi(s->url);
283283
284284 ret = SendMessage(ctx->hwnd, WM_CAP_DRIVER_CONNECT, devnum, 0);
285285 if(!ret) {
libavdevice/xcbgrab.c+4−4
@@ -629,14 +629,14 @@ static av_cold int xcbgrab_read_header(AVFormatContext *s) · 628 unmodified lines
629629 XCBGrabContext *c = s->priv_data;
630630 int screen_num, ret;
631631 const xcb_setup_t *setup;
632− char *display_name = av_strdup(s->filename);
632+ char *display_name = av_strdup(s->url);
633633
634634 if (!display_name)
635635 return AVERROR(ENOMEM);
636636
637− if (!sscanf(s->filename, "%[^+]+%d,%d", display_name, &c->x, &c->y)) {
637+ if (!sscanf(s->url, "%[^+]+%d,%d", display_name, &c->x, &c->y)) {
638638 *display_name = 0;
639− sscanf(s->filename, "+%d,%d", &c->x, &c->y);
639+ sscanf(s->url, "+%d,%d", &c->x, &c->y);
640640 }
641641
642642 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) · 1 unmodified line
644644
645645 if ((ret = xcb_connection_has_error(c->conn))) {
646646 av_log(s, AV_LOG_ERROR, "Cannot open display %s, error %d.\n",
647− s->filename[0] ? s->filename : "default", ret);
647+ s->url[0] ? s->url : "default", ret);
648648 return AVERROR(EIO);
649649 }
650650
libavdevice/xv.c+1−1
@@ -151,7 +151,7 @@ static int xv_write_header(AVFormatContext *s) · 150 unmodified lines
151151 xv->window_width, xv->window_height,
152152 0, 0, 0);
153153 if (!xv->window_title) {
154− if (!(xv->window_title = av_strdup(s->filename))) {
154+ if (!(xv->window_title = av_strdup(s->url))) {
155155 ret = AVERROR(ENOMEM);
156156 goto fail;
157157 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t