Bug: 178042763

Clone this repo:
  1. 4ecab6c [windows] Fix std::stringstream error after upgrading libc++ am: 81243c9d8f am: 841ef90e4a am: 4a4ffce8be by Ryan Prichard · 2 months ago main master
  2. 4a4ffce [windows] Fix std::stringstream error after upgrading libc++ am: 81243c9d8f am: 841ef90e4a by Ryan Prichard · 2 months ago
  3. 841ef90 [windows] Fix std::stringstream error after upgrading libc++ am: 81243c9d8f by Ryan Prichard · 2 months ago
  4. 81243c9 [windows] Fix std::stringstream error after upgrading libc++ by Ryan Prichard · 2 months ago
  5. a1f37d7 [windows] Fix stale pointer dereference. am: 95e21bc268 am: 1d08a291f5 am: e129a11372 by Joshua Duong · 2 years, 1 month ago aml_tz4_332714010 aml_tz5_341510010 android13-d2-release android13-d3-s1-release android13-d4-release android13-d4-s1-release android13-d4-s2-release android13-dev android13-frc-art-release android13-frc-cellbroadcast-release android13-frc-conscrypt-release android13-frc-odp-release android13-mainline-adservices-release android13-mainline-appsearch-release android13-mainline-go-adbd-release android13-mainline-go-adservices-release android13-mainline-go-appsearch-release android13-mainline-go-media-swcodec-release android13-mainline-go-mediaprovider-release android13-mainline-go-networking-release android13-mainline-go-neuralnetworks-release android13-mainline-go-odp-release android13-mainline-go-os-statsd-release android13-mainline-go-permission-release android13-mainline-go-resolv-release android13-mainline-go-scheduling-release android13-mainline-go-sdkext-release android13-mainline-go-tethering-release android13-mainline-go-tzdata4-release android13-mainline-go-uwb-release android13-mainline-go-wifi-release android13-mainline-tzdata4-release android13-mainline-uwb-release android13-qpr1-release android13-qpr1-s1-release android13-qpr1-s2-release android13-qpr1-s3-release android13-qpr1-s4-release android13-qpr1-s5-release android13-qpr1-s6-release android13-qpr1-s7-release android13-qpr1-s8-release android13-qpr2-b-s1-release android13-qpr2-release android13-qpr2-s1-release android13-qpr2-s10-release android13-qpr2-s11-release android13-qpr2-s12-release android13-qpr2-s2-release android13-qpr2-s3-release android13-qpr2-s5-release android13-qpr2-s6-release android13-qpr2-s7-release android13-qpr2-s8-release android13-qpr2-s9-release android13-qpr3-c-s1-release android13-qpr3-c-s10-release android13-qpr3-c-s11-release android13-qpr3-c-s12-release android13-qpr3-c-s2-release android13-qpr3-c-s3-release android13-qpr3-c-s4-release android13-qpr3-c-s5-release android13-qpr3-c-s6-release android13-qpr3-c-s7-release android13-qpr3-c-s8-release android13-qpr3-release android13-qpr3-s1-release android13-qpr3-s10-release android13-qpr3-s11-release android13-qpr3-s12-release android13-qpr3-s13-release android13-qpr3-s14-release android13-qpr3-s2-release android13-qpr3-s3-release android13-qpr3-s4-release android13-qpr3-s5-release android13-qpr3-s6-release android13-qpr3-s7-release android13-qpr3-s8-release android13-qpr3-s9-release android14-dev android14-mainline-adservices-release android14-mainline-appsearch-release android14-mainline-healthfitness-release android14-mainline-uwb-release android14-qpr1-release android14-qpr1-s2-release android14-qpr2-s1-release main-16k main-16k-with-phones aml_ads_331131000 aml_ads_331418080 aml_ads_331511020 aml_ads_331611190 aml_ads_331710270 aml_ads_331814200 aml_ads_331920180 aml_ads_340915050 aml_ads_341027030 aml_ads_341131050 aml_ads_341316030 aml_ads_341413000 aml_ase_331011020 aml_ase_331112000 aml_ase_331311020 aml_ase_340913000 aml_ase_341113000 aml_ase_341310010 aml_ase_341410000 aml_go_adb_330913000 aml_go_ads_330913000 aml_go_ads_330915000 aml_go_ads_330915100 aml_go_ase_330913000 aml_go_mpr_330912000 aml_go_net_330913000 aml_go_neu_330912000 aml_go_odp_330912000 aml_go_odp_330913000 aml_go_per_330912000 aml_go_res_330912000 aml_go_sch_330911000 aml_go_sdk_330810000 aml_go_sta_330911000 aml_go_swc_330913000 aml_go_tet_330914010 aml_go_tz4_330912000 aml_go_uwb_330912000 aml_go_wif_330911000 aml_hef_341114030 aml_hef_341311010 aml_hef_341415040 aml_rkp_341012000 aml_rkp_341015010 aml_rkp_341114000 aml_rkp_341311000 aml_tz4_331012000 aml_tz4_331012040 aml_tz4_331012050 aml_tz4_331314010 aml_tz4_331314020 aml_tz4_331314030 aml_tz4_331910000 aml_tz4_332714010 aml_tz5_341510010 aml_uwb_330810010 aml_uwb_331015040 aml_uwb_331115000 aml_uwb_331310030 aml_uwb_331410010 aml_uwb_331611010 aml_uwb_331613010 aml_uwb_331820070 aml_uwb_331910010 aml_uwb_341011000 aml_uwb_341111010 aml_uwb_341310030 aml_uwb_341310300 android-13.0.0_r16 android-13.0.0_r17 android-13.0.0_r18 android-13.0.0_r19 android-13.0.0_r20 android-13.0.0_r21 android-13.0.0_r22 android-13.0.0_r23 android-13.0.0_r24 android-13.0.0_r27 android-13.0.0_r28 android-13.0.0_r29 android-13.0.0_r30 android-13.0.0_r32 android-13.0.0_r33 android-13.0.0_r34 android-13.0.0_r35 android-13.0.0_r36 android-13.0.0_r37 android-13.0.0_r38 android-13.0.0_r39 android-13.0.0_r40 android-13.0.0_r41 android-13.0.0_r42 android-13.0.0_r43 android-13.0.0_r44 android-13.0.0_r45 android-13.0.0_r46 android-13.0.0_r47 android-13.0.0_r48 android-13.0.0_r49 android-13.0.0_r50 android-13.0.0_r51 android-13.0.0_r52 android-13.0.0_r53 android-13.0.0_r54 android-13.0.0_r55 android-13.0.0_r56 android-13.0.0_r57 android-13.0.0_r58 android-13.0.0_r59 android-13.0.0_r60 android-13.0.0_r61 android-13.0.0_r62 android-13.0.0_r63 android-13.0.0_r64 android-13.0.0_r65 android-13.0.0_r66 android-13.0.0_r67 android-13.0.0_r68 android-13.0.0_r69 android-13.0.0_r70 android-13.0.0_r71 android-13.0.0_r72 android-13.0.0_r73 android-13.0.0_r74 android-13.0.0_r75 android-13.0.0_r76 android-13.0.0_r77 android-13.0.0_r78 android-13.0.0_r79 android-13.0.0_r80 android-13.0.0_r81 android-13.0.0_r82 android-13.0.0_r83 android-14.0.0_r16 android-14.0.0_r17 android-14.0.0_r18 android-14.0.0_r19 android-14.0.0_r20 android-14.0.0_r21 android-14.0.0_r22 android-14.0.0_r23 android-14.0.0_r24 android-14.0.0_r25 android-14.0.0_r26 android-14.0.0_r27 android-14.0.0_r29 android-u-beta-1-gpl t_frc_art_330443060 t_frc_ase_330444010 t_frc_cbr_330443000 t_frc_con_330443020 t_frc_odp_330442000 t_frc_odp_330442040

Open Screen Library

The Open Screen Library implements the Open Screen Protocol and the Chromecast protocols (discovery, application control, and media streaming).

Information about the Open Screen Protocol and its specification can be found on GitHub.

Getting the code

Installing depot_tools

Library dependencies are managed using gclient, from the depot_tools repo.

To get gclient, run the following command in your terminal:

    git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git

Then add the depot_tools folder to your PATH environment variable.

Note that openscreen does not use other features of depot_tools like repo or drover. However, some git-cl functions do work, like git cl try, git cl format, git cl lint, and git cl upload.

Checking out code

From the parent directory of where you want the openscreen checkout (e.g., ~/my_project_dir), configure gclient and check out openscreen with the following commands:

    cd ~/my_project_dir
    gclient config https://chromium.googlesource.com/openscreen
    gclient sync

The first gclient command will create a default .gclient file in ~/my_project_dir that describes how to pull down the openscreen repository. The second command creates an openscreen/ subdirectory, downloads the source code, all third-party dependencies, and the toolchain needed to build things; and at their appropriate revisions.

Syncing your local checkout

To update your local checkout from the openscreen reference repository, just run

   cd ~/my_project_dir/openscreen
   git pull
   gclient sync

This will rebase any local commits on the remote top-of-tree, and update any dependencies that have changed.

Build setup

The following are the main tools are required for development/builds:

  • Build file generator: gn
  • Code formatter: clang-format
  • Builder: ninja (GitHub releases)
  • Compiler/Linker: clang (installed by default) or gcc (installed by you)

All of these--except gcc as noted above--are automatically downloaded/updated for the Linux and Mac environments via gclient sync as described above. The first two are installed into buildtools/<platform>/.

Mac only: XCode must be installed on the system, to link against its frameworks.

clang-format is used for maintaining consistent coding style, but it is not a complete replacement for adhering to Chromium/Google C++ style (that's on you!). The presubmit script will sanity-check that it has been run on all new/changed code.

Linux clang

On Linux, the build will automatically download the Clang compiler from the Google storage cache, the same way that Chromium does it.

Ensure that libstdc++ 8 is installed, as clang depends on the system instance of it. On Debian flavors, you can run:

   sudo apt-get install libstdc++-8-dev

Linux gcc

Setting the gn argument “is_gcc=true” on Linux enables building using gcc instead.

  mkdir out/debug-gcc
  gn gen out/debug-gcc --args="is_gcc=true"

Note that g++ version 7 or newer must be installed. On Debian flavors you can run:

  sudo apt-get install gcc-7

Mac clang

On Mac OS X, the build will use the clang provided by XCode, which must be installed.

Debug build

Setting the gn argument “is_debug=true” enables debug build.

  gn gen out/debug --args="is_debug=true"

To install debug information for libstdc++ 8 on Debian flavors, you can run:

   sudo apt-get install libstdc++6-8-dbg

gn configuration

Running gn args opens an editor that allows to create a list of arguments passed to every invocation of gn gen.

  gn args out/debug

Building targets

Cast Streaming sender and receiver

TODO(jophba): Fill in details

OSP demo

The following commands will build the Open Screen Protocol demo and run it.

  mkdir out/debug
  gn gen out/debug             # Creates the build directory and necessary ninja files
  ninja -C out/debug osp_demo  # Builds the executable with ninja
  ./out/debug/osp_demo          # Runs the executable

The -C argument to ninja works just like it does for GNU Make: it specifies the working directory for the build. So the same could be done as follows:

  ./gn gen out/debug
  cd out/debug
  ninja osp_demo
  ./osp_demo

After editing a file, only ninja needs to be rerun, not gn. If you have edited a BUILD.gn file, ninja will re-run gn for you.

Unless you like to wait longer than necessary for builds to complete, run autoninja instead of ninja, which takes the same command-line arguments. This will automatically parallelize the build for your system, depending on number of processor cores, RAM, etc.

For details on running osp_demo, see its README.md.

Building other targets

Running ninja -C out/debug gn_all will build all non-test targets in the repository.

gn ls --type=executable out/debug will list all of the executable targets that can be built.

If you want to customize the build further, you can run gn args out/debug to pull up an editor for build flags. gn args --list out/debug prints all of the build flags available.

Building and running unit tests

  ninja -C out/debug openscreen_unittests
  ./out/debug/openscreen_unittests

Contributing changes

Open Screen library code should follow the Open Screen Library Style Guide.

This library uses Chromium Gerrit for patch management and code review (for better or worse). You will need to register for an account at chromium-review.googlesource.com to upload patches for review.

The following sections contain some tips about dealing with Gerrit for code reviews, specifically when pushing patches for review, getting patches reviewed, and committing patches.

Uploading a patch for review

The git cl tool handles details of interacting with Gerrit (the Chromium code review tool) and is recommended for pushing patches for review. Once you have committed changes locally, simply run:

  git cl format
  git cl upload

The first command will will auto-format the code changes. Then, the second command runs the PRESUBMIT.py script to check style and, if it passes, a newcode review will be posted on chromium-review.googlesource.com.

If you make additional commits to your local branch, then running git cl upload again in the same branch will merge those commits into the ongoing review as a new patchset.

It's simplest to create a local git branch for each patch you want reviewed separately. git cl keeps track of review status separately for each local branch.

Addressing merge conflicts

If conflicting commits have been landed in the repository for a patch in review, Gerrit will flag the patch as having a merge conflict. In that case, use the instructions above to rebase your commits on top-of-tree and upload a new patchset with the merge conflicts resolved.

Tryjobs

Clicking the CQ DRY RUN button (also, confusingly, labeled COMMIT QUEUE +1) will run the current patchset through all LUCI builders and report the results. It is always a good idea get a green tryjob on a patch before sending it for review to avoid extra back-and-forth.

You can also run git cl try from the commandline to submit a tryjob.

Code reviews

Send your patch to one or more committers in the COMMITTERS file for code review. All patches must receive at least one LGTM by a committer before it can be submitted.

Submitting patches

After your patch has received one or more LGTM commit it by clicking the SUBMIT button (or, confusingly, COMMIT QUEUE +2) in Gerrit. This will run your patch through the builders again before committing to the main openscreen repository.

Additional resources