Skip to content

DRM Packaging Sample for GCP Live Stream API Integration

Notifications You must be signed in to change notification settings

inka-pallycon/pallycon-gcp-live-steam-sample

Repository files navigation


Google Cloud Live Stream API & PallyCon DRM Integration Sample

This sample shows how to integrate PallyCon Multi DRM with Google Cloud Live Stream API v1 using API Client 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 for more information about Live Stream API v1 features.


Prerequisites


How to launch the project and test

  1. Clone or download this sample repository.

  2. Open the root /PallyConGoogleLiveStreamSample.sln and select the active project to launch in Visual Studio.

  3. Make sure you have your Google Cloud project, bucket information and PallyCon KMS related information.

  4. Set the values of the variables at the top of the main method.

  5. Run the project.

  6. Copy the <RTMP input endpoint uri> 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.

    $ ffmpeg -re -f lavfi -i "testsrc=size=1280x720 [out0]; sine=frequency=500 [out1]" \
      -acodec aac -vcodec h264 -f flv <RTMP input endpoint uri>
  8. Check out your packaging results on the Buckets page in Google Cloud console.


PallyConKMSClientWrapper

C++/CLI project for wrap a C++ library(PallyConKmsClient_MD.lib) to communicate with PallyCon KMS server. The getPackagingInfoFromKmsServer function allows you to obtain packaging information from the KMS server.

bool PallyConKmsClientWrapper::getPackagingInfoFromKmsServer(String^ content_id, String^% key_id, String^% key, String^% iv, String^% hls_key_uri, String^% widevine_pssh, String^% playready_pssh)
{
	try
	{
		ContentPackagingInfo packInfos = _kmsClient->getContentPackagingInfoFromKmsServer(
			msclr::interop::marshal_as<std::string>(content_id), "", PackType::DASH | PackType::HLS);
		key_id = gcnew String(packInfos.keyId.c_str());
		key = gcnew String(packInfos.key.c_str());
		iv = gcnew String(packInfos.iv.c_str());
		hls_key_uri = gcnew String(packInfos.hlsKeyUri.c_str());
		widevine_pssh = gcnew String(packInfos.pssh_widevine.c_str());
		playready_pssh = gcnew String(packInfos.pssh_playready.c_str());
	}
	catch (std::exception& e)
	{
		std::cout << e.what();
	}

	return true;
}

References