diff options
author | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-01-07 17:54:22 +0000 |
---|---|---|
committer | markster <markster@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-01-07 17:54:22 +0000 |
commit | d1d90f47fd87ec50db7aa5badcc996854d93c0bf (patch) | |
tree | 34e09d3fba69a40757b42b46d8656a74744e6c7b /file.c | |
parent | cde8c70439d39f407bf73a892ef09caf81bb1899 (diff) |
Add support for H.264 with SIP and recording
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7855 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 58 |
1 files changed, 34 insertions, 24 deletions
@@ -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; } |