Skip to content

JSON RPC API メモ

Yoteichi edited this page Aug 18, 2016 · 10 revisions

HTML UI の実装に使われている JSON-RPC API のメモ。エンドポイントは /api/1 。呼び出すときは X-Requested-With: XMLRequest のように X-Requested-With ヘッダーを付ける必要がある。

addBroadcastHistory

addListener

addYellowPage(protocol, name, uri)

broadcastChannel(yellowPageId, sourceUri, contentReader, info, track, sourceStream)

チャンネルを開始。チャンネルIDを返す。

bumpChannel

チャンネルに再接続。

checkBandwidth

帯域チェック。

466

checkPorts

ポート開放状態をチェックする。

[7144]

checkUpdate

新バージョンのチェック。

clearLog

ログをクリア。返り値はない。

getBroadcastHistory

チャンネル作成フォームに入れた内容の履歴。

[{"streamType"=>"RTMP Source",
  "streamUrl"=>"rtmp://localhost/live/livestream",
  "bitrate"=>0,
  "contentType"=>"Flash Video (FLV)",
  "yellowPage"=>"SP",
  "channelName"=>"予定地",
  "genre"=>"spプログラミング",
  "description"=>"ラムダ電卓",
  "comment"=>"短時間マイク無し",
  "contactUrl"=>
   "http://jbbs.shitaraba.net/bbs/read.cgi/game/48538/1391100125/",
  "trackTitle"=>"",
  "trackAlbum"=>"",
  "trackArtist"=>"",
  "trackGenre"=>"",
  "trackUrl"=>"",
  "favorite"=>false},
 ... ]

getChannelConnections

チャンネルの接続情報。

[{"connectionId"=>1351461736,
  "type"=>"source",
  "status"=>"Connected",
  "sendRate"=>0.0,
  "recvRate"=>64698.2266,
  "protocolName"=>"RTMP Source",
  "localRelays"=>nil,
  "localDirects"=>nil,
  "contentPosition"=>345423,
  "agentName"=>"FMLE/3.0 (compatible; FMSc/1.0)",
  "remoteEndPoint"=>"127.0.0.1:64329",
  "remoteHostStatus"=>["local"],
  "remoteName"=>"rtmp://localhost/live/livestream"},
 {"connectionId"=>1724473770,
  "type"=>"direct",
  "status"=>"Connected",
  "sendRate"=>0.0,
  "recvRate"=>0.0,
  "protocolName"=>"HTTP Direct",
  "localRelays"=>nil,
  "localDirects"=>nil,
  "contentPosition"=>330616,
  "agentName"=>"VLC/2.1.5 LibVLC/2.1.5",
  "remoteEndPoint"=>"192.168.0.6:64320",
  "remoteHostStatus"=>["local"],
  "remoteName"=>"192.168.0.6:64320"},
 {"connectionId"=>919361550,
  "type"=>"relay",
  "status"=>"Connected",
  "sendRate"=>60694.1758,
  "recvRate"=>16.5836468,
  "protocolName"=>"PCP Relay",
  "localRelays"=>0,
  "localDirects"=>1,
  "contentPosition"=>135065042,
  "agentName"=>nil,
  "remoteEndPoint"=>"***.***.***.***:50475",
  "remoteHostStatus"=>["relayFull"],
  "remoteName"=>"***.***.***.***:50475"}]

getChannelInfo

{"info"=>
 {"name"=>"テストch",
  "url"=>"",
  "genre"=>"",
  "desc"=>"",
  "comment"=>"",
  "bitrate"=>512,
  "contentType"=>"FLV",
  "mimeType"=>"video/x-flv"},
 "track"=>{"name"=>"", "genre"=>"", "album"=>"", "creator"=>"", "url"=>""},
 "yellowPages"=>[]}

getChannelOutputs(channelId)

動画プレーヤー接続の情報。

[{"outputId"=>1835339218,
  "name"=>"HTTP Direct 127.0.0.1:64191 (NSPlayer/12.0.7601.17514) 472kbps",      "type"=>1}]

getChannelRelayTree(channelId)

リレーツリー情報。ルートは自分自身。

[{"sessionId"=>"F46190087E454DE6977B957D2D74D599",
  "address"=>"110.4.130.220",
  "port"=>7144,
  "isFirewalled"=>false,
  "localRelays"=>1,
  "localDirects"=>0,
  "isTracker"=>false,
  "isRelayFull"=>true,
  "isDirectFull"=>true,
  "isReceiving"=>true,
  "isControlFull"=>false,
  "version"=>nil,
  "versionVP"=>nil,
  "children"=>
   [{"sessionId"=>"0078CC0C7CF28A909E3AF7C5A30FAED6",
     "address"=>"***.***.***.***",
     "port"=>7144,
     "isFirewalled"=>false,
     "localRelays"=>0,
     "localDirects"=>1,
     "isTracker"=>false,
     "isRelayFull"=>false,
     "isDirectFull"=>true,
     "isReceiving"=>true,
     "isControlFull"=>false,
     "version"=>1218,
     "versionVP"=>27,
     "versionEX"=>"IM45",
     "children"=>[]}]}]

getChannelStatus(channelId)

特定のチャンネルの情報。

{"status"=>"Searching",
 "source"=>"rtmp://localhost/live/livestream",
 "uptime"=>166,
 "localRelays"=>0,
 "localDirects"=>0,
 "totalRelays"=>0,
 "totalDirects"=>0,
 "isBroadcasting"=>true,
 "isRelayFull"=>false,
 "isDirectFull"=>false,
 "isReceiving"=>false}

getChannels

すべてのチャンネルの情報。

[{"channelId"=>"A0B184CC8F166FD0BCB9618B74A2CD80",
  "status"=>
   {"status"=>"Searching",
    "source"=>"rtmp://localhost/live/livestream",
    "uptime"=>3,
    "localRelays"=>0,
    "localDirects"=>0,
    "totalRelays"=>0,
    "totalDirects"=>0,
    "isBroadcasting"=>true,
    "isRelayFull"=>false,
    "isDirectFull"=>false,
    "isReceiving"=>false},
  "info"=>
   {"name"=>"テストch",
    "url"=>"",
    "genre"=>"",
    "desc"=>"",
    "comment"=>"",
    "bitrate"=>0,
    "contentType"=>nil,
    "mimeType"=>"application/octet-stream"},
  "track"=>{"name"=>"", "genre"=>"", "album"=>"", "creator"=>"", "url"=>""},
  "yellowPages"=>[]}]

getContentReaders

コンテント解析器の情報。

[{"name"=>"ASF(WMV or WMA)", "desc"=>"ASF(WMV or WMA)"},
 {"name"=>"RAW", "desc"=>"RAW"},
 {"name"=>"Flash Video (FLV)", "desc"=>"Flash Video (FLV)"},
 {"name"=>"Matroska (MKV or WebM)", "desc"=>"Matroska (MKV or WebM)"}]

getListeners

PeerCast の接続を受け付けるIPアドレスとポートの情報。

[{"listenerId"=>546346459,
  "address"=>"0.0.0.0",
  "port"=>7144,
  "localAccepts"=>2147483647,
  "globalAccepts"=>7,
  "localAuthorizationRequired"=>false,
  "globalAuthorizationRequired"=>false,
  "authenticationId"=>"-!FO;Zsk(atStMKU",
  "authenticationPassword"=>"ZVdf_xQqQ,vhDIKk",
  "isOpened"=>nil}]

getLog(from, maxLines)

ログの取得。

{"from"=>0, "lines"=>1, "log"=>""}

{"from"=>0,
 "lines"=>2,
 "log"=>
 "OutputListener: 2015-01-18T10:19:31 [OutputListenerThread:0.0.0.0:7144] INFO  - Client connected 192.168.0.7:56442\n"}

getLogSettings

ログレベルの取得。0「ログの記録なし」、1「致命的なエラー」、2「エラー」、3「警告」、4「付加的な情報」、5「デバッグ用の情報」。

{"level"=>2}

getNewVersions

新バージョン情報の取得。

getNotificationMessages

ポップアップ用通知メッセージの取得。

[{"type"=>"error", "title"=>"テストch", "message"=>"チャンネルに接続できませんでした"},
 {"type"=>"info", "title"=>"テストch", "message"=>"チャンネルが終了しました"},
 ...]

getPlugins

プラグイン情報の取得。

[{"name"=>"ASF Content Reader",
  "isUsable"=>true,
  "assembly"=>
   {"name"=>"PeerCastStation.ASF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=a441b7b23e9d2fd0",
    "path"=>"PeerCastStation.ASF.dll",
    "version"=>"1.7.9.1",
    "copyright"=>" "}},
  ... ]

getSettings

リレーに関する設定の取得。

{"maxRelays"=>2,
 "maxRelaysPerChannel"=>1,
 "maxDirects"=>2,
 "maxDirectsPerChannel"=>0,
 "maxUpstreamRate"=>600,
 "maxUpstreamRatePerChannel"=>0,
 "channelCleaner"=>{"mode"=>3, "inactiveLimit"=>60000}}

getSourceStreams

対応しているソースストリームプロトコルの情報を取得。

[{"name"=>"RTMP Source",
  "desc"=>"RTMP Source",
  "scheme"=>"rtmp",
  "type"=>1,
  "defaultUri"=>"rtmp://localhost/live/livestream"},
 {"name"=>"http",
  "desc"=>"http",
  "scheme"=>"http",
  "type"=>1,
  "defaultUri"=>"http://localhost:8080/"},
 {"name"=>"pcp",
  "desc"=>"pcp",
  "scheme"=>"pcp",
  "type"=>2,
  "defaultUri"=>""}]

type は用途を表す。1は「配信用入力ストリーム」、 2は「リレー用入力ストリーム」。

getStatus

{"uptime"=>58541,
 "isFirewalled"=>false,
 "globalRelayEndPoint"=>["110.4.130.220", 7144],
 "globalDirectEndPoint"=>["110.4.130.220", 7144],
 "localRelayEndPoint"=>["192.168.0.6", 7144],
 "localDirectEndPoint"=>["192.168.0.6", 7144]}

稼働時間、ポート開放状態、IPアドレスなどの情報の取得。

getVersionInfo

{"agentName"=>"PeerCastStation/1.7.9.1",
 "apiVersion"=>"1.0.0",
 "jsonrpc"=>"2.0"}

バージョン情報の取得。

getYellowPageProtocols

[{"name"=>"PCP", "protocol"=>"pcp"}]

getYellowPages

[{"yellowPageId"=>1901542310,
  "name"=>"SP",
  "uri"=>"pcp://bayonet.ddo.jp:7146/",
  "protocol"=>"pcp",
  "channels"=>[]},          # [{channelId, status}...]
  ... ]

登録されているイエローページの取得。

removeListener

removeYellowPage

resetListenerAuthenticationKey

restartAnnounce

YP への接続をはりなおす。

restartChannelConnection

setChannelInfo

setListenerAccepts

setListenerAuthorizationRequired

setLogSettings

setSettings

stopAnnounce

stopChannel(channelId)

チャンネルを閉じる。

stopChannelConnection(channelId, connectionId)

チャンネルに関して特定の接続を停止する。成功すれば true、失敗すれば false を返す。

stopChannelOutput

Clone this wiki locally