1*3f982cf4SFabien Sanglard# [libcast] Cast Streaming Control Protocol (CSCP) 2*3f982cf4SFabien Sanglard 3*3f982cf4SFabien Sanglard## What is it? 4*3f982cf4SFabien Sanglard 5*3f982cf4SFabien SanglardCSCP is the standardized and modernized implement of the Castv2 Mirroring 6*3f982cf4SFabien SanglardControl Protocol, a legacy API implemented both inside of 7*3f982cf4SFabien Sanglard[Chrome's Mirroring Service](https://source.chromium.org/chromium/chromium/src/+/master:components/mirroring/service/receiver_response.h;l=75?q=receiverresponse%20&ss=chromium%2Fchromium%2Fsrc) 8*3f982cf4SFabien Sanglardand other Google products that communicate with 9*3f982cf4SFabien SanglardChrome, such as Chromecast. This API handles session control messaging, such as 10*3f982cf4SFabien Sanglardmanaging OFFER/ANSWER exchanges, getting status and capability information from 11*3f982cf4SFabien Sanglardthe receiver, and exchanging RPC messaging for handling media remoting. 12*3f982cf4SFabien Sanglard 13*3f982cf4SFabien Sanglard## What's in this folder? 14*3f982cf4SFabien SanglardThe `streaming_schema.json` file in this directory contains a 15*3f982cf4SFabien Sanglard[JsonSchema](https://json-schema.org/) for the validation of control messaging 16*3f982cf4SFabien Sanglarddefined in the Cast Streaming Control Protocol. This includes comprehensive 17*3f982cf4SFabien Sanglardrules for message definitions as well as valid values and ranges. Similarly, 18*3f982cf4SFabien Sanglardthe `receiver_schema.json` file contains a JsonSchema for validating receiver 19*3f982cf4SFabien Sanglardcontrol messages, such as `LAUNCH` and `GET_APP_AVAILABILITY`. 20*3f982cf4SFabien Sanglard 21*3f982cf4SFabien SanglardThe `validate_examples.sh` runs the control protocol against a wide variety of 22*3f982cf4SFabien Sanglardexample files in this directory, one for each type of supported message in CSCP. 23*3f982cf4SFabien SanglardIn order to see what kind of validation this library provides, you can modify 24*3f982cf4SFabien Sanglardthese example files and see what kind of errors this script presents. 25*3f982cf4SFabien Sanglard 26*3f982cf4SFabien SanglardNOTE: this script uses 27*3f982cf4SFabien Sanglard[`yajsv`](https://github.com/neilpa/yajsv/releases/tag/v1.4.0), 28*3f982cf4SFabien Sanglardwhich must be downloaded using the `tools/download-yajsv.py` script. 29*3f982cf4SFabien Sanglard 30*3f982cf4SFabien SanglardFor example, if we modify the launch.json to not have a language field: 31*3f982cf4SFabien Sanglard 32*3f982cf4SFabien Sanglard``` 33*3f982cf4SFabien Sanglard-> % ./validate_examples.sh -1- 34*3f982cf4SFabien Sanglard/usr/local/src/openscreen/cast/protocol/castv2/streaming_examples/answer.json: pass 35*3f982cf4SFabien Sanglard/usr/local/src/openscreen/cast/protocol/castv2/streaming_examples/capabilities_response.json: pass 36*3f982cf4SFabien Sanglard/usr/local/src/openscreen/cast/protocol/castv2/streaming_examples/get_capabilities.json: pass 37*3f982cf4SFabien Sanglard/usr/local/src/openscreen/cast/protocol/castv2/streaming_examples/get_status.json: pass 38*3f982cf4SFabien Sanglard/usr/local/src/openscreen/cast/protocol/castv2/streaming_examples/offer.json: pass 39*3f982cf4SFabien Sanglard/usr/local/src/openscreen/cast/protocol/castv2/streaming_examples/rpc.json: pass 40*3f982cf4SFabien Sanglard/usr/local/src/openscreen/cast/protocol/castv2/streaming_examples/status_response.json: pass 41*3f982cf4SFabien Sanglard/usr/local/src/openscreen/cast/protocol/castv2/receiver_examples/get_app_availability.json: pass 42*3f982cf4SFabien Sanglard/usr/local/src/openscreen/cast/protocol/castv2/receiver_examples/get_app_availability_response.json: pass 43*3f982cf4SFabien Sanglard/usr/local/src/openscreen/cast/protocol/castv2/receiver_examples/launch.json: fail: (root): Must validate "then" as "if" was valid 44*3f982cf4SFabien Sanglard/usr/local/src/openscreen/cast/protocol/castv2/receiver_examples/launch.json: fail: (root): language is required 45*3f982cf4SFabien Sanglard/usr/local/src/openscreen/cast/protocol/castv2/receiver_examples/launch.json: fail: (root): Must validate all the schemas (allOf) 46*3f982cf4SFabien Sanglard1 of 1 failed validation 47*3f982cf4SFabien Sanglard/usr/local/src/openscreen/cast/protocol/castv2/receiver_examples/launch.json: fail: (root): Must validate "then" as "if" was valid 48*3f982cf4SFabien Sanglard/usr/local/src/openscreen/cast/protocol/castv2/receiver_examples/launch.json: fail: (root): language is required 49*3f982cf4SFabien Sanglard/usr/local/src/openscreen/cast/protocol/castv2/receiver_examples/launch.json: fail: (root): Must validate all the schemas (allOf) 50*3f982cf4SFabien Sanglard/usr/local/src/openscreen/cast/protocol/castv2/receiver_examples/stop.json: pass 51*3f982cf4SFabien Sanglard``` 52*3f982cf4SFabien Sanglard 53*3f982cf4SFabien Sanglard## Updating schemas 54*3f982cf4SFabien Sanglard 55*3f982cf4SFabien SanglardWhen updating the JSON schema files, take care to ensure consistant formatting. 56*3f982cf4SFabien SanglardSince `clang-format` doesn't support JSON files (currently only Python, C++, 57*3f982cf4SFabien Sanglardand JavaScript), the JSON files here are instead formatted using 58*3f982cf4SFabien Sanglard(json-stringify-pretty-compact)[https://github.com/lydell/json-stringify-pretty-compact] 59*3f982cf4SFabien Sanglardwith a max line length of 80 and a 2-character indent. Many IDEs have an 60*3f982cf4SFabien Sanglardextension for this, such as VSCode's 61*3f982cf4SFabien Sanglard(json-compact-prettifier)[https://marketplace.visualstudio.com/items?itemName=inadarei.json-compact-prettifier]. 62*3f982cf4SFabien Sanglard 63