Add support for H.264 with SIP and recording

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7855 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2006-01-07 17:54:22 +00:00
parent 33323ac720
commit e2ef61814f
9 changed files with 341 additions and 35 deletions

58
file.c
View File

@@ -203,8 +203,7 @@ int ast_writestream(struct ast_filestream *fs, struct ast_frame *f)
if (fs->fmt->format < AST_FORMAT_MAX_AUDIO) {
/* This is the audio portion. Call the video one... */
if (!fs->vfs && fs->filename) {
/* XXX Support other video formats XXX */
const char *type = "h263";
const char *type = ast_getformatname(f->subclass & ~0x1);
fs->vfs = ast_writefile(fs->filename, type, NULL, fs->flags, 0, fs->mode);
ast_log(LOG_DEBUG, "Opened video output file\n");
}
@@ -495,10 +494,14 @@ struct ast_filestream *ast_openstream_full(struct ast_channel *chan, const char
} else
snprintf(filename2, sizeof(filename2), "%s/%s", preflang, filename);
fmts = ast_fileexists(filename2, NULL, NULL);
if (fmts > 0)
fmts &= AST_FORMAT_AUDIO_MASK;
}
if (fmts < 1) {
ast_copy_string(filename2, filename, sizeof(filename2));
fmts = ast_fileexists(filename2, NULL, NULL);
if (fmts > 0)
fmts &= AST_FORMAT_AUDIO_MASK;
}
if (fmts < 1) {
ast_log(LOG_WARNING, "File %s does not exist in any format\n", filename);
@@ -530,30 +533,35 @@ struct ast_filestream *ast_openvstream(struct ast_channel *chan, const char *fil
*/
int fd = -1;
int fmts = -1;
unsigned int format;
char filename2[256];
char lang2[MAX_LANGUAGE];
/* XXX H.263 only XXX */
char *fmt = "h263";
if (!ast_strlen_zero(preflang)) {
snprintf(filename2, sizeof(filename2), "%s/%s", preflang, filename);
fmts = ast_fileexists(filename2, fmt, NULL);
const char *fmt;
for (format = AST_FORMAT_MAX_AUDIO << 1; format <= AST_FORMAT_MAX_VIDEO; format = format << 1) {
if (!(chan->nativeformats & format))
continue;
fmt = ast_getformatname(format);
if (!ast_strlen_zero(preflang)) {
snprintf(filename2, sizeof(filename2), "%s/%s", preflang, filename);
fmts = ast_fileexists(filename2, fmt, NULL);
if (fmts < 1) {
ast_copy_string(lang2, preflang, sizeof(lang2));
snprintf(filename2, sizeof(filename2), "%s/%s", lang2, filename);
fmts = ast_fileexists(filename2, fmt, NULL);
}
}
if (fmts < 1) {
ast_copy_string(lang2, preflang, sizeof(lang2));
snprintf(filename2, sizeof(filename2), "%s/%s", lang2, filename);
ast_copy_string(filename2, filename, sizeof(filename2));
fmts = ast_fileexists(filename2, fmt, NULL);
}
if (fmts < 1) {
continue;
}
fd = ast_filehelper(filename2, (char *)chan, fmt, ACTION_OPEN);
if (fd >= 0)
return chan->vstream;
ast_log(LOG_WARNING, "File %s has video but couldn't be opened\n", filename);
}
if (fmts < 1) {
ast_copy_string(filename2, filename, sizeof(filename2));
fmts = ast_fileexists(filename2, fmt, NULL);
}
if (fmts < 1) {
return NULL;
}
fd = ast_filehelper(filename2, (char *)chan, fmt, ACTION_OPEN);
if (fd >= 0)
return chan->vstream;
ast_log(LOG_WARNING, "File %s has video but couldn't be opened\n", filename);
return NULL;
}
@@ -792,12 +800,14 @@ int ast_filecopy(const char *filename, const char *filename2, const char *fmt)
int ast_streamfile(struct ast_channel *chan, const char *filename, const char *preflang)
{
struct ast_filestream *fs;
struct ast_filestream *vfs;
struct ast_filestream *vfs=NULL;
char fmt[256];
fs = ast_openstream(chan, filename, preflang);
vfs = ast_openvstream(chan, filename, preflang);
if (fs)
vfs = ast_openvstream(chan, filename, preflang);
if (vfs)
ast_log(LOG_DEBUG, "Ooh, found a video stream, too\n");
ast_log(LOG_DEBUG, "Ooh, found a video stream, too, format %s\n", ast_getformatname(vfs->fmt->format));
if (fs){
if (ast_applystream(chan, fs))
return -1;
@@ -813,7 +823,7 @@ int ast_streamfile(struct ast_channel *chan, const char *filename, const char *p
#endif
return 0;
}
ast_log(LOG_WARNING, "Unable to open %s (format %s): %s\n", filename, ast_getformatname(chan->nativeformats), strerror(errno));
ast_log(LOG_WARNING, "Unable to open %s (format %s): %s\n", filename, ast_getformatname_multiple(fmt, sizeof(fmt), chan->nativeformats), strerror(errno));
return -1;
}