> For the complete documentation index, see [llms.txt](https://prosbcdocs.telcobridges.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://prosbcdocs.telcobridges.com/telecom-references/telecom-concepts/call-routing.md).

# Call Routing

Call routing is an important feature for gateway applications. Call routing is in charge of assigning call routes for incoming call attributes and this may change based on external factors like the time of the day or congestion. Call routes are responsible for providing call attributes for incoming and outgoing legs; they contain common routing information like the called number, the calling number and the network access point.

The media profile may be changed by a route so that a route can also change the media of a leg. This can be used to force specific codecs to be used for certain routes or to specify the transcoding type. The transcoding type is only important for VOIP calls since it indicates when the adapter should include itself in the media path. Transcoding is limited limited to the following type:

* Forced: always transcode.
* Only as a fallback: to try to save hardware resources.
* Disabled: if the the hardware resources are not available.

### Usage

The default routing implementation routes on only three optional criteria (there must be at least one per rule):

* Called number.
* Calling number.
* Incoming network access point.

When it finds a route matching the call attribute’s criteria, it applies remapping on the desired fields and creates a route that is returned to the application. Remapping can be done on:

* Called number
* Calling number
* Destination network access point

In the default route implementation, the media profile is also changed depending on the transcoding type. This is done by the route in GetIncomingAttributes and GetOutgoingAttributes, which will instantiate the attribute based on the transcoding type. This works fine for this initial profile but the leg’s profile may be changed during the call’s life and that change must be handled depending on the transcoding type. The attribute class is the one that is aware of the transcoding type because it is stored in the leg, and will be queried (through SetMediaProfile) when a profile change occurs.

```
     {
        switch( mRoutingEntry.TranscodingType )
        {
            case TBCAF_ROUTING_TRANSCODING_TYPE_NORMAL:
            {
              pAttributes = tbnew CTBCMC_CALL_LEG_ATTRIBUTE;
            }break;
            case TBCAF_ROUTING_TRANSCODING_TYPE_FORCED:
            {
              pAttributes = tbnew CTBCMC_CALL_LEG_FT_ATTRIBUTE;
            }break;
            case TBCAF_ROUTING_TRANSCODING_TYPE_NEVER:
            {
              pAttributes = tbnew CTBCMC_CALL_LEG_NT_ATTRIBUTE;
            }break;

            default:
            {
              TBX_EXIT_ERROR( TBX_RESULT_INVALID_STATE, 0, "Invalid transcoding type." );
            }
         }
      }
```

### Caveats

For now only forced transcoding is supported by the CMC server but this might change in the future. Video support in CMC might force the issue because video transcoding is not cheap.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://prosbcdocs.telcobridges.com/telecom-references/telecom-concepts/call-routing.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
