没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论












1
Asterisk 代码学习笔记
Asterisk 代码学习笔记
....................................................................................................................
1
Asterisk1.2
...........................................................................................................................................
4
1、配置文件参数读取相关的
...................................................................................................
4
2、chan_sip.c/ do_monitor
........................................................................................................
4
3、收到一个 invite 时的处理函数
............................................................................................
4
4、ast_waitfor_n
........................................................................................................................
6
5、app_queue.c/wait_for_answer
.............................................................................................
7
6、发送 183 和播放彩铃代码流程
..........................................................................................
7
7、frame.c/ast_smoother
..........................................................................................................
8
8、app_queue.c
..........................................................................................................................
8
9、manager.c/init_manager
.......................................................................................................
8
10、formats/codecs 目录
..........................................................................................................
8
11、file.c /app_queue.c/play_file 函数
....................................................................................
8
12、把对方 hold 住对方听背景音乐时,敲命令 moh reload
...............................................
9
13、music on hold
....................................................................................................................
10
14、chan_sip.c/sip_new
...........................................................................................................
10
Asterisk1.4
.........................................................................................................................................
11
1、A 打 B 简单通话的代码流程
.............................................................................................
11
2、熟悉代码流程
.....................................................................................................................
14
3、重要的结构体、变量
.........................................................................................................
14
4、module show
....................................................................................................................
15
5、 Asterisk 小结
.....................................................................................................................
19
6、 Asterisk 架构
.....................................................................................................................
19
Asterisk 代码架构概述
....................................................................................................................
21
1 引言
.....................................................................................................................................
21
2 模块构架
.............................................................................................................................
21
3 抽象接口类型
.....................................................................................................................
21
3.1 编码解释器 CodecInterpreter
..............................................................................
21
3.2 文件格式处理器 File Format Handler
................................................................
22
3.3 C API Providers
.....................................................................................................
22
3.4 Manager Interface (AMI) Actions
....................................................................
23
3.5 CLI Commands
...........................................................................................................
23
3.6 Channel Drivers
.....................................................................................................
23
3.7 桥接技术
....................................................................................................................
23
3.8 CDR 处理器
................................................................................................................
24
3.9 CEL 处理器
................................................................................................................
24
3.10 拨号计划应用(APP)
................................................................................................
24
3.11 拨号计划功能(FUN)
................................................................................................
24
3.12 RTP 引擎
..................................................................................................................
25

2
3.13 定时接口
..................................................................................................................
25
4 Asterisk 线程模型
............................................................................................................
25
4.1 通道线程
.................................................................................................................
25
4.2 网络监视线程
.........................................................................................................
26
4.3 服务连接线程
.........................................................................................................
26
4.4 其它线程
.................................................................................................................
26
5 其它架构概念
.....................................................................................................................
26
5.1 通道桥接
.................................................................................................................
26
6 代码流程实例
.......................................................................................................................
27
6.1 SIP 呼叫到 Playback
...............................................................................................
27
6.2 SIP 到 IAX2 的呼叫桥接
.................................................................................
28
7 Asterisk 数据结构
............................................................................................................
29
7.1 Astobj2
...................................................................................................................
29
7.2 链表
.........................................................................................................................
29
7.3 双端链表
.................................................................................................................
29
7.4 堆 Heap
....................................................................................................................
30
8 Asterisk 调试工具
.........................................................................................................
30
8.1 线程调试
...................................................................................................................
30
8.2 内存调试
...................................................................................................................
30
Asterisk 内核框架
..........................................................................................................................
31
一、asterisk 内核模块
..........................................................................................................
31
1. 内核模块
.................................................................................................................
31
1) PBX 交换核心模块(PBX Switching Core)
.................................................
31
2) 调度和 I/O 管理模块(Scheduler and I/O Manager)
................................
31
3) 应用调用模块(Application Launcher)
....................................................
32
4)编解码转换模块(Codec Translator)
..............................................................
32
5)动态模块加载器模块(Dynamic Module Loader)
............................................
33
6) CDR 生成模块(CDR Core)
.................................................................................
33
2. 外围可加载模块
.....................................................................................................
33
1)Applications
.....................................................................................................
33
2) Channel
...............................................................................................................
34
3)Functions
...........................................................................................................
34
二、asterisk 启动过程
..........................................................................................................
34
三、asterisk 基本呼叫流程
..................................................................................................
47
四、详细呼叫流程分析
...........................................................................................................
49
深入浅出 asterisk:app.c 代码分析
.............................................................................................
64
深入浅出 asterisk(一):asterisk 通道(Channels)
..............................................................
66
深入浅出 asterisk(二):chan_sip 代码分析(上)
..................................................................
67
1. 代码简介
...........................................................................................................................
67
2. 代码剖析
.............................................................................................................................
68
深入浅出 asterisk(三):chan_sip 代码分析(下)
..................................................................
71
深入浅出 asterisk(四):部署 CDR MySql 模块
...........................................................................
78
一.下载 asterisk-addons 包
...............................................................................................
78
二. 编译安装 asterisk addons
..........................................................................................
78

3
1. 修改 Makefile 文件
.................................................................................................
78
2.执行三部曲
.................................................................................................................
79
三. 修改所有配置文件
.........................................................................................................
79
四.在 Mysql 数据库中新建数据数据库、表
........................................................................
79
asterisk sip 协议栈 register 功能分析
.................................................................................
81
将 Asterisk 联入真实世界(PSTN)需要了解的
............................................................................
87
1.模拟接口
.............................................................................................................................
87
2.模拟信令
...........................................................................................................................
87
3. 恼人的忙音识别和拆线
.....................................................................................................
88
4.CLID(主叫号码)
...................................................................................................................
91
5.DTMF
.......................................................................................................................................
91
6.回声
.....................................................................................................................................
91
7.增益
.....................................................................................................................................
91
卸载 asterisk 会装就要会卸载 你会吗?
...................................................................................
92
1 针对用编译的方式安装时的卸载
.......................................................................................
92
2 针对 yum 安装的方式就更加简单了
.................................................................................
93
Asterisk Source Code Control With SVN
................................................................................
93
Asterisk cli 命令
.........................................................................................................................
94
Dialplan
...........................................................................................................................................
94
1、监听和强插
.........................................................................................................................
94
2、在 Dialplan 里创建一个 Callback 回拨服务
................................................................
98
3、构建 VoIP Web callback 系统 ---基于 Web 方式的 phone2phone
...........................
100
........................................................................................................................................
100
<1> 系统概念
............................................................................................................
100
<2> Callback 触发器
............................................................................................
101
[1]ANI(missed call) 触发(电话预约回拨)
.........................................
101
[2]DNIS(DID)callback
...............................................................................
102
[3]SMS callback
.........................................................................................
102
[4]Web callback
.................................................................................................
102
[5]Email callback
........................................................................................
103
<3> Callback 引擎
................................................................................................
104
<4>认证、计费
......................................................................................................
104
4、在 Dialplan 里实现 Find-Me-Follow-Me 功能
............................................................
105

4
Asterisk1.2
1、配置文件参数读取相关的
ast_config_engine_register
reload_queues->ast_config_load->ast_config_internal_load->load_func(queues.conf
时就是
config_text_file_load)-> process_text_line-> ast_category_browse-> ast_variable_browse-> queue_set_param
asterisk.c/main-> read_config_maps-> ast_config_internal_load-> config_text_file_load
-> ast_variable_browse-> append_mapping
2、chan_sip.c/ do_monitor
do_monitor -> ast_io_add-> sip_do_reload-> sip_poke_all_peers -> sip_send_all_registers->
ast_softhangup_nolock-> ast_queue_frame-> pthread_testcancel-> ast_sched_wait->
ast_io_wait-> sipsock_read-> ast_sched_runq //
在 调 用
callback
时 调 用 的 函 数 是 用
ast_sched_add
时设置的回调。
3、收到一个 invite 时的处理函数
系统初始化时:
load_module ->restart_monitor 起一个线程–>do_monitor 一个死循环,接收 sip 信令,\
This thread monitors all the SIP sessions and peers that needs notification of mwi (and thus do
not have a separate thread) indefinitely\
->ast_io_add//设置回调函数 sipsock_read, Add an I/O event to our SIP UDP socket, 有事件时则
回调 sipsock_read 读取 socket 数据->rtp.c/ast_rtp_sendcng->ast_sched_wait
->ast_io_wait//将调用 sipsock_read->ast_sched_runq-> sip_send_mwi_to_peer
在 reload-> sip_reload-> restart_monitor 也会调用 restart_monitor
*************Chan_sip.c/ sip_tech
收到一个 invite 时的处理函数:
sipsock_read ->parse_request//解析了消息的头部和体部,解析方法名

5
-> find_sip_method//找到方法名对应的 ID
-> find_call->get_header
->gettag
->sip_alloc//找不到/不存在,就分配一个,这里的是主叫的 sip_pvt
->handle_request-> get_header
//当收到响应消息时,会调用 handle_response
->handle_response-> hangup_sip2cause
->__sip_semi_ack->__sip_ack
->handle_response_peerpoke-> transmit_request-> reqprep
->send_request-> __sip_xmit-> sendto
-> handle_response_invite-> handle_request_options
-> handle_request_refer-> handle_request_cancel
-> handle_request_bye-> handle_request_message
-> handle_request_subscribe-> handle_request_register
-> handle_request_info
//当收到 invite 时,会调用 handle_request_invite
->handle_request_invite-> transmit_response_with_unsupported->respprep
-> init_resp-> copy_via_headers-> __get_header-> copy_all_header
-> __get_header-> add_header-> copy_header->send_response-> parse_copy
->append_history-> __sip_xmit-> sendto-> transmit_response
-> __transmit_response-> respprep -> send_response->check_via->find_sdp
->process_sdp
//收到第一个 invite 时鉴权
->check_user->check_user_full->find_peer->realtime_peer
->ast_load_realtime->check_auth_first->sip_new//分配主叫的 ast_channel
-> build_route->ast_pbx_start 创建一个线程运行 pbx_thread
pbx_thread-> __ast_pbx_run-> ast_exists_extension-> pbx_extension_helper
-> ast_spawn_extension-> pbx_extension_helper-> pbx_exec->执行到 Dial 时,调用回调函数
dial_exec,这个是通过 load_module->ast_register_application 注册的
-> ast_pbx_start
dial_exec->dial_exec_full->ast_request(sip_request_call)-> sip_alloc//这里是被叫的 sip_pvt
-> sip_new//分配被叫的 ast_channel->create_addr->find_peer-> realtime_peer
-> ast_load_realtime-> build_peer-> handle_common_options->sched.c/ast_sched_del
->acl.c/ast_get_ip_or_srv->acl.c/ast_append_ha->callerid.c/ast_parse_caller_presentation
->cdr.c/ast_cdr_amaflags2int->channel.c/ast_get_group->frame.c/ast_parse_allow_disallow
->config.c/ast_variable_new->sched.c/ast_sched_del->sched.c/ast_sched_add
->create_addr_from_peer->srv.c/ast_get_srv->autoservice.c/ast_autoservice_start
->ast_pthread_create/autoservice_run->dns.c/ast_search_dns->dns_parse_answer
->autoservice.c/ast_autoservice_stop-> pthread_kill-> ast_sip_ouraddrfor-> build_via
-> build_callid-> sip_new->channel.c/ast_channel_alloc->sched.c/sched_context_create
->sched.c/sched_context_destroy->ast_codec_choose->ast_best_codec->dsp.c/ast_dsp_new
剩余107页未读,继续阅读
资源评论


绝千殇
- 粉丝: 4
- 资源: 1
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


安全验证
文档复制为VIP权益,开通VIP直接复制
