Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Channel manager #133

Merged
merged 46 commits into from
Oct 30, 2023
Merged

Channel manager #133

merged 46 commits into from
Oct 30, 2023

Conversation

SenexCrenshaw
Copy link
Owner

Backend channel manager/proxy/stream updates

…dependencies in constructor

🔧 fix(StreamController.cs): fix CheckProcessExists method to use ProcessId property instead of parameter
✨ feat(StreamController.cs): add logging and error handling for stream operations, implement GetProxy and StartVideoStreaming methods
The logger variable in the StreamController class was incorrectly named, causing a compilation error. The variable has been renamed to _logger to match the ILogger<StreamController> type. Additionally, the constructor was missing some dependencies, including ILogger<StreamController> and IMemoryCache. These dependencies have been added to the constructor.

The CheckProcessExists method was using a processId parameter instead of the ProcessId property. This has been fixed to use the correct property.

The commit also introduces new features to the StreamController class. Logging and error handling have been added to the stream operations, including the GetProxy and StartVideoStreaming methods. The GetProxy method retrieves a proxy stream based on the stream URL and the specified streaming proxy type. The StartVideoStreaming method handles the actual streaming of the video, reading chunks of data from the stream and writing them to the circular buffer. Error handling and retry logic have been implemented to handle potential errors during the streaming process

🔧 refactor(StreamManager.cs): refactor StreamManager constructor parameters to improve readability and maintainability
🔧 refactor(StreamManager.cs): refactor GetOrCreateStreamController method to simplify logic and improve readability
🔧 refactor(StreamManager.cs): remove unused private methods and unnecessary comments
The constructor of the StreamManager class has been refactored to improve readability and maintainability. The constructor now takes in additional parameters for the StreamController logger and the StreamManager logger. This change allows for better separation of concerns and makes it easier to identify which logger is being used in each part of the code.

The GetOrCreateStreamController method has been refactored to simplify the logic and improve readability. The method now creates a new StreamController object and adds it to the _streamControllers dictionary using the TryAdd method. This change eliminates the need for the CreateNewStreamController method and reduces the complexity of the code.

Unused private methods and unnecessary comments have been removed to clean up the code and improve code quality.
📝 chore(IStreamManager.cs): update method signatures in IStreamManager interface
🐛 fix(ChannelManager.cs): update variable names and types in ChannelManager class
🐛 fix(ChannelStatus.cs): update variable names and types in ChannelStatus class
🐛 fix(CircularRingBuffer.cs): update variable names and types in CircularRingBuffer class
The changes were made to add a new interface `IStreamHandler` and update existing interfaces and classes to use the new interface. This improves the code organization and makes it easier to manage stream handling and management. The variable names and types were updated to improve clarity and consistency in the code.

🎉 feat(StreamHandler.cs): add StreamHandler class to manage video streaming

The StreamHandler class is responsible for managing the streaming of a single video stream. It handles client registrations, buffer handling, and the streaming operation itself. The class takes in various parameters such as the stream URL, logger instance, client manager, buffer, and other necessary information.

The StreamHandler class provides the following features:
- Support for creating an instance asynchronously with the CreateAsync method.
- Logging errors if any occur during stream operations.
- Starting the video streaming operation and handling retries and delays.
- Handling the cancellation of the streaming task.
- Providing events for stream failures, client registrations, client unregistrations, and stream stops.
- Providing methods to get client streamer configurations, register/unregister client streamers, and stop the stream.

The StreamHandler class is a valuable addition as it centralizes the management of video streaming, making it easier to handle client registrations, buffer handling, and stream operations.

🔧 refactor(StreamManager.cs): rename StreamController to StreamHandler for better clarity and consistency
🚀 feat(StreamManager.cs): improve StreamManager class by using StreamHandler instead of StreamController for better clarity and consistency

The StreamManager class has been updated to use the StreamHandler class instead of the StreamController class. This change improves the clarity and consistency of the codebase. The StreamHandler class provides better naming and more accurately reflects its purpose in managing video streams.
📦 chore(IChannelStatus.cs): add new interface IChannelStatus
🔧 refactor(ConfigureServices.cs): register IChannelService in the dependency injection container
The commit adds two new interfaces, IChannelService and IChannelStatus, to the project. These interfaces define the contract for managing channels and their status. The IChannelService interface includes methods for setting the global status of a channel, retrieving stream handlers, getting channel status, counting global streams, checking if a channel exists, registering a channel, and unregistering a channel. The IChannelStatus interface defines properties and methods related to the status of a channel, such as adding and removing client IDs, getting the list of client IDs, managing a cancellation token source, tracking failover progress, managing the global status, setting the rank, and managing the stream handler and video stream information. Additionally, the ConfigureServices class is updated to register the IChannelService in the dependency injection container. This allows the application to resolve and use the IChannelService implementation throughout the codebase.

🔧 refactor(ChannelManager.cs): remove unused using statements and commented out code
🔧 refactor(ChannelManager.cs): change access modifier of _channelService field to private readonly
🔧 refactor(ChannelManager.cs): change access modifier of ChannelManager constructor parameters to private readonly
🔧 refactor(ChannelManager.cs): change access modifier of RegisterWithChannelManager method to private
🔧 refactor(ChannelManager.cs): change access modifier of SetIsGlobal method to private
🔧 refactor(ChannelManager.cs): change access modifier of UnRegisterClient method to private
🔧 refactor(ChannelManager.cs): change access modifier of GetNextChildVideoStream method to private
🔧 refactor(ChannelManager.cs): change access modifier of HandleNextVideoStream method to private
🔧 refactor(ChannelManager.cs): change access modifier of ProcessStreamStatus method to private
🔧 refactor(ChannelManager.cs): change access modifier of RegisterClient method to private
🔧 refactor(ChannelManager.cs): change access modifier of RegisterWithChannelManager method to private
🔧 refactor(ChannelManager.cs): change access modifier of ChannelWatcher method to private
🔧 refactor(ChannelManager.cs): change access modifier of GetGlobalStreamsCount method to private
🔧 refactor(Channel

🐛 fix(ChannelManager.cs): refactor UnRegisterWithChannelManager method to use ChannelService and StreamHandler
✨ feat(ChannelManager.cs): improve code readability and maintainability by using ChannelService and StreamHandler

The UnRegisterWithChannelManager method has been refactored to use the ChannelService and StreamHandler classes for better code organization and maintainability. The code now checks if a channel exists using the HasChannel method of the ChannelService class. The ChannelStatus object is retrieved using the GetChannelStatus method of the ChannelService class. The StreamHandler's UnRegisterClientStreamer method is called to unregister the client streamer. If the client count reaches zero, the StreamHandler's UnRegisterClientStreamer method is called to stop the streaming and the channel is unregistered using the UnregisterChannel method of the ChannelService class. The code has been updated to remove the client ID from the ChannelStatus object using the RemoveClientId method. This refactor improves the readability and maintainability of the code.

🎉 feat(ChannelService.cs): add ChannelService class to manage video stream channels and their statuses
🔧 fix(ChannelStatus.cs): rename StreamController property to StreamHandler for better clarity
The ChannelService class is added to manage video stream channels and their statuses. It provides methods to register and unregister channels, get channel status, get stream handlers, check if a channel exists, and get the count of global streams. The ChannelStatus class is also modified to rename the StreamController property to StreamHandler for better clarity and consistency.
… in ChannelManager class

🔧 refactor(ChannelService.cs): remove unnecessary constructor in ChannelService class
The changes in ChannelManager class involve removing unused code, specifically the commented out line for the `_channelStatuses` variable. Additionally, the logging in the `FailClient` and `RegisterWithChannelManager` methods has been improved to include the relevant client ID.

In the ChannelService class, the unnecessary constructor has been removed.
…nnelService interface

🔧 chore(IChannelStatus.cs): remove unused method SetIsGlobal in IChannelStatus interface
✨ feat(IStreamFactory.cs): add new interface IStreamFactory to handle stream creation
🔧 chore(ConfigureServices.cs): register DefaultStreamFactory as a singleton in the dependency injection container
The unused method SetIsGlobal in both IChannelService and IChannelStatus interfaces has been removed to improve code cleanliness. The new interface IStreamFactory has been added to handle stream creation, allowing for better separation of concerns. The DefaultStreamFactory has been registered as a singleton in the dependency injection container to provide a default implementation for IStreamFactory.

🐛 fix(ChannelManager.cs): fix method names to improve clarity and semantics
✨ feat(ChannelManager.cs): add support for handling override video stream and switching to the next video stream
The method `HandleNextVideoStream` has been renamed to `SwitchToNextVideoStream` to better reflect its purpose. The method `GetNextChildVideoStream` has been renamed to `RetrieveNextChildVideoStream` to improve clarity. The method `HandleOverrideStream` has been added to handle the case when an override video stream is provided. The method `UpdateStreamHandler` has been added to update the stream handler with the new video stream. The method `ApplyDelay` has been added to apply a delay before switching to the next video stream. The method `ProcessStreamStatus` has been removed as it is no longer used.

🔀 refactor(ChannelManager.cs): rename HandleNextVideoStream to SwitchToNextVideoStream for clarity and consistency
The method HandleNextVideoStream has been renamed to SwitchToNextVideoStream to improve clarity and consistency with the naming conventions used in the codebase. This change helps to better convey the purpose of the method and makes it easier to understand its functionality.

🔧 fix(ChannelManager.cs): rename method HandleNextVideoStream to SwitchToNextVideoStream for clarity and consistency
🔥 chore(ChannelManager.cs): remove unused SetIsGlobal method
The method HandleNextVideoStream has been renamed to SwitchToNextVideoStream to improve clarity and consistency with the naming conventions. The SetIsGlobal method has been removed as it was unused and no longer needed.

🔧 chore(ChannelService.cs): comment out unused SetIsGlobal method
🔧 chore(ChannelStatus.cs): remove unused SetIsGlobal method
✨ feat(DefaultStreamFactory.cs): add implementation for CreateStreamAsync method
The SetIsGlobal method in ChannelService.cs and ChannelStatus.cs is no longer used and has been commented out and removed respectively. In DefaultStreamFactory.cs, a new class DefaultStreamFactory is added which implements the IStreamFactory interface. It provides a dummy implementation for the CreateStreamAsync method by returning a new MemoryStream.
…y null check in RegisterOldClientsToStream method

The variables `m3uFile` and `allStreamsCount` are no longer used in the code, so they have been removed to improve code readability and maintainability. The null check for `channelStatus.StreamHandler` in the `RegisterOldClientsToStream` method has been simplified to only check if `oldConfigs` is not null, as the null check for `oldConfigs` already covers the null check for `channelStatus.StreamHandler`. This simplification improves code clarity and reduces unnecessary checks.
…hunk of data into a Memory<byte> target

✨ feat(CircularRingBuffer.cs): implement ReadChunkMemory method to read a chunk of data into a Memory<byte> target
The ICircularRingBuffer interface now includes a ReadChunkMemory method that allows reading a chunk of data into a Memory<byte> target. The CircularRingBuffer class has been updated to implement this method. This change improves the flexibility of reading data from the circular ring buffer by allowing the use of Memory<T> instead of byte[] for more efficient memory management.

🐛 fix(CircularRingBuffer.cs): fix ReleaseSemaphore method to release semaphores for all clients
The ReleaseSemaphore method in the CircularRingBuffer class has been modified to release semaphores for all clients instead of a specific client. This change ensures that all semaphores are released when needed, improving the overall synchronization and performance of the circular ring buffer.

🐛 fix(RingBufferReadStream.cs): add ReadAsync method to read data asynchronously into a Memory<byte> buffer
✨ feat(RingBufferReadStream.cs): implement ReadAsync method to read data asynchronously into a Memory<byte> buffer
The RingBufferReadStream class now
…nternalIsPreBuffered for better encapsulation

The `isPreBuffered` property has been renamed to `InternalIsPreBuffered` to improve encapsulation and clarify its purpose as an internal property. This change ensures that the property is not directly accessible outside the class and follows proper naming conventions for private properties.
…eServices method call

🔧 fix(Program.cs): remove unnecessary parameter from AddInfrastructureServices method call
The `AddInfrastructureServices` method in the `Program.cs` file is called with an unnecessary parameter `builder.Configuration`. This parameter is not used within the method, so it can be safely removed to improve code readability and maintainability.

🔧 fix(CircularRingBuffer.cs): comment out unused variables and methods, add dependencies to constructor
✨ feat(CircularRingBuffer.cs): add dependencies to constructor and register input stream statistics
The unused variables and methods in the CircularRingBuffer class have been commented out to improve code readability and maintainability. The CircularRingBuffer constructor now takes additional dependencies: IStatisticsManager and IInputStatisticsManager. The input stream statistics are registered using the IInputStatisticsManager in the constructor. This allows for better management and tracking of input stream statistics.

🔧 refactor(StreamManager.cs): add statisticsManager and inputStatisticsManager dependencies to StreamManager constructor
The StreamManager class now accepts two additional dependencies, statisticsManager and inputStatisticsManager, in its constructor. This change was made to enable the StreamManager to utilize these dependencies for handling statistics related to video streaming.
…ticsResult

🐛 fix(ICircularRingBuffer.cs): remove unused methods GetAllStatistics and GetSingleStreamStatisticsResult
🐛 fix(IStreamManager.cs): remove unused method GetSingleStreamStatisticsResult
🐛 fix(ChannelManager.cs): remove unused method GetSingleStreamStatisticsResult
The removed methods were not being used and were unnecessary, so they were removed to improve code cleanliness and maintainability.

🐛 fix(StreamHandler.cs): remove unnecessary blank lines and comments for code cleanup
🐛 fix(StreamHandler.cs): return null if stream or error is null in CreateAsync method
🐛 fix(StreamHandler.cs): rename StartVideoStreaming method to StartVideoStreamingAsync for consistency
🐛 fix(StreamHandler.cs): cancel VideoStreamingCancellationToken instead of cancellationToken
🐛 fix(StreamHandler.cs): remove unused StreamingTask property
🐛 fix(StreamHandler.cs): remove unused OnStreamControllerStopped method
🐛 fix(StreamHandler.cs): remove unused Stop method
🐛 fix(StreamManager.cs): remove unnecessary blank lines and comments for code cleanup
🐛 fix(StreamManager.cs): return null if streamController is null in GetStreamHandler method
🔥 chore(StreamManager.cs): remove unused GetSingleStreamStatisticsResult method
The changes in StreamHandler.cs remove unnecessary blank lines and comments to improve code readability and cleanliness. The CreateAsync method now returns null if the stream or error is null. The StartVideoStreaming method is renamed to StartVideoStreamingAsync for consistency. The VideoStreamingCancellationToken is canceled instead of the cancellationToken. The unused StreamingTask property and OnStreamControllerStopped method are removed. The unused Stop method is
…plementation

🐛 fix(StreamHandler): remove unnecessary streamUrl parameter from constructor and CreateAsync method
🐛 fix(StreamHandler): pass ICircularRingBufferFactory to CreateAsync method instead of individual dependencies
🐛 fix(StreamHandler): pass IMemoryCache to GetProxy method instead of ILogger and Setting
🐛 fix(StreamHandler): create ICircularRingBuffer instance using CircularRingBufferFactory instead of directly instantiating it
🐛 fix(StreamHandler): pass ICircularRingBuffer instance to StartVideoStreamingAsync method instead of individual dependencies
🐛 fix(StreamHandler): remove unnecessary streamUrl parameter from GetProxy method
🐛 fix(StreamHandler): remove unnecessary streamUrl property from StreamHandler class
🐛 fix(StreamHandler): remove unnecessary videoStreamId and videoStreamName parameters from CreateAsync method
🐛 fix(StreamHandler): remove unnecessary rank parameter from CreateAsync method
🐛 fix(StreamHandler): remove unnecessary circularBufferLogger parameter from CreateAsync method
🐛 fix(StreamHandler): remove unnecessary statisticsManager and inputStatisticsManager parameters from CreateAsync method
🐛 fix(StreamHandler): remove unnecessary childVideoStreamDto parameter from CreateAsync

🔧 refactor(StreamManager.cs): refactor StreamManager constructor parameters and GetOrCreateStreamController method parameters for improved readability and maintainability
🔥 chore(StreamManager.cs): remove commented out code for GetSingleStreamStatisticsResult method
The StreamManager constructor parameters have been refactored to use more descriptive names and to remove unnecessary dependencies. The GetOrCreateStreamController method parameters have also been refactored to remove unused parameters and to improve readability. Additionally, commented out code for the GetSingleStreamStatisticsResult method has been removed as it is no longer needed. These changes improve the overall readability and maintainability of the StreamManager class.
…percase PORT to improve semantics

✨ feat(server.ts): add support for process.env.PORT environment variable to be able to run app on a configurable port
The port variable is now named PORT, which improves consistency with the naming conventions as PORT is a constant. Support for an environment variable allows the application to be more flexible as it can now run on any available port specified via the process.env.PORT environment variable.

🚚 chore(ConfigureServices.cs): remove unused code and add missing dependencies
The unused code related to adding FluentValidationAutoValidation and HttpClient has been removed. The missing dependencies IProxyFactory and ICurrentCancellationTokenService have been added to the ConfigureServices class.

✨ feat(ICancellationTokenService.cs): add interface for CancellationTokenService
An interface ICurrentCancellationTokenService has been added to the Common.Interfaces namespace. This interface defines a CancellationToken property.

✨ feat(IProxyFactory.cs): add interface for ProxyFactory
An interface IProxyFactory has been added to the Common.Interfaces namespace. This interface defines a GetProxy method that returns a tuple containing a Stream, a processId, and a ProxyStreamError.

✨ feat(HttpClientExtensions.cs): remove unused code
The byteRangeStart

🔨 refactor(StreamManager.cs): add proxyFactory parameter to StreamManager constructor to improve extensibility and flexibility
The StreamManager class now accepts an additional parameter, `IProxyFactory`, in its constructor. This change was made to improve the extensibility and flexibility of the StreamManager class. The `IProxyFactory` parameter allows for the injection of a proxy factory implementation, which can be used by the StreamManager to create proxy objects as needed. This change ensures that the StreamManager class is more modular and can easily support different proxy implementations in the future.
…eamHandler interface

🔧 fix(StreamHandler.cs): remove unused dependencies and fields, refactor constructor to include ChildVideoStreamDto parameter, update StartVideoStreamingAsync method to public
🔧 fix(StreamManager.cs): rename _streamControllers to _streamHandlers, refactor GetOrCreateStreamController method to use CreateStreamHandler method, update GetStreamInformationFromStreamUrl and GetStreamsCountForM3UFile methods to use _streamHandlers dictionary
The changes were made to add a new method StartVideoStreamingAsync to the IStreamHandler interface, which was missing. In the StreamHandler class, unused dependencies and fields were removed, and the constructor was refactored to include the ChildVideoStreamDto parameter. The StartVideoStreamingAsync method was updated to be public. In the StreamManager class, the _streamControllers dictionary was renamed to _streamHandlers for clarity. The GetOrCreateStreamController method was refactored to use the CreateStreamHandler method, which creates a new StreamHandler instance and starts video streaming asynchronously. The GetStreamInformationFromStreamUrl and GetStreamsCountForM3UFile methods were updated to use the _streamHandlers dictionary instead of _streamControllers.
…ager to IClientStreamerManager2 for clarity and consistency

🔧 fix(IStreamHandler.cs): remove unused methods and properties from IStreamHandler interface
🔧 fix(IStreamManager.cs): rename method GetOrCreateStreamController to GetOrCreateStreamHandler for clarity and consistency
🔧 fix(ConfigureServices.cs): remove registration of ClientStreamerManager from the DI container
🔧 fix(ChannelManager.cs): update method calls to match the renamed methods in IStreamManager interface
🔧 fix(ClientStreamerManager.cs): rename class ClientStreamerManager to ClientStreamerManager2 for clarity and consistency, update method signatures and implementation to support multiple client configurations per stream URL
The changes were made to improve the clarity and consistency of the codebase. The interface and class names were updated to provide more descriptive names. The method signatures and implementations were modified to support multiple client configurations per stream URL, allowing for better management and organization of client configurations.

🐛 fix(StreamHandler.cs): remove unused dependencies and methods to improve code readability and maintainability
🐛 fix(StreamHandler.cs): remove unused ClientCount property to improve code consistency
🐛 fix(StreamHandler.cs): remove unused GetClientStreamerConfiguration and GetClientStreamerConfigurations methods to improve code clarity
🐛 fix(StreamHandler.cs): remove unused RegisterClient and UnRegisterClient methods to improve code simplicity
🐛 fix(StreamHandler.cs): remove unused ClientCount property to improve code consistency
🐛 fix(StreamHandler.cs): remove unused GetClientStreamerConfiguration and GetClientStreamerConfigurations methods to improve code clarity
🐛 fix(StreamHandler.cs): remove unused RegisterClient and UnRegisterClient methods to improve code simplicity
🐛 fix(StreamManager.cs): remove unused clientStreamerManager dependency to improve code clarity
✨ feat(StreamManager.cs): rename GetOrCreateStreamController method to GetOrCreateStreamHandler for better naming consistency
✨ feat(StreamManager.cs): remove unused circularRingBufferFactory and memoryCache dependencies to simplify code
The changes in StreamHandler.cs remove unused dependencies and methods that were not being used, improving code readability and maintainability. The ClientCount property, GetClientStreamerConfiguration, GetClientStreamerConfigurations,
…to uppercase PORT for improved semantics

🔥 refactor(server.ts): add support for process.env.PORT environment variable for configurable port
The changes in `server.ts` refactor the code to improve semantics and make it more flexible. The `port` variable is renamed to `PORT` to follow naming conventions for constants. Additionally, support for the `process.env.PORT` environment variable is added, allowing the application to run on a configurable port. This change improves code readability and makes the application more adaptable to different deployment environments.

🔥 refactor: remove unused IClientStreamerManager2 interface and ClientStreamerManager2 class
The changes in the files `IClientStreamerManager.cs`, `ClientStreamerManager.cs`, and `StreamManager.cs` remove the unused `IClientStreamerManager2` interface and `ClientStreamerManager2` class. These files are no longer needed and can be safely deleted. This cleanup improves code maintainability and reduces unnecessary complexity.
…thod from Task<ActionResult> to IActionResult

🔀 merge(IChannelManager.cs): change return type of FailClient method from Task to void
🔀 merge(IStreamSwitcher.cs): add new interface IStreamSwitcher
🔀 merge(IVideoStreamInterfaces.cs): change return type of FailClient method from Task<ActionResult> to IActionResult
🔀 merge(TokenExtensions.cs): add TokenExtensions class with ApplyDelay method
✨ feat(ConfigureServices.cs): add IStreamSwitcher to the list of services
The return type of the FailClient method in the VideoStreamsController.cs file is changed from Task<ActionResult> to IActionResult to improve consistency with the other methods in the controller. The return type of the FailClient method in the IChannelManager.cs interface is changed from Task to void to reflect that the method does not return any value. The IStreamSwitcher interface is added to the project to provide a contract for switching video streams. The TokenExtensions class is added with the ApplyDelay method to provide an extension method for CancellationToken to apply a delay. The IStreamSwitcher is added to the list of services in the ConfigureServices.cs file to enable dependency injection.

🔧 refactor(ChannelManager.cs): remove unused using statements and dependencies, refactor constructor parameters
🚀 feat(ChannelManager.cs): introduce a stream switcher to handle switching to the next video stream

The commit removes unused using statements and dependencies in the ChannelManager class to improve code cleanliness and remove unnecessary dependencies. The constructor parameters of the ChannelManager class are refactored to introduce a stream switcher dependency, which will handle the logic for switching to the next video stream. This change improves the separation of concerns and makes the code more modular and maintainable.

🔥 refactor: remove unused code in RegisterWithChannelManager method
The code block that registers the client streamer with the channel manager is no longer needed and has been removed. This improves code readability and eliminates unnecessary code execution.

🔀 refactor(ChannelManager.cs): replace UnRegisterClient method with UnRegisterWithChannelManager method for better code organization and clarity
The UnRegisterClient method has been replaced with the UnRegisterWithChannelManager method. This change improves code organization and clarity by consolidating the logic for unregistering a client with the channel manager into a single method.

📦 chore(StreamSwitcher.cs): add StreamSwitcher class to handle switching between video streams
🔧 refactor(StreamSwitcher.cs): refactor UpdateStreamHandler method to improve readability and error handling
🔧 refactor(StreamSwitcher.cs): refactor SwitchToNextVideoStreamAsync method to improve readability and error handling
🔧 refactor(StreamSwitcher.cs): refactor GetGlobalStreamsCount method to improve readability
🔧 refactor(StreamSwitcher.cs): refactor RegisterClientsToNewStream method to improve readability
🔧 refactor(StreamSwitcher.cs): refactor HandleOverrideStream method to improve readability and error handling
🔧 refactor(StreamSwitcher.cs): refactor FetchNextChildVideoStream method to improve readability and error handling
🔧 refactor(StreamSwitcher.cs): refactor RetrieveNextChildVideoStream method to improve readability and error handling
The StreamSwitcher class is added to handle the switching between video streams. The UpdateStreamHandler method is refactored to improve readability and error handling. The SwitchToNextVideoStreamAsync method is refactored to improve readability and error handling. The GetGlobalStreamsCount method is refactored to improve readability. The RegisterClientsToNewStream method is refactored to improve readability. The HandleOverrideStream method
…elay method

The commented out code for the ApplyDelay method has been removed as it is no longer needed. This improves the readability and maintainability of the codebase by removing unnecessary commented out code.
…isticService in the dependency injection container

✨ feat(ConfigureServices.cs): add registration for IBroadcastService in the dependency injection container
The missing registration for IStreamStatisticService in the ConfigureServices class has been added to ensure that the service can be resolved correctly. This allows other components to depend on IStreamStatisticService and use its functionality.

The registration for IBroadcastService has been added to the ConfigureServices class to enable the broadcasting of stream statistics to clients. The BroadcastService class is responsible for periodically retrieving stream statistics using the IStreamStatisticService and broadcasting them to connected clients via the StreamMasterHub.

🔧 refactor(ChannelManager.cs): remove unused using statements and constructor parameters
🔧 refactor(ChannelManager.cs): remove unused private fields and methods
The commit removes unused using statements and constructor parameters in the ChannelManager class. It also removes unused private fields and methods. These changes improve code readability and maintainability by removing unnecessary code clutter.

🐛 fix(ChannelManager.cs): replace private logger field with local logger variable for consistency and readability
🔀 refactor(ChannelManager.cs): replace usages of _channelService with channelService for consistency and readability
🔀 refactor(ChannelManager.cs): replace usages of _streamSwitcher with streamSwitcher for consistency and readability
🔀 refactor(ChannelManager.cs): replace usages of _streamManager with streamManager for consistency and readability
The private logger field is replaced with a local logger variable to improve consistency and readability. The usages of the _channelService field are replaced with the channelService parameter for consistency and readability. Similarly, the usages of the _streamSwitcher field are replaced with the streamSwitcher parameter, and the usages of the _streamManager field are replaced with the streamManager parameter for consistency and readability.

🐛 fix(RingBufferReadStream.cs): rename variables for better clarity and consistency
✨ feat(RingBufferReadStream.cs): add support for client master token to handle cancellation requests
The variables `_cancellationSource`, `_cancellationTokenSource`, and `_clientId` have been renamed to `_clientMasterToken` and `_clientId`, respectively, to improve clarity and consistency. The support for the client master token allows for better handling of cancellation requests, ensuring that the read operations are properly cancelled when requested.

✨ feat(StreamStatistics.cs): add support for retrieving stream statistics for all URLs
A new method `GetAllStatisticsForAllUrls` has been added to the `StreamStatisticService` class. This method retrieves stream statistics for all URLs by iterating through the collection of stream handlers and aggregating the statistics. Additionally, the method checks the `ShowClientHostNames` setting and resolves the client IP addresses to host names if enabled. This provides more comprehensive stream statistics for analysis and monitoring purposes.
…treamManager

The missing dependencies `StreamMasterInfrastructure.VideoStreamManager.Factories` and `StreamMasterInfrastructure.VideoStreamManager.Statistics` are imported to ensure that the VideoStreamManager functionality can be used in the application.

🎉 feat(CircularRingBuffer.cs): implement CircularRingBuffer class for streaming data

The CircularRingBuffer class is implemented to handle streaming data in a circular ring buffer. It provides methods for reading and writing data, as well as managing client registrations and statistics. The buffer size and preload percentage are configurable via the constructor parameters.

This implementation allows for efficient streaming of data by continuously overwriting the oldest data in the buffer. It also supports multiple clients reading from the buffer concurrently, with each client having its own read index.

The CircularRingBuffer class is designed to be used in a video streaming application, where it is important to efficiently buffer and serve video data to clients.

🆕 feat(RingBufferReadStream.cs): add implementation of the RingBufferReadStream class
🆕 feat(ChannelManager.cs): add ChannelManager class to manage channels in the video stream manager
🆕 feat(CircularRingBufferFactory.cs): add CircularRingBufferFactory class to create and manage circular ring buffers
🆕 feat(DefaultStreamFactory.cs): add DefaultStreamFactory class to create a default stream
🆕 feat(ProxyFactory.cs): add ProxyFactory class to handle proxy streams

The commit adds several new files and classes to the project:
1. `RingBufferReadStream.cs`: This file contains the implementation of the `RingBufferReadStream` class, which is responsible for reading data from a circular ring buffer.
2. `ChannelManager.cs`: This file contains the implementation of the `ChannelManager` class, which is responsible for managing channels in the video stream manager.
3. `CircularRingBufferFactory.cs`: This file contains the implementation of the `CircularRingBufferFactory` class, which is responsible for creating and managing circular ring buffers.
4. `DefaultStreamFactory.cs`: This file contains the implementation of the `DefaultStreamFactory` class, which is responsible for creating a default stream.
5. `ProxyFactory.cs`: This file

📦 chore(Statistics): add InputStatisticsManager, StatisticsManager, and StreamStatistics classes
🔧 refactor(InputStatisticsManager): create InputStatisticsManager class to manage input stream statistics
🔧 refactor(StatisticsManager): create StatisticsManager class to manage client statistics
🔧 refactor(StreamStatistics): create StreamStatistics class to retrieve stream statistics for all URLs

The commit adds three new classes: InputStatisticsManager, StatisticsManager, and StreamStatistics. These classes are responsible for managing input stream statistics, client statistics, and retrieving stream statistics for all URLs, respectively. The new classes are added to improve the organization and modularity of the codebase, making it easier to manage and retrieve statistics related to video streaming.
🐛 fix: remove unused ICurrentCancellationTokenService class
✨ feat: add CancellationToken parameter to GetProxy method in IProxyFactory interface
🐛 fix: add CancellationToken parameter to GetOrCreateStreamHandler method in IStreamManager interface
🐛 fix: add CancellationToken parameter to GetOrCreateStreamHandler method in IStreamManager interface
🐛 fix: add CancellationToken parameter to GetOrCreateStreamHandler method in IStreamManager interface
🐛 fix: add CancellationToken parameter to GetOrCreateStreamHandler method in IStreamManager interface
🐛 fix: add CancellationToken parameter to GetOrCreateStreamHandler method in IStreamManager interface
🐛 fix: add CancellationToken parameter to GetOrCreateStreamHandler method in IStreamManager interface
🐛 fix: add CancellationToken parameter to GetOrCreateStreamHandler method in IStreamManager interface
🐛 fix: add CancellationToken parameter to GetOrCreateStreamHandler method in IStreamManager interface
🐛 fix: add CancellationToken parameter to GetOrCreateStreamHandler method in IStreamManager interface
🐛 fix: add CancellationToken parameter to GetOrCreateStreamHandler method in IStreamManager interface
🐛 fix: add CancellationToken parameter to GetOrCreateStreamHandler method

🐛 fix(ChannelManager.cs): fix compilation errors and remove unused code
✨ feat(ChannelManager.cs): add support for broadcasting and stopping broadcasting in ChannelManager
The changes in ChannelManager.cs include fixing compilation errors by adding missing dependencies and removing unused code. Additionally, support for broadcasting and stopping broadcasting has been added to the ChannelManager. This allows for better control and management of video streaming channels.

🐛 fix(ProxyFactory.cs): remove unused CancellationToken parameter from GetProxy method
🐛 fix(ProxyFactory.cs): remove unused CancellationToken parameter from GetProxyStream method
🐛 fix(StreamManager.cs): remove unused CancellationToken parameter from CreateStreamHandler method
🐛 fix(StreamManager.cs): remove unused CancellationToken parameter from GetOrCreateStreamHandler method
🐛 fix(StreamManager.cs): remove unused CancellationToken parameter from GetOrCreateStreamHandler method
🐛 fix(StreamManager.cs): remove unused CancellationToken parameter from GetOrCreateStreamHandler method
🐛 fix(StreamManager.cs): remove unused CancellationToken parameter from GetOrCreateStreamHandler method
🐛 fix(StreamManager.cs): remove unused CancellationToken parameter from GetOrCreateStreamHandler method
🐛 fix(StreamManager.cs): remove unused CancellationToken parameter from GetOrCreateStreamHandler method
🐛 fix(StreamManager.cs): remove unused CancellationToken parameter from GetOrCreateStreamHandler method
🐛 fix(StreamManager.cs): remove unused CancellationToken parameter from GetOrCreateStreamHandler method
🐛 fix(StreamManager.cs): remove unused CancellationToken parameter from GetOrCreateStreamHandler method
🐛 fix(StreamManager.cs): remove unused CancellationToken parameter from GetOrCreateStreamHandler method
🐛 fix(StreamManager.cs): remove unused CancellationToken

🐛 fix(StreamSwitcher.cs): fix variable naming and nullability issues in StreamSwitcher class
🔀 refactor(StreamSwitcher.cs): refactor GetNextChildVideoStream method to improve readability and handle null cases
The changes in this commit fix some variable naming and nullability issues in the StreamSwitcher class. The `StreamSwitcher` class now uses a nullable `IStreamHandler` variable instead of directly accessing the `StreamHandler` property. The `GetNextChildVideoStream` method has been refactored to improve readability and handle null cases more effectively. Additionally, some logging messages have been updated to reflect the changes made.
…operty

The commented out code related to the `streamHandler` property has been removed as it is not being used. The `streamHandler` property itself has been removed as well. This improves code readability and removes unnecessary clutter.
…le next video stream" to "attempting to switch to next video stream" for better clarity

🐛 fix(ChannelManager.cs): change log message from "Exiting ProcessStreamStatus with {handled} after handling next video stream" to "Exiting ProcessStreamStatus with {handled} after switching to next video stream" for better clarity
🐛 fix(ChannelManager.cs): change log message from "Exiting RegisterWithChannelManager with {handled} after handling next video stream" to "Exiting RegisterWithChannelManager with {handled} after switching to next video stream" for better clarity
✨ feat(ChannelManager.cs): add support for registering new channels and handling existing channels in RegisterWithChannelManager method
The log messages have been updated to provide better clarity on the actions being performed. The RegisterWithChannelManager method now supports registering new channels and handling existing channels. This allows for better management of channels and ensures that the appropriate actions are taken based on the channel's status.
SenexCrenshaw and others added 16 commits October 16, 2023 18:28
…egisterWithChannelManager method

The commented out code related to the RegisterWithChannelManager method has been removed. This code was not being used and was cluttering the file. Removing it improves code readability and maintainability.
…turn a Task instead of void for consistency

✨ feat(IChannelService.cs): add GetChannelStatuses method to retrieve the statuses of all channels
🐛 fix(IChannelStatus.cs): fix namespace declaration and add missing using statement for StreamMasterApplication.Common.Models
🐛 fix(IStreamHandler.cs): add missing HasClient method to check if there is an existing client registered
✨ feat(IStreamManager.cs): add GetStreamInformations method to retrieve all stream handlers
🐛 fix(TokenExtensions.cs): add ApplyDelay method to apply a delay using Task.Delay
🐛 fix(BroadcastService.cs): fix logic to handle empty statistics results and prevent unnecessary broadcasts
🐛 fix(CircularRingBuffer.cs): remove commented out code and update log message in RegisterClient method
The changes were made to fix bugs and add new features to the codebase. The bug fixes include changing the method signature of the RemoveClient method in the IChannelManager interface to return a Task instead of void for consistency. The namespace declaration in the IChannelStatus interface was also fixed, and a missing using statement for StreamMasterApplication.Common.Models was added. The IStreamHandler interface now

🐛 fix(ChannelManager.cs): fix race condition by adding semaphores for register and unregister operations
✨ feat(ChannelManager.cs): add support for channel watcher to monitor channel status and handle client registrations and unregistrations
The changes in this commit fix a race condition in the ChannelManager class by adding semaphores to ensure that register and unregister operations are executed in a thread-safe manner. Additionally, support for a channel watcher is added to monitor the status of channels and handle client registrations and unregistrations accordingly. This improves the reliability and stability of the ChannelManager functionality.

🐛 fix: add missing newline at the end of the file in MyClass.cs
The commit fixes a missing newline at the end of the file in MyClass.cs. Adding the newline ensures that the file conforms to standard coding practices and avoids any potential issues with certain tools or processes that may require a newline at the end of a file.

🐛 fix(ChannelService.cs): change method name from GetChannelStatuses to GetChannelStatuses to improve naming consistency
✨ feat(ChannelStatus.cs): change ClientIds dictionary value type from Guid to ClientStreamerConfiguration to store additional client information
🐛 fix(ChannelStatus.cs): change method name from GetChannelClientIds to GetChannelClientClientStreamerConfigurations to improve naming consistency
✨ feat(ChannelStatus.cs): add ClientCount property to get the count of registered clients
🐛 fix(ChannelStatus.cs): change method name from AddToClientIds to RegisterClient to improve naming consistency
🐛 fix(ChannelStatus.cs): change method name from RemoveClientId to UnRegisterClient to improve naming consistency
🐛 fix(StreamHandler.cs): change method name from UnRegisterClientStreamer to UnRegisterClient to improve naming consistency
✨ feat(StreamHandler.cs): add HasClient method to check if a client with a given ID exists
🐛 fix(StreamManager.cs): remove unnecessary else block and log message duplication
✨ feat(StreamManager.cs): add log message when creating a new buffer for a stream
🐛 fix(StreamManager.cs): add log message when reusing a buffer for a stream
🐛 fix(StreamManager.cs
@SenexCrenshaw SenexCrenshaw merged commit 1de7b43 into main Oct 30, 2023
4 checks passed
@SenexCrenshaw SenexCrenshaw deleted the Channel-Manager branch October 30, 2023 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant