vlc源码研究
Posted 风翼科技
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vlc源码研究相关的知识,希望对你有一定的参考价值。
有位传说中的大神告诉我,我的p2p打洞打不通是因为,sdp描述信息中的地址不对
也就是IN IP4 XXX.XXX.X.XXX这一句
我看到确实是个局域网地址,那么vlc在接收到IN IP4 XXX.XXX.X.XXX的时候到底是如何处理的呢,引起了我极大的好奇
一定要去源码里面找一下
在source insight 里面搜索了一下IN IP
接收肯定是从字符串里面解析东西,不是输入东西
所以估计在
Sap.c (modules\\services_discovery): if (sscanf (sfilter, " incl IN IP%u %*s %255s ", &ipv,
Sap.c (modules\\services_discovery): int res = sscanf (str, "IN IP%u %59[^/]/%u/%u", &fam, host, &n1, &n2);
Sap.c (modules\\services_discovery): if ((sscanf (data, "%63s %"SCNu64" %"SCNu64" IN IP%u %1023s",
sap.c文件里面
static sdp_t *ParseSDP (vlc_object_t *p_obj, const char *psz_sdp)
里面有
switch (expect) { /* Session description */ case \'V\': break; case \'O\': { expect = \'S\'; if (cat != \'o\') { msg_Dbg (p_obj, "missing SDP originator"); goto error; } if ((sscanf (data, "%63s %"SCNu64" %"SCNu64" IN IP%u %1023s", p_sdp->username, &p_sdp->session_id, &p_sdp->session_version, &p_sdp->orig_ip_version, p_sdp->orig_host) != 5) || ((p_sdp->orig_ip_version != 4) && (p_sdp->orig_ip_version != 6))) { msg_Dbg (p_obj, "SDP origin not supported: %s", data); /* Or maybe out-of-range, but this looks suspicious */ goto error; } EnsureUTF8 (p_sdp->orig_host); break; } case \'S\': { break; } case \'I\': { break; } case \'U\': expect = \'E\'; if (cat == \'u\') break; case \'E\': expect = \'E\'; if (cat == \'e\') break; case \'P\': expect = \'P\'; if (cat == \'p\') break; case \'C\': expect = \'B\'; if (cat == \'c\') { if (ParseSDPConnection (data, &glob_addr, &glob_len, &glob_count)) { msg_Dbg (p_obj, "SDP connection infos not supported: " "%s", data); goto error; } break; }
所以这段sdp
Owner/Creator, Session Id (o): - 1502808625152723 1502808625152723 IN IP4 192.168.1.146
被解析进了p_sdp->orig_host里面
另一段sdp
Connection Information (c): IN IP4 192.168.1.146
被ParseSDPConnection (data, &glob_addr, &glob_len, &glob_count)处理了,放入了glob_addr里面
再看这一段
case \'m\': media: { expect = \'i\'; if (cat != \'m\') { msg_Dbg (p_obj, "missing SDP media description"); goto error; } struct sdp_media_t *m; m = realloc (p_sdp->mediav, (p_sdp->mediac + 1) * sizeof (*m)); if (m == NULL) goto error; p_sdp->mediav = m; m += p_sdp->mediac; p_sdp->mediac++; memset (m, 0, sizeof (*m)); memcpy (&m->addr, &glob_addr, m->addrlen = glob_len); m->n_addr = glob_count;
最后被放进了p_sdp->mediav->addr 里面
所以要追踪p_sdp的动向
static int OpenDemux( vlc_object_t *p_this ) p_demux->p_sys->p_sdp = p_sdp;
以上是关于vlc源码研究的主要内容,如果未能解决你的问题,请参考以下文章
vlc源码分析 vlc-android native调试配置