Archives: software programming

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: Advance pattern:     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: 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.!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:   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 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   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 described the details of h264 profile, level. Profiles • Read More »

c++ coroutine 5/5 (1)

Coroutines Internals Coroutines introduction Your first coroutine co_awaiting coroutines   Please rate this rating

gdb and signal handling ( especially sigwaitinfo ) 5/5 (1)

How gdb generally works In a debugging session, when the debugger wants to set a breakpoint, it replaces an instruction by int3 When the trap instruction (0xCC on x86) is executed, the processor notifies the OS. On UNIX, the OS checks to see whether the process is being ptraced by somebody. If no, the SIGTRAP signal is delivered to • Read More »

c++ lambda capture, weak_ptr, shared_ptr many subtle caveats 5/5 (1)

Some notes about C++ lamba capture, shared_ptr/weak_ptr, they are not quite obvious! (1) lambda capture implement it is simply just put the captures as members either by copy or reference. special capture this point:  we don’t need to make a distinction between local variables and fields of a class when writing lambda functions. how to • Read More »

c++ why std::shared_ptr need atomic_store, atomic_load or why we need atomic shared_ptr 5/5 (1)

shared_ptr is some sort of confusing especially why we need atomic_store, atomic_load on that. It is NOT thread safe. In fact,  the primary intended use of std::shared_ptr is letting multiple threads control the lifetime of the same object, but not thread-safe. A good summary is: A shared_ptr behaves like a built-in type regarding thread-safety, Concurrent access to distinct • Read More »