Little Step

Shared/self-serviced treadmill

It says 0.2 yuan each minute, at least 1 yuan, and there is a QR code you can pay.

The small room has one TV and one air conditioning.

Nowdays it is very common for C/C++ projects use cmake as the build tool, or at least will support cmake.

Then the easy command to build the project will be like:

cd project \
&& mkdir build \
&& cd build \
&& cmake .. \
&& make

As I wrote in the previous article, if you want to make build fast you should set more jobs, like:

make $(nproc)

Or you can use another build tool, ninja, which use the the number of processors as the default job number, like:

cd project \
&& mkdir build \
&& cd build \
&& cmake -GNinja .. \
&& ninja

Here are several advantages for ninja:

  1. Use the default number of process as the job number
  2. No annoying output on standard output if no error or waning
  3. More fast than make especially for large projects and for no change build
  4. And for parallel jobs, the output is buffered, and will not mixed with other job

But a very disadvantages for ninja is that you can't write the ninja makefile like the common makefile, the beset way is to use a generator, like cmake.

If you like the build tool only works well and won't complain under normal case ninja is a good choice.

First snow in 2020

first snow in 2020

Just finished the reading of book RTP: Audio and Video for the Internet. RTP: Audio and Video for the Internet

It is an old book published at 2003, but is still the best book for RTP related topics.

Maybe 4-5 years ago, the live streaming is becoming more and more popular in China. Many companies use RTMP as the streaming protocol and with CDN support, they create a lot of live stream apps very quickly.

But for RTMP, the typical delay is 3-5 seconds, and is not suitable for some cases which require more strictly on delay. One of them is the online education. So RTMP can't make it, which one can?

Here comes webrtc! Many companies realize that RTMP and the transport protocol under it-TCP is not proper for this case, but webrtc which uses RTP and UDP is designed for this scenario for a long time.

But they have problems. UDP is simple, while RTP is complicated. They can't create an app quickly with webrtc. There are a lot of open source projects for webrtc, but none of them is like nginx-rtmp which you can setup and is works just as excepted.

One of the reason is that RTP is a complicated protocol and especially with UDP. It is like the application protocol since it is above UDP, while actually it is more beyond that, and has many functions for transport layer, and even codec and encryption layer.

This book starts with the case for internet with voip, and after introduces the design consideration for RTP and RTCP (the Application Level Framing), it introduces the details for two protocols. The most import sections includes timing, lip sync, error concealment and error correction, and congestion control.

It also covers header compression, multiplexing, and tunneling, but I don't think these technics are useful now. Since RTP is complex already, with these techniques you will be lost.

At the last it covers SRTP, which is the secure version of RTP is now the standard protocol in webrtc.

If you are a C/C++ programmer, and are accustomed with the common build process, you will know the make and install commands.

make && make install

If it is a big project, and the whole build process costs a lot. So you want to build parallelized, adding more jobs, like this:

make -j8 && make install

This will creates 8 jobs at the same time. And the best number of job is the number of CPU processors. How to get the number of processor on Linux platform?

Here is one simple way, the nproc command. Its only purpose is to print the number of processors. The build command now will be like:

make $(nproc) && make install

Of course, you can also use this way:

grep -c processor /proc/cpuinfo

And you can also you lscpu command with grep or awk, like this:

lscpu |  awk '{ if ($1 == "CPU(s):") print $2 }'