wowza拉流和推流接口备忘

拉流接口地址:https://www.wowza.com/docs/stream-management-query-examples#

推流接口地址:https://www.wowza.com/docs/stream-targets-query-examples-push-publishing

  概述:wowza的接口地址是将部分参数拼在URL里的,并且是以键值对的形式存在的。

Add a stream file

  作用:添加一个流文件到wowza服务器中。

  URL:http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/streamfiles

  参数:{"name": "creedence","serverName": "_defaultServer_","uri": "udp://1.2.3.4:10000" }

  header:Accept:application/json; charset=utf-8' ;'Content-Type:application/json

  提交方式:post

  参数解释:

    localhost:8087:wowza设备的IP和端口

    key:servers,value:_defaultServer_

    key:vhosts,value:_defaultVHost_

    key:applications,value:live

    name:流文件的唯一标识,在其他地方通常叫ID

    serverName:servers的值

    uri:添加流文件最重要的参数

Connect a stream file

  作用:wowza服务器里的流文件有两种创建方式,一种是通过Add a stream file接口添加进来的,第二种是从其他服务器推送过来的。不管wowza里的流文件是哪种来源方式,都需要调用Connect a stream file接口连接流后才可以使用。

  URL:http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/streamfiles/creedence/actions/connect?connectAppName=live&appInstance=_definst_&mediaCasterType=rtp

   参数:全部拼接在URL里了

  header:Accept:application/json; charset=utf-8' ;'Content-Type:application/json

  提交方式:put

  参数解释:

     creedence:Add a stream file接口中的name属性值

    connectAppName:Add a stream file接口中的application的属性值

      key:appInstance,value:_definst_

      key:mediaCasterType,value:rtp

  备注:一台wowza服务器可以有多个application,一个application可以有多个appInstance,不过通常会创建多个application而每个application只有一个appInstance

Disconnect a stream file

  作用:Connect a stream file接口的相反操作,由于断开流文件的连接

  URL:http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/incomingstreams/creedence.stream/actions/disconnectStream

   header:Accept:application/json; charset=utf-8' ;'Content-Type:application/json

  提交方式:put

  参数:全部拼接在URL里了

    参数解释:

     creedence:Add a stream file接口中的name属性值

  备注:流文件要先断开再移除

Remove a stream file

  作用:从wowza设备中移除一个流文件

  URL:http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/streamfiles/creedence

    header:Accept:application/json; charset=utf-8

  提交方式:delete

   参数:全部拼接在URL里了

  参数解释:

    creedence:Add a stream file接口中的name属性值

Create a stream target

  作用:推流接口,将流文件从服务器A推到服务器B(这句话很重要),设置服务器B的一些属性。

    URL:http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/pushpublish/mapentries/ppsource

  header:Accept:application/json; charset=utf-8;Content-type:application/json

  提交方式:post

  参数:{ "serverName": "_defaultServer_", "sourceStreamName": "myStream", "entryName": "ppsource", "profile": "rtmp", "host": "localhost", "application": "live", "userName": "testUser", "password": "pass", "streamName": "myStream" }

  参数解释:

    ppsource:是下面的entryName属性值

    serverName:服务器B的servers属性,就是Add a stream file接口里的servers属性

    sourceStreamName:服务器A的流文件name属性

    entryName:推流的任务id(wowza喜欢讲ID叫做name),推流任务的唯一标识。

    profile:传输协议,我用的是rtmp

    host:服务器B的IP

    application:服务器B的application属性

    userName:如果服务器B开启验证的话,服务器A的推流参数里要设置服务器B认可的用户名和密码才能给服务器B推流

    password:看上一条

    streamName:流文件在服务器B的唯一标识,可以和sourceStreamName(流文件在服务器A的唯一标识)相同,但不能没有

  备注:官网的这个推流文档里没有将服务器B的端口写上去,你可以将服务器B的端口拼在host属性值后面,也可以增加port属性。

    最后:十分感恩robin在我研读文档期间给我的支持和帮助,谢谢你。

 

posted @ 2017-09-11 18:49  luckyMichaelHuang  阅读(1219)  评论(0编辑  收藏  举报