Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio...
[asterisk/asterisk.git] / main / slinfactory.c
index f7363ab..338305b 100644 (file)
@@ -39,20 +39,14 @@ void ast_slinfactory_init(struct ast_slinfactory *sf)
        ast_format_set(&sf->output_format, AST_FORMAT_SLINEAR, 0);
 }
 
        ast_format_set(&sf->output_format, AST_FORMAT_SLINEAR, 0);
 }
 
-int ast_slinfactory_init_rate(struct ast_slinfactory *sf, unsigned int sample_rate) 
+int ast_slinfactory_init_with_format(struct ast_slinfactory *sf, const struct ast_format *slin_out)
 {
        memset(sf, 0, sizeof(*sf));
        sf->offset = sf->hold;
 {
        memset(sf, 0, sizeof(*sf));
        sf->offset = sf->hold;
-       switch (sample_rate) {
-       case 8000:
-               ast_format_set(&sf->output_format, AST_FORMAT_SLINEAR, 0);
-               break;
-       case 16000:
-               ast_format_set(&sf->output_format, AST_FORMAT_SLINEAR16, 0);
-               break;
-       default:
+       if (!ast_format_is_slinear(slin_out)) {
                return -1;
        }
                return -1;
        }
+       ast_format_copy(&sf->output_format, slin_out);
 
        return 0;
 }
 
        return 0;
 }
@@ -93,8 +87,11 @@ int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f)
 
                if (!sf->trans) {
                        if (!(sf->trans = ast_translator_build_path(&sf->output_format, &f->subclass.format))) {
 
                if (!sf->trans) {
                        if (!(sf->trans = ast_translator_build_path(&sf->output_format, &f->subclass.format))) {
-                               ast_log(LOG_WARNING, "Cannot build a path from %s to %s\n", ast_getformatname(&f->subclass.format),
-                                       ast_getformatname(&sf->output_format));
+                               ast_log(LOG_WARNING, "Cannot build a path from %s (%d)to %s (%d)\n",
+                                       ast_getformatname(&f->subclass.format),
+                                       f->subclass.format.id,
+                                       ast_getformatname(&sf->output_format),
+                                       sf->output_format.id);
                                return 0;
                        }
                        ast_format_copy(&sf->format, &f->subclass.format);
                                return 0;
                        }
                        ast_format_copy(&sf->format, &f->subclass.format);