[asterisk-commits] file: branch group/media_formats r407982 - in /team/group/media_formats: form...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Feb 12 06:25:03 CST 2014


Author: file
Date: Wed Feb 12 06:24:58 2014
New Revision: 407982

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407982
Log:
Finish up format_h263 and format_h264.

Modified:
    team/group/media_formats/formats/format_h263.c
    team/group/media_formats/formats/format_h264.c
    team/group/media_formats/include/asterisk/format_cache.h
    team/group/media_formats/include/asterisk/frame.h

Modified: team/group/media_formats/formats/format_h263.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/formats/format_h263.c?view=diff&rev=407982&r1=407981&r2=407982
==============================================================================
--- team/group/media_formats/formats/format_h263.c (original)
+++ team/group/media_formats/formats/format_h263.c Wed Feb 12 06:24:58 2014
@@ -35,6 +35,7 @@
 #include "asterisk/mod_format.h"
 #include "asterisk/module.h"
 #include "asterisk/endian.h"
+#include "asterisk/format_cache.h"
 
 /* Some Ideas for this code came from makeh263e.c by Jeffrey Chilton */
 
@@ -82,9 +83,6 @@
 		ast_log(LOG_WARNING, "Length %d is too long\n", len);
 		return NULL;
 	}
-	s->fr.frametype = AST_FRAME_VIDEO;
-	ast_format_set(&s->fr.subclass.format, AST_FORMAT_H263, 0);
-	s->fr.mallocd = 0;
 	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
 	if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
 		if (res)
@@ -93,11 +91,7 @@
 	}
 	s->fr.samples = fs->lastts;	/* XXX what ? */
 	s->fr.datalen = len;
-	if (mark) {
-		ast_format_set_video_mark(&s->fr.subclass.format);
-	}
-	s->fr.delivery.tv_sec = 0;
-	s->fr.delivery.tv_usec = 0;
+	s->fr.subclass.video.rtp_marker_bit = mark;
 	if ((res = fread(&ts, 1, sizeof(ts), s->f)) == sizeof(ts)) {
 		fs->lastts = ntohl(ts);
 		*whennext = fs->lastts * 4/45;
@@ -112,15 +106,7 @@
 	unsigned int ts;
 	unsigned short len;
 	uint32_t mark = 0;
-	if (f->frametype != AST_FRAME_VIDEO) {
-		ast_log(LOG_WARNING, "Asked to write non-video frame!\n");
-		return -1;
-	}
-	mark = ast_format_get_video_mark(&f->subclass.format) ? 0x8000 : 0;
-	if (f->subclass.format.id != AST_FORMAT_H263) {
-		ast_log(LOG_WARNING, "Asked to write non-h263 frame (%s)!\n", ast_getformatname(&f->subclass.format));
-		return -1;
-	}
+	mark = f->subclass.video.rtp_marker_bit ? 0x8000 : 0;
 	ts = htonl(f->samples);
 	if ((res = fwrite(&ts, 1, sizeof(ts), fs->f)) != sizeof(ts)) {
 			ast_log(LOG_WARNING, "Bad write (%d/4): %s\n", res, strerror(errno));
@@ -182,7 +168,7 @@
 
 static int load_module(void)
 {
-	ast_format_set(&h263_f.format, AST_FORMAT_H263, 0);
+	h263_f.format = ast_format_h263;
 	if (ast_format_def_register(&h263_f))
 		return AST_MODULE_LOAD_FAILURE;
 	return AST_MODULE_LOAD_SUCCESS;

Modified: team/group/media_formats/formats/format_h264.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/formats/format_h264.c?view=diff&rev=407982&r1=407981&r2=407982
==============================================================================
--- team/group/media_formats/formats/format_h264.c (original)
+++ team/group/media_formats/formats/format_h264.c Wed Feb 12 06:24:58 2014
@@ -35,6 +35,7 @@
 #include "asterisk/mod_format.h"
 #include "asterisk/module.h"
 #include "asterisk/endian.h"
+#include "asterisk/format_cache.h"
 
 /* Some Ideas for this code came from makeh264e.c by Jeffrey Chilton */
 
@@ -74,9 +75,6 @@
 		ast_log(LOG_WARNING, "Length %d is too long\n", len);
 		len = BUF_SIZE;	/* XXX truncate */
 	}
-	s->fr.frametype = AST_FRAME_VIDEO;
-	ast_format_set(&s->fr.subclass.format, AST_FORMAT_H264, 0);
-	s->fr.mallocd = 0;
 	AST_FRAME_SET_BUFFER(&s->fr, s->buf, AST_FRIENDLY_OFFSET, len);
 	if ((res = fread(s->fr.data.ptr, 1, s->fr.datalen, s->f)) != s->fr.datalen) {
 		if (res)
@@ -85,11 +83,7 @@
 	}
 	s->fr.samples = fs->lastts;
 	s->fr.datalen = len;
-	if (mark) {
-		ast_format_set_video_mark(&s->fr.subclass.format);
-	}
-	s->fr.delivery.tv_sec = 0;
-	s->fr.delivery.tv_usec = 0;
+	s->fr.subclass.video.rtp_marker_bit = mark;
 	if ((res = fread(&ts, 1, sizeof(ts), s->f)) == sizeof(ts)) {
 		fs->lastts = ntohl(ts);
 		*whennext = fs->lastts * 4/45;
@@ -105,15 +99,7 @@
 	unsigned short len;
 	int mark;
 
-	if (f->frametype != AST_FRAME_VIDEO) {
-		ast_log(LOG_WARNING, "Asked to write non-video frame!\n");
-		return -1;
-	}
-	mark = ast_format_get_video_mark(&f->subclass.format) ? 0x8000 : 0;
-	if (f->subclass.format.id != AST_FORMAT_H264) {
-		ast_log(LOG_WARNING, "Asked to write non-h264 frame (%s)!\n", ast_getformatname(&f->subclass.format));
-		return -1;
-	}
+	mark = f->subclass.video.rtp_marker_bit ? 0x8000 : 0;
 	ts = htonl(f->samples);
 	if ((res = fwrite(&ts, 1, sizeof(ts), s->f)) != sizeof(ts)) {
 		ast_log(LOG_WARNING, "Bad write (%d/4): %s\n", res, strerror(errno));
@@ -175,7 +161,7 @@
 
 static int load_module(void)
 {
-	ast_format_set(&h264_f.format, AST_FORMAT_H264, 0);
+	h264_f.format = ast_format_h264;
 	if (ast_format_def_register(&h264_f))
 		return AST_MODULE_LOAD_FAILURE;
 	return AST_MODULE_LOAD_SUCCESS;

Modified: team/group/media_formats/include/asterisk/format_cache.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/format_cache.h?view=diff&rev=407982&r1=407981&r2=407982
==============================================================================
--- team/group/media_formats/include/asterisk/format_cache.h (original)
+++ team/group/media_formats/include/asterisk/format_cache.h Wed Feb 12 06:24:58 2014
@@ -144,6 +144,11 @@
 extern struct ast_format *ast_format_h263;
 
 /*!
+ * \brief Built-in cached h264 format.
+ */
+extern struct ast_format *ast_format_h264;
+
+/*!
  * \brief Built-in cached jpeg format.
  */
 extern struct ast_format *ast_format_jpeg;

Modified: team/group/media_formats/include/asterisk/frame.h
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/include/asterisk/frame.h?view=diff&rev=407982&r1=407981&r2=407982
==============================================================================
--- team/group/media_formats/include/asterisk/frame.h (original)
+++ team/group/media_formats/include/asterisk/frame.h Wed Feb 12 06:24:58 2014
@@ -129,9 +129,15 @@
 	AST_FRFLAG_HAS_TIMING_INFO = (1 << 0),
 };
 
+struct ast_frame_video {
+	struct ast_format *format;
+	unsigned int rtp_marker_bit;
+};
+
 union ast_frame_subclass {
 	int integer;
 	struct ast_format *format;
+	struct ast_frame_video video;
 };
 
 /*! \brief Data structure associated with a single frame of data




More information about the asterisk-commits mailing list