• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..16-Feb-2021-

receiver_examples/H16-Feb-2021-1818

streaming_examples/H16-Feb-2021-113113

README.mdH A D16-Feb-20214 KiB6352

receiver_schema.jsonH A D16-Feb-20211.8 KiB6262

streaming_schema.jsonH A D16-Feb-20218.6 KiB291291

validate_examples.shH A D16-Feb-2021738 2411

README.md

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