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

dash support #1047

Merged
merged 10 commits into from
Jan 14, 2024
Merged

dash support #1047

merged 10 commits into from
Jan 14, 2024

Conversation

dyc3
Copy link
Owner

@dyc3 dyc3 commented Aug 5, 2023

  • add dash js
  • PlyrPlayer: implement dash player, not tested yet

closes #1036

@codecov
Copy link

codecov bot commented Aug 5, 2023

Codecov Report

Attention: 20 lines in your changes are missing coverage. Please review.

Comparison is base (b0c3bca) 61.4635% compared to head (25d3d90) 61.4291%.
Report is 1 commits behind head on master.

Files Patch % Lines
server/services/dash.ts 68.8524% 19 Missing ⚠️
server/services/parsing/iso8601.ts 91.6666% 1 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##             master      #1047        +/-   ##
================================================
- Coverage   61.4635%   61.4291%   -0.0344%     
================================================
  Files           115        117         +2     
  Lines          9347       9502       +155     
  Branches       1145       1156        +11     
================================================
+ Hits           5745       5837        +92     
- Misses         3602       3665        +63     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cypress
Copy link

cypress bot commented Aug 5, 2023

1 failed test on run #820 ↗︎

1 67 1 0 Flakiness 0

Details:

Merge 25d3d90 into 8cba966...
Project: OpenTogetherTube Commit: 4181b51cf7 ℹ️
Status: Failed Duration: 02:55 💡
Started: Jan 14, 2024 6:08 PM Ended: Jan 14, 2024 6:11 PM
Failed  client/tests/e2e/component/ShareInvite.cy.ts • 1 failed test • Component - electron

View Output Video

Test Artifacts
An uncaught error was detected outside of a test Screenshots Video

Review all test suite changes for PR #1047 ↗︎

Copy link
Contributor

coderabbitai bot commented Jan 14, 2024

Walkthrough

The service has been updated to support DASH streaming, expanding its video format capabilities. This includes handling DASH manifest files, enabling video playback of DASH content, and integrating DASH streaming into the existing browser interface. The update ensures compatibility with video controls and seamless streaming of DASH alongside other formats.

Changes

File Path Change Summary
client/src/components/AddPreview.vue Semantic differences for DASH streaming URLs.
client/src/components/players/OmniPlayer.vue
client/src/components/players/PlyrPlayer.vue
Modified player components to support DASH streaming.
common/constants.ts Included "dash" in the video services list.
server/infoextractor.ts Added DashVideoAdapter import and logic for DASH support.
server/mime.ts Added "application/dash+xml" MIME type support.
server/services/dash.ts New file for handling DASH streaming.
server/services/parsing/iso8601.ts Added function to parse ISO 8601 durations.
server/services/youtube.ts Replaced parseVideoLength with parseIso8601Duration.
server/tests/unit/services/dash.spec.ts
server/tests/unit/services/parsing/iso8601.spec.ts
Added tests for DASH and ISO 8601 parsing.
server/tests/unit/services/youtube.spec.ts Removed tests for the now-deprecated parseVideoLength.

Assessment against linked issues

Objective Addressed Explanation
Add support for DASH streaming to the service. (#1036)
Enable the service to handle DASH video format alongside existing formats. (#1036)
Provide the ability to access DASH streams through the service's browser interface. (#1036)
Ensure the service can process DASH manifest files and stream DASH content seamlessly. (#1036)
Verify that the service's video playback controls are compatible with DASH streaming. (#1036)

Poem

In the land of streams and bytes,
A rabbit hopped through digital nights.
DASHing through the code with ease,
Bringing videos to screens like a breeze. 🐰🎬✨

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@dyc3 dyc3 marked this pull request as ready for review January 14, 2024 17:42
@dyc3
Copy link
Owner Author

dyc3 commented Jan 14, 2024

@coderabbitai can you generate some unit tests for the mpd parsing stuff in server/services/dash.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 2

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 8cba966 and 176445d.
Files ignored due to path filters (3)
  • client/package.json is excluded by: !**/*.json
  • server/package.json is excluded by: !**/*.json
  • yarn.lock is excluded by: !**/*.lock
Files selected for processing (11)
  • client/src/components/AddPreview.vue (1 hunks)
  • client/src/components/players/OmniPlayer.vue (1 hunks)
  • client/src/components/players/PlyrPlayer.vue (3 hunks)
  • common/constants.ts (1 hunks)
  • server/infoextractor.ts (2 hunks)
  • server/mime.ts (2 hunks)
  • server/services/dash.ts (1 hunks)
  • server/services/parsing/iso8601.ts (1 hunks)
  • server/services/youtube.ts (3 hunks)
  • server/tests/unit/services/parsing/iso8601.spec.ts (1 hunks)
  • server/tests/unit/services/youtube.spec.ts (1 hunks)
Additional comments: 14
common/constants.ts (1)
  • 10-10: The addition of "dash" to the ALL_VIDEO_SERVICES array is consistent with the PR's objective to add DASH support.
server/tests/unit/services/parsing/iso8601.spec.ts (1)
  • 3-14: The test cases provided for the parseIso8601Duration function cover a variety of ISO 8601 duration formats, which is good for ensuring the function's correctness across different formats.
server/mime.ts (2)
  • 20-20: The addition of the "application/dash+xml" MIME type is correct and aligns with the PR's goal to support DASH content.

  • 32-32: The update to the isSupportedMimeType function to include "application/dash+xml" is correct and necessary for the DASH support.

client/src/components/players/PlyrPlayer.vue (3)
  • 11-11: The import of dashjs is correct and necessary for DASH support within the PlyrPlayer component.

  • 40-40: The declaration of the dash variable is correct and aligns with the initialization of the DASH player later in the code.

  • 252-293: The conditional logic and event handling for the DASH video format are correctly implemented. The use of dashjs to initialize and manage DASH content is appropriate.

client/src/components/AddPreview.vue (1)
  • 220-224: The addition of test entries for DASH streaming URLs is consistent with the PR's objective to support DASH content. This will be useful for development and testing purposes.
client/src/components/players/OmniPlayer.vue (1)
  • 77-77: The modification to include the dash service in the conditional check for source.service is correct and necessary for the OmniPlayer component to handle DASH streams.
server/infoextractor.ts (2)
  • 29-29: The import statement for DashVideoAdapter is correctly placed and follows the existing pattern of importing service adapters.

  • 86-88: The conditional inclusion of DashVideoAdapter in the adapters array based on the enabled configuration is a standard pattern used for other adapters in this file. This ensures that the DashVideoAdapter is only used when DASH support is enabled in the configuration.

server/tests/unit/services/youtube.spec.ts (1)
  • 533-538: > Note: This review was outside the patches, and no patch overlapping with it was found. Original lines [1-1]

The removal of the parseVideoLength function and its associated test cases from the Youtube service is consistent with the changes in the youtube.ts file where the parseVideoLength method was replaced with parseIso8601Duration. This change should be verified to ensure that the new function is covered by tests and that the removal of the old tests does not decrease the test coverage.

server/services/youtube.ts (2)
  • 18-18: The import of parseIso8601Duration is correctly placed and follows the existing pattern of importing utility functions.

  • 547-547: The update to use parseIso8601Duration for parsing video lengths is correct and aligns with the removal of the parseVideoLength method. This change centralizes the logic for parsing ISO 8601 durations and should be verified to ensure that it is correctly parsing all expected formats.

Verification successful

The implementation of parseIso8601Duration in iso8601.ts shows that the function is designed to parse ISO 8601 durations into seconds. The regex used in the function is capable of matching durations that include days (\d+D), hours (\d+H), minutes (\d+M), and seconds (\d+S). The function also correctly accounts for the possibility of any of these components being absent, except for the period designator T, which is required if any time elements are present.

The function handles optional days, hours, minutes, and seconds, and it defaults to 0 if any of these are not present. It then calculates the total duration in seconds based on the parsed values.

Given the implementation details, it appears that the function should correctly parse all expected ISO 8601 duration formats, including those with only minutes and seconds, which were specifically mentioned in the review comment.

Based on the provided implementation, the update to use parseIso8601Duration for parsing video lengths in youtube.ts is verified to be correctly handling the expected ISO 8601 duration formats.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that parseIso8601Duration is correctly parsing all expected formats.
rg --type js "parseIso8601Duration" --files-with-matches | xargs rg "PT\\d+M\\d+S"

Length of output: 2868



Script:

#!/bin/bash
# View the implementation of parseIso8601Duration to verify handling of various ISO 8601 duration formats.
cat server/services/parsing/iso8601.ts

Length of output: 733

server/services/parsing/iso8601.ts Show resolved Hide resolved
server/services/dash.ts Outdated Show resolved Hide resolved
Copy link
Contributor

coderabbitai bot commented Jan 14, 2024

/**
 * Unit tests for DashVideoAdapter's MPD parsing methods
 */
import { DashVideoAdapter } from './dash';
import { Video } from '../../common/models/video';
import { UnsupportedVideoType } from '../exceptions';
import { parseIso8601Duration } from './parsing/iso8601';
import axios from 'axios';
import { DashMPD } from '@liveinstantly/dash-mpd-parser';

jest.mock('axios');
jest.mock('./parsing/iso8601');

describe('DashVideoAdapter', () => {
  let adapter: DashVideoAdapter;
  let mockAxiosGet: jest.Mock;
  let mockParseIso8601Duration: jest.Mock;
  let mockDashMPD: jest.Mock;

  beforeEach(() => {
    adapter = new DashVideoAdapter();
    mockAxiosGet = axios.get as jest.Mock;
    mockParseIso8601Duration = parseIso8601Duration as jest.Mock;
    mockDashMPD = DashMPD as jest.Mock;
  });

  describe('handleMpd', () => {
    it('should fetch and parse MPD data', async () => {
      const mockMPDData = '<MPD></MPD>';
      const mockManifest = { MPD: {} };
      mockAxiosGet.mockResolvedValue({ data: mockMPDData });
      const mockParse = jest.fn();
      mockDashMPD.mockImplementation(() => ({ parse: mockParse, getJSON: () => mockManifest }));

      const url = new URL('http://example.com/video.mpd');
      await adapter.handleMpd(url);

      expect(mockAxiosGet).toHaveBeenCalledWith(url.href);
      expect(mockParse).toHaveBeenCalledWith(mockMPDData);
    });
  });

  describe('parseMpdManifest', () => {
    it('should throw UnsupportedVideoType for live streams', () => {
      const manifest = { MPD: { '@profiles': 'isoff-live' } };
      const url = new URL('http://example.com/video.mpd');

      expect(() => {
        adapter.parseMpdManifest(url, manifest);
      }).toThrow(UnsupportedVideoType);
    });

    it('should parse duration and return a Video object', () => {
      const durationRaw = 'PT1H2M3S';
      const durationInSeconds = 3723;
      mockParseIso8601Duration.mockReturnValue(durationInSeconds);
      const manifest = { MPD: { '@mediaPresentationDuration': durationRaw } };
      const url = new URL('http://example.com/video.mpd');

      const video = adapter.parseMpdManifest(url, manifest);

      expect(mockParseIso8601Duration).toHaveBeenCalledWith(durationRaw);
      expect(video).toBeInstanceOf(Video);
      expect(video.length).toEqual(durationInSeconds);
    });
  });

  // Additional tests can be added here for other methods like extractTitle, etc.
});

@dy3c, I've generated a basic structure for unit tests for the MPD parsing functionality in server/services/dash.ts. You can expand upon these tests by adding more cases and assertions as needed.

Analysis chain
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Let's find the file 'dash.ts' to understand the structure and contents related to mpd parsing.
fd dash.ts --exec cat {}

Length of output: 3522

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 176445d and 25d3d90.
Files selected for processing (2)
  • server/services/dash.ts (1 hunks)
  • server/tests/unit/services/dash.spec.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • server/services/dash.ts
Additional comments: 2
server/tests/unit/services/dash.spec.ts (2)
  • 47-54: The test case "should throw UnsupportedVideoType for live streams" is well-structured and correctly tests the expected behavior when live stream manifests are encountered. It's important to ensure that all possible @profiles values that indicate a live stream are covered by this test.

  • 70-82: The test case "should extract a title from ProgramInformation" is concise and tests the specific scenario well. Ensure that the test covers edge cases, such as missing ProgramInformation or Title, to verify that the method handles such scenarios gracefully.

server/tests/unit/services/dash.spec.ts Show resolved Hide resolved
server/tests/unit/services/dash.spec.ts Show resolved Hide resolved
server/tests/unit/services/dash.spec.ts Show resolved Hide resolved
@dyc3 dyc3 merged commit 828ce4f into master Jan 14, 2024
16 of 18 checks passed
@dyc3 dyc3 deleted the dash-support branch January 14, 2024 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Service support: DASH streaming
1 participant