CheckForUpdates
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
/osc/checkForUpdates
API は、クライアントが最後に認識した stateFingerprint
とカメラの現在の fingerprint
を比較して、状態の更新を特定します。
名前 |
型 |
説明 |
stateFingerprint |
文字列 |
クライアントが最後に /osc/state または /osc/checkForUpdates を呼び出したときのカメラ状態のフィンガープリント。 |
waitTimeout |
整数(省略可) |
レスポンスを返す前にカメラの状態変化を待機する秒数。waitTimeout が期限切れになると、指紋が変更されていなくても、カメラから応答が返されます。waitTimeout が期限切れになる前に状態変更が検出された場合、または waitTimeout が省略された場合、カメラはすぐにレスポンスを返します。注: フィンガープリントが変更されていなくても、waitTimeout の有効期限が切れる前にカメラがレスポンスを返すことがありますが、ベスト プラクティスとして、waitTimeout が期限切れになるまで待つことをおすすめします。 |
カメラ実装に関する注意事項:
- この呼び出しを受信すると、カメラは現在の状態のフィンガープリントと受け取った
stateFingerprint
パラメータを比較します。フィンガープリントが変更されている場合は、カメラはすぐに新しいフィンガープリントを返す必要があります。
出力
名前 |
タイプ |
説明 |
stateFingerprint |
文字列 |
カメラの状態の新しいフィンガープリント(/osc/state API と同様)。 |
throttleTimeout |
Integer |
クライアントが次の checkForUpdates 呼び出しの前に待機する推奨秒数。クライアントは throttleTimeout の期限が切れる前にリクエストを送信できます。カメラは、可能であればこれらの早期リクエストを許可する必要があります。 |
クライアント実装に関する注意事項:
- レスポンスを受信したら、クライアントは受信した
stateFingerprint
をそのコピーと比較する必要があります。一致しない場合、クライアントは _/osc/state
API を使用してカメラの現在の状態をリクエストする必要があります。
- スマート クライアントは、カメラの応答に関係なくリクエストをスロットリングします。たとえば、カメラが標準以外のレスポンスを返した場合(すぐに変更なしで、
throttleTimeout)
が小さいか 0 の場合)、クライアントはカメラに別の checkForUpdates
をリクエストする前に、独自の throttleTimeout
を適用する必要があります。
カメラ実装に関する注意事項:
checkForUpdates
に応答する際、カメラは適切な throttleTimeout
を判断する必要があります。カメラが長時間のリクエスト ロジックをサポートしている場合(状態が変わっていない場合、waitTimeout
の後にのみ応答する場合)、throttleTimeout
を 0
として返しても問題ありません。この場合、クライアントはすぐにアップデートをリクエストできます。
- カメラが迅速な応答のみをサポートしている場合(おすすめしません)、クライアントとの継続的なリクエスト/レスポンス トラフィックが発生しないように、適切な
throttleTimeout
を返す必要があります。たとえば、1 分あたり 1 つのクライアント リクエストを許可するには、適切な throttleTimeout
は 60 秒です。
- ベスト プラクティスとして、カメラの機能に適した
throttleTimeout
を返すことをおすすめします。サーバーの問題によりサーバーが適切な throttleTimeout
を判断できない場合、カメラは 5XX ステータス コードと serverError
エラーコードを含む JSON 本文を返します。
エラー
エラーコード |
説明 |
missingParameter |
stateFingerprint が指定されていません。 |
invalidParameterName |
認識できない入力パラメータ名があります。 |
invalidParameterValue |
パラメータ名は認識されていますが、無効な値が 1 つ以上あります。たとえば、waitTimeout が範囲外であるか、タイプが正しくありません。 |
serverError |
サーバーはレスポンスに適した throttleTimeout 値を特定できませんでした。サーバーの問題は、レスポンスで返される 5XX の値で識別できます。カメラのメーカーは、このエラーをスローする可能性がある 5XX コードと対応するサーバーの状態の表を提供する必要があります。 |
例 |
リクエスト |
POST /osc/checkForUpdates HTTP/1.1
Host: [camera ip address]:[httpUpdatesPort]
Content-Type: application/json;charset=utf-8
Accept: application/jsonContent-Length: {CONTENT_LENGTH}
X-XSRF-Protected: 1
{
"stateFingerprint": "12EGA33",
"waitTimeout": 300
} |
レスポンス |
HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8
Content-Length: {CONTENT_LENGTH}
X-Content-Type-Options: nosniff
{
"stateFingerprint": "12EGA86",
"throttleTimeout": 60
} |
リクエスト |
POST /osc/checkForUpdates HTTP/1.1
Host: [camera ip address]:[httpUpdatesPort]
Content-Type: application/json;charset=utf-8
Accept: application/jsonContent-Length: {CONTENT_LENGTH}
X-XSRF-Protected: 1
{
"stateFingerprint": "12EGA33",
"waitTimeout": 300
} |
レスポンス |
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=utf-8
Content-Length: {CONTENT_LENGTH}
X-Content-Type-Options: nosniff
{
"name": "camera.checkForUpdates",
"state": "error",
"error": {
"code": "missingParameter",
"message": "parameter stateFingerprint is missing."
}
} |
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2025-07-25 UTC。
[null,null,["最終更新日 2025-07-25 UTC。"],[[["\u003cp\u003eThe \u003ccode\u003e/osc/checkForUpdates\u003c/code\u003e API allows clients to efficiently check for camera state changes without repeatedly requesting the full state.\u003c/p\u003e\n"],["\u003cp\u003eClients provide their last known state fingerprint, and the camera responds with a new fingerprint if the state has changed.\u003c/p\u003e\n"],["\u003cp\u003eA \u003ccode\u003ethrottleTimeout\u003c/code\u003e value is provided to guide clients on how frequently to check for updates, optimizing network traffic.\u003c/p\u003e\n"],["\u003cp\u003eIf the camera's state has not changed, it may wait for a specified \u003ccode\u003ewaitTimeout\u003c/code\u003e before responding to avoid unnecessary updates.\u003c/p\u003e\n"],["\u003cp\u003eErrors are provided if parameters are missing, invalid, or if the server encounters an issue determining an appropriate \u003ccode\u003ethrottleTimeout\u003c/code\u003e.\u003c/p\u003e\n"]]],["The `/osc/checkForUpdates` API checks for camera state changes. The client sends its `stateFingerprint` and an optional `waitTimeout`. The camera compares the received `stateFingerprint` with its current one, immediately returning the new fingerprint if changed. The camera also returns a `throttleTimeout` suggesting how long the client should wait before its next check. If the fingerprints match or after the wait time expires, a response is sent. Clients then request the current state if fingerprints don't match.\n"],null,["# CheckForUpdates\n\nThe `/osc/checkForUpdates` API identifies state updates by comparing the client's last known `stateFingerprint` to the camera's current `fingerprint`.\n\nInput\n-----\n\n| **Name** | **Type** | **Description** |\n|--------------------|--------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `stateFingerprint` | String | Camera state fingerprint from the last time the client called `/osc/state` or `/osc/checkForUpdates`. |\n| `waitTimeout` | Integer (optional) | Number of seconds to wait for state change on the camera to occur before returning the response. When `waitTimeout` expires, the camera should return a response even if the fingerprint hasn't changed. If a state change is detected before `waitTimeout` expires, or if `waitTimeout` is omitted, the camera should immediately return the response.**Note:** the camera can return a response before `waitTimeout` has expired even if the fingerprint hasn't changed, but the ***best practice*** is to wait until `waitTimeout` expires. |\n\n### Camera implementation notes:\n\n- Upon receiving this call, the camera compares its current state fingerprint with the received `stateFingerprint` parameter. If the fingerprint has changed, the camera must immediately return the new fingerprint.\n\nOutput\n------\n\n| **Name** | **Type** | **Description** |\n|--------------------|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `stateFingerprint` | String | New fingerprint of the camera state (same as in `/osc/state` API). |\n| `throttleTimeout` | Integer | Recommended number of seconds for client to wait before next `checkForUpdates` call. Clients can make requests before `throttleTimeout` expires, and cameras should allow these early requests if possible. |\n\n### Client implementation notes:\n\n- Upon receiving a response, the client should compare the received `stateFingerprint` with its copy. If they don't match, the client should request the camera's current state using the `_/osc/state` API.\n- Smart clients will throttle requests regardless of the camera response. For example, if a camera returns a non-standard response (immediately, with *no change* and a low or 0 `throttleTimeout)`, the client should impose its own `throttleTimeout` before requesting another `checkForUpdates` from the camera.\n\n### Camera implementation notes:\n\n- When responding to `checkForUpdates`, the camera should determine a reasonable `throttleTimeout`. If the camera supports long standing request logic (respond only after `waitTimeout` if state hasn't changed), it is OK to return `throttleTimeout` as `0`. In this case, clients can immediately request updates.\n- If the camera supports only fast responses (*not recommended* ), it should return a reasonable `throttleTimeout` to avoid constant request/response traffic with the client. For example, a reasonable `throttleTimeout` would be 60 seconds, to allow one client request per minute.\n- The ***best practice*** is to return a `throttleTimeout` appropriate for the camera's capabilities. If the server cannot determine an appropriate `throttleTimeout` due to a server issue, the camera should respond with a 5XX status code and a JSON body containing `serverError` error code.\n\nError\n-----\n\n| **Error code** | **Description** |\n|-------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `missingParameter` | `stateFingerprint` is not specified. |\n| `invalidParameterName` | One or more input parameter names is unrecognized. |\n| `invalidParameterValue` | The parameter names are recognized, but one or more values is invalid; for example, `waitTimeout` is out of range or its type is incorrect. |\n| `serverError` | The server was unable to determine an appropriate `throttleTimeout` value for its response. The server problem will be identified by the 5XX value returned in the response. Camera manufacturers should supply a table of 5XX codes and corresponding server states that can throw this error. |\n\n| Example ------- ||\n|--------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| **Request** | ```http POST /osc/checkForUpdates HTTP/1.1 Host: [camera ip address]:[httpUpdatesPort] Content-Type: application/json;charset=utf-8 Accept: application/jsonContent-Length: {CONTENT_LENGTH} X-XSRF-Protected: 1 { \"stateFingerprint\": \"12EGA33\", \"waitTimeout\": 300 } ``` |\n| **Response** | ```http HTTP/1.1 200 OK Content-Type: application/json;charset=utf-8 Content-Length: {CONTENT_LENGTH} X-Content-Type-Options: nosniff { \"stateFingerprint\": \"12EGA86\", \"throttleTimeout\": 60 } ``` |\n| **Request** | ```http POST /osc/checkForUpdates HTTP/1.1 Host: [camera ip address]:[httpUpdatesPort] Content-Type: application/json;charset=utf-8 Accept: application/jsonContent-Length: {CONTENT_LENGTH} X-XSRF-Protected: 1 { \"stateFingerprint\": \"12EGA33\", \"waitTimeout\": 300 } ``` |\n| **Response** | ```http HTTP/1.1 400 Bad Request Content-Type: application/json;charset=utf-8 Content-Length: {CONTENT_LENGTH} X-Content-Type-Options: nosniff { \"name\": \"camera.checkForUpdates\", \"state\": \"error\", \"error\": { \"code\": \"missingParameter\", \"message\": \"parameter stateFingerprint is missing.\" } } ``` |"]]