Skip to content

Commit

Permalink
✨ NetGear_Async: New exclusive Bidirectional Mode for bidirectional d…
Browse files Browse the repository at this point in the history
…ata transfer [#239]

- ✨ NetGear_Async's first-ever exclusive Bidirectional mode with pure asyncio implementation.
- ⚠️ Bidirectional mode is only available with User-defined Custom Source(i.e. `source=None`)
- ⚡️ Added support for `PAIR` & `REQ/REP` bidirectional patterns for this mode.
- ⚡️ Added powerful `asyncio.Queues` for handling user data and frames in real-time.
- ✨ Implemented new `transceive_data` method  to Transmit _(in Recieve mode)_ and Receive _(in Send mode)_ data in real-time.
- ✨ Implemented `terminate_connection` internal asyncio method to safely terminate ZMQ connection and queues.
- ⚡️ Added `msgpack` automatic compression encoding and decoding of data and frames in bidirectional mode.
- ⚡️ Added support for `np.ndarray` video frames.
- ✨ Added new `bidirectional_mode` attribute for enabling this mode.
- ⚡️ Added 8-digit random alphanumeric id generator for each device.
- ⚠️ NetGear_Async will throw `RuntimeError` if bidirectional mode is disabled at server or client but not both.
- ✨ Added new `secrets` and `string` imports.
- 🐛 Fixed bug related asyncio queue freezing on calling `join()`.
- 🚑️ Added `task_done()` method after every `get()` call to gracefully terminate queues.
- 🔨 Improved custom source handling.
- 🐛 Fixed ZMQ connection bugs in bidirectional mode.
- 🚑️ Fixed several critical bugs in event loop handling.
- 🐛 Fixed several bugs in bidirectional mode implementation.
- 🎨 Added missing socket termination in both server and client end.
- 🎨 Removed deprecated `loop` parameter from asyncio methods.
- 🎨 Re-implemented `skip_loop` parameter in `close()` method.
- 💥 `run_until_complete` will not used if `skip_loop` is enabled.
- ✨ Added new `disable_confirmation` used to force disable termination confirmation from client in `terminate_connection`.
- 💥 `skip_loop` now will create asyncio task instead and will enable `disable_confirmation` by default.
- 🚑️ Replaced `create_task` with `ensure_future` to ensure backward compatibility with python-3.6 legacies.
- ✏️ Fixed typos in error messages.
- 🎨 Simplified code for `transceive_data` method.
- 🐛 Fixed `timeout` parameter logic.
- 💡 Added and Updated code comments.
- 💄 Updated Admonitions.


Docs: 
- 📝 Added usage examples for NetGear_Async's Bidirectional Mode.
  - 📝 Added new Usage examples and Reference doc for NetGear_Async's Bidirectional Mode.
  - 🍱 Added new image asset for NetGear_Async's Bidirectional Mode.
  - 🚩 Added NetGear_Async's `option` parameter reference.
  - 📝 Updated NetGear_Async definition in docs.
  - 💄 Changed font size for Helper methods.
  - 📝 Renamed `Bonus` to `References` in mkdocs.yml
  - 📝 Added missing helper methods in Reference.
  - 📝 Added more content to docs.
  - 🩹 Fixed redundant properties in CSS
  - 🐛 Fixed bugs in mkdocs.yml
  - ✏️ Fixed  typos and context.
  - 📝 Added `stream.release()` missing in docs.
  - ✏️ Fixed several typos in code comments.
  - 🔊 Updated logging messages.
  - 💡 Updated Code Comments.
  - ✏️ Fixed links in docs.
- 💄 Added support for search suggestions, search highlighting and search sharing (i.e. deep linking)
- 🚸 Added more content to docs to make it more user-friendly.
- 🚸 Added warning that JPEG Frame-Compression is disabled with Custom Source in WebGear.
- 🎨 Updates images and fixed context & typos.

CI: 
  - 👷 Added complete CI tests for Bidirectional Mode
    - 👷 Added complete CI tests for new Bidirectional Mode.
    - ✨ Implemented new exclusive `Custom_Generator` class for testing bidirectional data dynamically on server-end.
    - ✨ Implemented new exclusive `client_dataframe_iterator` method for testing bidirectional data on client-end.
    - ✨ Implemented `test_netgear_async_options` and `test_netgear_async_bidirectionalmode` two new tests.
    - 🐛 Fixed several bugs in new CI tests.
    - 💚 Added `timeout` value on server end in CI tests.
  - 💚 Fixed typo in `TimeoutError` exception import.
  - ☂️ Bumped CodeCov.
  - 👷 Added more directories to Codecov ignore list.
  - 🚸 Minor tweaks to `needs-more-info` template.

Helper: 
- ⚡️ Implemented RTSP protocol validation as demuxer
- ⚡️ Implemented RSTP protocol validation as demuxer, since it's not a protocol but a demuxer.
- 🎨 Implemented `get_supported_demuxers` method to get list of supported demuxers.
- ✨ Added 4320p resolution support to `dimensions_to_resolutions` method.
- 📝 Minor docs tweaks

NetGear:
- ⚡️ Update array indexing with `np.copy`.
- 🎨 Minor tweaks.

Asyncio: 
  - 💥 Changed `asyncio.sleep` value to 0
  - 💥 The amount of time sleep is irrelevant; the only purpose await asyncio.sleep() serves is to force asyncio to suspend execution to the event loop, and give other tasks a chance to run. Also, `await asyncio.sleep(0)` will achieve the same effect. https://stackoverflow.com/a/55782965/10158117
  • Loading branch information
abhiTronix authored Aug 22, 2021
2 parents 11f7dad + 466f49a commit c73428d
Show file tree
Hide file tree
Showing 35 changed files with 1,646 additions and 230 deletions.
2 changes: 2 additions & 0 deletions .github/needs-more-info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ labelToAdd: 'MISSING : TEMPLATE :grey_question:'
issue:
reactions:
- eyes
- '-1'
badTitles:
- update
- updates
Expand All @@ -12,6 +13,7 @@ issue:
- debug
- demo
- new
- help
badTitleComment: >
@{{ author }} Please re-edit this issue title to provide more relevant info.
Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ SteamGear also creates a Manifest file _(such as MPD in-case of DASH)_ or a Mast
NetGear implements a high-level wrapper around [**PyZmQ**][pyzmq] python library that contains python bindings for [**ZeroMQ**][zmq] - a high-performance asynchronous distributed messaging library.

NetGear seamlessly supports [**Bidirectional data transmission**][netgear_bidata_doc] along with video-frames between receiver(client) and sender(server).
NetGear seamlessly supports additional [**bidirectional data transmission**][netgear_bidata_doc] between receiver(client) and sender(server) while transferring video-frames all in real-time.

NetGear can also robustly handle [**Multiple Server-Systems**][netgear_multi_server_doc] and [**Multiple Client-Systems**][netgear_multi_client_doc] and at once, thereby providing access to a seamless exchange of video-frames & data between multiple devices across the network at the same time.

Expand Down Expand Up @@ -611,11 +611,13 @@ web.shutdown()
</p>
.

> _NetGear_Async can generate the same performance as [NetGear API](#netgear) at about one-third the memory consumption, and also provide complete server-client handling with various options to use variable protocols/patterns similar to NetGear, but it doesn't support any of [NetGear's Exclusive Modes][netgear-exm] yet._
> _NetGear_Async can generate the same performance as [NetGear API](#netgear) at about one-third the memory consumption, and also provide complete server-client handling with various options to use variable protocols/patterns similar to NetGear, but lacks in term of flexibility as it supports only a few [NetGear's Exclusive Modes][netgear-exm]._
NetGear_Async is built on [`zmq.asyncio`][asyncio-zmq], and powered by a high-performance asyncio event loop called [**`uvloop`**][uvloop] to achieve unmatchable high-speed and lag-free video streaming over the network with minimal resource constraints. NetGear_Async can transfer thousands of frames in just a few seconds without causing any significant load on your system.

NetGear_Async provides complete server-client handling and options to use variable protocols/patterns similar to [NetGear API](#netgear) but doesn't support any [NetGear Exclusive modes][netgear-exm] yet. Furthermore, NetGear_Async allows us to define our custom Server as source to manipulate frames easily before sending them across the network(see this [doc][netgear_Async-cs] example).
NetGear_Async provides complete server-client handling and options to use variable protocols/patterns similar to [NetGear API](#netgear). Furthermore, NetGear_Async allows us to define our custom Server as source to manipulate frames easily before sending them across the network(see this [doc][netgear_Async-cs] example).

NetGear_Async now supports additional [**bidirectional data transmission**][btm_netgear_async] between receiver(client) and sender(server) while transferring video-frames. Users can easily build complex applications such as like [Real-Time Video Chat][rtvc] in just few lines of code.

NetGear_Async as of now supports [all four ZeroMQ messaging patterns](#attributes-and-parameters-wrench):
* [**`zmq.PAIR`**][zmq-pair] _(ZMQ Pair Pattern)_
Expand Down Expand Up @@ -708,7 +710,7 @@ Here is a Bibtex entry you can use to cite this project in a publication:

# Copyright

**Copyright © abhiTronix 2019-2021**
**Copyright © abhiTronix 2019**

This library is released under the **[Apache 2.0 License][license]**.

Expand Down Expand Up @@ -747,6 +749,8 @@ Internal URLs
[azure-pipeline]:https://dev.azure.com/abhiuna12/public/_build?definitionId=2
[app]:https://ci.appveyor.com/project/abhiTronix/vidgear
[code]:https://codecov.io/gh/abhiTronix/vidgear
[btm_netgear_async]: https://abhitronix.github.io/vidgear/latest/gears/netgear_async/advanced/bidirectional_mode/
[rtvc]: https://abhitronix.github.io/vidgear/latest/gears/netgear_async/advanced/bidirectional_mode/#using-bidirectional-mode-for-video-frames-transfer

[test-4k]:https://github.com/abhiTronix/vidgear/blob/e0843720202b0921d1c26e2ce5b11fadefbec892/vidgear/tests/benchmark_tests/test_benchmark_playback.py#L65
[bs_script_dataset]:https://github.com/abhiTronix/vidgear/blob/testing/scripts/bash/prepare_dataset.sh
Expand Down
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,7 @@ coverage:

ignore:
- "vidgear/tests"
- "docs"
- "scripts"
- "vidgear/gears/asyncio/__main__.py" #trivial
- "setup.py"
31 changes: 30 additions & 1 deletion docs/bonus/reference/helper.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,33 @@ limitations under the License.

::: vidgear.gears.helper.get_video_bitrate

&nbsp;
&nbsp;

::: vidgear.gears.helper.check_WriteAccess

&nbsp;

::: vidgear.gears.helper.check_open_port

&nbsp;

::: vidgear.gears.helper.delete_file_safe

&nbsp;

::: vidgear.gears.helper.get_supported_demuxers

&nbsp;

::: vidgear.gears.helper.get_supported_vencoders

&nbsp;

::: vidgear.gears.helper.youtube_url_validator

&nbsp;


::: vidgear.gears.helper.validate_auth_keys

&nbsp;
6 changes: 5 additions & 1 deletion docs/bonus/reference/helper_async.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,8 @@ limitations under the License.

::: vidgear.gears.asyncio.helper.download_webdata

&nbsp;
&nbsp;

::: vidgear.gears.asyncio.helper.validate_webdata

&nbsp;
2 changes: 1 addition & 1 deletion docs/contribution/PR.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ You can clone your [**Forked**](https://docs.github.com/en/free-pro-team@latest/
Typically any feature/improvement/bug-fix code flows as follows:

<figure>
<img src='http://www.plantuml.com/plantuml/svg/RKzDYrD143pRlwAFYH1GmKjOmcwoA7jGGh9x4f5sfdmxP3wUFVFKAFvt9s_yUC5SXkcgwghgwrn4on0yvOEBlQW4DbvoVfLYsRlluESl9vIc8LgJD4BvnRC9OV591bzEMsybWFVe4lZXxd_9FRwL6--w610Bc_f0Bnjjaa_AjwA7pL7YH5Cx5_0FMeivT6Eb9jsAnsi58jsefgyDt4CQjavgeR_1Nbti6lulQksh8Lqi-9EefGPeXm_cCJa3lhfgdzMAwD5PC49VZcoHZRg-k1JftTFtl5Yi-1PVu5C_UYxPf11SoJH5g-hSVSdRmVl53fy7vCApxMvEKy6uSL-fUaeLR-wuZBfUSeQTj-WBfhi_yJohfqAZ-3cTztk8kSX73pgpFmsmFFDo2fhJaxzqJNaZbLHUjZXguvBtpQUDOvqTF2I3hX7j4Fml'>
<img src='../../assets/images/branch_flow.svg'>
</figure>

```sh
Expand Down
1 change: 1 addition & 0 deletions docs/gears/netgear/advanced/bidirectional_mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ Now, Open the terminal on another Server System _(a Raspberry Pi with Camera Mod
```python
# import required libraries
from vidgear.gears import VideoGear
from vidgear.gears import NetGear
from vidgear.gears import PiGear

# add various Picamera tweak parameters to dictionary
Expand Down
Loading

0 comments on commit c73428d

Please sign in to comment.