oneofftech/k-link-streaming-upload-client

上传视频到K-Link流媒体服务

dev-master / 0.4.x-dev 2021-06-04 19:11 UTC

This package is auto-updated.

Last update: 2024-09-05 02:43:47 UTC


README

通过API联系K-Link视频流媒体服务。

在Alpine Linux上不可用,因为它需要一个为Alpine编译的执行文件。

入门

安装

使用以下命令安装包:

composer require php-http/guzzle6-adapter guzzlehttp/psr7 oneofftech/k-link-streaming-upload-client

为什么需要这么多包?

K-Link流媒体上传客户端依赖于虚拟包php-http/client-implementation,这要求您安装一个适配器,但我们并不关心是哪一个。这是您应用程序中的一个实现细节。我们还需要一个PSR-7实现和一个消息工厂。

如果您不想使用php-http/guzzle6-adapter,也可以使用。您可以使用php-http/curl-client。有关虚拟包的更多信息,为什么这是一个好主意以及它带来的灵活性,请参阅HTTPlug文档

安装后/更新后/要求后

流媒体服务客户端依赖于Tus Cli,它不包括在这个存储库中,以保持大小在合理范围内。由于各种原因,Composer不会执行必需包的post-install脚本,因此需要手动运行。

您可以通过bash/shell来完成此操作:

composer run-script post-install-cmd -d ./vendor/oneofftech/k-link-streaming-upload-client

或从定义在composer.json中的post-install-cmd/post-update-cmd脚本中调用该脚本。

"scripts": {
    "post-install-cmd": "@composer run-script post-install-cmd -d ./vendor/oneofftech/k-link-streaming-upload-client",
    "post-update-cmd": "@composer run-script post-install-cmd -d ./vendor/oneofftech/k-link-streaming-upload-client"
}

用法

客户端需要在K-Registry上注册的应用程序,因为流媒体服务将验证该应用程序是否有上传视频的权限。

use Oneofftech\KlinkStreaming\Client;

$streaming_service_url = 'https://streaming.test.klink.asia/';
$application_token = 'Application Token';
$application_url = 'https://myapp.local/';

$client = new Client($streaming_service_url, $application_token, $application_url);

$client->upload($file);

文档

目前还没有完整的文档,对于用法示例,您可能需要查看集成测试

测试

使用PHPUnit自动进行代码测试。

有3个测试套件

  • 单元:在隔离状态下测试类
  • 功能:使用模拟响应测试客户端类的功能
  • 集成:使用真实的K-Link视频流媒体服务测试功能

可以使用以下命令执行测试:

vendor/bin/phpunit

执行集成测试

集成测试需要设置环境变量VIDEO_STREAMING_SERVICE_URL为运行中的K-Link视频流媒体服务的URL。

如果留空VIDEO_STREAMING_SERVICE_URL变量,将导致集成测试被跳过。已提供的phpunit.xml.dist中已包含该变量,您只需将phpunit.xml.dist复制到phpunit.xml并执行即可。

贡献

感谢您考虑为K-Link流媒体服务PHP客户端做出贡献!贡献指南尚未提供,但在此期间,您仍然可以提交Pull Requests。

许可

本项目遵循 MIT 许可协议