经过几天的 pjsip 测试后,我终于了解了它的工作原理。我希望它能帮助我从站点进行 WebRTC 调用。
情况:
这是 pjsip "webrtc" 配置(目前):
[webrtc]
type=endpoint
transport=transport-udp
context=webrtc
disallow=all
allow=alaw
allow=ulaw
dtls_cert_file=/etc/letsencrypt/live/example.org/fullchain.pem
dtls_private_key=/etc/letsencrypt/live/example.org/privkey.pem
auth=webrtc
aors=webrtc
use_avpf=yes
direct_media=no
[webrtc]
type=aor
contact=sip:webrtc@example.org:5060
max_contacts=1000
outbound_proxy=sip:example.org
[webrtc]
type=auth
auth_type=userpass
username=webrtc
password=psswd
realm=example.org
Run Code Online (Sandbox Code Playgroud)
当我打电话时出现问题:
[Sep 1 17:50:37] ERROR[7760] pjproject: sip_endpoint.c Error processing packet from 127.0.0.1:57928: Rx buffer overflow (PJSIP_ERXOVERFLOW) [code 171062]:
INVITE sip:1@example.org SIP/2.0
Via: SIP/2.0/WSS df7jal23ls0d.invalid;branch=z9hG4bKX7Ng7L0OKRBkpUqGlHPV4GfxO0I7d93i;rport
From: <sip:webrtc@example.org>;tag=ypLlm1BDxPkn8aTTkVJL
To: <sip:1@example.org>
Contact: <sips:webrtc@df7jal23ls0d.invalid;rtcweb-breaker=no;click2call=no;transport=wss>;+g.oma.sip-im;language="en,fr"
Call-ID: 30f526f4-3c4f-e96f-391d-39290b9dc983
CSeq: 60845 INVITE
Content-Type: …Run Code Online (Sandbox Code Playgroud) 我可以vec![1,2,3]用来构建一个矢量.
我可以在Rust中构建一个像这样的hashmap:
hashmap![("key", "value")]
Run Code Online (Sandbox Code Playgroud)
没有创建单独的变量并且.insert()每次调用?
我有一个像:
pub enum Tag<'a> {
Container { c: Vec<Tag<'a>> },
// ...
}
Run Code Online (Sandbox Code Playgroud)
当我尝试匹配时:
impl<'a> Display for Tag<'a> {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match *self {
Tag::Container { ref c } => write!(f, "{}", "container"),
// ...
}
}
}
Run Code Online (Sandbox Code Playgroud)
我明白了:
warning: unused variable: `c`, #[warn(unused_variables)] on by default
|
65 | Tag::Container{ref c} => write!(f, "{}", "container"),
Run Code Online (Sandbox Code Playgroud)
在其他一些地方.
我试图使用_,只是为了删除,ref c但这一切都会导致错误.
我使用Gin创建了一个 HTTP 服务器,我想为用户提供一个动态生成的 zip 存档。
理论上我可以先在文件系统上生成一个 zip 文件,然后再提供它。但这确实是一种糟糕的方式(在开始下载之前等待 5 分钟)。我想立即开始将其提供给用户并在生成时推送内容。
我找到了 DataFromReader(示例),但在存档完成之前不知道 ContentLength。
func DownloadEndpoint(c *gin.Context) {
...
c.DataFromReader(
http.StatusOK,
ContentLength,
ContentType,
Body,
map[string]string{
"Content-Disposition": "attachment; filename=\"archive.zip\""),
},
)
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?
如何为一行字节进行正则表达式匹配?
例如,如何用regexp检查二进制数据是否包含(0-10个字节)字符?
data = 0x00 0x05 0x02 0x00 0x03 ...(不是字符串,二进制数据)
我使用 mysqldump 保存表中的数据并将其移动到 Postgres 数据库。
我用以下方法进行转储:
mysqldump --complete-insert --no-create-info --no-create-db --compatible=postgresql -uroot -p music files > music_files.sql
Run Code Online (Sandbox Code Playgroud)
但是在做的时候psql:
=> \i music_files.sql
Run Code Online (Sandbox Code Playgroud)
有这个错误:
music_files.sql:29: ERROR: syntax error at or near "s"
LINE 1: ...,5,'Impossible',NULL),(33,4103,178,841,198,'Tifa\'s Theme [P...
Run Code Online (Sandbox Code Playgroud)
Postgres 不理解这种转义。它''之前需要 2 个引号s
我怎样才能用 mysqldump 来实现它?
我希望我的默认编码保持 utf-8。
但是在 Windows 下 - 我想使用 cp1251 查看我的一些文件名。(因为 Windows 不支持 utf)
一切都显示为: \361\345\354
那么我怎样才能做到这一点:
(setq coding-system-for-read 'cp1251)
Run Code Online (Sandbox Code Playgroud)
仅适用于直接模式而不适用于其他模式?
我在Emacs中有一个shell但是major-mode给了我一个comint-mode.
有没有办法确定哪种类型的shell?
也许Emacs的功能被称为启动它?
或者至少是解释器的可执行文件是什么?
问题是我无法通过点击谷歌浏览器中的时间线来改变播放位置(它总是从头到尾播放)
如果Nginx 向客户端提供mp3 文件一切正常,我可以改变播放位置。
在我的脚本中,我以这种方式提供 mp3:
from django.core.servers.basehttp import FileWrapper
wrapper = FileWrapper(file( 'mp3file.mp3' ))
response = HttpResponse(wrapper, content_type='audio/mpeg')
response['Content-Length'] = os.path.getsize( 'mp3file.mp3' )
return response
Run Code Online (Sandbox Code Playgroud)
网址是: http://server/mp3/###.mp3
所以整个文件都给了客户端,但仍然无法更改播放位置。怎么了?
PS:不要使用任何专有的 sh*t 像 mp3 - 使用“.ogg”格式
我从来没有在流中使用过这样的代码:
print >>self._stream, indentation + line
Run Code Online (Sandbox Code Playgroud)
想看看文档.谷歌不善于搜索">>".
问题是 - 如何在Python 3中编写它?
它会导致错误:
Python unsupported operand type(s) for >>
Run Code Online (Sandbox Code Playgroud)
默认情况下(在函数中)流是 sys.stdout
背景:对于我的计算机科学课,我们被要求创建一个程序,帮助小学生学习基础数学.
他们会选择他们想要学习的操作(加法,减法,乘法或除法),或选择随机选择其中一个操作的随机.
选择一个操作后,将询问用户一个问题,然后输入答案,如果程序正确,则会询问另一个问题,总共最多4个问题,然后程序将返回菜单.
如果答案不正确,则会要求用户再次输入答案,最多三次,如果答案仍然不正确,将显示正确答案,然后会询问另一个问题(如果未满足4个问题配额) )如果没有其他问题,请返回菜单.
问题:我已经写完了所有内容,当我在IDLE中运行程序时,一切似乎都在工作,但是由于某种原因选择了一个操作后,程序停留在一个无限循环上,并且在4个问题之后不会返回菜单被问到了.
我首先使用for循环来满足4个问题配额并且不起作用,所以我尝试了一个while循环读取 while x<4: etc etc,在while循环之前将x定义为x = 0,然后在函数添加结束时x=x+1.
再次从阅读代码,它似乎应该适用于每个功能,但运行后,我仍然陷入无限循环.
继承人代码:
def show_instructions():
"""
Displays a greeting to the user and provides instructions on how to use the
program. [PURPOSE]
"""
print " "
print "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-"
print " Math Mania"
print " "
print "Welcome to Math Mania! This program is designed to help you learn basic"
print "math skills in addition, subtraction, multiplication, and division."
print "-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-"
print " "
print "To …Run Code Online (Sandbox Code Playgroud)