[asterisk-commits] rizzo: branch rizzo/video_v2 r85387 - /team/rizzo/video_v2/channels/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 11 02:48:03 CDT 2007


Author: rizzo
Date: Thu Oct 11 02:48:02 2007
New Revision: 85387

URL: http://svn.digium.com/view/asterisk?view=rev&rev=85387
Log:
in reception use whatever format the other side decides to use.
If supported, of course!


Modified:
    team/rizzo/video_v2/channels/console_video.c

Modified: team/rizzo/video_v2/channels/console_video.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/video_v2/channels/console_video.c?view=diff&rev=85387&r1=85386&r2=85387
==============================================================================
--- team/rizzo/video_v2/channels/console_video.c (original)
+++ team/rizzo/video_v2/channels/console_video.c Thu Oct 11 02:48:02 2007
@@ -1185,7 +1185,22 @@
 };
 
 /*
+ * Map the AST_FORMAT to the library. If not recognised, fail.
+ * This is useful in the input path where we get frames.
+ */
+static struct video_codec_desc *map_video_codec(int fmt)
+{
+	int i;
+
+	for (i = 0; supported_codecs[i]; i++)
+		if (fmt == supported_codecs[i]->format)
+			return supported_codecs[i];
+	return NULL;
+}
+;
+/*
  * Map the codec name to the library. If not recognised, use a default.
+ * This is useful in the output path where we decide by name, presumably.
  */
 static struct video_codec_desc *map_config_video_format(char *name)
 {
@@ -1220,6 +1235,7 @@
 		v->frame = NULL;
 	}
 	v->codec = NULL;	/* only a reference */
+	v->dec = NULL;		/* forget the decoder */
 	v->discard = 1;		/* start in discard mode */
 	fbuf_free(&v->dec_in);
 	fbuf_free(&v->dec_out);
@@ -1585,9 +1601,19 @@
 	struct video_desc *env = get_video_desc(chan);
 	struct video_in_desc *v = &env->in;
 
-	/* XXX todo: try to allocate the encoder on the first input frame,
-	 * if it fails may retry later, but not too often.
-	 */
+	if (v->dec == NULL) {	/* try to get the codec */
+		v->dec = map_video_codec(f->subclass & ~1);
+		if (v->dec == NULL) {
+			ast_log(LOG_WARNING, "cannot find video codec, drop input 0x%x\n", f->subclass);
+			return 0;
+		}
+		if (video_in_init(v, v->dec->format)) {
+			/* This is not fatal, but we won't have incoming video */
+			ast_log(LOG_WARNING, "Cannot initialize input decoder\n");
+			v->dec = NULL;
+			return 0;
+		}
+	}
 	if (v->dec_ctx == NULL) {
 		ast_log(LOG_WARNING, "cannot decode, dropping frame\n");
 		return 0;	/* error */
@@ -1803,17 +1829,8 @@
 	 */
 	avcodec_init();
 	avcodec_register_all();
+	av_log_set_level(AV_LOG_ERROR);	/* only report errors */
 	env->out.enc = map_config_video_format(env->codec_name);
-	env->in.dec = env->out.enc;
-
-	av_log_set_level(AV_LOG_ERROR);	/* only report errors */
-#if 1
-	if (video_in_init(&env->in, env->in.dec->format)) {
-		/* This is not fatal, but we won't have incoming video */
-		ast_log(LOG_WARNING, "Cannot initialize input decoder - %s\n",
-			SDL_GetError());
-	}
-#endif
 
 	/*
 	 * initialize the SDL environment




More information about the asterisk-commits mailing list