[svn-commits] rizzo: branch rizzo/video_v2 r85230 - /team/rizzo/video_v2/channels/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Oct 10 04:11:43 CDT 2007


Author: rizzo
Date: Wed Oct 10 04:11:43 2007
New Revision: 85230

URL: http://svn.digium.com/view/asterisk?view=rev&rev=85230
Log:
start putting the encoder calls into a per-format callback


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=85230&r1=85229&r2=85230
==============================================================================
--- team/rizzo/video_v2/channels/console_video.c (original)
+++ team/rizzo/video_v2/channels/console_video.c Wed Oct 10 04:11:43 2007
@@ -529,6 +529,17 @@
 }
 
 /*
+ * generic encoder, used by the various protocols supported here.
+ */
+static int ffmpeg_encode(struct video_out_desc *v)
+{
+	struct fbuf_t *b = &v->enc_out;
+
+	b->used = avcodec_encode_video(v->enc_ctx, b->data, b->size, v->frame);
+	return 0;
+}
+
+/*
  * Generic decoder, which is used by h263p, h263 and h261 as it simply
  * invokes ffmpeg's decoder.
  * av_parser_parse should merge a randomly chopped up stream into
@@ -564,7 +575,7 @@
 	.format = AST_FORMAT_H263_PLUS,
 	.enc_init = h263p_enc_init,
 	.enc_encap = h263p_encap,
-	.enc_run = NULL,
+	.enc_run = ffmpeg_encode,
 	.dec_init = NULL,
 	.dec_decap = h263p_decap,
 	.dec_run = ffmpeg_decode
@@ -740,7 +751,7 @@
 	.format = AST_FORMAT_H263,
 	.enc_init = h263_enc_init,
 	.enc_encap = h263_encap,
-	.enc_run = NULL,
+	.enc_run = ffmpeg_encode,
 	.dec_init = NULL,
 	.dec_decap = h263_decap,
 	.dec_run = ffmpeg_decode
@@ -808,7 +819,7 @@
 	.format = AST_FORMAT_H261,
 	.enc_init = h261_enc_init,
 	.enc_encap = h261_encap,
-	.enc_run = NULL,
+	.enc_run = ffmpeg_encode,
 	.dec_init = NULL,
 	.dec_decap = h261_decap,
 	.dec_run = ffmpeg_decode
@@ -1544,11 +1555,7 @@
 static struct ast_frame *get_video_frames(struct video_desc *env, struct ast_frame **tail)
 {
 	struct video_out_desc *v = &env->out;
-	struct fbuf_t *b = &v->enc_out;
 	struct ast_frame *dummy;
-
-	if (tail == NULL)
-		tail = &dummy;
 
 	if (!v->loc_src.data) {
 		static volatile int a = 0;
@@ -1556,21 +1563,26 @@
 			ast_log(LOG_WARNING, "fail, no loc_src buffer\n");
 		return NULL;
 	}
-
 	if (!video_read(v))
 		return NULL;	/* can happen, e.g. we are reading too early */
 
+	if (tail == NULL)
+		tail = &dummy;
 	*tail = NULL;
-	/* get frame and put them in the queue */
+	/* Scale the video for the encoder, then use it for local rendering
+	 * so we will see the same as the remote party.
+	 */
 	my_scale(&v->loc_src, NULL, &v->enc_in, NULL);
 	show_frame(env, 1);
-	if (b->data == NULL) {
-		ast_log(LOG_WARNING, "fail, no encbuf\n");
-		return NULL;
-	}
 	if (!v->sendvideo)
 		return NULL;
-	b->used = avcodec_encode_video(v->enc_ctx, b->data, b->size, v->frame);
+	if (v->enc_out.data == NULL) {
+		static volatile int a = 0;
+		if (a++ < 2)
+			ast_log(LOG_WARNING, "fail, no encbuf\n");
+		return NULL;
+	}
+	env->current_codec->enc_run(v);
 	return env->current_codec->enc_encap(v, tail);
 }
 




More information about the svn-commits mailing list