七牛APIインタフェースドキュメントV 1

39242 ワード

APIインタフェース文書V 1
huxicong・発表于:2016-08-12 15:22・更新于:2016-11-21 18:14

フローの作成


リクエストhub.createStream(title, publishKey, publishSecurity);
パラメータ説明title(string)、ストリーム名、namePattern、err:=regexpを満たす必要があります.Compile(^[a-zA-Z 0-9_-]{4200}$.publishKey(string)検証のkey publishSecurity認証方式「dynamic」または「static」、「dynamic」がデフォルト
POST /v1/streams HTTP/1.1
Host: pili.qiniuapi.com
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: application/json
Authorization: Qiniu vI2xPIjOoh7udcRw4GdYNvf3o_gKsCx9wdZaC9u-:oJeCsKJUyv6KCLlnP4vyCheYKnk=
Content-Length: 87

{"hub":"1314xicong","title":"hello","publishKey":"huxicong","publishSecurity":"static"}

応答
{
    "id": "z1.1314xicong.hello",
    "createdAt": "2016-08-08T11:50:22.09+08:00",
    "updatedAt": "2016-08-08T11:50:22.09+08:00",
    "title": "hello",
    "hub": "1314xicong",
    "disabledTill": 0,
    "disabled": false,
    "publishKey": "huxicong",
    "publishSecurity": "static",
    "hosts": {
        "publish": {
            "rtmp": "pili-publish.pili.echohu.top"
        },
        "live": {
            "hdl": "pili-live-hdl.pili.echohu.top",
            "hls": "pili-live-hls.pili.echohu.top",
            "http": "pili-live-hls.pili.echohu.top",
            "rtmp": "pili-live-rtmp.pili.echohu.top",
            "snapshot": "100008j.live1-snapshot.z1.pili.qiniucdn.com"
        },
        "playback": {
            "hls": "100008j.playback1.z1.pili.qiniucdn.com",
            "http": "100008j.playback1.z1.pili.qiniucdn.com"
        },
        "play": {
            "http": "pili-live-hls.pili.echohu.top",
            "rtmp": "pili-live-rtmp.pili.echohu.top"
        }
    }
}

ストリームの取得


リクエスト
hub.getStream(streamId)
streamId(フローの表示z 1.1314 xicong.huxicongp)
GET /v1/streams/z1.1314xicong.hello HTTP/1.1
Host: pili.qiniuapi.com
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: application/json
User-Agent: pili-sdk-php/1.5.4 curl/7.47.1 PHP/7.0.8
Authorization: Qiniu vI2xPIjOoh7udcRw4GdYNvf3o_gKsCx9wdZaC9u-:yvLyCKiXvBdAWgGGDyLIZUvMCmY=

応答
{
    "id": "z1.1314xicong.hello",
    "createdAt": "2016-08-08T11:50:22.09+08:00",
    "updatedAt": "2016-08-08T11:50:22.09+08:00",
    "title": "hello",
    "hub": "1314xicong",
    "disabledTill": 0,
    "disabled": false,
    "publishKey": "huxicong",
    "publishSecurity": "static",
    "hosts": {
        "publish": {
            "rtmp": "pili-publish.pili.echohu.top"
        },
        "live": {
            "hdl": "pili-live-hdl.pili.echohu.top",
            "hls": "pili-live-hls.pili.echohu.top",
            "http": "pili-live-hls.pili.echohu.top",
            "rtmp": "pili-live-rtmp.pili.echohu.top",
            "snapshot": "100008j.live1-snapshot.z1.pili.qiniucdn.com"
        },
        "playback": {
            "hls": "100008j.playback1.z1.pili.qiniucdn.com",
            "http": "100008j.playback1.z1.pili.qiniucdn.com"
        },
        "play": {
            "http": "pili-live-hls.pili.echohu.top",
            "rtmp": "pili-live-rtmp.pili.echohu.top"
        }
    }
}

列挙フロー
リクエスト
hub.listStreams(marker, limit, title_prefix, status);
パラメータ説明title_prefix(string)文字列は、オプションで、prefixを接頭辞とするストリーム名のみを返すことを制限し、非限定接頭辞を表すことを指定しない.limit(int)整数は、オプションで、返されるストリームの数を限定し、システムの制限に従う最大数を指定しません.marker(int)文字列、オプション、前回のクエリーで返されたタグは、サービス側が前回調べた場所からクエリーを継続するように要求するために使用され、先頭クエリーを指定しません.
GET /v1/streams?hub=1314xicong&limit=2 HTTP/1.1
Host: pili.qiniuapi.com
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: application/json
User-Agent: pili-sdk-php/1.5.4 curl/7.47.1 PHP/7.0.8
Authorization: Qiniu vI2xPIjOoh7udcRw4GdYNvf3o_gKsCx9wdZaC9u-:mTUdSB0pTLQka-rpfNf4jM36l28=

応答
{
    "marker": "2",
    "items": [
        {
            "id": "z1.1314xicong.hello",
            "createdAt": "2016-08-08T11:50:22.09+08:00",
            "updatedAt": "2016-08-08T11:50:22.09+08:00",
            "title": "hello",
            "hub": "1314xicong",
            "disabledTill": 0,
            "disabled": false,
            "publishKey": "huxicong",
            "publishSecurity": "static",
            "hosts": {
                "publish": {
                    "rtmp": "pili-publish.pili.echohu.top"
                },
                "live": {
                    "hdl": "pili-live-hdl.pili.echohu.top",
                    "hls": "pili-live-hls.pili.echohu.top",
                    "http": "pili-live-hls.pili.echohu.top",
                    "rtmp": "pili-live-rtmp.pili.echohu.top",
                    "snapshot": "100008j.live1-snapshot.z1.pili.qiniucdn.com"
                },
                "playback": {
                    "hls": "100008j.playback1.z1.pili.qiniucdn.com",
                    "http": "100008j.playback1.z1.pili.qiniucdn.com"
                },
                "play": {
                    "http": "pili-live-hls.pili.echohu.top",
                    "rtmp": "pili-live-rtmp.pili.echohu.top"
                }
            }
        },
        {
            "id": "z1.1314xicong.57a801305e77b03d5202aa31",
            "createdAt": "2016-08-08T11:49:04.224+08:00",
            "updatedAt": "2016-08-08T11:49:04.224+08:00",
            "title": "57a801305e77b03d5202aa31",
            "hub": "1314xicong",
            "disabledTill": 0,
            "disabled": false,
            "publishKey": "b321c6c6-9004-4cad-b29a-7d5dec42659b",
            "publishSecurity": "static",
            "hosts": {
                "publish": {
                    "rtmp": "pili-publish.pili.echohu.top"
                },
                "live": {
                    "hdl": "pili-live-hdl.pili.echohu.top",
                    "hls": "pili-live-hls.pili.echohu.top",
                    "http": "pili-live-hls.pili.echohu.top",
                    "rtmp": "pili
123.059.063.003.00080-192.168.200.120.61037: -live-rtmp.pili.echohu.top",
                    "snapshot": "100008j.live1-snapshot.z1.pili.qiniucdn.com"
                },
                "playback": {
                    "hls": "100008j.playback1.z1.pili.qiniucdn.com",
                    "http": "100008j.playback1.z1.pili.qiniucdn.com"
                },
                "play": {
                    "http": "pili-live-hls.pili.echohu.top",
                    "rtmp": "pili-live-rtmp.pili.echohu.top"
                }
            }
        }
    ],
    "end": false
}

ストリームの更新
stream.updata()
POST /v1/streams/z1.1314xicong.hello HTTP/1.1
Host: pili.qiniuapi.com
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: application/json
User-Agent: pili-sdk-php/1.5.4 curl/7.47.1 PHP/7.0.8
Authorization: Qiniu vI2xPIjOoh7udcRw4GdYNvf3o_gKsCx9wdZaC9u-:d9Ak7nhlZoc3AAudOGHd6QxRB7Q=
Content-Length: 60

{"publishKey":"new_secret_words","publishSecurity":"static"}

応答
{
    "id": "z1.1314xicong.hello",
    "createdAt": "2016-08-08T11:50:22.09+08:00",
    "updatedAt": "2016-08-08T13:00:10.281105075+08:00",
    "title": "hello",
    "hub": "1314xicong",
    "disabledTill": 0,
    "disabled": false,
    "publishKey": "new_secret_words",
    "publishSecurity": "static",
    "hosts": {
        "publish": {
            "rtmp": "pili-publish.pili.echohu.top"
        },
        "live": {
            "hdl": "pili-live-hdl.pili.echohu.top",
            "hls": "pili-live-hls.pili.echohu.top",
            "http": "pili-live-hls.pili.echohu.top",
            "rtmp": "pili-live-rtmp.pili.echohu.top",
            "snapshot": "100008j.live1-snapshot.z1.pili.qiniucdn.com"
        },
        "playback": {
            "hls": "100008j.playback1.z1.pili.qiniucdn.com",
            "http": "100008j.playback1.zone1.pili.qiniucdn.com"
        },
        "play": {
            "http": "pili-live-hls.pili.echohu.top",
            "rtmp": "pili-live-rtmp.pili.echohu.top"
        }
    }
}

ストリームの禁止と有効化
ストリームの禁止
disabledTill:(タイムスタンプ)いつ禁止しますか?
stream.disable(disabledTill);
POST /v1/streams/z1.1314xicong.huxicongp/available HTTP/1.1
Host: pili.qiniuapi.com
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: application/json
User-Agent: pili-sdk-php/1.5.4 curl/7.47.1 PHP/7.0.8
Authorization: Qiniu vI2xPIjOoh7udcRw4GdYNvf3o_gKsCx9wdZaC9u-:m5mdD-RngQE9SwruF6Qc93qCSyw=

{"available":"disabled","disabledTill":1470633009}
HTTP/1.1 204 No Content

ストリームの有効化
stream.enable()
POST /v1/streams/z1.1314xicong.huxicongp/available HTTP/1.1
Host: pili.qiniuapi.com
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: application/json
User-Agent: pili-sdk-php/1.5.4 curl/7.47.1 PHP/7.0.8
Authorization: Qiniu vI2xPIjOoh7udcRw4GdYNvf3o_gKsCx9wdZaC9u-:PNk9q1aCLiWk_MqpZWTk5l_2Rr0=
Content-Length: 23

{"available":"enabled"}

 HTTP/1.1 204 No Content

この2つの要求は、ステータスコードで要求が成功したか否かを判断する.

ストリームのステータス取得


stream.status()
ストリームのステータスには(connect接続とdisconnect未接続)があります.
GET /v1/streams/z1.1314xicong.huxicongp/status HTTP/1.1
Host: pili.qiniuapi.com
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: application/json
User-Agent: pili-sdk-php/1.5.4 curl/7.47.1 PHP/7.0.8
Authorization: Qiniu vI2xPIjOoh7udcRw4GdYNvf3o_gKsCx9wdZaC9u-:sZvsYZ4t_3zt_m6pNrZZEONW7po=

応答
HTTP/1.1 200 OK
{
    "reqId": "",
    "hub": "1314xicong",
    "stream": "huxicongp",
    "startFrom": "0001-01-01T00:00:00Z",
    "updatedAt": "0001-01-01T00:00:00Z",
    "addr": "",
    "status": "disconnected",
    "bytesPerSecond": 0,
    "framesPerSecond": {
        "audio": 0,
        "video": 0,
        "data": 0
    }
}

再生URL(flv RTMP hls)プッシュフローURLの取得
urls = stream.httpFlvLiveUrls();//flvの再生アドレスを取得
urls = stream.hlsLiveUrls();//hlsの再生アドレスを取得
urls = stream.rtmpLiveUrls();//RTMPの再生アドレスを取得
publishUrl = stream.rtmpPublishUrl();//Pushアドレスの取得
GET /v1/streams/z1.1314xicong.huxicongp HTTP/1.1
Host: pili.qiniuapi.com
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: application/json
User-Agent: pili-sdk-php/1.5.4 curl/7.47.1 PHP/7.0.8
Authorization: Qiniu vI2xPIjOoh7udcRw4GdYNvf3o_gKsCx9wdZaC9u-:Knw_76FTr_FSz5-VHM5Xj4ERmhs=

HTTP/1.1 200 OK

応答
{
    "id": "z1.1314xicong.huxicongp",
    "createdAt": "2016-07-12T18:06:29.009+08:00",
    "updatedAt": "2016-07-12T18:06:29.009+08:00",
    "title": "huxicongp",
    "hub": "1314xicong",
    "disabledTill": 0,
    "disabled": false,
    "publishKey": "b321c6c6-9004-4cad-b29a-7d5dec42659b",
    "publishSecurity": "static",
    "hosts": {
        "publish": {
            "rtmp": "pili-publish.pili.echohu.top"
        },
        "live": {
            "hdl": "pili-live-hdl.pili.echohu.top",
            "hls": "pili-live-hls.pili.echohu.top",
            "http": "pili-live-hls.pili.echohu.top",
            "rtmp": "pili-live-rtmp.pili.echohu.top",
            "snapshot": "100008j.live1-snapshot.z1.pili.qiniucdn.com"
        },
        "playback": {
            "hls": "100008j.playback1.z1.pili.qiniucdn.com",
            "http": "100008j.playback1.z1.pili.qiniucdn.com"
        },
        "play": {
            "http": "pili-live-hls.pili.echohu.top",
            "rtmp": "pili-live-rtmp.pili.echohu.top"
        }
    }
}
    

string(97) "rtmp://pili-publish.pili.echohu.top/1314xicong/huxicongp?key=b321c6c6-9004-4cad-b29a-7d5dec42659b"
array(1) {
  ["ORIGIN"]=>
  string(58) "rtmp://pili-live-rtmp.pili.echohu.top/1314xicong/huxicongp"
}
array(1) {
  ["ORIGIN"]=>
  string(61) "http://pili-live-hdl.pili.echohu.top/1314xicong/huxicongp.flv"
}
array(1) {
  ["ORIGIN"]=>
  string(62) "http://pili-live-hls.pili.echohu.top/1314xicong/huxicongp.m3u8"
}

Push履歴を取得して保存する(履歴Pushデータを取得してから再生を保存する)


ストリームの履歴の取得
stream.segments(start, end, limit);
パラメータ説明start(タイムスタンプ)取得の開始期間end(タイムスタンプ)取得の終了期間limit(int)制限で最も多く得られる情報数
GET /v1/streams/z1.1314xicong.mytest/segments HTTP/1.1
Host: pili.qiniuapi.com
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: application/json
User-Agent: pili-sdk-php/1.5.4 curl/7.47.1 PHP/7.0.8
Authorization: Qiniu vI2xPIjOoh7udcRw4GdYNvf3o_gKsCx9wdZaC9u-:2eEI-1NL_xAVjuon-wfZ72pgiEc=

HTTP/1.1 200 OK

{"start":1462417984,"end":1462417993,"duration":9,"segments":[{"start":1462417984,"end":1462417993}]}

ストリームを再生する
stream.saveAs(name, format, start, end, notifyUrl, pipeline);
パラメータ説明name(string)保存されたファイル名format保存されたファイルフォーマットnullはm 3 u 8//optional start&end(タイムスタンプまたは-1)保存された期間パス-1を指定します.この期間は、上の履歴フローレコード{「start」:1462417984、「end」:1462417993}notifyUrl(string)です.MP 4ファイルにマージしたときの処理に成功しましたこのコールバックでサーバurl pipelineが処理したキューをmp 4に保存するにはキューを指定する必要があります.そうしないと処理速度が遅くなります.
192.168.200.120.61423-123.059.063.003.00080: POST /v1/streams/z1.1314xicong.huxicongp/saveas HTTP/1.1
Host: pili.qiniuapi.com
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: application/json
User-Agent: pili-sdk-php/1.5.4 curl/7.47.1 PHP/7.0.8
Authorization: Qiniu vI2xPIjOoh7udcRw4GdYNvf3o_gKsCx9wdZaC9u-:mCB1hBdmSE8amWIO9Ww_pRX7dqc=

{"name":"videoName.mp4","start":-1,"end":-1}
HTTP/1.1 200 OK

応答
{
"url":"http://pili-media.pili.echohu.top/recordings/z1.1314xicong.huxicongp/videoName.m3u8","duration":2569,
"persistentId":""
}

ストリームの削除
stream.delete()
DELETE /v1/streams/z1.1314xicong.huxicongp HTTP/1.1
Host: pili.qiniuapi.com
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: application/json
User-Agent: pili-sdk-php/1.5.4 curl/7.47.1 PHP/7.0.8
Authorization: Qiniu vI2xPIjOoh7udcRw4GdYNvf3o_gKsCx9wdZaC9u-:iGQX6GfyDaiU6CetyCOhLZOdkmY=

HTTP/1.1 204 No Content

生中継スクリーンショット(使用時は生中継がある状態でなければ使用できません)
stream.snapshot(name, format, time, notifyUrl, pipeline)
パラメータ説明name保存ファイル名format保存ファイルのフォーマット「jpg」、「png」time切り取り時間notifyUrl切り取りコールバックのURL pipelineキューを正常に通知
POST /v1/streams/z1.1314xicong.huxicongp/snapshot HTTP/1.1
Host: pili.qiniuapi.com
Accept: */*
Accept-Encoding: deflate, gzip
Content-Type: application/json
User-Agent: pili-sdk-php/1.5.4 curl/7.47.1 PHP/7.0.8
Authorization: Qiniu vI2xPIjOoh7udcRw4GdYNvf3o_gKsCx9wdZaC9u-:I8-k7BbBiqwdLyvIqimFUhpNmDM=
Content-Length: 57

{"name":"imageName.jpg","format":"jpg","time":1470641287}
HTTP/1.1 200 OK

対応
{"targetUrl":"http://pili-static.pili.echohu.top/snapshots/z1.1314xicong.huxicongp/imageName.jpg"}

ふろく
携帯端末のjsonプッシュ方式はサポートのみ(staticとdynamic)
まず、上記のいくつかの取得されたストリームのjsonの方法は呼び出しをサポートしています(ストリームがオンであることを覚えておいてください.無効ではありません).
Stream = hub.createStream(title,publishKey,publishSecurity)/ストリームを再作成してプッシュ
Stream = hub.getStream(streamId)/既存のストリームを取得してストリームをプッシュ
Stream.toJSOnString()これをクライアントに返す