aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-24 03:45:42 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-24 03:45:42 +0000
commit6a53ae2cd676fa9045c0ef44b5dcb6c1fa6e6508 (patch)
treeede51de306059523a1018419c8ee2375fcb11778 /main
parent3dc74cbf263fca4835576cb1e247f3c7e8d63e20 (diff)
add an API call to allow channel drivers to determine which media formats are compatible (passthrough or transcode) with the format an existing channel is already using
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@46082 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/translate.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/main/translate.c b/main/translate.c
index 77feabbac..f51822f3f 100644
--- a/main/translate.c
+++ b/main/translate.c
@@ -777,3 +777,45 @@ unsigned int ast_translate_path_steps(unsigned int dest, unsigned int src)
return tr_matrix[src][dest].multistep + 1;
}
+unsigned int ast_translate_available_formats(unsigned int dest, unsigned int src)
+{
+ unsigned int res = dest;
+ unsigned int x;
+ unsigned int src_audio = powerof(src & AST_FORMAT_AUDIO_MASK);
+ unsigned int src_video = powerof(src & AST_FORMAT_VIDEO_MASK);
+
+ for (x = 1; x < AST_FORMAT_MAX_AUDIO; x <<= 1) {
+ /* if this is not a desired format, nothing to do */
+ if (!dest & x)
+ continue;
+
+ /* if the source is supplying this format, then
+ we can leave it in the result */
+ if (src & x)
+ continue;
+
+ /* if we don't have a translation path from the src
+ to this format, remove it from the result */
+ if (!tr_matrix[src_audio][powerof(x)].step)
+ res &= ~x;
+ }
+
+ /* roll over into video formats */
+ for (; x < AST_FORMAT_MAX_VIDEO; x <<= 1) {
+ /* if this is not a desired format, nothing to do */
+ if (!dest & x)
+ continue;
+
+ /* if the source is supplying this format, then
+ we can leave it in the result */
+ if (src & x)
+ continue;
+
+ /* if we don't have a translation path from the src
+ to this format, remove it from the result */
+ if (!tr_matrix[src_video][powerof(x)].step)
+ res &= ~x;
+ }
+
+ return res;
+}