ut0mt8 / nginx-rtmp-module

NGINX-based Media Streaming Server
http://nginx-rtmp.blogspot.com
BSD 2-Clause "Simplified" License
87 stars 32 forks source link

Big endian #24

Open jbubik opened 4 years ago

jbubik commented 4 years ago

I have sacrificed some sleep and made nginx-rtmp-module running on both Little-endian and Big-endian platforms. Tested with local playback and "push" functionality on PC/cygwin (x86 64bit LE) and TP-Link Archer C7 v5 (MIPS 32bit BE). Other functions (pull, record, vod, stats, etc.) untested - problems on BE expected there. The original code was written with LE perspective only. This PR fixes #22 and will collide with #23 (pierreyves258 was faster to spot the issue with gcc 8).

ut0mt8 commented 3 years ago

This should work; but I'm not in this code right now, and don't completely understand your changes.

jbubik commented 3 years ago

No new features at all. All changes in this PR address a problem on CPUs with Big Endian architecture. See Wikipedia for technical background. Original code compiles on both architectures, but woks correctly only on Little Endian CPUs (i32, amd64). When there is a 16bit value 0xABCD in RTMP packet, it is fetched into CPU as 0xCDAB on Little Endian platforms. Original code always swaps the bytes to get back the correct value 0xABCD. This "swap" is a bad idea on Big Endian platforms. See libc manual for the recommended solution. Functions ntohs/ntohl/htons/htonl are declared in the compiler according to endianess of target platform.

jbubik commented 3 years ago

Hi @ut0mt8 - are you aware, that your repository is the source for OpenWrt package "nginx"? OpenWrt project supports many different routers with many different CPU architectures - some of them are Big Endian. I wanted to make the code working correctly on these architectures (I own TPLink Archer C7, MIPS BE). The project (nginx-rtmp-module) started with @arut, then has been forked by @sergey-dryabzhinsky, then has been forked by @ut0mt8. All repositories seemed abandoned in May 2020 when I authored the changes. Please let me (and/or the OpenWrt folks) know if you are willing to maintain the project. If it is not possible, the community must find a different way to go forward.

I am willing to help, but at the moment I see lack of communication between the developers. Any comments on this?

ut0mt8 commented 3 years ago

@jbubik really? I was aware of the situation. But unfortunately I tried to re-upstream my work and you no one respond, even if @arut help me in some case. The problem is I start this fork for my previous work, it was a lot of fun, but it's already too old, and don't have time to maintain it anymore. That's a shame cause my work add some interesting features (sometime the code is a bit hacky) but at least it serve well my previous employer during the 2018 soccer world cup :)

I never talked to sergy btw. So yes we are the classic situation of "abandonware" :/