Results 107 issues of Hui

## setup 跟着 [libuv/build-instructions](https://github.com/libuv/libuv#build-instructions) 指引通过cmake编译和安装: ```sh ~ mkdir -p build ~ cd build ~ cmake .. ~ cmake --build build ~ sudo make install ``` ## hello world [guide#hello-world](http://docs.libuv.org/en/v1.x/guide/basics.html#hello-world) uv.c...

## http chunk `Transfer-Encoding: chunked`表示本次http response的body长度不能确定,比如后面我们看到的httpflv正是利用这个特性。 文件下载: 如果是文件下载,比如2G的一个iso,这时候因为文件大小是确定的,所以content-length会直接给出,然后body不断输入bytes,所以chunked和内容的长度无关,只和是否知道长度有关。 - [HTTP 协议中的 Transfer-Encoding | JerryQu 的小站](https://imququ.com/post/transfer-encoding-header-in-http.html) app.js ```js require('net') .createServer(function (sock) { sock.on('data', function (data) { sock.write('HTTP/1.1 200 OK\r\n'); sock.write('Transfer-Encoding: chunked\r\n\r\n');...

## 创建 tcp server 框架 不到50行的净代码, ```c #include "flvhttpd.h" #include #include #include #include #include #include #include #include #include #include #include #include void error_die(const char *); void accept_request(void *arg); int main(void)...

## 概念 - Compiling (编译): 通过 compiler (编译器) 将一种语言转换另一种语言的过程 - Linking (链接): 通过 linker (链接器) 将多个文件 (object files) 合并后生成一个单一文件的过程, linking分为dynamic linking和static linking两种方式 - Debugging (调试): 通过 debugger (调试器) 跟踪程序运行的过程 之前我们写过从app.c到a.out分为4个步骤:...

# H264 Format AnnexB format: ``` ([start code] NALU) | ( [start code] NALU) | ``` AVCC format: ``` ([extradata]) | ([length] NALU) | ([length] NALU) | ``` In annexb,...

favor

今天在obs看到这样一句代码 ```c struct encoder_packet packet = {.type = OBS_ENCODER_VIDEO, .timebase_den = 1, .keyframe = true}; ``` 查了一下这个叫做Designated Initializers,不限于struct,gcc的文档中描述: Standard C90中初始化必须按顺序执行,在ISO C99中扩展支持指定初始化。 ### Array `int a[6] = { [4] = 29,...

Version: Swift 5.6, macOS 12.3, Xcode 11 重新整理了swift调用librtmp - 将librtmp放到项目直接编译 - 参考librtmp目录结构,2个makefile - 增加了googletest 目录结构: - rtmpr - librtmpr/ - Makefile - bridge.h - app.swift - Makefile rtmpr/Makefile ```make all:...

favor

## const 修饰变量 ANSI C 通过const声明常量,常量在第一次赋值后不能再次修改,可以理解为只读,readonly。Swift中通过let定义常量。 ```c const int x = 5; x = 8; // error: cannot assign to variable 'x' with const-qualified type 'const int' ``` `const int...

通过Xcode可以很方便的在swift项目中加入bridge header和c file,通过命令行也可以实现, 下面介绍的方式是我个人尝试,未必是标准答案,辩证理解: - 通过gcc/clang -c编译c生成object file - swiftc通过同时输入swift和object file - 通过`import-obj-header`增加bridge文件 src/main.swift ```swift import Foundation func main() { let version = RTMP_LibVersion() print(String(format: "0x%08x", version)) hello() } main()...

favor

frameworks: - [google/googletest: GoogleTest - Google Testing and Mocking Framework](https://github.com/google/googletest) 26.4k stars - [CUnit | A Unit Testing Framework for C](http://cunit.sourceforge.net) n/a - [Check | Unit testing framework for C](https://libcheck.github.io/check/)...