Skip to content

[video_player_platform_interface] Add VideoDrmConfiguration - #13318

Open
nateshmbhat wants to merge 7 commits into
flutter:mainfrom
nateshmbhat:video_player_drm_platform_interface
Open

nateshmbhat wants to merge 7 commits into
flutter:mainfrom
nateshmbhat:video_player_drm_platform_interface

Conversation

@nateshmbhat

@nateshmbhat nateshmbhat commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Platform interface part of #11115 (DRM support for video_player), split out now that the combined PR is approved, per the federated plugin change process. This is the interface code that was reviewed there, plus WidevineDrmConfiguration, which moved here from video_player_android per this request since Widevine isn't Android-only.

Part of flutter/flutter#24923

Summary

 video_player_platform_interface 6.9.0 -> 6.10.0
+@immutable
+abstract class VideoDrmConfiguration {
+  const VideoDrmConfiguration();
+}
+
+@immutable
+class WidevineDrmConfiguration extends VideoDrmConfiguration {
+  const WidevineDrmConfiguration({
+    required this.licenseUri,
+    this.licenseHeaders = const <String, String>{},
+  });
+  final Uri licenseUri;
+  final Map<String, String> licenseHeaders;
+}

 class DataSource {
   ...
   Map<String, String> httpHeaders;
+  final VideoDrmConfiguration? drmConfiguration;  // optional, defaults to null

VideoDrmConfiguration is the common type carried on DataSource. WidevineDrmConfiguration lives here because Widevine can be supported on several platforms (Android today; iOS, Linux, macOS and Windows are possible). Implementations that support it recognize it; others reject it like any unsupported configuration. FairPlay is Apple-only, so FairPlayDrmConfiguration stays in video_player_avfoundation. The implementation changes follow in the next PRs once this is published.

The pending ## NEXT changelog entry (minimum SDK bump) is folded into 6.10.0.

Evidence

Run locally with the CI-pinned Flutter (.ci/flutter_master.version) using the repo's CI task scripts:

Target Result
repo_checks (format, license, README, version, federated safety, publishability) all pass
analyze, including pathified dependents (video_player, _android, _avfoundation, _web) all pass
Dart unit tests, including pathified dependents all pass

New tests in test/drm_configuration_test.dart:

DataSource has no DRM configuration by default      -> drmConfiguration is null
DataSource passes through its DRM configuration     -> same instance returned
WidevineDrmConfiguration has no license headers by default -> licenseHeaders is empty
WidevineDrmConfiguration can be passed on a DataSource     -> licenseUri and licenseHeaders preserved

Merge Danger

Door: two-way

Additive only: two new classes and a new optional, nullable constructor parameter. No existing signature changes.

Blast Radius: minimal

Implementations that ignore drmConfiguration behave exactly as before.

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2

Adds a VideoDrmConfiguration base class and DataSource.drmConfiguration so
platform implementations can accept DRM configuration for network sources.

Split out of flutter#11115 per the federated plugin change process.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces VideoDrmConfiguration and adds a drmConfiguration property to DataSource in the video_player_platform_interface package to support DRM configurations for network sources. The feedback suggests enforcing the restriction that DRM configurations are only supported for network data sources by adding an assertion to the DataSource constructor, along with a corresponding unit test to verify this behavior.

Comment on lines +242 to 243
this.drmConfiguration,
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Since the documentation explicitly states that drmConfiguration is only supported for DataSourceType.network videos, we should enforce this invariant at the platform interface level using an assertion. This ensures consistent behavior across all platform implementations and catches misconfigurations early during development.

Suggested change
this.drmConfiguration,
});
this.drmConfiguration,
}) : assert(
drmConfiguration == null || sourceType == DataSourceType.network,
'DRM configurations are only supported for network data sources.',
);

Comment on lines +32 to +34
expect(dataSource.drmConfiguration, same(configuration));
});
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Add a unit test to verify that constructing a DataSource with a DRM configuration for a non-network source type throws an assertion error, ensuring the new assertion behaves as expected.

Suggested change
expect(dataSource.drmConfiguration, same(configuration));
});
}
expect(dataSource.drmConfiguration, same(configuration));
});
test('DataSource throws assertion error if DRM configuration is provided for non-network source', () {
expect(
() => DataSource(
sourceType: DataSourceType.asset,
asset: 'assets/video.mp4',
drmConfiguration: const _FakeDrmConfiguration(),
),
throwsAssertionError,
);
});
}
References
  1. Code should be tested. Changes to plugin packages should have appropriate tests. (link)

…the platform interface

Widevine is supported on more platforms than Android, so its configuration
now lives alongside VideoDrmConfiguration where any implementation can
recognize it.
nateshmbhat added a commit to nateshmbhat/flutter_packages that referenced this pull request Oct 28, 2026
Widevine is supported on more platforms than Android, so its configuration
now lives in video_player_platform_interface (matching flutter#13318) instead of
video_player_android. video_player re-exports it, so apps no longer need to
depend on video_player_android directly to use Widevine.
@nateshmbhat

Copy link
Copy Markdown
Contributor Author

@tarrinneal have updated the pr as suggested by @loic-sharma

Comment on lines +220 to +223
/// Widevine is not tied to a single platform, so this configuration is shared
/// by every platform implementation that supports it. Implementations that do
/// not support Widevine reject it like any other unsupported
/// [VideoDrmConfiguration].

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Consider normative wording (Implementations that do not support Widevine should reject it...) to match [VideoDrmConfiguration] and [DataSource.drmConfiguration], since un-updated third-party implementations—and video_player_web unless updated in a follow-up PR—will ignore drmConfiguration until updated.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, reworded to "should reject".

Comment on lines +293 to +296
/// Only supported for [DataSourceType.network] videos. Implementations
/// should throw an [ArgumentError] if a configuration is provided for
/// another source type, or if it is a subclass of [VideoDrmConfiguration]
/// that the implementation does not support.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In newer flutter/packages platform interfaces (e.g. path_provider_platform_interface, google_sign_in_platform_interface), unsupported platform capabilities throw [UnsupportedError] while invalid parameter combinations throw [ArgumentError]. Should an unsupported [VideoDrmConfiguration] subclass (or a platform without DRM support, such as video_player_web in the follow-up PRs) throw [UnsupportedError] rather than [ArgumentError]?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Unsupported subclasses now throw UnsupportedError; a DRM config on a non-network source is still an ArgumentError. Android and AVFoundation are updated to match in #11115.

…atform_interface

# Conflicts:
#	packages/video_player/video_player_platform_interface/CHANGELOG.md
…orted DRM systems

Unsupported DRM systems now throw UnsupportedError instead of ArgumentError, matching other platform interfaces. Also uses normative wording for implementations that don't support Widevine.
/// The license exchange itself is performed by the platform implementation,
/// using [licenseUri] and [licenseHeaders].
@immutable
class WidevineDrmConfiguration extends VideoDrmConfiguration {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

note to self: If we get more shared drm configs, we should move them to a new sub directory to keep things organized.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You can do it now if you want, but I won't prevent this from landing over it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, moved both into lib/src/drm/ (exported from the main library).

@tarrinneal tarrinneal added the CICD Run CI/CD label Nov 13, 2026

@tarrinneal tarrinneal left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A couple things. If you feel differently about these, I'm open to hearing it

Comment on lines +213 to +243
@immutable
abstract class VideoDrmConfiguration {
/// Allows subclasses to be const constructed.
const VideoDrmConfiguration();
}

/// Configuration for playing Widevine-protected content.
///
/// Widevine is not tied to a single platform, so this configuration is shared
/// by every platform implementation that supports it. Implementations that do
/// not support Widevine should reject it like any other unsupported
/// [VideoDrmConfiguration].
///
/// The license exchange itself is performed by the platform implementation,
/// using [licenseUri] and [licenseHeaders].
@immutable
class WidevineDrmConfiguration extends VideoDrmConfiguration {
/// Creates a configuration for Widevine playback.
const WidevineDrmConfiguration({
required this.licenseUri,
this.licenseHeaders = const <String, String>{},
});

/// The license acquisition URL of the Widevine license server.
final Uri licenseUri;

/// Headers to attach to each license request sent to [licenseUri].
///
/// This is typically where provider-specific authorization tokens go.
final Map<String, String> licenseHeaders;
}

@tarrinneal tarrinneal Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This class (VideoDrmConfiguration) should probably be abstract base (and WidevineDrmConfiguration) so external code can't implements it, keeping future additive changes non-breaking.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done: VideoDrmConfiguration is now abstract base and WidevineDrmConfiguration is base.

VideoDrmConfiguration is now abstract base and WidevineDrmConfiguration is base, so external code can't implement them and members can be added later without a breaking change. Both move to lib/src/drm/ and are exported from the main library.
@flutter-dashboard flutter-dashboard Bot removed the CICD Run CI/CD label Nov 30, 2026
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.

2 participants