forked from flutter-tizen/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[video_player_videohole] Fix web build (flutter-tizen#602)
- Loading branch information
1 parent
5736eeb
commit b33b193
Showing
5 changed files
with
118 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
## NEXT | ||
## 0.1.2 | ||
|
||
* Increase the minimum Flutter version to 3.3. | ||
* Fix web build | ||
|
||
## 0.1.1 | ||
|
||
|
86 changes: 86 additions & 0 deletions
86
packages/video_player_videohole/lib/src/register_drm_callback_real.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright 2023 Samsung Electronics Co., Ltd. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'dart:ffi'; | ||
import 'dart:isolate'; | ||
|
||
import 'package:flutter/foundation.dart'; | ||
|
||
import 'drm_configs.dart'; | ||
|
||
typedef _InitDartApi = int Function(Pointer<Void>); | ||
typedef _InitDartApiNative = IntPtr Function(Pointer<Void>); | ||
|
||
typedef _RegisterSendPort = void Function(int, int); | ||
typedef _RegisterSendPortNative = Void Function(Int64, Int64); | ||
|
||
class _CppRequest { | ||
_CppRequest.fromList(List<Object?> message) | ||
: replyPort = message[0]! as SendPort, | ||
pendingCall = message[1]! as int, | ||
method = message[2]! as String, | ||
data = message[3]! as Uint8List; | ||
|
||
final SendPort replyPort; | ||
final int pendingCall; | ||
final String method; | ||
final Uint8List data; | ||
} | ||
|
||
class _CppResponse { | ||
_CppResponse(this.pendingCall, this.data); | ||
|
||
final int pendingCall; | ||
final Uint8List data; | ||
|
||
List<Object?> toList() => <Object?>[pendingCall, data]; | ||
} | ||
|
||
/// Registers the DRM callback and communication channel for handling license challenges. | ||
/// | ||
/// This function is used to register the necessary callback and communication channel | ||
/// to handle DRM-related operations and license challenges for the video playback. | ||
/// It establishes communication with native code using DynamicLibrary, and handles | ||
/// incoming requests for license challenges from the platform side. | ||
/// | ||
/// The [drmConfigs] parameter contains configuration details for DRM operations, | ||
/// including a [licenseCallback] function that is responsible for acquiring licenses | ||
/// based on the provided challenges. | ||
/// | ||
/// It is important to call this function within the [initialize] method of the video | ||
/// player to enable DRM capabilities and communicate with the native side properly. | ||
/// | ||
/// Example usage: | ||
/// ```dart | ||
/// registerDrmCallback(licenseCallback, _playerId); | ||
/// ``` | ||
/// | ||
/// Note: This function should not be called directly outside the [initialize] method, | ||
/// and it requires proper configuration and setup of the native C/C++ code to handle | ||
/// DRM operations. | ||
void registerDrmCallback(LicenseCallback licenseCallback, int playerId) { | ||
final DynamicLibrary process = DynamicLibrary.process(); | ||
final _InitDartApi initDartApi = | ||
process.lookupFunction<_InitDartApiNative, _InitDartApi>( | ||
'VideoPlayerTizenPluginInitDartApi'); | ||
initDartApi(NativeApi.initializeApiDLData); | ||
|
||
final ReceivePort receivePort = ReceivePort(); | ||
receivePort.listen((dynamic message) async { | ||
final _CppRequest request = _CppRequest.fromList(message as List<Object?>); | ||
|
||
if (request.method == 'onLicenseChallenge') { | ||
final Uint8List challenge = request.data; | ||
final Uint8List result = await licenseCallback(challenge); | ||
|
||
final _CppResponse response = _CppResponse(request.pendingCall, result); | ||
request.replyPort.send(response.toList()); | ||
} | ||
}); | ||
|
||
final _RegisterSendPort registerSendPort = | ||
process.lookupFunction<_RegisterSendPortNative, _RegisterSendPort>( | ||
'VideoPlayerTizenPluginRegisterSendPort'); | ||
registerSendPort(playerId, receivePort.sendPort.nativePort); | ||
} |
26 changes: 26 additions & 0 deletions
26
packages/video_player_videohole/lib/src/register_drm_callback_stub.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Copyright 2023 Samsung Electronics Co., Ltd. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
import 'drm_configs.dart'; | ||
|
||
/// Register DRM callback function (No-op implementation). | ||
/// | ||
/// This function is a no-op (no-operation) implementation for registering the DRM callback | ||
/// and communication channel to handle license challenges for video playback. It does not | ||
/// perform any actual DRM operations but serves as a placeholder to maintain consistency | ||
/// in the codebase when DRM functionality is not required. | ||
/// | ||
/// This function does not perform any communication with the native side or any DRM-related | ||
/// operations. It can be used when DRM functionality is not required, or when a specific DRM | ||
/// plugin or platform support is not available. | ||
/// | ||
/// Example usage: | ||
/// ```dart | ||
/// registerDrmCallback(drmConfigs, _playerId); | ||
/// ``` | ||
/// | ||
/// Note: This function does not have any DRM functionality and should only be used in cases | ||
/// where DRM support is not necessary or when using a DRM plugin that does not require native | ||
/// communication for license handling. | ||
void registerDrmCallback(LicenseCallback licenseCallback, int playerId) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters