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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Sep 28 11:52:32 CDT 2007


Author: rizzo
Date: Fri Sep 28 11:52:32 2007
New Revision: 84109

URL: http://svn.digium.com/view/asterisk?view=rev&rev=84109
Log:
The main purpose of this patch is to remove the leftover calls to
get_video_frames() in chan_oss and chan_alsa, since video input is
now handled entirely by the video thread. At the same time,
change the period of the thread from 1s to 50ms.

This might fix the ast_queue corruption that i and Matteo were
seeing, as the two threads were contending for the video device
and the codec.

The second (and largest, but comment-only) part of the patch is to
start documenting the way we add video support, and list the various
video representations that are in use.  As you can see from the
comment we have many different representations to handle (local_source,
encoder_in, encoder_out, local_display, decoder_in, decoder_out,
remote_display).

The current implementation completely overlooked this, assuming that
the geometry is the same for all representations, and also that
bitstream formats are the same for some of these representations.
Now that I know, i must patiently add descriptors for all of them,
and possibly invoke img_convert/sws_scale as appropriate.


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

Modified: team/rizzo/video_v2/channels/chan_alsa.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/video_v2/channels/chan_alsa.c?view=diff&rev=84109&r1=84108&r2=84109
==============================================================================
--- team/rizzo/video_v2/channels/chan_alsa.c (original)
+++ team/rizzo/video_v2/channels/chan_alsa.c Fri Sep 28 11:52:32 2007
@@ -689,10 +689,8 @@
 	snd_pcm_state_t state;
 	int r = 0;
 	int off = 0;
-	struct ast_frame *fv = get_video_frames(get_video_desc(chan));
-
-	ast_mutex_lock(&alsalock);
-	AST_LIST_NEXT(&f, frame_list) = fv;
+
+	ast_mutex_lock(&alsalock);
 	/* Acknowledge any pending cmd */
 	f.frametype = AST_FRAME_NULL;
 	f.subclass = 0;

Modified: team/rizzo/video_v2/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/video_v2/channels/chan_oss.c?view=diff&rev=84109&r1=84108&r2=84109
==============================================================================
--- team/rizzo/video_v2/channels/chan_oss.c (original)
+++ team/rizzo/video_v2/channels/chan_oss.c Fri Sep 28 11:52:32 2007
@@ -932,12 +932,10 @@
 	int res;
 	struct chan_oss_pvt *o = c->tech_pvt;
 	struct ast_frame *f = &o->read_f;
-	struct ast_frame *fv = get_video_frames(get_video_desc(c));
 
 	/* XXX can be simplified returning &ast_null_frame */
 	/* prepare a NULL frame in case we don't have enough data to return */
 	bzero(f, sizeof(struct ast_frame));
-	AST_LIST_NEXT(f, frame_list) = fv;	/* append video frames */
 	f->frametype = AST_FRAME_NULL;
 	f->src = oss_tech.type;
 

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=84109&r1=84108&r2=84109
==============================================================================
--- team/rizzo/video_v2/channels/console_video.c (original)
+++ team/rizzo/video_v2/channels/console_video.c Fri Sep 28 11:52:32 2007
@@ -55,14 +55,50 @@
 {
 }
 
-static struct ast_frame *get_video_frames(struct video_desc *e)
-{
-	return NULL;
-}
-
 #else
 /*
  * The real thing, with support for SDL and codecs, and possibly V4L/X11.
+ *
+
+The code is structured as follows.
+
+When a new console channel is created, we call console_video_start()
+to initialize SDL, the source and the encoder/ decoder
+(XXX the latter two should be done later, once the codec
+negotiation is complete).
+Also a thread is created to handle the video source and generate frames.
+
+While communication is on, the local source is generated by the
+video thread, which wakes up periodically, generates frames and enqueues
+them in chan->readq.  Incoming rtp frames are passed to
+console_write_video(), decoded and passed to SDL for display.
+
+For as unfortunate and confusing as it can be, we need to deal with a
+number of different video "formats" (meaning size, codec/pixel format,
+codec parameters), as follows:
+
+ loc_src_fmt	is the data coming from the camera/X11/etc.
+	This is typically constrained by the video device driver.
+
+ enc_in_fmt	is the input format required by the encoder.
+	Typically constrained in size by the encoder type.
+
+ enc_out_fmt	is the format used in the bitstream transmitted over RTP.
+	Typically negotiated while the call is established.
+
+ loc_dpy_fmt	is how we are going to display the local video source.
+	Depending on user preferences this can have the same size as
+	loc_src_fmt, or enc_in_fmt, or thumbnail size (e.g. PiP output)
+
+ dec_in_fmt	is the format received on the RTP bitstream. Negotiated
+	during call establishment, it is not necessarily the same as
+	enc_in_fmt
+
+ dec_out_fmt	the output of the decoder
+
+ rem_dpy_fmt	the format used to display the remote stream
+
+
  *
  * In order to decode video you need the following patch to the
  * main Makefile:
@@ -105,6 +141,12 @@
 	uint8_t	*data;	/* malloc-ed memory */
 	int	size;	/* total size in bytes */
 	int	used;	/* space used so far */
+};
+
+struct vid_fmt {
+	int	w;
+	int	h;
+	int	pix_fmt;
 };
 
 /*
@@ -1049,7 +1091,8 @@
 	int i = 0;
 	struct video_desc *env = arg;
 	for (;;i++) {
-		struct timeval t = { 1, 0 };
+		/* XXX 20 times/sec */
+		struct timeval t = { 0, 50000 };
 		struct ast_frame *p, *f;
 		struct ast_channel *chan = env->owner;
 		int fd = chan->alertpipe[1];




More information about the asterisk-commits mailing list