HTTP Traffic by Telnet

This is just to show the traffic when requesting and submiting a minimum web form by telnet. Command used: c:\ telnet 80, which is our AWS dev server.
There are two round trip traffic. Frist, clent requests a user name password form, second, client submit this form. Server set a cookie when sending out the form. “Access-Control-Allow-Origin *” is important for our streaming server since this allows the web server containing the video player to play the content.¬†Headers are terminated by the sequence \r\n\r\n, then content length is said in header.
The traffic is listed below, excluding commends after # sign.
Client sends #1 to request form:

Host: #nginx requires domain name on the line of GET and HOST
Connection: keep-alive #server doesn’t close this connection, and client reuses this socket.
Cache-Control: max-age=0 #must re-fetch
Upgrade-Insecure-Requests: 1 #please redirect me to a secure representation of the resource
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36 #Chrome UA string
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate # I understand compressed content.
Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7 # I understand these languages
# hit return on keyboard twice

Server sends #1 returning the form:

HTTP/1.1 200 OK
Server: nginx/1.9.15
Date: Sat, 14 Jul 2018 22:07:49 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 216
Connection: keep-alive
Set-Cookie: LoginForm=SentAlready #sends client a cookie
Access-Control-Allow-Origin: * #allow pages originated from other web sites to fetch this content
<form action=”/test” method=”post”> #just a minimum web form
Username: <input name=”username” type=”text” value=”a”/>
Password: <input name=”password” type=”password” value=”a”/>
<input value=”Login” type=”submit” />

Client sends #2 to submitting the form:

POST HTTP/1.1 #post the form
Connection: keep-alive
Content-Length: 21
Cache-Control: max-age=0
Origin: #the web server that generated this page.
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
User-Agent: # same as last request
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Referer: #previous web page
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7
Cookie: LoginForm=SentAlready #the cookie set by last server response.
# hit return on keyboard twice

Server sends #2 saying form submitted successfully:

HTTP/1.1 200 OK
Server: nginx/1.9.15
Date: Sat, 14 Jul 2018 22:07:51 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 23
Connection: keep-alive
Cache-Control: no-cache


Python at MaxxSports

C++ has been my primary language in my entire career until a year ago, when Python came to our tool set.
We chose Python for it’s rich collection of modules. In our case, for example:

  1. AI: keras module to TensorFlow for player recognition
  2. REST API: bottle and json module, through which AWS server talks to the clients
  3. Database: pymysql module access video recordings saved in MySql
  4. HLS Playlist parsing: m3u8 module
  5. Access AWS: boto3 module to control ec2 instances


Audio Live Streaming with Icecast2

Icecast2 is our choice for TSRN’s live audio streaming due to the inherent delay of HLS, which delivers NHL video to our sports fans.¬†Icecast2 uses HTTP on the transport layer and added some headers to support application layer, for example, interleaving meta data with audio stream, “Icy-MetaData:1”.

There are some other low latency protocols that don’t meet our needs as good. SHOUTCast is proprietary. WebRtc is P2P for small number of listeners. RTMP is closely related to Flash. RTP is too weak on mobile device.

The PPA repository we use is

Convert to Bayer Format

Image sample files are everywhere, but files in Bayer format are not easy to find. Actually I didn’t have one until we ordered a GeniCam camera. Therefore I made this tool to convert to Bayer formatted files.

Bayer files (I name it .bay) hold one or more raw Bayer frames, like .yuv in the sense that neither of them contains meta data. I convert to .bay with Opencv SDK. OpenCV has functions to convert from Bayer to other format, e.g. CV_BayerRG2RGB, but no support for conversion the other way. Therefore I manipulate the bytes manually, in MatToMatOrBits_MatToBits in gui.cpp in the download link below.

Command line to run the tool, mux.exe, to convert to*.bay:

  1. from .jpg: converts to .bay picture: mux.exe –FileIn pic.jpg –FileOut pic.bay –Action 2
  2. from .mp4: it also converts to .bay video, which only means multiple frames one after another: mux.exe –FileIn video.mp4 –FileOut video.bay –Action 1

Source code and executable:

Runtime DLLs required: Visual Studio 2015 Debug x64, OpenCV 2.4 for VC14