1. 对消息的处理
ngx_rtmp_receive_message里面,对消息的头部h的type做判断之后,会调用cmcf->events[h->type]里面的handler,而这些handler是模块注册的
ngx_rtmp.c里面,解析配置时,可能注册
ngx_rtmp_protocol_message_handler
ngx_rtmp_amf_message_handler
ngx_rtmp_user_message_handler
ngx_rtmp_aggregate_message_handler
2. 对amf命令的处理
cmcf->amf_hash是存放amf命令名称与处理函数对应关系的地方。每个模块会在postconfiguration的时候,将要处理的命令与处理函数的对应关系放到cmcf->amf这个array里面
cmcf->amf会在配置解析完成后,统一放到cmcf->amf_hash中。
cmcf->amf_hash在ngx_rtmp_receive.c的ngx_rtmp_amf_message_handler函数中拿出来调用。而ngx_rtmp_amf_message_handler也是1中注册的一种消息处理函数,专门用于处理amf类型的消息
ngx_rtmp_cmd_module中注册了以下命令的处理方法:
connect
createStream
closeStream
deleteStream
publish
play
seek
pause
pauseraw
ngx_rtmp_codec_module中注册了以下命令的处理方法:
@setDataFrame
onMetaData
ngx_rtmp_relay_module中注册了以下命令的处理方法:
_result
_error
onStatus
3. 命令的chain_handler
一个模块xxx,在postconfiguration的时候,对于一个命令yyy,可能会定义一个函数ngx_rtmp_xxx_yyy来处理这个命令,将全局的ngx_rtmp_yyy指向ngx_rtmp_xxx_yyy,并定义一个next_yyy,指向原来的ngx_rtmp_yyy
例如:
next_play = ngx_rtmp_play;
ngx_rtmp_play = ngx_rtmp_live_play;
chain handler包括这些
ngx_rtmp_connect_pt ngx_rtmp_connect;
ngx_rtmp_disconnect_pt ngx_rtmp_disconnect;
ngx_rtmp_create_stream_pt ngx_rtmp_create_stream;
ngx_rtmp_close_stream_pt ngx_rtmp_close_stream;
ngx_rtmp_delete_stream_pt ngx_rtmp_delete_stream;
ngx_rtmp_publish_pt ngx_rtmp_publish;
ngx_rtmp_play_pt ngx_rtmp_play;
ngx_rtmp_seek_pt ngx_rtmp_seek;
ngx_rtmp_pause_pt ngx_rtmp_pause;
ngx_rtmp_stream_begin_pt ngx_rtmp_stream_begin;
ngx_rtmp_stream_eof_pt ngx_rtmp_stream_eof;
ngx_rtmp_stream_dry_pt ngx_rtmp_stream_dry;
ngx_rtmp_recorded_pt ngx_rtmp_recorded;
ngx_rtmp_set_buflen_pt ngx_rtmp_set_buflen;
阅读(1434) | 评论(0) | 转发(0) |