API

概要

API は Sora に対して HTTP 経由で実行できます。

API は DynamoDB や Route53 などの AWS API が独特な仕様なので紹介 - Qiita を参考にしており、 x-sora-target というヘッダーを使って実行します。

全ての処理は POST であり PATH は / です。投げる Body は全て JSON を使用します。

設定

api_port

sys.config にて API のポート番号を設定してください。

{api_port, 3000}

api_cors_origin

API をクロスドメインで使用したい場合に設定します。

{api_cors_origin, "http://127.0.0.1:5000"}

こうすることで http://127.0.0.1:5000 から API を叩くことができるようになります。

httpie

ここでの例では httpie という Python のライブラリを使用しています。

シグナリング API

指定したチャネルの接続をすべて切断する

サービス:Sora
バージョン:20151104
オペレーション:DisconnectChannel
x-sora-target:Sora_20151104.DisconnectChannel
キー
channel_id string
$ http POST 127.0.0.1:3000 \
    x-sora-target:Sora_20151104.DisconnectChannel \
    channel_id=sora \
    -vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 22
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.3
x-sora-target: Sora_20151104.DisconnectChannel

{
    "channel_id": "sora"
}

HTTP/1.1 200 OK
content-length: 0
content-type: application/json
date: Sun, 24 Jul 2016 06:04:53 GMT
server: Cowboy

指定したクライアント ID の接続を切断する

サービス:Sora
バージョン:20151104
オペレーション:Disconnect
x-sora-target:Sora_20151104.Disconnect
キー
channel_id string
client_id string
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20151104.Disconnect \
    channel_id=sora \
    client_id=d5339cd0-2d4c-4524-8103-7a70d3794a16 \
    -vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 75
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.3
x-sora-target: Sora_20151104.Disconnect

{
    "channel_id": "sora",
    "client_id": "d5339cd0-2d4c-4524-8103-7a70d3794a16"
}

HTTP/1.1 200 OK
content-length: 0
content-type: application/json
date: Sun, 29 May 2016 05:13:20 GMT
server: Cowboy

指定したチャネルの接続一覧を取得する

サービス:Sora
バージョン:20151104
オペレーション:ListConnections
x-sora-target:Sora_20151104.ListConnections
キー
channel_id string
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20151104.ListConnections \
    channel_id=sora \
    -vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 22
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.3
x-sora-target: Sora_20151104.ListConnections

{
    "channel_id": "sora"
}

HTTP/1.1 200 OK
content-length: 278
content-type: application/json
date: Sun, 29 May 2016 05:11:51 GMT
server: Cowboy

[
    {
        "channel_id": "sora",
        "client_id": "bec6055c-2c0d-4cd0-9f1e-74886d00c7b1",
        "role": "downstream"
    },
    {
        "channel_id": "sora",
        "client_id": "d5339cd0-2d4c-4524-8103-7a70d3794a16",
        "role": "downstream"
    },
    {
        "channel_id": "sora",
        "client_id": "8b6c8c40-476f-4881-81ba-ceb07eefd2c5",
        "role": "upstream"
    }
]

すべての接続一覧を取得する

サービス:Sora
バージョン:20151104
オペレーション:ListAllConnections
x-sora-target:Sora_20151104.ListAllConnections

レスポンス項目

リスト

  • channel_id
  • client_id
  • role
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20151104.ListAllConnections \
    -vvv
POST / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.3
x-sora-target: Sora_20151104.ListAllConnections



HTTP/1.1 200 OK
content-length: 464
content-type: application/json
date: Sun, 29 May 2016 05:12:25 GMT
server: Cowboy

[
    {
        "channel_id": "akane",
        "client_id": "5918fdd4-cef4-4486-b9dd-574ca14f168c",
        "role": "downstream"
    },
    {
        "channel_id": "sora",
        "client_id": "bec6055c-2c0d-4cd0-9f1e-74886d00c7b1",
        "role": "downstream"
    },
    {
        "channel_id": "sora",
        "client_id": "d5339cd0-2d4c-4524-8103-7a70d3794a16",
        "role": "downstream"
    },
    {
        "channel_id": "akane",
        "client_id": "b66c327e-e219-4fe8-90a3-acfab257a36f",
        "role": "upstream"
    },
    {
        "channel_id": "sora",
        "client_id": "8b6c8c40-476f-4881-81ba-ceb07eefd2c5",
        "role": "upstream"
    }
]

指定したチャネルのクライアント情報を取得する

サービス:Sora
バージョン:20170814
オペレーション:ListChannelClients
x-sora-target:Sora_20170814.ListChannelClients
キー
channel_id string

レスポンス項目

リスト

  • role
  • multistream
  • channel_id
  • client_id
  • audio
  • video
  • minutes
    • 分単位での接続経過時間
  • event_metadta
    • 認証時に認証サーバから指定した event_metadata
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20170814.ListChannelClients \
    channel_id=sora \
    -vvv
POST / HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 22
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.9
x-sora-target: Sora_20170814.ListChannelClients

{
    "channel_id": "sora"
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 395
content-type: application/json
date: Sun, 13 Aug 2017 12:28:24 GMT
server: Cowboy

[
    {
        "audio": false,
        "client_id": "cebb13d5-1f36-4d39-96d2-c5929013a6cf",
        "event_metadata": {
            "spam": "egg"
        },
        "minutes": 2,
        "multistream": false,
        "role": "upstream",
        "video": {
            "bit_rate": 500,
            "codec_type": "VP9"
        }
    },
    {
        "audio": {
            "codec_type": "OPUS"
        },
        "client_id": "fb859c2e-5af4-454b-a06b-e05a421139e6",
        "event_metadata": {
            "spam": "egg"
        },
        "minutes": 0,
        "multistream": false,
        "role": "downstream",
        "video": {
            "bit_rate": 500,
            "codec_type": "VP9"
        }
    }
]

プッシュ API

シグナリングで使用している WebSocket を活用できる API です。この機能を使うことでアプリ側でプッシュの仕組みを用意する必要がなくなります。

指定したチャネル全員にプッシュ通知を送る

サービス:Sora
バージョン:20160711
オペレーション:PushChannel
x-sora-target:Sora_20160711.PushChannel
キー
channel_id string
data object

data には全員に通知する JSON を指定してください。 クライアントには data に指定した JSON が送られます。

$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20160711.PushChannel \
    channel_id=sora \
    data:="{\"spam\": \"egg\"}" \
    -vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 47
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.4
x-sora-target: Sora_20160711.PushChannel

{
    "channel_id": "sora",
    "data": {
        "spam": "egg"
    }
}

HTTP/1.1 200 OK
content-length: 37
content-type: application/json
date: Sun, 24 Jul 2016 06:26:21 GMT
server: Cowboy

{
    "data": {
        "spam": "egg"
    },
    "type": "push"
}

指定したチャネルのクライアントにプッシュ通知を送る

サービス:Sora
バージョン:20160711
オペレーション:PushClient
x-sora-target:Sora_20160711.PushClient
キー
channel_id string
client_id string
data object
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20160711.PushClient \
    channel_id=sora \
    client_id=0a3313e2-7666-4d54-a301-4866b07bb93c \
    data:="{\"spam\": \"egg\"}" \
    -vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 100
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.4
x-sora-target: Sora_20160711.PushClient

{
    "channel_id": "sora",
    "client_id": "0a3313e2-7666-4d54-a301-4866b07bb93c",
    "data": {
        "spam": "egg"
    }
}

HTTP/1.1 200 OK
content-length: 37
content-type: application/json
date: Sun, 24 Jul 2016 07:46:31 GMT
server: Cowboy

{
    "data": {
        "spam": "egg"
    },
    "type": "push"
}

指定したチャネルの配信者にプッシュ通知を送る

サービス:Sora
バージョン:20160711
オペレーション:PushUpstream
x-sora-target:Sora_20160711.PushUpstream
キー
channel_id string
data object
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20160711.PushUpstream \
    channel_id=sora \
    data:="{\"spam\": \"egg\"}" \
    -vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 47
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.4
x-sora-target: Sora_20160711.PushUpstream

{
    "channel_id": "sora",
    "data": {
        "spam": "egg"
    }
}

HTTP/1.1 200 OK
content-length: 37
content-type: application/json
date: Sun, 24 Jul 2016 06:29:08 GMT
server: Cowboy

{
    "data": {
        "spam": "egg"
    },
    "type": "push"
}

指定したチャネルの視聴者にプッシュ通知を送る

サービス:Sora
バージョン:20160711
オペレーション:PushDownstream
x-sora-target:Sora_20160711.PushDownStream
キー
channel_id string
data object
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20160711.PushDownstream \
    channel_id=sora \
    data:="{\"spam\": \"egg\"}" \
    -vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 47
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.4
x-sora-target: Sora_20160711.PushDownstream

{
    "channel_id": "sora",
    "data": {
        "spam": "egg"
    }
}

HTTP/1.1 200 OK
content-length: 37
content-type: application/json
date: Sun, 24 Jul 2016 06:29:20 GMT
server: Cowboy

{
    "data": {
        "spam": "egg"
    },
    "type": "push"
}

録画 API

録画されたファイルは sys.config の archive_dir に指定したフォルダに置かれます。

録画可能な組み合わせ
映像コーデック 音声コーデック 出力形式
VP8 false webm
VP9 false webm
VP8 Opus webm
VP9 Opus webm
false Opus webm
false PCMU wav

映像コーデックの指定はシグナリング開始時に指定してください。

指定したチャネルの録画を開始する

サービス:Sora
バージョン:20161101
オペレーション:StartRecording
x-sora-target:Sora_20161101.StartRecording
キー
channel_id string
expire_time integer
  • start_time は録画を開始した時間で Unix Time (UTC) の秒数で返ってきます
  • expire_time を 0 に指定した場合、録画の期限が無くなります
  • expire_time の範囲は 0 から 86400 までで、秒数を指定してください

expire_time が 0:

$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20161101.StartRecording \
    channel_id=sora \
    expire_time:=0 \
    -vvv
POST / HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 41
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.9
x-sora-target: Sora_20161101.StartRecording

{
    "channel_id": "sora",
    "expire_time": 0
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 82
content-type: application/json
date: Wed, 19 Apr 2017 06:35:38 GMT
server: Cowboy

{
    "channel_id": "sora",
    "expire_time": 0,
    "id": "77b83ad8-48d8-4323-9c56-30cedb716e60"
}

expire_time が 3600:

$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20161101.StartRecording \
    channel_id=sora \
    expire_time:=3600 \
    -vvv
POST / HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 43
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.9
x-sora-target: Sora_20161101.StartRecording

{
    "channel_id": "sora",
    "expire_time": 3600
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 84
content-type: application/json
date: Wed, 19 Apr 2017 06:37:08 GMT
server: Cowboy

{
    "channel_id": "sora",
    "expire_time": 3600,
    "id": "bb55eb3d-feef-4983-a7c2-8be8664d1d04"
}

エラー

すでに録画が開始している場合は "STARTED-RECORDING" が返ってきます。

$ http POST 127.0.0.1:3000/ \
        x-sora-target:Sora_20161101.StartRecording \
        channel_id=sora \
        expire_time:=3600 \
        -vvv
POST / HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 43
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.9
x-sora-target: Sora_20161101.StartRecording

{
    "channel_id": "sora",
    "expire_time": 3600
}

HTTP/1.1 400 Bad Request
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 34
content-type: application/json
date: Wed, 19 Apr 2017 06:44:58 GMT
server: Cowboy

{
    "error_type": "STARTED-RECORDING"
}
  • "STARTED-RECORDING"
    • すでに指定したチャネルでは録画が開始されている

指定したチャネルの録画を停止する

サービス:Sora
バージョン:20161101
オペレーション:StopRecording
x-sora-target:Sora_20161101.StopRecording
キー
channel_id string
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20161101.StopRecording \
    channel_id=sora \
    -vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 22
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.4
x-sora-target: Sora_20161101.StopRecording

{
    "channel_id": "sora"
}

HTTP/1.1 200 OK
content-length: 21
content-type: application/json
date: Fri, 11 Nov 2016 14:29:14 GMT
server: Cowboy

{
    "channel_id": "sora"
}

エラー

  • NOT-STARTED-RECORDING
    • 指定したチャネルの録画が開始されていない

録画が有効かどうかを確認する

サービス:Sora
バージョン:20161101
オペレーション:GetStartedRecording
x-sora-target:Sora_20161101.GetStartedRecording
キー
channel_id string
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20161101.GetStartedRecording \
    channel_id=sora \
    -vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 22
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.4
x-sora-target: Sora_20161101.GetStartedRecording

{
    "channel_id": "sora"
}

HTTP/1.1 200 OK
content-length: 88
content-type: application/json
date: Sat, 19 Nov 2016 13:03:24 GMT
server: Cowboy

{
    "channel_id": "sora",
    "expire_time": 3600,
    "expired_at": 1479563964,
    "start_time": 1479560364
}

エラー

指定したチャネルで録画が開始されていない場合は "NOT-STARTED-RECORDING" が返ってきます

$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20161101.GetStartedRecording \
    channel_id=sora \
    -vvv
POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 22
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.4
x-sora-target: Sora_20161101.GetStartedRecording

{
    "channel_id": "sora"
}

HTTP/1.1 400 Bad Request
content-length: 38
content-type: application/json
date: Sat, 19 Nov 2016 13:03:53 GMT
server: Cowboy

{
    "error_type": "NOT-STARTED-RECORDING"
}
  • NOT-STARTED-RECORDING
    • 指定したチャネルの録画が開始されていない

録画が行われているチャネル一覧を取得する

サービス:Sora
バージョン:20161101
オペレーション:ListStartedRecording
x-sora-target:Sora_20161101.ListGetStartedRecording
$ http POST 127.0.0.1:3000/ \
    "x-sora-target:Sora_20161101.ListStartedRecording" \
    -vvv
POST / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.4
x-sora-target: Sora_20161101.ListStartedRecording



HTTP/1.1 200 OK
content-length: 168
content-type: application/json
date: Sat, 19 Nov 2016 13:05:38 GMT
server: Cowboy

[
    {
        "channel_id": "sora",
        "expire_time": 3600,
        "expired_at": 1479564309,
        "start_time": 1479560709
    },
    {
        "channel_id": "akane",
        "expire_time": 0,
        "expired_at": 0,
        "start_time": 1479560735
    }
]

現在録画中の状態を取得する

サービス:Sora
バージョン:20161101
オペレーション:ListArchiving
x-sora-target:Sora_20161101.ListArchiving
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20161101.ListArchiving \
    -vvv
POST / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.4
x-sora-target: Sora_20161101.ListArchiving



HTTP/1.1 200 OK
content-length: 78
content-type: application/json
date: Fri, 11 Nov 2016 14:39:13 GMT
server: Cowboy

[
    {
        "audio": false,
        "channel_id": "sora",
        "seconds": 2,
        "video": {
            "codec_name": "VP8"
        }
    }
]
  • seconds は録画を開始してからの経過時間(秒)です
  • video が設定されていない場合は "video": false という値が入ってきます
  • audio が設定されていない場合は "audio": false という値が入ってきます

RTP 転送 API

指定したチャネル ID の配信している映像または音声の RTP を指定した IP アドレスとポートに送信します。

指定したチャネルの RTP を転送を開始する

サービス:Sora
バージョン:20170814
オペレーション:StartForwardingRtp
x-sora-target:Sora_20170814.StartForwardingRtp
キー
channel_id string
client_id (オプション) string
ip_address string
audio_port integer
video_port integer

マルチストリームの映像を転送する場合は client_id を指定してください。

$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20170814.StartForwardingRtp \
    channel_id=sora \
    ip_address=192.0.2.100 \
    audio_port:=60001 \
    video_port:=60003 \
    -vvv

POST / HTTP/1.1
Accept: application/json
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 93
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.2
x-sora-target: Sora_20170814.StartForwardingRtp

{
    "audio_port": 60001,
    "channel_id": "sora",
    "ip_address": "192.0.2.100",
    "video_port": 60003
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 262
content-type: application/json
date: Wed, 30 Aug 2017 02:08:50 GMT
server: Cowboy

{
    "sdp": "v=0\r\no=- 0 0 IN IP4 0.0.0.0\r\ns=-\r\nt=0 0\r\nm=audio 60001 RTP/SAVPF 109\r\nc=IN IP4 127.0.0.1\r\na=rtpmap:109 opus/48000/2\r\nm=video 60003 RTP/SAVPF 120\r\nc=IN IP4 127.0.0.1\r\na=rtpmap:120 VP9/90000\r\na=fmtp:120 max-fs=12288;max-fr=60\r\n"
}

指定したチャネルの RTP を転送を停止する

サービス:Sora
バージョン:20170814
オペレーション:StopForwardingRtp
x-sora-target:Sora_20170814.StopForwardingRtp
キー
channel_id string
client_id (オプション) string
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20170814.StopForwardingRtp \
    channel_id=sora \
    -vvv

POST / HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 22
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.9
x-sora-target: Sora_20170814.StopForwardingRtp

{
    "channel_id": "sora"
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 21
content-type: application/json
date: Fri, 25 Aug 2017 13:32:48 GMT
server: Cowboy

{
    "channel_id": "sora"
}

統計 API

指定したクライアントの統計情報を取得する

サービス:Sora
バージョン:20170529
オペレーション:GetStats
x-sora-target:Sora_20170529.GetStats
キー
channel_id string
client_id string
$ http POST 192.0.2.1:3000/
    x-sora-target:Sora_20170529.GetStats \
    channel_id=sora \
    client_id=82587784-d3f9-4a8b-ba39-0fdb5a7b16d7 -vvv
POST / HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 75
Content-Type: application/json
Host: 192.0.2.1:3000
User-Agent: HTTPie/0.9.9
x-sora-target: Sora_20170529.GetStats

{
    "channel_id": "sora",
    "client_id": "82587784-d3f9-4a8b-ba39-0fdb5a7b16d7"
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 2028
content-type: application/json
date: Mon, 13 Nov 2017 11:36:09 GMT
server: Cowboy

{
    "channel_id": "sora",
    "client_id": "82587784-d3f9-4a8b-ba39-0fdb5a7b16d7",
    "rtp": {
        "total_received_bytes": 221062,
        "total_received_packets": 4639,
        "total_received_rtcp": 4639,
        "total_received_rtcp_bye": 0,
        "total_received_rtcp_psfb_afb": 0,
        "total_received_rtcp_psfb_fir": 0,
        "total_received_rtcp_psfb_pli": 0,
        "total_received_rtcp_rr": 4639,
        "total_received_rtcp_rtpfb_generic_nack": 465,
        "total_received_rtcp_rtpfb_tmmbn": 0,
        "total_received_rtcp_rtpfb_tmmbr": 0,
        "total_received_rtcp_rtpfb_transport_wide": 0,
        "total_received_rtcp_sdes": 0,
        "total_received_rtcp_sr": 0,
        "total_received_rtcp_unknown": 0,
        "total_received_rtcp_xr": 0,
        "total_received_rtp": 0,
        "total_sent_bytes": 412308802,
        "total_sent_packets": 557404,
        "total_sent_rtcp": 8949,
        "total_sent_rtcp_bye": 0,
        "total_sent_rtcp_psfb_afb": 0,
        "total_sent_rtcp_psfb_fir": 0,
        "total_sent_rtcp_psfb_pli": 0,
        "total_sent_rtcp_rr": 0,
        "total_sent_rtcp_rtpfb_generic_nack": 0,
        "total_sent_rtcp_rtpfb_tmmbn": 0,
        "total_sent_rtcp_rtpfb_tmmbr": 0,
        "total_sent_rtcp_rtpfb_transport_wide": 0,
        "total_sent_rtcp_sdes": 8949,
        "total_sent_rtcp_sr": 8949,
        "total_sent_rtcp_unknown": 0,
        "total_sent_rtcp_xr": 0,
        "total_sent_rtp": 548455
    },
    "timestamp": "2017-11-13T11:36:09Z",
    "turn": {
        "total_received_allocate_request": 0,
        "total_received_binding_request": 0,
        "total_received_channel_bind_request": 0,
        "total_received_channel_data": 0,
        "total_received_create_permission_request": 0,
        "total_received_refresh_request": 0,
        "total_received_send_indication": 0,
        "total_received_turn_binding_error": 0,
        "total_received_turn_binding_request": 0,
        "total_received_turn_binding_success": 0,
        "total_sent_allocate_error": 0,
        "total_sent_allocate_success": 0,
        "total_sent_binding_error": 0,
        "total_sent_binding_success": 0,
        "total_sent_channel_bind_error": 0,
        "total_sent_channel_bind_success": 0,
        "total_sent_channel_data": 0,
        "total_sent_create_permission_error": 0,
        "total_sent_create_permission_success": 0,
        "total_sent_data_indication": 0,
        "total_sent_refresh_error": 0,
        "total_sent_refresh_success": 0,
        "total_sent_turn_binding_error": 0,
        "total_sent_turn_binding_request": 0,
        "total_sent_turn_binding_success": 0
    }
}

すべてのクライアントの統計情報を取得する

サービス:Sora
バージョン:20171101
オペレーション:GetStatsAllConnections
x-sora-target:Sora_20171101.GetStatsAllConnections
$ http POST 192.0.2.1:3000/ \
    "x-sora-target:Sora_20171101.GetStatsAllConnections" -vvv
POST / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
Host: 192.0.2.1:3000
User-Agent: HTTPie/0.9.9
x-sora-target: Sora_20171101.GetStatsAllConnections



HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 4067
content-type: application/json
date: Mon, 13 Nov 2017 11:34:32 GMT
server: Cowboy

[
    {
        "channel_id": "sora",
        "client_id": "e8137c14-8774-4c86-aaba-7f6507cc5099",
        "rtp": {
            "total_received_bytes": 404798473,
            "total_received_packets": 551822,
            "total_received_rtcp": 13067,
            "total_received_rtcp_bye": 0,
            "total_received_rtcp_psfb_afb": 0,
            "total_received_rtcp_psfb_fir": 0,
            "total_received_rtcp_psfb_pli": 0,
            "total_received_rtcp_rr": 4282,
            "total_received_rtcp_rtpfb_generic_nack": 0,
            "total_received_rtcp_rtpfb_tmmbn": 0,
            "total_received_rtcp_rtpfb_tmmbr": 0,
            "total_received_rtcp_rtpfb_transport_wide": 0,
            "total_received_rtcp_sdes": 8785,
            "total_received_rtcp_sr": 8785,
            "total_received_rtcp_unknown": 0,
            "total_received_rtcp_xr": 0,
            "total_received_rtp": 538755,
            "total_sent_bytes": 553406,
            "total_sent_packets": 8873,
            "total_sent_rtcp": 8873,
            "total_sent_rtcp_bye": 0,
            "total_sent_rtcp_psfb_afb": 7152,
            "total_sent_rtcp_psfb_fir": 0,
            "total_sent_rtcp_psfb_pli": 7,
            "total_sent_rtcp_rr": 7152,
            "total_sent_rtcp_rtpfb_generic_nack": 1714,
            "total_sent_rtcp_rtpfb_tmmbn": 0,
            "total_sent_rtcp_rtpfb_tmmbr": 0,
            "total_sent_rtcp_rtpfb_transport_wide": 0,
            "total_sent_rtcp_sdes": 0,
            "total_sent_rtcp_sr": 0,
            "total_sent_rtcp_unknown": 0,
            "total_sent_rtcp_xr": 0,
            "total_sent_rtp": 0
        },
        "timestamp": "2017-11-13T11:34:32Z",
        "turn": {
            "total_received_allocate_request": 0,
            "total_received_binding_request": 0,
            "total_received_channel_bind_request": 0,
            "total_received_channel_data": 0,
            "total_received_create_permission_request": 0,
            "total_received_refresh_request": 0,
            "total_received_send_indication": 0,
            "total_received_turn_binding_error": 0,
            "total_received_turn_binding_request": 0,
            "total_received_turn_binding_success": 0,
            "total_sent_allocate_error": 0,
            "total_sent_allocate_success": 0,
            "total_sent_binding_error": 0,
            "total_sent_binding_success": 0,
            "total_sent_channel_bind_error": 0,
            "total_sent_channel_bind_success": 0,
            "total_sent_channel_data": 0,
            "total_sent_create_permission_error": 0,
            "total_sent_create_permission_success": 0,
            "total_sent_data_indication": 0,
            "total_sent_refresh_error": 0,
            "total_sent_refresh_success": 0,
            "total_sent_turn_binding_error": 0,
            "total_sent_turn_binding_request": 0,
            "total_sent_turn_binding_success": 0
        }
    },
    {
        "channel_id": "sora",
        "client_id": "82587784-d3f9-4a8b-ba39-0fdb5a7b16d7",
        "rtp": {
            "total_received_bytes": 214972,
            "total_received_packets": 4512,
            "total_received_rtcp": 4512,
            "total_received_rtcp_bye": 0,
            "total_received_rtcp_psfb_afb": 0,
            "total_received_rtcp_psfb_fir": 0,
            "total_received_rtcp_psfb_pli": 0,
            "total_received_rtcp_rr": 4512,
            "total_received_rtcp_rtpfb_generic_nack": 450,
            "total_received_rtcp_rtpfb_tmmbn": 0,
            "total_received_rtcp_rtpfb_tmmbr": 0,
            "total_received_rtcp_rtpfb_transport_wide": 0,
            "total_received_rtcp_sdes": 0,
            "total_received_rtcp_sr": 0,
            "total_received_rtcp_unknown": 0,
            "total_received_rtcp_xr": 0,
            "total_received_rtp": 0,
            "total_sent_bytes": 401350162,
            "total_sent_packets": 542731,
            "total_sent_rtcp": 8708,
            "total_sent_rtcp_bye": 0,
            "total_sent_rtcp_psfb_afb": 0,
            "total_sent_rtcp_psfb_fir": 0,
            "total_sent_rtcp_psfb_pli": 0,
            "total_sent_rtcp_rr": 0,
            "total_sent_rtcp_rtpfb_generic_nack": 0,
            "total_sent_rtcp_rtpfb_tmmbn": 0,
            "total_sent_rtcp_rtpfb_tmmbr": 0,
            "total_sent_rtcp_rtpfb_transport_wide": 0,
            "total_sent_rtcp_sdes": 8708,
            "total_sent_rtcp_sr": 8708,
            "total_sent_rtcp_unknown": 0,
            "total_sent_rtcp_xr": 0,
            "total_sent_rtp": 534023
        },
        "timestamp": "2017-11-13T11:34:32Z",
        "turn": {
            "total_received_allocate_request": 0,
            "total_received_binding_request": 0,
            "total_received_channel_bind_request": 0,
            "total_received_channel_data": 0,
            "total_received_create_permission_request": 0,
            "total_received_refresh_request": 0,
            "total_received_send_indication": 0,
            "total_received_turn_binding_error": 0,
            "total_received_turn_binding_request": 0,
            "total_received_turn_binding_success": 0,
            "total_sent_allocate_error": 0,
            "total_sent_allocate_success": 0,
            "total_sent_binding_error": 0,
            "total_sent_binding_success": 0,
            "total_sent_channel_bind_error": 0,
            "total_sent_channel_bind_success": 0,
            "total_sent_channel_data": 0,
            "total_sent_create_permission_error": 0,
            "total_sent_create_permission_success": 0,
            "total_sent_data_indication": 0,
            "total_sent_refresh_error": 0,
            "total_sent_refresh_success": 0,
            "total_sent_turn_binding_error": 0,
            "total_sent_turn_binding_request": 0,
            "total_sent_turn_binding_success": 0
        }
    }
]

統計情報を取得する

サービス:Sora
バージョン:20171010
オペレーション:GetStatsReport
x-sora-target:Sora_20171010.GetStatsReport

Sora の起動している間の統計情報を取得することができます。この統計情報は Sora を止めたり再起動したりすることでクリアされますので注意してください。

レスポンス項目

  • total_successful_connections
    • 現在までの接続が成功した数
  • total_ongoing_connections
    • 現在接続している数
  • total_failed_connections
    • 現在までの接続が失敗した数
  • total_duration_sec
    • 現在までの合計接続時間 (秒)
  • total_turn_udp_connections
    • 現在までの TURN-UDP での接続数
  • total_turn_tcp_connections
    • 現在までの TURN-TCP または TURN-TLS での接続数
  • average_duration_sec
    • 平均接続時間 (秒)
  • average_setup_time_msec
    • 平均セットアップ時間 (ミリ秒)
$ http POST 127.0.0.1:3000/ \
    x-sora-target:Sora_20171010.GetStatsReport \
    -vvv

POST / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.9
x-sora-target: Sora_20171010.GetStatsReport



HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 172
content-type: application/json
date: Tue, 10 Oct 2017 10:23:22 GMT
server: Cowboy

{
    "average_duration_sec": 24,
    "average_setup_time_msec": 77,
    "total_duration_sec": 48,
    "total_failed_connections": 0,
    "total_ongoing_connections": 1,
    "total_successful_connections": 3,
    "total_turn_udp_connections": 2,
    "total_turn_tcp_connections": 1
}

ライセンス API

現在利用しているライセンス情報を取得する

サービス:Sora
バージョン:20171218
オペレーション:GetLicense
x-sora-target:Sora_20171218.GetLicense
$ http POST 192.0.2.1:3000/
    x-sora-target:Sora_20171218.GetLicense -vvv
POST / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.9
x-sora-target: Sora_20171218.GetLicense



HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 174
content-type: application/json
date: Fri, 05 Jan 2018 06:41:35 GMT
server: Cowboy

{
    "max_connections": 100,
    "product_name": "Sora",
    "serial_code": "123ABC-SRA-E001-20180101-100",
    "signature": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "type": "Experimental"
}

ライセンスを更新する

サービス:Sora
バージョン:20171218
オペレーション:UpdateLicense
x-sora-target:Sora_20171218.UpdateLicense

sys.config の license_file に設定したファイルを新規のライセンスとして読み込みます。ライセンスが壊れていたり、見つからない場合はエラーになります

$ http POST 192.0.2.1:3000/ x-sora-target:Sora_20171218.UpdateLicense -vvv

POST / HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 0
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.9
x-sora-target: Sora_20171218.UpdateLicense



HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 379
content-type: application/json
date: Fri, 05 Jan 2018 06:44:47 GMT
server: Cowboy

{
    "new_license": {
        "max_connections": 100,
        "product_name": "Sora",
        "serial_code": "123ABC-SRA-E001-20180101-100",
        "signature": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
        "type": "Experimental"
    },
    "old_license": {
        "max_connections": 100,
        "product_name": "Sora",
        "serial_code": "123ABC-SRA-E002-20190101-100",
        "signature": "1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
        "type": "Experimental"
    }
}

スポットライト API

警告

スポットライト機能はプレビュー版のため正式版では仕様が変更される可能性があります

指定した参加者を強制的に画面に表示する

サービス:Sora
バージョン:20180404
オペレーション:CastSpotlight
x-sora-target:Sora_20180404.CastSpotlight
キー
channel_id string
client_id string
$ http POST 127.0.0.1:3000/ x-sora-target:Sora_20180404.CastSpotlight \
                            channel_id=sora \
                            client_id=ad31f60c-73e9-4a0b-a4ee-1de001174004 \
                            -vvv
POST / HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 75
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.9
x-sora-target: Sora_20180404.CastSpotlight

{
    "channel_id": "sora",
    "client_id": "ad31f60c-73e9-4a0b-a4ee-1de001174004"
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 72
content-type: application/json
date: Fri, 27 Apr 2018 02:01:35 GMT
server: Cowboy

{
    "channel_id": "sora",
    "client_id": "ad31f60c-73e9-4a0b-a4ee-1de001174004"
}

指定した参加者を常に画面に表示する

サービス:Sora
バージョン:20180404
オペレーション:CastAlwaysSpotlight
x-sora-target:Sora_20180404.CastAlwaysSpotlight
キー
channel_id string
client_id string
spotlight_id string
$ http POST 127.0.0.1:3000/ x-sora-target:Sora_20180404.CastAlwaysSpotlight \
                            channel_id=sora \
                            client_id=af9103b1-2412-4a3c-88b2-cc4d84114d98 \
                            spotlight_id=spotlight-1 \
                            -vvv
POST / HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 106
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.9
x-sora-target: Sora_20180404.CastAlwaysSpotlight

{
    "channel_id": "sora",
    "client_id": "af9103b1-2412-4a3c-88b2-cc4d84114d98",
    "spotlight_id": "spotlight-1"
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 101
content-type: application/json
date: Wed, 25 Apr 2018 07:11:30 GMT
server: Cowboy

{
    "channel_id": "sora",
    "client_id": "af9103b1-2412-4a3c-88b2-cc4d84114d98",
    "spotlight_id": "spotlight-1"
}

指定した参加者を常に画面に表示するから解除する

サービス:Sora
バージョン:20180404
オペレーション:CancelSpotlight
x-sora-target:Sora_20180404.CancelSpotlight
キー
channel_id string
client_id string
$ http POST 127.0.0.1:3000/ x-sora-target:Sora_20180404.CancelSpotlight \
                            channel_id=sora \
                            client_id=af9103b1-2412-4a3c-88b2-cc4d84114d98 \
                            -vvv
POST / HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 75
Content-Type: application/json
Host: 127.0.0.1:3000
User-Agent: HTTPie/0.9.9
x-sora-target: Sora_20180404.CancelSpotlight

{
    "channel_id": "sora",
    "client_id": "af9103b1-2412-4a3c-88b2-cc4d84114d98"
}

HTTP/1.1 200 OK
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, x-sora-target
access-control-allow-methods: POST, OPTIONS
access-control-allow-origin: http://127.0.0.1:5000
access-control-max-age: 1000
content-length: 72
content-type: application/json
date: Wed, 25 Apr 2018 07:12:01 GMT
server: Cowboy

{
    "channel_id": "sora",
    "client_id": "af9103b1-2412-4a3c-88b2-cc4d84114d98"
}