[asterisk-commits] rizzo: branch rizzo/video_v2 r85192 - /team/rizzo/video_v2/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Oct 9 21:53:35 CDT 2007
Author: rizzo
Date: Tue Oct 9 21:53:35 2007
New Revision: 85192
URL: http://svn.digium.com/view/asterisk?view=rev&rev=85192
Log:
clean up some comments and code, remove unused field, staticize
some variables
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=85192&r1=85191&r2=85192
==============================================================================
--- team/rizzo/video_v2/channels/console_video.c (original)
+++ team/rizzo/video_v2/channels/console_video.c Tue Oct 9 21:53:35 2007
@@ -200,7 +200,6 @@
AVCodecContext *enc_ctx; /* encoding context */
AVCodec *codec;
AVFrame *frame; /* The initial part is an AVPicture */
- int lasttxframe; /* XXX useless: RTP overwrite seqno */
int mtu;
struct timeval last_frame; /* when we read the last frame ? */
@@ -241,7 +240,6 @@
typedef int (*encoder_encode_f)(struct video_out_desc *v);
/*! \brief encapsulate the bistream in RTP frames */
-/* XXX len is redundant */
typedef struct ast_frame *(*encoder_encap_f)(struct video_out_desc *out,
struct ast_frame **tail);
@@ -255,6 +253,7 @@
typedef int (*decoder_decode_f)(struct video_in_desc *v, struct fbuf_t *b);
struct video_codec_desc {
+ const char *name; /* format name */
int format; /* AST_FORMAT_* */
encoder_init_f enc_init;
encoder_encap_f enc_encap;
@@ -359,11 +358,14 @@
}
-/*----- codec specific code --------*/
-
-/*
- * For each codec, we define the various callback in use
- */
+/*
+ * Here starts the glue code for the various supported video codecs.
+ * For each of them, we need to provide routines for initialization,
+ * calling the encoder, encapsulating the bitstream in ast_frames,
+ * extracting payload from ast_frames, and calling the decoder.
+ */
+
+/*--- h263+ support --- */
/*! \brief initialization of h263p */
static int h263p_enc_init(struct video_out_desc *v)
@@ -487,7 +489,7 @@
* 5 bits HMVD horiz motion vector
* 5 bits VMVD vert. motion vector
*
- * For h263, the format is defined in RFC 2429
+ * For h263+, the format is defined in RFC 2429
* and basically has a fixed 2-byte header as follows:
* 5 bits RR reserved, shall be 0
* 1 bit P indicate a start/end condition,
@@ -557,7 +559,8 @@
return 1;
}
-struct video_codec_desc h263p_codec = {
+static struct video_codec_desc h263p_codec = {
+ .name = "h263p",
.format = AST_FORMAT_H263_PLUS,
.enc_init = h263p_enc_init,
.enc_encap = h263p_encap,
@@ -567,7 +570,7 @@
.dec_run = ffmpeg_decode
};
-/*--- plain H263 support --------*/
+/*--- Plain h263 support --------*/
static int h263_enc_init(struct video_out_desc *v)
{
@@ -732,7 +735,8 @@
return data;
}
-struct video_codec_desc h263_codec = {
+static struct video_codec_desc h263_codec = {
+ .name = "h263",
.format = AST_FORMAT_H263,
.enc_init = h263_enc_init,
.enc_encap = h263_encap,
@@ -743,7 +747,7 @@
};
-/*---- plain H261 support -----*/
+/*---- h261 support -----*/
static int h261_enc_init(struct video_out_desc *v)
{
return 0;
@@ -799,7 +803,8 @@
return data+4;
}
-struct video_codec_desc h261_codec = {
+static struct video_codec_desc h261_codec = {
+ .name = "h261",
.format = AST_FORMAT_H261,
.enc_init = h261_enc_init,
.enc_encap = h261_encap,
@@ -1040,14 +1045,12 @@
return CODEC_ID_NONE;
}
-struct _config_map { /* map config format to asterisk format */
- char *name;
- struct video_codec_desc *codec;
-} str_format_map[] = {
- { "h263+", &h263p_codec },
- { "h263", &h263_codec },
- { "h261", &h261_codec },
- { NULL, NULL }
+/* pointers to supported codecs. We assume the first one to be non null. */
+static struct video_codec_desc *supported_codecs[] = {
+ &h263p_codec,
+ &h263_codec,
+ &h261_codec,
+ NULL
};
/*
@@ -1057,16 +1060,16 @@
{
int i;
- for (i = 0; str_format_map[i].name != NULL; i++)
- if(strcasecmp(name, str_format_map[i].name) == 0)
+ for (i = 0; supported_codecs[i]; i++)
+ if (!strcasecmp(name, supported_codecs[i]->name))
break;
- if (str_format_map[i].name == NULL) {
+ if (supported_codecs[i] == NULL) {
ast_log(LOG_WARNING, "Cannot find codec for '%s'\n", name);
i = 0;
- strcpy(name, str_format_map[i].name);
+ strcpy(name, supported_codecs[i]->name);
}
ast_log(LOG_WARNING, "Using codec '%s'\n", name);
- return str_format_map[i].codec;
+ return supported_codecs[i];
}
/*! \brief uninitialize the descriptor for remote video stream */
@@ -1173,7 +1176,6 @@
v->enc_ctx = NULL;
v->codec = NULL;
v->frame = NULL;
- v->lasttxframe = -1;
v->enc_out.data = NULL;
if (v->loc_src.data == NULL) {
More information about the asterisk-commits
mailing list