Showing posts with label Broadcast. Show all posts
Showing posts with label Broadcast. Show all posts

Saturday, April 16, 2022

Scalable WebRTC peer-to-peer broadcasting

 https://github.com/muaz-khan/WebRTC-Scalable-Broadcast



WebRTC Scalable Broadcast

Scalable WebRTC peer-to-peer broadcasting demo.

npm downloads

This module simply initializes socket.io and configures it in a way that single broadcast can be relayed over unlimited users without any bandwidth/CPU usage issues. Everything happens peer-to-peer!

RTCMultiConnection v3 and Scalable Broadcast

RTCMultiConnection v3 now naively supports scalable-broadcast:

DemoTitleTestLiveViewSource
Scalable Audio/Video BroadcastDemoSource
Scalable Screen BroadcastDemoSource
Scalable Video BroadcastDemoSource
Scalable File SharingDemoSource

Demos

Note: These (below) are old demos. Above (RTCMultiConnection-v3) demos are preferred (and up-to-dated).

  1. index.html - share video or screen or audio over unlimited users using p2p methods.
  2. share-files.html - share files with unlimited users using p2p methods!

Browsers Support:

BrowserSupport
FirefoxStable / Aurora / Nightly
Google ChromeStable / Canary / Beta / Dev

Browsers Comparison

host means the browser that is used to forward remote-stream.

HostStreamsReceiversIssues
ChromeAudio+VideoChrome,FirefoxRemote audio tracks are skipped.
ChromeAudioNoneChrome can NOT forward remote-audio
ChromeVideoChrome,FirefoxNo issues
ChromeScreenChrome,FirefoxNo issues
FirefoxAudio+VideoChrome,FirefoxNo issues
FirefoxAudio+ScreenChrome,FirefoxNo issues
FirefoxAudioChrome,FirefoxNo issues
FirefoxVideoChrome,FirefoxNo issues
FirefoxScreenChrome,FirefoxNo issues
  1. First column shows browser name
  2. Second column shows type of remote-stream forwarded
  3. Third column shows browsers that can receive the remote forwarded stream
  4. Fourth column shows sender's i.e. host's issues

Chrome-to-Firefox interoperability also works!

Android devices are NOT tested yet. Opera is also NOT tested yet (though Opera uses same chromium code-base).

Currently you can't share audio in Chrome out of this big. In case of audio+video stream, chrome will skip remote-audio tracks forwarding. However chrome will keep receiving remote-audio from Firefox!

Firefox

Firefox additionally allows remote-stream-forwarding for:

  1. Streams captured from <canvas>
  2. Streams captured from <video>
  3. Streams captured or generated by AudioContext i.e. WebAudio API

Is stream keeps quality?

Obviously "nope". It will have minor side-effects (e.g. latency in milliseconds/etc.).

If you'll be testing across tabs on the same system, then you'll obviously notice quality lost; however it will NOT happen if you test across different systems.

WebRTC Scalable Broadcast

In the image, you can see that each NEW-peer is getting stream from most-recent peer instead of getting stream directly from the moderator.

npm install webrtc-scalable-broadcast

Now, goto node_modules>webrtc-scalable-broadcast:

cd node_modules
cd webrtc-scalable-broadcast

# and run the server.js file
node server.js

Or:

cd ./node_modules/webrtc-scalable-broadcast/
node ./server.js

Or install using WGet:

mkdir webrtc-scalable-broadcast && cd webrtc-scalable-broadcast
wget http://dl.webrtc-experiment.com/webrtc-scalable-broadcast.tar.gz
tar -zxvf webrtc-scalable-broadcast.tar.gz
ls -a
node server.js

Or directly download the TAR/archive on windows:

And now open: http://localhost:8888 or 127.0.0.1:8888.

If server.js fails to run:

# if fails,
lsof -n -i4TCP:8888 | grep LISTEN
kill process-ID

# and try again
node server.js

How it works?

Above image showing terminal logs explains it better.

For more details, to understand how this broadcasting technique works:

WebRTC Scalable Broadcast

Assuming peers 1-to-10:

First Peer:

Peer1 is the only peer that invokes getUserMedia. Rest of the peers will simply forward/relay remote stream.

peer1 captures user-media
peer1 starts the room

Second Peer:

peer2 joins the room
peer2 gets remote stream from peer1
peer2 opens a "parallel" broadcasting peer named as "peer2-broadcaster"

Third Peer:

peer3 joins the room
peer3 gets remote stream from peer2
peer3 opens a "parallel" broadcasting peer named as "peer3-broadcaster"

Fourth Peer:

peer4 joins the room
peer4 gets remote stream from peer3
peer4 opens a "parallel" broadcasting peer named as "peer4-broadcaster"

Fifth Peer:

peer5 joins the room
peer5 gets remote stream from peer4
peer5 opens a "parallel" broadcasting peer named as "peer5-broadcaster"

and 10th peer:

peer10 joins the room
peer10 gets remote stream from peer9
peer10 opens a "parallel" broadcasting peer named as "peer10-broadcaster"

Conclusion

  1. Peer9 gets remote stream from peer8
  2. Peer15 gets remote stream from peer14
  3. Peer50 gets remote stream from peer49

and so on.

License

Scalable WebRTC Broadcasting Demo is released under MIT licence . Copyright (c) Muaz Khan.

Friday, June 08, 2012

Dinosaur Broadcasters Turn to Congress to Mandate Their Relevance

My Droid X has an FM radio.  It's sucks, it only works with the headphones plugged in and it doesn't work very well.  Add to that FM radio is really a low quality analog service when compared to MP3 and Internet based services like Pandora and iHeart Radio.

Even in my card I can listen to the station on AM or FM then switch to the iHeart Radio version and the sound quality is remarkable better it's immune to fading, assuming my Verizon Data Service doesn't cut out.

If they wish to push some emergency services for cell phone they would be far better off using something like my proposed Mobile Device Behavior Protocol. 



Click her to view a transcript of Gary Shapiro's testimony Wednesday, June 6.

FROM: Forbes,  Gary Shapiro,  May 30


Dinosaur Broadcasters Turn to Congress to Mandate Their Relevance


The technology of the audio industry is booming, leading to wonderful competition to generate new products. In this survival-of-the-fittest game, innovative products become more readily available while unpopular products disappear – except when the companies that make the outdated devices appeal to Congress to mandate old technology on new products – thus stifling innovation. One of these proposals was the topic of a House Committee on Energy and Commerce hearing today, where I testified on behalf of the companies who innovate. Specifically, broadcasters want to require that analog receivers be installed in a host of digital devices – a cell phone with an FM antenna.
At a time, where most agree that government is over reaching and when the economic bright spots are our innovation sectors, it seems incredible that this inane proposal choking a fast-developing new technology with an old technology would not pass the hee-haw test. But broadcasters still carry political weight, and many members of Congress fear them, so I found myself on the witness list this morning addressing why this idea makes as much sense as requiring every car be led by a horse.
We live in an amazing time, where wireless and the Internet have meshed to create a golden age of content creation. People can get news, music, video and other entertainment in many different ways. Also testifying today was the head of Pandora, whose service is sweeping America. Consumers can now buy music by the song, or all they can hear, or use any of several market offerings to sample, search and personalize. While some of the big distribution companies may see their market shrink, entrepreneurs and new creators rapidly jump in and create new services, products and groundbreaking content.
Broadcast radio now faces unprecedented competition, and despite already having the advantage of a free license for public spectrum and being the only media not to pay performers, it is stagnating. Broadcasters have lost their historic monopoly on music transmission, and they now exist in a more competitive environment. Indeed, digital audio advertising giant TargetSpot found nearly half of 18- to 24-year-olds (47 percent) spend less time listening to broadcast radio than they did a year ago. Not surprisingly, the steepest decline in broadcast radio listenership was among these “digital natives.”
At today’s hearing, Members of Congress on the House Energy and Commerce Committee also heard why the broadcasters’ plea to mandate an FM radio chip in each smartphone, ostensibly for emergency reasons, is a bad idea.
First, at least two dozen phones equipped with FM tuners are already in the marketplace for consumers who desire that feature. Most consumers surveyed say they don’t want Congress to mandate the FM chip, and their marketplace refusal to buy phones that have these FM chips speaks volumes.
Second, the delivery method is outdated and the extra hardware, including a special antenna, and design requirements increase production costs for little return in value.
Third, the role of radio in emergencies is diminishing rapidly. Many if not most radio stations are no longer manned 24-hours a day. People with cell phones can actually use the phone and a new system to send emergency text messages just recently mandated by Congress.
The correct answer for broadcasters is not to seek new laws or studies from Congress to protect their business model. Instead, broadcasters must do what other industries do when faced with new market entrants – learn to compete smarter and harder.
Wasting taxpayer funds on studying an unnecessary restriction on innovation is the kind of special interest expenditure that frustrates average Americans. You don’t have to be a member of the Tea Party to hate waste and special interest market intervention.
Innovation is driving our economy, and nowhere is this truer than the audio industry. Hardware manufacturers, online innovators and artists are all taking advantage of extraordinary new business opportunities. As always during times of disruptive innovation, incumbent industries are coming to Congress and requesting special protections. Congress should ignore these self-interested pleas, and continue to promote a vibrant and dynamic free market economy that creates investment and jobs.
Gary Shapiro is president and CEO of the Consumer Electronics Association (CEA)®, the U.S. trade association representing more than 2,000 consumer electronics companies, and author of The New York Times bestselling book, “The Comeback: How Innovation Will Restore the American Dream.”