int show_filters(void *optctx, const char *opt, const char *arg)
{
- AVFilter av_unused(**filter) = NULL;
+ const AVFilter av_unused(*filter) = NULL;
+ char descr[64], *descr_cur;
+ int i, j;
+ const AVFilterPad *pad;
printf("Filters:\n");
#if CONFIG_AVFILTER
- while ((filter = av_filter_next(filter)) && *filter) {
- while ((filter = avfilter_next(filter)))
- printf("%-16s %s\n", filter->name, filter->description);
++ while ((filter = avfilter_next(filter))) {
+ descr_cur = descr;
+ for (i = 0; i < 2; i++) {
+ if (i) {
+ *(descr_cur++) = '-';
+ *(descr_cur++) = '>';
+ }
- pad = i ? (*filter)->outputs : (*filter)->inputs;
++ pad = i ? filter->outputs : filter->inputs;
+ for (j = 0; pad && pad[j].name; j++) {
+ if (descr_cur >= descr + sizeof(descr) - 4)
+ break;
+ *(descr_cur++) = get_media_type_char(pad[j].type);
+ }
+ if (!j)
+ *(descr_cur++) = '|';
+ }
+ *descr_cur = 0;
- printf("%-16s %-10s %s\n", (*filter)->name, descr, (*filter)->description);
++ printf("%-16s %-10s %s\n", filter->name, descr, filter->description);
+ }
#endif
return 0;
}
}
}
-static int video_open(VideoState *is)
+static void stream_close(VideoState *is)
+{
+ VideoPicture *vp;
+ int i;
+ /* XXX: use a special url_shutdown call to abort parse cleanly */
+ is->abort_request = 1;
+ SDL_WaitThread(is->read_tid, NULL);
+ packet_queue_destroy(&is->videoq);
+ packet_queue_destroy(&is->audioq);
+ packet_queue_destroy(&is->subtitleq);
+
+ /* free all pictures */
+ for (i = 0; i < VIDEO_PICTURE_QUEUE_SIZE; i++) {
+ vp = &is->pictq[i];
+ if (vp->bmp) {
+ SDL_FreeYUVOverlay(vp->bmp);
+ vp->bmp = NULL;
+ }
+ }
+ SDL_DestroyMutex(is->pictq_mutex);
+ SDL_DestroyCond(is->pictq_cond);
+ SDL_DestroyMutex(is->subpq_mutex);
+ SDL_DestroyCond(is->subpq_cond);
+ SDL_DestroyCond(is->continue_read_thread);
+#if !CONFIG_AVFILTER
+ sws_freeContext(is->img_convert_ctx);
+#endif
+ av_free(is);
+}
+
+static void do_exit(VideoState *is)
+{
+ if (is) {
+ stream_close(is);
+ }
+ av_lockmgr_register(NULL);
+ uninit_opts();
+#if CONFIG_AVFILTER
- avfilter_uninit();
+ av_freep(&vfilters);
+#endif
+ avformat_network_deinit();
+ if (show_status)
+ printf("\n");
+ SDL_Quit();
+ av_log(NULL, AV_LOG_QUIET, "%s", "");
+ exit(0);
+}
+
+static void sigterm_handler(int sig)
+{
+ exit(123);
+}
+
+static int video_open(VideoState *is, int force_set_video_mode, VideoPicture *vp)
{
int flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL;
int w,h;
return min;
}
- #define MAX_REGISTERED_AVFILTERS_NB 256
-
- static AVFilter *registered_avfilters[MAX_REGISTERED_AVFILTERS_NB + 1];
-
- static int next_registered_avfilter_idx = 0;
+void ff_update_link_current_pts(AVFilterLink *link, int64_t pts)
+{
+ if (pts == AV_NOPTS_VALUE)
+ return;
+ link->current_pts = av_rescale_q(pts, link->time_base, AV_TIME_BASE_Q);
+ /* TODO use duration */
+ if (link->graph && link->age_index >= 0)
+ ff_avfilter_graph_update_heap(link->graph, link);
+}
+
+int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags)
+{
+ if(!strcmp(cmd, "ping")){
+ av_strlcatf(res, res_len, "pong from:%s %s\n", filter->filter->name, filter->name);
+ return 0;
+ }else if(filter->filter->process_command) {
+ return filter->filter->process_command(filter, cmd, arg, res, res_len, flags);
+ }
+ return AVERROR(ENOSYS);
+}
+
+ static AVFilter *first_filter;
AVFilter *avfilter_get_by_name(const char *name)
{
int avfilter_register(AVFilter *filter)
{
- if (next_registered_avfilter_idx == MAX_REGISTERED_AVFILTERS_NB) {
- av_log(NULL, AV_LOG_ERROR,
- "Maximum number of registered filters %d reached, "
- "impossible to register filter with name '%s'\n",
- MAX_REGISTERED_AVFILTERS_NB, filter->name);
- return AVERROR(ENOMEM);
- }
-
+ AVFilter **f = &first_filter;
+ int i;
+
- registered_avfilters[next_registered_avfilter_idx++] = filter;
+ for(i=0; filter->inputs && filter->inputs[i].name; i++) {
+ const AVFilterPad *input = &filter->inputs[i];
+ av_assert0( !input->filter_frame
+ || (!input->start_frame && !input->end_frame));
+ }
+
+ while (*f)
+ f = &(*f)->next;
+ *f = filter;
+ filter->next = NULL;
++
return 0;
}
static const AVClass *filter_child_class_next(const AVClass *prev)
{
- AVFilter **f = NULL;
+ AVFilter *f = NULL;
- while (prev && *(f = av_filter_next(f)))
- if ((*f)->priv_class == prev)
+ /* find the filter that corresponds to prev */
+ while (prev && (f = avfilter_next(f)))
+ if (f->priv_class == prev)
break;
- if (prev && !(*f))
+ /* could not find filter corresponding to prev */
- while (*(f = av_filter_next(f)))
- if ((*f)->priv_class)
- return (*f)->priv_class;
++ if (prev && !f)
+ return NULL;
+
+ /* find next filter with specific options */
+ while ((f = avfilter_next(f)))
+ if (f->priv_class)
+ return f->priv_class;
+
return NULL;
}
int priv_size; ///< size of private data to allocate for the filter
+ struct AVFilter *next;
++
+ /**
+ * Make the filter instance process a command.
+ *
+ * @param cmd the command to process, for handling simplicity all commands must be alphanumeric only
+ * @param arg the argument for the command
+ * @param res a buffer with size res_size where the filter(s) can return a response. This must not change when the command is not supported.
+ * @param flags if AVFILTER_CMD_FLAG_FAST is set and the command would be
+ * time consuming then a filter should treat it like an unsupported command
+ *
+ * @returns >=0 on success otherwise an error code.
+ * AVERROR(ENOSYS) on unsupported commands
+ */
+ int (*process_command)(AVFilterContext *, const char *cmd, const char *arg, char *res, int res_len, int flags);
+
+ /**
+ * Filter initialization function, alternative to the init()
+ * callback. Args contains the user-supplied parameters, opaque is
+ * used for providing binary data.
+ */
+ int (*init_opaque)(AVFilterContext *ctx, void *opaque);
+
+ /**
+ * Shorthand syntax for init arguments.
+ * If this field is set (even to an empty list), just before init the
+ * private class will be set and the arguments string will be parsed
+ * using av_opt_set_from_string() with "=" and ":" delimiters, and
+ * av_opt_free() will be called just after uninit.
+ */
+ const char *const *shorthand;
} AVFilter;
/** An instance of a filter */