Archives: software programming

vim cheat sheet No ratings yet.

useful .vimrc set tabstop=2 set shiftwidth=2 set expandtab inoremap <S-Tab> <C-V><Tab> syntax on set t_Co=256 set colorcolumn=80 “crazy vim, do not allow copy/paste set mouse=v setlocal spell spelllang=en_us “for vert term  ( split vertical vim window) :set splitright :set splitbelow   useful .screenrc # Enable mouse scrolling and scroll bar history scrolling termcapinfo xterm* ti@:te@ • Read More »



cross compile native libwebrtc ( on x86_64 host) for arm64 No ratings yet.

Direct compile webrtc on arm64 will fail: webrtc seems does not support direct support on arm, we will get errors: … Running hooks: 18% ( 4/22) sysroot_arm64 ________ running ‘vpython src/build/linux/sysroot_scripts/install-sysroot.py –arch=arm64’ in ‘/webrtcbuilds/out’ Installing Debian sid arm64 root image: /webrtcbuilds/out/src/build/linux/debian_sid_arm64-sysroot Downloading https://commondatastorage.googleapis.com/chrome-linux-sysroot/toolchain/953c2471bc7e71a788309f6c2d2003e8b703305d/debian_sid_arm64_sysroot.tar.xz Running hooks: 50% (11/22) binutils ________ running ‘vpython src/third_party/binutils/download.py’ in ‘/webrtcbuilds/out’ Host • Read More »


c++ json lib: nlohmann::json No ratings yet.

nlohmann::json is a popluar json lib. code at: https://github.com/nlohmann/json document at: https://nlohmann.github.io/json/doxygen/index.html   sample code: #include <iostream> 2 #include <nlohmann/json.hpp> 3 4 using json = nlohmann::json; 5 6 int main() 7 { 8  // create a JSON object with different entry types 9  json j = 10  { 11  {“integer”, 1}, 12  {“floating”, 42.23}, 13  {“string”, “hello world”}, 14  • Read More »


webassembly and web audio worklet No ratings yet.

Some notes: web assembly: a cool technology allows you to compile c/c++/rust and other languages into wasm, expose API to javascript world. Web audio worklet/worker: allows developer to intercept audio stream/custom processing A good introduction is at: https://developers.google.com/web/updates/2017/12/audio-worklet Advance pattern: https://developers.google.com/web/updates/2018/06/audio-worklet-design-pattern https://github.com/GoogleChromeLabs/web-audio-samples/tree/master/audio-worklet/design-pattern/shared-buffer/     Combination of wasm and audio worklet can do a fair amount • Read More »


C++ how to replace mutex code with CAS ( compare and exchange ) ( lock-less programming ) 5/5 (2)

It is well known that if  mutex protected codes could potentially be replaced by atomic compare exchange,  thus we cab achieve lock-less programming. In practice, it may need several techniques to get it working. Let’s look at a subscription example: Normal mutex An subscriber  can subscribe some content from a publisher, in other word, a publisher • Read More »


Janus Video Room plugin (how webrtc sfu works) 5/5 (1)

Repo: https://github.com/meetecho/janus-gateway code: video sfu code at: plugins/janus_videoroom.c How sub/pub works: in its plugin implementation: plugins/janus_videoroom.c , there is: struct janus_videoroom_publisher { GSList subscribers; / Subscriptions to this publisher (who’s watching this publisher) */ GSList subscriptions; / Subscriptions this publisher has created (who this publisher is watching) */ } for every incoming  rtp from a publisher: • Read More »


how to submit a patch to google’s webrtc native 5/5 (1)

I recently submitted a patch to webrtc native. https://webrtc-review.googlesource.com/c/src/+/143841 https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!topic/discuss-webrtc/zn4kmjflvt4 The process is not that difficult, but there could be some caveats depending on your os version etc. Here is my notes/steps:   Read official doc Basically you should follow this official doc is at: https://webrtc.org/contributing/   install depot_tools mkdir webrtc && cd webrtc $ git clone • Read More »


vim how to install vim-grammarous plugin ( grammar check ) 5/5 (2)

vim has a grammar check plugin https://github.com/rhysd/vim-grammarous How to install vim-grammarous? it uses new vim 8+ plugin mechanism, so we can easily install it by: mkdir -p ~/.vim/pack/bundle/start cd ~/.vim/pack/bundle/start git clone https://github.com/rhysd/vim-grammarous   The first time you run the: GrammarousCheck in the vim, it will auto download the languagetool (java jar) etc. How to • Read More »


H.264 profile-level-id, packetization-mode, NAL, I-frame, I-slice 5/5 (3)

H.264 profile-level-id in sdp: profile-level-id = 428014  ( remember SDP use hex, wiki/h264 they use decimal ) profile_idc 0x42 == 66 so it is Baseline profile profile-iop 0x80 mean constraint_set0_flag=1 (so it is Constrained Baseline profile) and others 0 level-idc 0x14 == 20 so it is Level 2.0 https://en.wikipedia.org/wiki/H.264/MPEG-4_AVC described the details of h264 profile, level. Profiles • Read More »