精华内容
下载资源
问答
  • turn up&turn off&turn on用法

    千次阅读 2019-10-05 08:57:52
    turn up: vt. 朝上翻(出现,来到,,卷起,找到,被找到,出现,发生) ... could you turn it up a bit? 收音机我听不太清楚, 你把声音开大点行吗? 2. We invited her to dinner but she didn't even both...

    turn up: 

    vt. 朝上翻(出现,来到,,卷起,找到,被找到,出现,发生)

     
    例句与用法:
    1. I can't hear the radio very well; could you turn it up a bit? 
     收音机我听不太清楚, 你把声音开大点行吗?
     
    2. We invited her to dinner but she didn't even bother to turn up. 
     我们请她吃饭她都不露面.
     
    3. He turned up his coat collar against the chill wind. 
     他竖起大衣领抵御寒风.
     
    4. Investment is turning up sharply. 
     投资额急遽增长.
     
    5. I'm sure your watch will turn up one of these days. 
     我担保你的手表准有一天能找到.
     
    6. He's still hoping something (eg a job or a piece of good luck) will turn up. 
     他仍在期待机会出现(如得到工作或好运).
     
    7. The farmer turned up a human skull while ploughing the field. 
     那农民 地时挖出一个人类的头颅骨.
     
    8. The soil had been turned up by the plough. 
     那片地是用 翻的.
     

     
    英英解释:
    名词turn up:

    1. the lap consisting of a turned-back hem encircling the end of the sleeve or leg
    同义词:cuff, turnup

    动词turn up:

    1. appear or become visible; make a showing
    同义词:come on, come out, surface, show up

    2. bend or lay so that one part covers the other
    同义词:fold, fold up

    3. discover the location of; determine the place of; find by searching or examining
    同义词:locate

    4. be shown or be found to be
    同义词:prove, turn out

    5. find by digging in the ground
    同义词:excavate, dig up

     
    turn off: 

    关掉

     
    例句与用法:
    1. You should have had enough sense to turn off the electricity supply before disconnecting the wires. 
     你本来应该有足够的常识,在拆开电线之前先把电源切断。
     
    2. Please turn off the electric power. 
     请把电源关掉。
     
    3. Turn off the switch when anything goes wrong with the machine. 
     如果机器出故障,就把开关关掉。
     
    4. Do you mind if I turn off the light? 
     我把灯关掉你不反对吗?
     

     
    英英解释:
    名词turn off:

    1. something causing antagonism or loss of interest
    同义词:turnoff, negative stimulation

    2. a side road where you can turn off
    同义词:turnoff

    动词turn off:

    1. cause to stop operating by disengaging a switch
    同义词:switch off, cut, turn out

    2. make a turn

    3. cause to feel intense dislike or distaste
    同义词:put off

     
    turn on: [ tə:n ɔn ] 

    打开,拧开
    v. 反对,攻击

     
    例句与用法:
    1. She's often turned on by men with beards. 
     有胡子的男子每每引起她的性欲。
     
    2. Why are you all turning on me (ie criticizing or blaming me)? 
     你们为什麽都突然冲我来了(批评或责备我)?
     
    3. The success of a picnic usually turns on the weather. 
     参加野餐是否尽兴,通常要看天气好坏。
     
    4. The discussion turned on the need for better public health care. 
     讨论环绕着善公众卫生保健的必要性。
     
    5. Jazz has never really turned me on. 
     我从未对爵士乐真正产生过兴趣。
     
    6. His normally placid dog turned on him and bit him in the leg. 
     他那条狗平日很温顺, 这次突然发作咬了他的腿.
     
    7. He asked me to turn on the radio for him. 
     他让我替他打开收音机。
     
    8. He forgot to turn on the radio and thus missed the program. 
     他忘了打开收音机, 因此错过了那个节目。
     

     
    英英解释:
    名词turn on:

    1. something causing excitement or stimulating interest
    同义词:turn-on

    动词turn on:

    1. cause to operate by flipping a switch
    同义词:switch on

    2. be contingent on
    同义词:depend on, devolve on, depend upon, ride, hinge on, hinge upon

    3. produce suddenly or automatically

    4. become hostile towards

    5. cause to be agitated, excited, or roused
    同义词:agitate, rouse, charge, commove, excite, charge up

    6. stimulate sexually
    同义词:arouse, sex, excite, wind up

    7. get high, stoned, or drugged
    同义词:trip, trip out, get off

    转载于:https://www.cnblogs.com/CodingPerfectWorld/archive/2010/06/22/1762668.html

    展开全文
  • turn over/turn around/turn up等动词词组

    千次阅读 2020-08-26 20:00:54
    本博文讲述treat to/treat with/trust to/trust with/try on /try out/turn away(from)/turn back/turn down/turn off/turn on/turn out/turn over/turn around/turn up等动词词组

    本博文源于《词博士的私教课·英语动词词组速记420》本博文属于“Day7 Week 3”,撒花/撒花,今天是最后一天!

    Reading

    translate from/into 翻译;转变为

    • If something said or written is translated from one language into another,It is said or written again in the second language.
    • If one thing is translated into another,the second happens or is done as result of the first.

    treat to 款待

    • If you treat someone to something special which they will enjoy,you but it or arrange it for them.

    treat with (用某种物质)处理

    • If something is treated with a particular substance,the substance is put onto or into it in order to clean it,to protect it,or to give it special properties.

    trust to 信赖

    • If you trust someone to do something,you believe that they will do it.

    trust with 托付

    • If you trust someonee with something important or valuable,you allow them to look after it or deal with it.

    try on 试穿

    • If you try on a piece of clothing,you put it on to see if it fits you or if it looks nice.

    try out 测试(性能)

    • If you try something out,you test it in order to find out how useful or effective it is or what it is like.

    turn away(from) 拒之门外;不再使用

    • If you turn someone away,you do not allow them to enter your country,home,or other place.
    • To turn away from something such as a method or an idea means to stop using it or to become different from it.

    turn back 往回走;回头

    • If you turn back of if someone turns you back when you are going somewhere,you change direction and go toward where you started from.
    • If you cannot turn back,you cannot change your plans and decide not to do something,because the action you have already taken makes it impossible.

    turn down 拒绝;调低(音量或热度)

    • If you turn down a person or their request or offer,you refuse their request or offer.
    • =When you turn down a radio,heater,or other piece of equipment,you reduce the amount of sound or heat being produced,by adjusting the controls.

    turn off 关掉;对…失去兴趣

    • When you turn off a piece of equipment or a supply of something,you stop heat,sound,or water from being produced by adjusting the controls.
    • If something turns you off a particular subject or activity,it makes you have no interest in it.

    turn on 打开

    • When you turn on a piece of equipment or a supply of something,you cause heat,sound,or water to be produced by adjusting the controls.

    turn out 结果为;被发现是;关掉

    • If something turns out a particular way,it happens in that way or has the result or degree of success indicated.
    • If something turns out to be a particular thing,it is discovered to be that thing.
    • When you turn out something such as a light,you move the switch or knob that controls it so that it stops giving out light or heat.

    turn over 翻转;翻身;仔细考虑;移交

    • If you turn something over,or if it turns over,it is moved so that the top part is now facing downward.
    • If you turn over,for example,when you are lying in bed,you move your body so that you are lying in a different position.
    • If you turn something over in your mind,you think carefully about it.
    • If you turn something over to someone,you give it to them when they ask for it,because they have a right to it.

    turn around 调转方向;(生意或经济)好转

    • If you turn something around,or if it turns around,it is moved so that it faces the opposite direction.
    • If something such as a business or economy turns around,or if someone turns it around,it becomes successful,after being unsuccessful for a period of time.

    turn up (意外或终于) 出现;找到,发现;调高(音量或热度)

    • If you say that someone or something turns up,you mean that they arrive unexpectedly or after you have been waiting a long time.
    • If you turn something up or if it turns up,you find ,discover,or notice it.
    • When you turn up a radio,heater ,or other piece of equipment,you increase the amount of sound,heat,or power being produced,by adjusting the controls .

    use up 耗尽,用光

    • If you use something up,you consume it completely.

    wait for 等候

    • When you wait for something or someone,you spend some time doing very little,because you cannot act until that thing happens or that person arrives.

    warm up 加热,变暖;热身,预备;(机器或引擎)预热

    • If you warm something up or if it warms up,it gets hotter.
    • If you warm up for an event such as a race,you prepare yourself for it by doing exercises or by practicing just before it starts.
    • When a machine or engine warms up or someone warms it up,it becomes ready for use a little while after being switched on or started.

    work out 找到(解决办法);计算;进展顺利;锻炼

    • If you work out a solution to a problem or mystery,you manage to find the solution by thinking or talking about it.
    • If you work out the answer to a mathematical problem,you calculate it.
    • If a situation works out,it happens or progresses in a satisfactory way.
    • If you work out,you do physical exercises in order to make your body fit and strong.

    Recalling

    一般建议将中文含义捂住,然后看英文读中文,如果不放心,顺带中文看英文

    动词词组中文含义
    work out找到(解决办法);计算;进展顺利;锻炼
    use up耗尽,用光
    warm up加热,变暖;热身,预备;(机器或引擎)预热
    trust with托付
    turn away(from)拒之门外;不再使用
    try out测试(性能)
    turn back往回走;回头
    turn off关掉;对…失去兴趣
    translate from/into翻译;转变为
    turn over翻转;翻身;仔细考虑;移交
    treat with(用某种物质)处理
    try on试穿
    turn on打开
    treat to款待
    wait for等候
    trust to信赖
    turn around调转方向;(生意或经济)好转
    turn out结果为;被发现是;关掉
    turn up(意外或终于) 出现;找到,发现;调高(音量或热度)
    turn down拒绝;调低(音量或热度)

    Recycling

    真题练习

    1. We invited her to dinner but she didn’t even bother to ___ .
    2. I was positive that things were going to ___ fine.
    3. Please ___ the lights when you go out of the room.
    4. You should ___ the wound ___ a medicated spray.
    5. A doctor cannot ___ a dying man in any circumstance.
    6. Tomorrow I’ll ___ myself ___ a whole day’s gardening.
    7. I should prefer you to __ me at the bus stop.
    8. You ought to ___ that radio before you decide to buy it.
    9. In winter,he blew on his hands in order to ___ them ____.
    10. In his career,Horton strove to ___ two entire companies.
    11. Don’t ___ the lamp,because we can see in the firelight.
    12. He couldn’t ____ the equation,so his sister helped him out.
    13. A sudden shift in weight caused the boat to ___.
    14. Do you think in Enlish or ____ mentally ___ your own language?
    15. I don’t advise you to ____ him ___ valuable things.
    16. Remember to ___ the shoes before you buy them.
    17. You should not touch the film winder before you ___ all the film.
    18. Nobody can wishfully ___ the wheel of history.
    19. Don’t forget to ___ the gas for another hour,or the dish will be overcooked.
    20. Can you find me a servant whom I can ___ do the work While I am away from home?

    练习答案

    1. turn up
    2. turn out
    3. turn off
    4. treat with
    5. turn away
    6. treat to
    7. wait for
    8. try out
    9. warm up
    10. turn around
    11. turn on
    12. work out
    13. turn over
    14. translate from
    15. trust with
    16. try on
    17. use up
    18. turn back
    19. turn down
    20. trust to

    博主上一篇博文(day6 week3):

    trade for/trade with/train for等动词词组

    展开全文
  • 用turtle实现用正方形画圆

    千次阅读 多人点赞 2018-11-19 13:34:54
    add – True or False – if True, a new binding will be added, otherwise it will replace a former binding 添加新的绑定函数,否则替代之前函数 例子:def turn(x, y): 。。。 left(180) onclick(turn) on...

    最近发现一个很有意思的画图的python库,叫做turtle,这里先说下用turtle这个库来实现用正方形画圆的思路。

    每次都用乌龟(turtle)乌龟来画出一个正方形,然后通过旋转3°后,继续画一样的正方形,在通过120次循环后就实现了完整的圆,这里当然也可以用其他的角度和次数,只要能完成360度就可以了。

    先看完成的图形和代码。

    正方形画圆
    代码如下:

    import turtle
    
    window = turtle.Screen() #设置好画图的基本参数
    window.bgcolor(“blue”)
    wugui= turtle.Turtle()
    wugui.shape(“turtle”)
    wugui.color(“red”)
    wugui.speed(5)
    for i in range(120):    #这里设定正方形的个数
    	wugui.forward(100)
    	wuguiright(90)
    	wugui.forward(100)
    	wugui.right(90)
    	wugui.forward(100)
    	wugui.right(90)
    	wugui.forward(100)
    	wugui.right(93)#这里决定每次旋转角度,也就决定了需要画正方形的次数。
    
    window.exitonclick()
    
    

    代码应该很简单易懂,就不再说了。turtle真的是非常强大的一个绘图工具,可以绘制各种各样有趣的图形,详情请看 turtle官方文档,这里说点基本的参数与用法吧。主要包括两部分,乌龟与画布。

    乌龟方法

    乌龟运动

    乌龟移动与绘画

    forward() | fd() 向前移动指定的距离。参数:(integer or float))一个数字

    backward() | bk() | back() 向后移动指定的距离。参数:(integer or float))一个数字

    right() | rt() left() | lt() 向右 旋转指定的角度。参数:(integer or float))一个数字

    goto() | setpos() | setposition() 去到位置(x,y)。参数:(x, y=None))一个数字

    setx() 设置X位置。参数:(integer or float)一个数字

    sety() 设置Y位置。参数:(integer or float)一个数字

    setheading() | seth() 方向设置为to_angle.就是东西南北方向,上北下南左西右东

    home() 移动到原点 – 坐标(0,0):并将其标题设置为其起始方向

    circle() 绘制一个给定半径的圆。参数:(radius,extent,steps)(一个数字__半径,如果值为正则逆时针,负数为顺时针__,一个数字, 执行的步数)

    dot() 用颜色画出一个直径大小的圆点。参数:(size,color)(一个大于1的整数_可None,颜色值)

    stamp() 将当前位置上的形状复制到画布上,返回stamp_id.可通过下方的clearstamp删除

    clearstamp() 删除stamp()返回来的值,参数:(stamp_id)stamp函数返回值

    clearstamps() 删除所有的stamp,默认无参数,删除所有

    undo() 撤销上一步动作

    speed() 乌龟爬行速度,我们这设置的是5,不设置为最快,直接生成

    乌龟当前状态

    position() | pos() 当前位置
    towards() 返回与指定点之间的角度 参数:(X,Y)一个位置
    xcor() 返回乌龟X坐标
    ycor() 返回乌龟Y坐标
    heading() 返回当前乌龟的方向值
    distance() 返回乌龟与坐标点之间的距离。参数:(X,Y)一个位置

    设置与测量

    degrees() 设置整个圆的角度,最好不要动。参数:(integer or float)一个整数
    radians() 将角度测量单位设置为弧度。360度就是2π

    画笔控制

    绘画状态

    pendown() | pd() | down() 将笔落下放在图上,移动的时候将会绘图
    penup() | pu() | up() 将笔提起来,移动的时候将不会绘图
    pensize() | width() 设置线条的粗细。参数:(width)一个正数
    pen() 使用键值对设置笔的属性

    “shown”: True/False  显示
    “pendown”: True/False    笔落下
    “pencolor”: color-string or color-tuple   笔的颜色
    “fillcolor”: color-string or color-tuple    填充颜色
    “pensize”: positive number                      笔大小(正整数)
    “speed”: number in range 0..10              绘画速度(范围0-10)
    “resizemode”: “auto” or “user” or “noresize”  大小调整模式
    “stretchfactor”: (positive number, positive number)    拉伸参数
    “outline”: positive number   外部
    “tilt”: number   倾斜
    

    isdown() 如果笔停止返回True,反之返回False

    颜色控制

    color() 颜色,直接使用返回当前笔颜色与填充颜色
    pencolor() 设置笔的颜色
    fillcolor() 设置笔的填充颜色

    填充

    filling() 返回填充状态,
    begin_fill() 在填充之前使用
    end_fill() 结束填充

    更多绘画控制

    reset() 重置所有参数
    clear() 删除绘画,与reset不同之处仅仅是删除图形,参数保留
    write() 写文字

    arg – object to be written to the TurtleScreen   写到TurtleScreen的参数
    move – True/False     移动
    align – one of the strings “left”, “center” or right”    对齐参数3选1(left,right,center)
    font – a triple (fontname, fontsize, fonttype)  字体
    

    乌龟状态

    可视性

    showturtle() | st() 显示乌龟的形状
    hideturtle() | ht() 隐藏乌龟的形状
    isvisible() 是否可见,返回True or False

    外表

    shape() 设置乌龟的图形形状,可选( “arrow”, “turtle”, “circle”, “square”, “triangle”, “classic”)
    resizemode() 大小调整模式

    “auto”: adapts the appearance of the turtle corresponding to the value of pensize.           由画笔大小决定(自动)
    “user”: adapts the appearance of the turtle according to the values of stretchfactor and outlinewidth (outline), 由拉伸参数决定
    “noresize”: no adaption of the turtle’s appearance takes place.                                              不调整
    

    shapesize() | turtlesize() 返回笔的属性。
    shearfactor() 设置或者返回当前剪切因子
    settiltangle() 与tilt() 一样,只是可以为空,则返回当前旋转角度
    tiltangle() 弃用
    tilt() 设置当前乌龟角度,不调整乌龟前进方向(仅仅改变乌龟样子)
    shapetransform() 设置或返回乌龟的形状的当前转换矩阵
    get_shapepoly() 返回当前形状的坐标

    监听动作

    onclick() 鼠标点击事件

    fun – a function with two arguments which will be called with the coordinates of the clicked point on the canvas函数需要有两个参数
    num – number of the mouse-button, defaults to 1 (left mouse button)    单击次数,默认1
    add – True or False – if True, a new binding will be added, otherwise it will replace a former binding  添加新的绑定函数,否则替代之前函数
    例子:def turn(x, y):
         。。。 left(180)
    onclick(turn)
    

    onrelease() 鼠标释放事件,同上

    ondrag() 鼠标移动事件,同上

    乌龟一些特殊方法
    begin_poly() 开始记录多边形的顶点,当前点为起始点
    end_poly() 结束记录多边形的顶点,当前点为起始点
    get_poly() 返回最后记录的多边形
    clone() 复制一个一模一样的乌龟
    getturtle() | getpen() 获取trutle对象本身
    getscreen() 获取画布对象
    setundobuffer() 设置或禁用中断器
    undobufferentries() 返回undobuffer中的条目数

    画布的方法

    窗口控制

    bgcolor() 设置或返回当前画布的背景颜色
    bgpic() 设置或返回当前画布的背景图片名称
    clear() | clearscreen() 清除图形
    reset() | resetscreen() 重置画布
    screensize() 画布大小

    canvwidth – positive integer, new width of canvas in pixels    宽度
    canvheight – positive integer, new height of canvas in pixels  高度
    bg – colorstring or color-tuple, new background color                 颜色
    

    setworldcoordinates() 全局坐标

    llx – a number, x-coordinate of lower left corner of canvas          左下X坐标
    lly – a number, y-coordinate of lower left corner of canvas           左下X坐标
    urx – a number, x-coordinate of upper right corner of canvas      右下X坐标
    ury – a number, y-coordinate of upper right corner of canvas       右下X坐标
    

    动画控制

    delay() 动画延迟(毫秒)参数:(integer )一个数字
    tracer() 开启动画,设置延迟

    n – nonnegative integer              n个动作执行一次
    delay – nonnegative integer      延迟,毫秒
    

    update() 更新画布,当tracer关闭时使用

    画布监听

    listen() 开启监听,将鼠标定位到画布
    onkey() | onkeyrelease() 键盘弹起(需要位于焦点上,使用上面listen后)

    fun – a function with no arguments or None 动作函数
    key – a string: key (e.g. “a”) or key-symbol (e.g. “space”) 按键
    onkeypress() 键盘按下事件,同上

    onclick() | onscreenclick() 鼠标点击事件

    fun – a function with two arguments which will be called with the coordinates of the clicked point on the canvas 函数需要两个参数
    num – number of the mouse-button, defaults to 1 (left mouse button) 点击次数
    add – True or False – if True, a new binding will be added, otherwise it will replace a former binding 是否是添加,还是替换
    ontimer() 计时器

    fun – a function with no arguments 无需函数
    t – a number >= 0 事件间隔
    mainloop() | done() 开始事件循环,必须是乌龟绘画中的最后一个函数

    设置与特殊方法

    mode() 绘图模式,3选1 “standard”, “logo” or “world”
    colormode() 颜色模式, 1.0 或者 255
    getcanvas() 返回当前TurtleScreen.的Canvas
    getshapes() 返回当前可用形状
    register_shape() | addshape() 3种调用方式。

    1.直接调用图片。screen.register_shape(“turtle.gif”)

    2.调用形状,制定点位置。

         screen.register_shape("triangle", ((5,-3), (0,5), (-5,-3)))
    

    3,调用形状,名字随便取
    turtles() 返回乌龟list数组
    window_height() 返回窗口高度
    window_width() 返回窗口宽度

    输入方法

    textinput() 文字输入

    title – string 输入名字
    prompt – string 输入的文本
    numinput() 数字输入

    title – string 输入名字
    prompt – string 输入文本
    default – number (optional) 默认
    minval – number (optional) 最小
    maxval – number (optional) 最大

    屏幕特有方法

    bye() 关闭turtle窗口
    exitonclick() 鼠标点击关闭窗口
    setup() 设置主窗口参数

    width – if an integer, a size in pixels, if a float, a fraction of the screen; default is 50% of screen 宽 度
    height – if an integer, the height in pixels, if a float, a fraction of the screen; default is 75% of screen 高度
    startx – if positive, starting position in pixels from the left edge of the screen, if negative from the right edge, if None, center window horizontally 左边开始位置
    startx – if positive, starting position in pixels from the top edge of the screen, if negative from the bottom edge, if None, center window vertically 右边开始位置
    title() 设置绘画窗口标题

    个人博客 https://www.bobobk.com/39.html

    展开全文
  • 配置TURN服务器实现NAT穿透

    千次阅读 2019-07-07 20:07:31
    我在刚接触TURN时的一些疑问 搭建TURN服务器 如何测试我的TURN服务器是否成功运行? 解决ICE问题过程中遇到的另一个问题 最近使用WebRTC传输媒体流时,接收端已经成功收到了发送端发来的offer,并且传回的...

    目录

    对问题的分析

    我在刚接触TURN时的一些疑问

    搭建TURN服务器

    如何测试我的TURN服务器是否成功运行?

    解决ICE问题过程中遇到的另一个问题

     


    最近使用WebRTC传输媒体流时,接收端已经成功收到了发送端发来的offer,并且传回的answer也已经发送方被接收,之后接收端的ontrack/onaddstream成功触发,收到了媒体流并且能够打印出来,但是既不能得到画面,也不能得到声音。

    先说结论:

    原因在于ice候选,在本机测试时和局域网测试时我只使用了谷歌的免费STUN服务器,是否成功视网络情况而不同。

    本地测试和局域网测试即便没有ice候选也能成功连接传输媒体流,但是一旦部署到服务器上,ice就非常重要了

    -----2020更新------

    有很多朋友看了之后跟我说有相同的问题,接收端也得到了,也成功打印出来了,但是黑屏没有画面。配置了turn服务器之后也没能解决,不知道是turn服务器的问题还是其他的问题。说一下我的想法:也有可能是MIMEType的问题,建议两端用同一个浏览器同一个MIMEType来测试,因为MIMEType还蛮刁钻的,我当时发送方是Chrome,接收方是FireFox,尽管双方设置的MIMEType相同但接收方黑屏。以后有机会再研究一下MIMEType吧

    对问题的分析

    我找不到思路的地方,在于我"能收到媒体流"(ontrack/onaddstream会触发),但是无法播放,

    发送端的ice状态:new -> checking -> close,无法达到connected或者completed,也就无法传输媒体流(onaddstream/ontrack是在RTCPeerConnection的对方挂载媒体流时触发的,并不一定开始传输流)

    接收端的RTCPeerConnection

    IceConnectionState:new

    IceGatheringState:completed

    IceConnectionState:checking

    IceGatheringState:completed

    ==========================

    发送端的RTCPeerConnection则是

    IceConnectionState:new

    IceGatheringState:completed

    IceConnectionState:checking

    IceGatheringState:completed

    IceConnectionState:closed

    IceGatheringState:completed

    也就是说双方都能完成ice候选的收集工作,但是无法连接。

    从stackoverflow上摘了一段:

    The ice gathering state is not so important, as the application logic does not care usually about those (the application might monitor the candidates and know if the gathering is done when a null candidate surfaces), the ice connection states are VERY important to know if a connection was established and your application should focus on that. The peer connection state can be stable, and all the handshake done, without media flowing if the ICE connection state is failed.

    也就是说iceConnectionState说明连接是否建立,即便websocket的握手完成,倘若iceConnectionState连接失败(状态不是connected),那么就不会有媒体流传输

    考虑到自己在创建RTCPeerConnection时只使用了STUN服务器,是不是需要TURN服务器?

     

    我在刚接触TURN时的一些疑问

    Q:TURN和STUN的区别

    A:百度:“TURN和STUN的区别”,我只是使用了STUN和TURN,并没有对其背后的原理进一步深入了解,就在这里不丢人了。

    Q:需要两台服务器吗?TURN服务器可不可以和信令服务器是同一台服务器?

    A:一台就够,TURN服务可以和信令转发服务配置在同一台服务器上,只要确保其使用的端口不冲突就可以了,我已经试过并成功了

    Q:自己搭TURN服务器感觉好麻烦啊,可以只使用STUN服务器吗?有免费的TURN服务器吗?

    A:网上一搜有很多“国内免费的STUN服务器”,具体是否能用你可以用我下面提到的Trickle ICE来检测;

    这个网站提供了免费的STUN/TURN服务器(需要注册)http://numb.viagenie.ca/

    但是但是但是!尽管我在Trickle ICE中能够成功得到ice候选,如下图。而且在使用时RTCPeerConnection的iceConnectionState属性也显示为connected,但我仍然没能成功传输媒体流。在我的整个WebRTC项目完成后我回过头来测试这个仍然不行...

    注册后成功后你的邮箱会收到邮件(注册时验证码可能要多刷新几次)

    最终我还是搭建了自己的TURN服务器

     

    搭建TURN服务器


    参考:

    Centos6 安装 stun/turn服务  https://yq.aliyun.com/articles/138462

    搭建ICE(TURN、STUN)服务  https://blog.csdn.net/qq_41345773/article/details/88965707

    我服务器是CentOS 7.3.x

    1.安装必须的文件

    yum install -y make gcc cc gcc-c++ wget

    yum install -y openssl-devel libevent libevent-devel mysql-devel mysql-server

     

    2.下载并安装 LibEvent modules

    下载

    wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz

    解压

    tar zxvf libevent-2.0.21-stable.tar.gz

    进入解压生成的文件夹:

    cd libevent-2.0.21-stable 

    生成makefile文件

    ./configure

    执行make

    sudo make  

    安装

    sudo make install

    退回上一级目录

    cd ..

     

    3.下载并安装 TURN modules

    和上面一样

    wget http://turnserver.open-sys.org/downloads/v4.4.5.2/turnserver-4.4.5.2.tar.gz
    tar -zxvf turnserver-4.4.5.2.tar.gz
    cd turnserver-4.4.5.2 
    ./configure
    sudo make
    sudo make install

    4.turnserver安装成功后会出现如下信息

    告知相关使用事项,需要一直看完(我还以为卡掉了....)

    1) If you system supports automatic start-up system daemon services,

    the, to enable the turnserver as an automatically started system

    service, you have to:

            a) Create and edit /etc/turnserver.conf or

            /usr/local/etc/turnserver.conf .

            Use /usr/local/etc/turnserver.conf.default as an example.

            b) For user accounts settings: set up SQLite or PostgreSQL or

            MySQL or MongoDB or Redis database for user accounts.

            Use /usr/local/share/turnserver/schema.sql as SQL database schema,

            or use /usr/local/share/turnserver/schema.userdb.redis as Redis

            database schema description and/or

            /usr/local/share/turnserver/schema.stats.redis

            as Redis status & statistics database schema description.

            If you are using SQLite, the default database location is in

            /var/db/turndb or in /usr/local/var/db/turndb or in /var/lib/turn/turndb.

            c) add whatever is necessary to enable start-up daemon for the

            /usr/local/bin/turnserver.

    2) If you do not want the turnserver to be a system service,

       then you can start/stop it "manually", using the "turnserver"

       executable with appropriate options (see the documentation).

    3) To create database schema, use schema in file

    /usr/local/share/turnserver/schema.sql.

    4) For additional information, run:

       $ man turnserver

       $ man turnadmin

       $ man turnutils
     

    5.配置conf文件

    找到以下目录的文件,注意!这个default文件只是个示例!!

    /usr/local/etc/turnserver.conf.default

    使用cp命令将其复制到/etc/turnserver.conf/usr/local/etc/turnserver.conf

    即执行命令

    cp /usr/local/etc/turnserver.conf.default /etc/turnserver.conf

    cp /usr/local/etc/turnserver.conf.default /usr/local/etc/turnserver.conf

    我使用的是第一条命令,第二条命令没有测试

     

    6.修改turnserver.conf的内容

    turnserver.conf文件中有对设置内容的详细描述,学好英语或善用翻译软件

    需要设置的主要有以下几点:

    内网IP:

    listening-ip=172.16.0.13

    端口listening-port不设置默认为3478

    外网IP:
    external-ip=106.52.27.49

    长时验证
    lt-cred-mech

    登录用户名&密码(假如我的是winka9587,密码是123)
    user=winka9587:123

    其他的都用默认值

    未解决的问题:

    很奇怪的一点,我在conf文件中同时设置两个静态用户就无法成功获得候选

    user=user:pwd

    user=user2:pwd2

    但是如果只设置一个,那么就可以成功获得候选(没搞明白为什么)

     

    7.启动turnserver

    假设你在conf文件中设置的

    外网ip为106.52.27.49

    端口为3478

    记得去服务器控制台配置好安全组规则,开放3478端口

    你的conf路径为/etc/turnserver.conf

    执行命令turnserver -v -r 106.52.27.49:3478 -a -o -c /etc/turnserver.conf

    8.关闭turnserver

    ps -ef|grep turnserver
    kill -9 [序号]

     

    如何测试我的TURN服务器是否成功运行?

    浏览器访问 http://【 TURN服务器iIP地址 】:【 端口 】

    出现下图 表示TURN服务器已经成功运行

    此外,你可能会想看看是否能够成功通过你的TURN服务器获得ICE候选

    可以使用Trickle ICE,这是WebRTC官方部署在github上的一个示例,可以用它来检测通过STUN/TURN服务器获得的ICE候选

    默认的是Google的一个免费STUN服务器stun.l.google.com:19302

    单击Gather candidates即可通过你输入的所有STUN/TURN服务器收集候选

     

    比如我自己的TURN服务器ip及端口为106.52.27.49:3478

    因为测试的是TURN服务器,所以前面加上turn:(如果测试STUN服务器就加stun,就像上面的Google服务器是stun.l.google.com:19302,前面要加上stun:

    turn:106.52.27.49:3478

    用户名xxx

    密码xxx

    添加之后收集候选

    Component Type 为 relay 的就是通过TURN服务器得到的候选

     

    解决ICE问题过程中遇到的另一个问题

    在尝试解决上面问题的途中我遇到了另一个问题,在使用node-wrtc的过程中我无法SetRemoteDescription,会抛出异常,查看之后发现原因是服务器端的RTCPeerConnection的signalingState在构造函数完成后状态变为closed,而客户端的初始状态为stable(PeerConnection刚刚建立还未开始协商或者已经协商完成,参考:signalingState的官方文档

    参考问题:https://github.com/feross/simple-peer/issues/426

    因为在RTCPeerConnection的构造函数中参数有turn服务器和stun服务器的地址,问题出在其中的url和urls上

    WebRTC的最新标准已经抛弃了url,使用urls

    这里说一下我因为绕了一些弯路的原因,在服务器端需要使用WebRTC,所以使用了nodejs的node-wrtc模块,这个模块严格遵守了最新的WebRTC标准,很多官方最新标准中被废弃的功能在这里面“非常及时”地被删除了...而在浏览器上仍然可用,比如onaddstream、url

    var iceOption= { 
            iceServers: [
               //stun服务器
    			{
    				urls:"stun:stun.l.google.com:19302"
    			},
                //turn服务器&登录用户名&密码
    			{
                    urls: "turn:106.52.27.49:3478",
    				username:"用户名",
    				credential:"密码"
                }]
    		};
    
    var pc = new RTCPeerConnection(iceOption);

    见iceServer的官方文档

    https://developer.mozilla.org/en-US/docs/Web/API/RTCIceServer

    解决方案:将url修改为urls

     

     

    展开全文
  • "Turn Page. Do Not Turn Back

    2021-06-29 16:44:59
    who see it printed a t the bottom of many test pages. In fact, on occasion teachers are likely to have experienced problems with students who attempted to turn back and reread a previous test page. ...
  • 流利说 Level 3 全文

    万次阅读 多人点赞 2019-05-22 10:51:17
    It usually takes 45 minutes to drive her kids to school, but today it took longer. It took them longer because they stopped for breakfast along the way. It took 15 minutes for them to have...
  • centos上TURN服务器搭建及测试

    千次阅读 2019-10-17 19:35:43
    腾讯云公网ip:106.54.xxx.xxx 腾讯云内网ip:172.17.0.14 ...cp /usr/local/etc/turnserver.conf.default /etc/turnserver/turnserver.conf cp /home/wangc/turnserver-4.4.5.2/examples/etc/turn...
  • 基于stm32蓝牙智能小车设计

    万次阅读 多人点赞 2019-01-02 16:46:31
    该系统采用STM32微处理器为核心,在MDK环境下进行编程,通知控制L298N模块IN1~IN4引脚的高低电平进而控制电机的转动方向,使小车产生不同的转动模式。控制小车的转动模式通过蓝牙模块来实现,利用手机蓝牙助手和蓝牙...
  • turnserver.conf文件详解

    千次阅读 2015-11-14 14:51:25
    谷歌推荐的开源穿透服务器,包含trun和stun服务,主页:https://code.google.com/p/rfc5766-turn-server/ (个人觉得可以利用这个来进一步搭建VPN,有兴趣的可以试试) 由于国内通讯都被监控,...版本:turnserver-
  • 新视野大学英语(第三版)读写教程4答案

    万次阅读 多人点赞 2018-04-19 11:49:21
    Language focus: Expressions in use 1.(l) held (2) in high regard 2.In the interim 3 was onto something in turn from time to time 6. pick on 7 take a stab at 8. boil down to Translation 近年来,随着...
  • WebRTC之STUN、TURN和ICE研究

    千次阅读 2018-05-05 00:46:34
    P2P通信标准协议(二)之TURN P2P通信标准协议(三)之ICE 这个可以做为补充: P2P技术详解(三):P2P技术之STUN、TURN、ICE详解 先学习上面文章的基础知识,然后开始分析WebRTC创建PeerConne...
  • Turn Right

    2017-02-10 08:32:07
    He knew an algorithm called "Always Turn Right", it's procedure is as follows: at any grid of this room, if we can turn right(no wall at right side), then we must turn right; if we can't turn right ...
  • 谷歌推荐的开源穿透服务器,包含trun和stun服务,主页:https://code.google.com/p/rfc5766-turn-server/ (个人觉得可以利用这个来进一步搭建VPN,有兴趣的可以试试) 转载请注明出处(www.webrtcbbs.com),...
  • turnserver穿透服务器详细配置

    万次阅读 2017-03-15 11:21:58
    配置需要:为webrtc配合 ubuntu系统 rfc5766-turn-server 下载安装包: $ wget http://ftp.cn.debian.org/debian/pool/main/r/rfc5766-turn-server/rfc5766-turn-server_3.2.4.4-1_amd64.deb 可以根据网址从网站...
  • How to Turn Off Shape Protection in Visio

    千次阅读 2014-06-23 17:17:10
    原帖地址:...Shape protection in Visio 2013 makes it possible for specific aspects of shapes to be locked. Aspects of shapes that can be l
  • webrtc(2):Centos6 安装 stun/turn服务

    千次阅读 2015-07-28 18:05:57
    /stop it "manually" , using the "turnserver" executable with appropriate options (see the documentation). 3 ) To create database schema , use schema in file /usr/ local /share/...
  • MySQL5.7 启动报错:initialize specified but the data directory has files in it. Aborting. 1、mysql 5.7 启动 [root@hadoop102 ~]# systemctl start mysqld Job for mysqld.service failed because the control ...
  • Centos安装turn stun 服务器

    千次阅读 2015-09-22 23:09:24
    1.install and download prerequisite for CentOS  yum install -y make gcc cc gcc-c++ wget  yum install -y openssl-devel libevent libevent-devel mysql-devel mysql-...2. download and in
  • Ubuntu中安装TurnServer服务器

    万次阅读 2015-10-30 16:02:27
    If it has 0x then it is a key, otherwise it is a password). # ('0x'开始的关键是区分从密码的关键。 # 如果它有0x,那么它是一个关键,否则这是一个密码)。 # # The corresponding user account entry in the ...
  • WebRTC中的信令和内网穿透技术 STUN / TURN

    万次阅读 多人点赞 2018-11-01 22:32:30
    Translated from WebRTC in the real world: STUN, TURN and signaling. 最近刚接触到WebRTC,网上看到这篇介绍WebRTC的文章不错,仔细读了读还算有用,分享出来能帮到一些刚入门的人也挺好的,翻译不好的地方可以...
  • : Turn your Session into FlushMode.COMMIT/AUTO or remove 'readOnly' marker from transaction definition. 如下图所示: 问题分析:  在我的Web.xml中配置了 “ OpenSessionInViewFilter ”过滤器,主要用来...
  • 寻迹小车_it_linux_源码

    2021-10-02 13:33:51
    use in 51 MCU LED.It can contrul 51's LED0 and LED1 turn on or turn off.
  • 最近在搞互动直播,apprtc+coturn方案 本来想禁用掉udp relay,但发现turnserver开启no-udp-relay选项后直接就relay不通了 找到google group里面的一篇...topic/turn-server-project-rfc5766-turn-server/CVfxzfnfvqM
  • not in scope>和<cannot evaluate>,无奈凑合着通过printf函数进行串口打印查看。 后来实在受不了,想了一下,觉得应该是编译器把这个局部变量给优化掉了,并没有在内存中生成,果断把优化...
  • 下载 笔记版/无笔记版 pdf资料: GitHub - zhbink/LiuLiYueDu: 流利阅读pdf汇总 本文内容全部来源于流利阅读...Turn down the volume: WHO takes aim at harmful smartphone use 调低音量:世卫组织对不健康的智能手...
  • javaScript+turn.js实现图书翻页效果

    万次阅读 2016-12-07 16:16:13
    为了实现图书翻页的效果 我们在网上可以看到很多教程 在这里 推荐turn.js 网上的turn.js 有api 不过是英文的 很多人看起来不方便 关于代码也是奇形怪状 在这里 我将详细讲解 如何使用turn.js实现翻页效果 本篇文章...
  • 数据简化DataSimp导读:A.2016年英文IT文章列表;B.640篇英文IT文章列表;C.数据简化DataSimp公众号。(文章列表里的标题文字带链接,按“ctrl+点击标题”可跳转浏览器,微信限制外链,请下载PDF使用链接)。如有...
  • 此为《Gans in Action》(对抗神经网络实战)第一章读书笔记 Chapter 1. Introduction to GANs 对抗神经网络介绍 本章内容包括:GAN概述、GAN的特别之处以及GAN的应用
  • Teams Bot开发系列:Activity和Turn

    千次阅读 2020-09-06 15:55:03
    这篇文章我们来说一下Activity和Turn这两个bot framework中最重要的两个概念,同时也介绍一下TurnContext和BotAdapter Activity 一个activity是聊天双方的一个信息载体,它可以是一条消息,也可以是一个动作。比如...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 98,063
精华内容 39,225
关键字:

initturn