https://github.com/doverunner/gcp-live-stream-sample
DRM Packaging Sample for GCP Live Stream API Integration
https://github.com/doverunner/gcp-live-stream-sample
Last synced: 4 months ago
JSON representation
DRM Packaging Sample for GCP Live Stream API Integration
- Host: GitHub
- URL: https://github.com/doverunner/gcp-live-stream-sample
- Owner: doverunner
- Created: 2023-05-18T08:42:49.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2026-01-15T01:53:35.000Z (5 months ago)
- Last Synced: 2026-01-15T07:59:31.962Z (5 months ago)
- Language: C#
- Homepage: https://doverunner.com/
- Size: 81.9 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
---------------------------------------
# Google Cloud Live Stream API & DoveRunner DRM Integration Sample
This sample shows how to integrate DoveRunner Multi DRM with Google Cloud Live Stream API v1 using [API Client Libraries](https://cloud.google.com/livestream/docs/reference/libraries). Since this sample focused on DRM integration, only a simple scenario of applying Widevine, PlayReady, and FairPlay DRM to a live stream in fmp4 format is used, see the [references link](https://cloud.google.com/dotnet/docs/reference/Google.Cloud.Video.LiveStream.V1/latest) for more information about Live Stream API v1 features.
---------------------------------------
## Prerequisites
- A Windows 10/11 PC
- Visual Studio 2022 (Windows 10/11)
- .NET 6.0 SDK : https://dotnet.microsoft.com/download
- Google Cloud account : https://cloud.google.com/
- Create a project : https://cloud.google.com/resource-manager/docs/creating-managing-projects
- Create a bucket : https://cloud.google.com/storage/docs/creating-buckets
- Google Application Default Credentials (ADC) : https://cloud.google.com/docs/authentication/provide-credentials-adc
- Identity and Access Management (IAM)
- roles/livestream.editor
- roles/storage.admin
- roles/secretmanager.admin
- roles/secretmanager.secretAccessor
- This role should be granted to the service account, not the user, as it is the permission to access Google Secret from the service API.
- https://cloud.google.com/livestream/docs/access-control#access_to_gcs
- {enc-token} used for CPIX API communication with DoveRunner KMS. This is an API authentication token that is generated when you sign up DoveRunner service, and can be found on the DoveRunner Console site.
- Encoder to generate the input stream that the API processes.
- In this sample, [ffmpeg](https://ffmpeg.org/download.html) is used.
---------------------------------------
## How to launch the project and test
1. Clone or download this sample repository.
2. Open the root /DoveRunnerGoogleLiveStreamSample.sln and select the active project to launch in Visual Studio.
3. Make sure you have your Google Cloud project, bucket information and DoveRunner KMS related information.
4. Set the values of the variables at the top of the main method.
5. Run the project.
6. Copy the `` that is printed to the console.
7. When the streamingState is `AwaitingInput` and you see the output saying `the channel is ready`, send a live stream to the input endpoint as shown below.
```shell
$ ffmpeg -re -f lavfi -i "testsrc=size=1280x720 [out0]; sine=frequency=500 [out1]" \
-acodec aac -vcodec h264 -f flv
```
8. Check out your packaging results on the Buckets page in Google Cloud console.
---------------------------------------
## DoveRunnerCpixClientWrapper
C++/CLI project for wrap a C++ library(*DoveRunnerCpixClient.lib*) to communicate with DoveRunner KMS server.
The _GetContentKeyInfoFromDoveRunnerKMS_ function allows you to obtain packaging information from the KMS server.
```c#
ContentPackagingInfo DoveRunner::CpixClientWrapper::GetContentKeyInfoFromDoveRunnerKMS(String^ cid, DrmType drmType, EncryptionScheme encryptionScheme, TrackType trackType, long periodIndex)
{
ContentPackagingInfo packInfos;
try {
doverunner::ContentPackagingInfo contentPackInfo = _cpixClient->GetContentKeyInfoFromDoveRunnerKMS(msclr::interop::marshal_as(cid), static_cast(drmType), static_cast(encryptionScheme), static_cast(trackType), periodIndex);
packInfos.ContentId = gcnew String(contentPackInfo.contentId.c_str());
packInfos.DrmInfos = gcnew List;
for (auto multiDrmInfo : contentPackInfo.multiDrmInfos)
{
...
packInfos.DrmInfos->Add(drmInfo);
}
}
catch (doverunner::CpixClientException& e)
{
std::string errMsg = "An error has occurred in the CPIX Client module : \n";
errMsg.append(e.what());
throw gcnew Exception(gcnew String(errMsg.c_str()));
}
catch (std::exception& e)
{
throw gcnew Exception(gcnew String(e.what()));
}
return packInfos;
}
```
---------------------------------------
## References
- https://docs.doverunner.com/content-security/multi-drm/
- https://docs.doverunner.com/content-security/multi-drm/packaging/cpix-api/
- https://cloud.google.com/livestream/docs/reference/libraries
- https://cloud.google.com/secret-manager/docs/reference/libraries#client-libraries-install-csharp
- https://cloud.google.com/livestream/docs/reference/drm#string
---------------------------------------