The code contains things that make any modern C++ or Rust developer cringe: naked pointers, unsafe type casts, raw loops, using malloc/free to manually allocate memory for buffers, and calls to unsafe free functions like strcat. So much slow boilerplate is required to do things like handling memory allocation. The increased source code size for even the simplest things becomes harder to maintain. Danger is waiting ar…
You literally go from thread to thread posting the same pro-Rust anti-C drivel, derailing every thread. Sorry to be crude, but can you people take this self-righteous bs elsewhere? Not every thread needs to be about the superiority of Rust or your gripes with C. This cancer is ruining every thread on HN now.
A simple C implementation to stream H.264 to browser using WebRTC
91–100 of 128 posts
Re: A simple C implementation to stream H.264 to browser using WebRTC
#92In complete sincerity, how is this better than ffmpeg https://trac.ffmpeg.org/wiki/StreamingGuide
WebRTC with STUN is pure p2p where ffmpeg it requires a rtmp or rtsp server
If you implement p2p video streaming chances are no company will want to touch it with a ten foot pole.
Re: A simple C implementation to stream H.264 to browser using WebRTC
#93Earlier quoted context omitted.
As far as I can tell, this is an open forum. If people keep repeating the same mistakes when they use C, I’ll keep promoting the alternatives. I’m not trying to eschew flamebait, it just so happens that people get upset when their ideas are challenged. If it makes people uncomfortable, then that’s fantastic, because no one who was comfortable ever learned anything. I get it: learning new things and new languages is h…
It seems you think their mistake was using C in the first place, and not the way they used C. Calling people out for not using a language that you prefer is not helping them learn, nor is it bitter medicine to those who find learning your preferred language "hard".
I mean, guns are restricted in all countries, while of course it's the way guns are used that is truly what people take issue with. If you hang it up on your own wall and never take it off, nobody has an issue with your gun, but enforcement of that is nigh impossible and so we restrict the ownership to policemen and allow only things like hunting rifles for the small group that still likes to go hunting.
As someone working in security, I'd make a similar though obviously less extreme case for unsafe languages like C. If you don't need it, then why use something that you can shoot yourself in the foot with? You put other people at risk through using it incorrectly and it's nigh impossible to enforce secure coding. Many people seem to think that you need C++, C, or assembly to write fast code whereas nowadays there are plenty of alternatives without some of C's biggest issues.
Re: A simple C implementation to stream H.264 to browser using WebRTC
#94Earlier quoted context omitted.
Ownership semantics in rust largely prevent circular references, so it's not the same deal
Sorry, I'm not a Rust pro, but from the docs about reference cycles linked above: > We can see that Rust allows memory leaks by using Rc and RefCell : it’s possible to create references where items refer to each other in a cycle. This creates memory leaks because the reference count of each item in the cycle will never reach 0, and the values will never be dropped. This sounds a lot like what happens when you create…
Re: A simple C implementation to stream H.264 to browser using WebRTC
#95The code contains things that make any modern C++ or Rust developer cringe: naked pointers, unsafe type casts, raw loops, using malloc/free to manually allocate memory for buffers, and calls to unsafe free functions like strcat. So much slow boilerplate is required to do things like handling memory allocation. The increased source code size for even the simplest things becomes harder to maintain. Danger is waiting ar…
Dude. The alternative is that the author would not have written the project. Not everyone has hundreds of hours of free time to throw away at learning the next hot programming language.
Also consider that it also impacts other people if you put unsafe code out there or if others want to contribute or build upon it (even if your C is better than even the chromium team, that doesn't mean your contributors' or developer-users are).
In my opinion C has reached a point where using a project like this as a learning opportunity to try out another language, if you don't know one already, would be worth considering.
Re: A simple C implementation to stream H.264 to browser using WebRTC
#96Earlier quoted context omitted.
What other protocols do you know that offer low latency almost real time video and all that in the browser? There is RTSP but that does not work in browsers.
MPEG1 over WebSockets: https://jsmpeg.com/
Re: A simple C implementation to stream H.264 to browser using WebRTC
#97Earlier quoted context omitted.
Ownership semantics in rust largely prevent circular references, so it's not the same deal
Sorry, I'm not a Rust pro, but from the docs about reference cycles linked above: > We can see that Rust allows memory leaks by using Rc and RefCell : it’s possible to create references where items refer to each other in a cycle. This creates memory leaks because the reference count of each item in the cycle will never reach 0, and the values will never be dropped. This sounds a lot like what happens when you create…
Re: A simple C implementation to stream H.264 to browser using WebRTC
#98I've seen a few WebRTC server implementations pop up recently but the only clients I have seen are web browsers. Does anyone know of any WebRTC client implementations apart from the browser? Or am I misunderstanding the WebRTC architecture completely?
The official one, pion (go) and webrtc-rs (rust) can all be used on both sides.
Re: A simple C implementation to stream H.264 to browser using WebRTC
#99I'm not very familiar with WebRTC & how the browser pulls video usually, in what way is this better? Also, what benefits does WebRTC give over other protocols?
If you have the time give WebRTC for the Curious[0] a read. I try and explain what WebRTC is and how it actually works. The big advantages that I see are. * Can do P2P (and Client/Server) * Mandatory Encryption * Handles codec/track negotation. You don't need to know ahead of time what is being sent. * Data channels. Can also be configured to be lossy/unordered for kind of performance needed for gaming. * Uses existi…
Re: A simple C implementation to stream H.264 to browser using WebRTC
#100Earlier quoted context omitted.
Thanks is, as the GitHub title says, for iot and embedded devices. There’s a whole class of these that don’t have the resources to run C++ or rust. Source: develop on a Linux system with 7 megabyte roofs and 16 megs of ram. Oh! We have a 1 meg application partition.
If it can run C, it can run C++ (or rust I guess). The majority of abstractions have little to no overhead. Also 16 megabytes were enough for a very decent desktop computer in the '90, enough to run very complex C++ applications with ease.
There are ways around all of these:
* a. Static vs dynamic linkage: in an embedded system, it'd be reasonable to just produce a single userspace binary that does everything. It can change its behavior based on argv[0]. I think this is not too unusual for constrained systems even with C binaries. Eg busybox does it. If you only have one binary, you don't need dynamic linking. Also, I think it's not strictly true that Rust doesn't support dynamic linking. I think you can dynamically link everything if you ensure the whole system is built with the same compiler version.
* b. Standard library. You don't have to use it at all, or you can use it sparingly, paying only for what you use.
* c. Monomorphization. You could write (for example) a Go-like map [2] rather than relying so heavily on monomorphization. I'd love to see someone take this idea as far as possible; it might be a good idea for a lot of non-inner-loop code in general, not just on tight embedded systems.
* d. Using full-featured libraries. Obviously no one is making you do this; the same cheats available in C are available in Rust.
but in fairness, the further you go down this path, the further you are from just being able to just take advantage of the whole Rust ecosystem.
Personally, I'd still rather develop or use a #![no_std] Rust codebase than a C one. Memory safety is important to me. IOT devices are no exception to that. Their security history is horrible, and I'd like their security future to be better...
[1] https://github.com/sepfy/pear/blob/b984c8dccaafdcdd1b181786a...
[2] https://dave.cheney.net/2018/05/29/how-the-go-runtime-implem...