Update includes and BUILD
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
namespace widevine {
|
||||
namespace cas {
|
||||
|
||||
const char kTestEcmgChannelSetup[] = {
|
||||
constexpr char kTestEcmgChannelSetup[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x00', '\x01', // message_type - Channel_setup
|
||||
'\x00', '\x0e', // message_length
|
||||
@@ -26,7 +26,55 @@ const char kTestEcmgChannelSetup[] = {
|
||||
'\x4a', '\xd4', '\x00', '\x00' // parameter_value
|
||||
};
|
||||
|
||||
const char kTestEcmgChannelStatus[] = {
|
||||
constexpr char kTestEcmgChannelSetupWithPrivateParameters[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x00', '\x01', // message_type - Channel_setup
|
||||
'\x00', '\x70', // message_length
|
||||
'\x00', '\x0e', // parameter_type - ECM_channel_id
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x01', // parameter_value
|
||||
'\x00', '\x01', // parameter_type- SUPER_CAS_ID
|
||||
'\x00', '\x04', // parameter_length
|
||||
'\x4a', '\xd4', '\x00', '\x00', // parameter_value
|
||||
'\x80', '\x00', // parameter_type - AGE_RESTRICTION
|
||||
'\x00', '\x01', // parameter_length
|
||||
'\x00', // parameter_value
|
||||
'\x80', '\x01', // parameter_type - CRYPTO_MODE
|
||||
'\x00', '\x07', // parameter_length
|
||||
'A', 'e', 's', 'S', 'c', 't', 'e', // parameter_value
|
||||
'\x80', '\x04', // parameter_type - TRACK_TYPES
|
||||
'\x00', '\x02', // parameter_length
|
||||
'S', 'D', // parameter_value
|
||||
'\x80', '\x04', // parameter_type - TRACK_TYPES
|
||||
'\x00', '\x02', // parameter_length
|
||||
'H', 'D', // parameter_value
|
||||
'\x80', '\x02', // parameter_type - CONTENT_ID
|
||||
'\x00', '\x09', // parameter_length
|
||||
'C', 'a', 's', 'T', 's', 'F', 'a', 'k',
|
||||
'e', // parameter_value - CasTsFake
|
||||
'\x80', '\x03', // parameter_type - CONTENT_PROVIDER
|
||||
'\x00', '\x0d', // parameter_length
|
||||
'w', 'i', 'd', 'e', 'v', 'i', 'n', 'e',
|
||||
'_', 't', 'e', 's', 't', // parameter_value - widevine_test
|
||||
'\x80', '\x06', // parameter_type - CONTENT_IV
|
||||
'\x00', '\x10', // parameter_length
|
||||
'\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07',
|
||||
'\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f',
|
||||
'\x80', '\x06', // parameter_type - CONTENT_IV
|
||||
'\x00', '\x10', // parameter_length
|
||||
'\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17',
|
||||
'\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f'};
|
||||
|
||||
constexpr char kTestEcmgChannelTest[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x00', '\x02', // message_type - Channel_test
|
||||
'\x00', '\x06', // message_length
|
||||
'\x00', '\x0e', // parameter_type - ECM_channel_id
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x01', // parameter_value
|
||||
};
|
||||
|
||||
constexpr char kTestEcmgChannelStatus[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x00', '\x03', // message_type - Channel_status
|
||||
'\x00', '\x39', // message_length
|
||||
@@ -62,7 +110,28 @@ const char kTestEcmgChannelStatus[] = {
|
||||
'\x00', '\x64' // parameter_value
|
||||
};
|
||||
|
||||
const char kTestEcmgStreamSetup[] = {
|
||||
constexpr char kTestEcmgStreamSetupWithPrivateParameters[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x01', '\x01', // message_type - Stream_setup
|
||||
'\x00', '\x1e', // message_length
|
||||
'\x00', '\x0e', // parameter_type - ECM_channel_id
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x01', // parameter_value
|
||||
'\x00', '\x0f', // parameter_type - ECM_stream_id
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x01', // parameter_value
|
||||
'\x00', '\x19', // parameter_type - ECM_id
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x02', // parameter_value
|
||||
'\x00', '\x10', // parameter_type - nominal_CP_duration
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x64', // parameter_value
|
||||
'\x80', '\x05', // parameter_type - STREAM_TRACK_TYPE
|
||||
'\x00', '\x02', // parameter_length
|
||||
'S', 'D', // parameter_value
|
||||
};
|
||||
|
||||
constexpr char kTestEcmgStreamSetup[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x01', '\x01', // message_type - Stream_setup
|
||||
'\x00', '\x18', // message_length
|
||||
@@ -80,7 +149,19 @@ const char kTestEcmgStreamSetup[] = {
|
||||
'\x00', '\x64' // parameter_value
|
||||
};
|
||||
|
||||
const char kTestEcmgStreamStatus[] = {
|
||||
constexpr char kTestEcmgStreamTest[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x01', '\x02', // message_type - Stream_test
|
||||
'\x00', '\x0c', // message_length
|
||||
'\x00', '\x0e', // parameter_type - ECM_channel_id
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x01', // parameter_value
|
||||
'\x00', '\x0f', // parameter_type - ECM_stream_id
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x01', // parameter_value
|
||||
};
|
||||
|
||||
constexpr char kTestEcmgStreamStatus[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x01', '\x03', // message_type - Stream_status
|
||||
'\x00', '\x17', // message_length
|
||||
@@ -98,7 +179,7 @@ const char kTestEcmgStreamStatus[] = {
|
||||
'\x01' // parameter_value
|
||||
};
|
||||
|
||||
const char kTestEcmgCwProvision[] = {
|
||||
constexpr char kTestEcmgCwProvision[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x02', '\x01', // message_type - CW_provision
|
||||
'\x00', '\x44', // message_length
|
||||
@@ -125,8 +206,87 @@ const char kTestEcmgCwProvision[] = {
|
||||
'\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17',
|
||||
'\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f'};
|
||||
|
||||
constexpr char kTestEcmgCwProvisionWithAccessCriteria[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x02', '\x01', // message_type - CW_provision
|
||||
'\x00', '\xaa', // message_length
|
||||
'\x00', '\x0e', // parameter_type - ECM_channel_id
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x01', // parameter_value
|
||||
'\x00', '\x0f', // parameter_type - ECM_stream_id
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x01', // parameter_value
|
||||
'\x00', '\x12', // parameter_type - CP_number
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x00', // parameter_value
|
||||
'\x00', '\x13', // parameter_type - CP_duration
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x64', // parameter_value
|
||||
'\x00', '\x14', // parameter_type - CP_CW_Combination
|
||||
'\x00', '\x12', // parameter_length
|
||||
'\x00', '\x00', // parameter_value - CP (2 bytes) then CW next (16 bytes)
|
||||
'\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07',
|
||||
'\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f',
|
||||
'\x00', '\x14', // parameter_type - CP_CW_Combination
|
||||
'\x00', '\x12', // parameter_length
|
||||
'\x00', '\x01', // parameter_value - CP (2 bytes) then CW next (16 bytes)
|
||||
'\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17',
|
||||
'\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f',
|
||||
'\x00', '\x0d', // parameter_type - access_criteria
|
||||
'\x00', '\x62', // parameter_length
|
||||
'\x80', '\x00', // access_criteria parameter_type - AGE_RESTRICTION
|
||||
'\x00', '\x01', // parameter_length
|
||||
'\x00', // parameter_value
|
||||
'\x80', '\x01', // access_criteria parameter_type - CRYPTO_MODE
|
||||
'\x00', '\x07', // parameter_length
|
||||
'A', 'e', 's', 'S', 'c', 't', 'e', // parameter_value
|
||||
'\x80', '\x04', // access_criteria parameter_type - TRACK_TYPES
|
||||
'\x00', '\x02', // parameter_length
|
||||
'S', 'D', // parameter_value
|
||||
'\x80', '\x05', // access_criteria parameter_type - STREAM_TRACK_TYPE
|
||||
'\x00', '\x02', // parameter_length
|
||||
'S', 'D', // parameter_value
|
||||
'\x80', '\x02', // access_criteria parameter_type - CONTENT_ID
|
||||
'\x00', '\x09', // parameter_length
|
||||
'C', 'a', 's', 'T', 's', 'F', 'a', 'k',
|
||||
'e', // parameter_value - CasTsFake
|
||||
'\x80', '\x03', // access_criteria parameter_type - CONTENT_PROVIDER
|
||||
'\x00', '\x0d', // parameter_length
|
||||
'w', 'i', 'd', 'e', 'v', 'i', 'n', 'e',
|
||||
'_', 't', 'e', 's', 't', // parameter_value - widevine_test
|
||||
'\x80', '\x06', // access_criteria parameter_type - CONTENT_IV
|
||||
'\x00', '\x10', // parameter_length
|
||||
'\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07',
|
||||
'\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f',
|
||||
'\x80', '\x06', // access_criteria parameter_type - CONTENT_IV
|
||||
'\x00', '\x10', // parameter_length
|
||||
'\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17',
|
||||
'\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f'};
|
||||
|
||||
constexpr char kTestEcmgCwProvisionSingleKey[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x02', '\x01', // message_type - CW_provision
|
||||
'\x00', '\x2e', // message_length
|
||||
'\x00', '\x0e', // parameter_type - ECM_channel_id
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x01', // parameter_value
|
||||
'\x00', '\x0f', // parameter_type - ECM_stream_id
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x01', // parameter_value
|
||||
'\x00', '\x12', // parameter_type - CP_number
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x00', // parameter_value
|
||||
'\x00', '\x13', // parameter_type - CP_duration
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x64', // parameter_value
|
||||
'\x00', '\x14', // parameter_type - CP_CW_Combination
|
||||
'\x00', '\x12', // parameter_length
|
||||
'\x00', '\x00', // parameter_value - CP (2 bytes) then CW next (16 bytes)
|
||||
'\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07',
|
||||
'\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f'};
|
||||
|
||||
// CW is encrypted using hardcoded fixed entitlement key.
|
||||
const char kTestEcmgEcmResponse[] = {
|
||||
constexpr char kTestEcmgEcmResponse[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x02', '\x02', // message_type - ECM_response
|
||||
'\x00', '\xd2', // message_length
|
||||
@@ -142,8 +302,8 @@ const char kTestEcmgEcmResponse[] = {
|
||||
'\x00', '\x15', // parameter_type - ECM_datagram
|
||||
'\x00', '\xbc', // parameter_length
|
||||
// parameter_value - ECM_datagram
|
||||
'\x47', '\x40', '\x02', '\x10', '\x00', '\x80', '\x70', '\x95', '\x4a',
|
||||
'\xd4', '\x01', '\x05', '\x80', '\x66', '\x61', '\x6b', '\x65', '\x5f',
|
||||
'\x47', '\x40', '\x00', '\x10', '\x00', '\x80', '\x70', '\xa5', '\x4a',
|
||||
'\xd4', '\x02', '\x0b', '\xc0', '\x66', '\x61', '\x6b', '\x65', '\x5f',
|
||||
'\x6b', '\x65', '\x79', '\x5f', '\x69', '\x64', '\x31', '\x2e', '\x2e',
|
||||
'\x2e', '\x2e', '\xef', '\x40', '\x57', '\x48', '\xa7', '\xad', '\xdd',
|
||||
'\x34', '\x73', '\xfe', '\x5d', '\x1c', '\x65', '\xa0', '\xbf', '\x93',
|
||||
@@ -164,7 +324,7 @@ const char kTestEcmgEcmResponse[] = {
|
||||
'\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff',
|
||||
'\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff', '\xff'};
|
||||
|
||||
const char kTestEcmgStreamCloseRequest[] = {
|
||||
constexpr char kTestEcmgStreamClose[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x01', '\x04', // message_type - Stream_close_request
|
||||
'\x00', '\x0c', // message_length
|
||||
@@ -176,7 +336,7 @@ const char kTestEcmgStreamCloseRequest[] = {
|
||||
'\x00', '\x01' // parameter_value
|
||||
};
|
||||
|
||||
const char kTestEcmgStreamCloseResponse[] = {
|
||||
constexpr char kTestEcmgStreamCloseResponse[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x01', '\x05', // message_type - Stream_close_response
|
||||
'\x00', '\x0c', // message_length
|
||||
@@ -188,7 +348,7 @@ const char kTestEcmgStreamCloseResponse[] = {
|
||||
'\x00', '\x01' // parameter_value
|
||||
};
|
||||
|
||||
const char kTestEcmgChannelClose[] = {
|
||||
constexpr char kTestEcmgChannelClose[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x00', '\x04', // message_type - Channel_close
|
||||
'\x00', '\x06', // message_length
|
||||
@@ -197,6 +357,57 @@ const char kTestEcmgChannelClose[] = {
|
||||
'\x00', '\x01' // parameter_value
|
||||
};
|
||||
|
||||
constexpr char kTestChannelErrorResponse[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x00', '\x05', // message_type - Channel_error_response
|
||||
'\x00', '\x0c', // message_length
|
||||
'\x00', '\x0e', // parameter_type - ECM_channel_id
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x01', // parameter_value
|
||||
'\x70', '\x00', // parameter_type - error_status
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x00' // parameter_value: actual value varies.
|
||||
};
|
||||
|
||||
constexpr char kTestStreamErrorResponse[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x01', '\x06', // message_type - Stream_error_response
|
||||
'\x00', '\x12', // message_length
|
||||
'\x00', '\x0e', // parameter_type - ECM_channel_id
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x01', // parameter_value
|
||||
'\x00', '\x0f', // parameter_type - ECM_stream_id
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x01', // parameter_value
|
||||
'\x70', '\x00', // parameter_type - error_status
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x00' // parameter_value: actual value varies.
|
||||
};
|
||||
|
||||
constexpr char kTestEcmgChannelSetupWrongParameterLength[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x00', '\x01', // message_type - Channel_setup
|
||||
'\x00', '\x0e', // message_length
|
||||
'\x00', '\x0e', // parameter_type - ECM_channel_id
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x01', // parameter_value
|
||||
'\x00', '\x01', // parameter_type- SUPER_CAS_ID
|
||||
'\x00', '\x02', // parameter_length -- Should be \x04
|
||||
'\x4a', '\xd4', '\x00', '\x00' // parameter_value
|
||||
};
|
||||
|
||||
constexpr char kTestEcmgChannelSetupWrongMessageLength[] = {
|
||||
'\x03', // protocol_version
|
||||
'\x00', '\x01', // message_type - Channel_setup
|
||||
'\x00', '\xee', // message_length -- Should be \x0e
|
||||
'\x00', '\x0e', // parameter_type - ECM_channel_id
|
||||
'\x00', '\x02', // parameter_length
|
||||
'\x00', '\x01', // parameter_value
|
||||
'\x00', '\x01', // parameter_type- SUPER_CAS_ID
|
||||
'\x00', '\x04', // parameter_length -- Should be \x04
|
||||
'\x4a', '\xd4', '\x00', '\x00' // parameter_value
|
||||
};
|
||||
|
||||
} // namespace cas
|
||||
} // namespace widevine
|
||||
|
||||
|
||||
Binary file not shown.
@@ -8,11 +8,15 @@
|
||||
|
||||
// Example of how to use the wv_cas_ecm library.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <cassert>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include <cstdint>
|
||||
#include "media_cas_packager_sdk/public/wv_cas_ecm.h"
|
||||
#include "media_cas_packager_sdk/public/wv_cas_types.h"
|
||||
|
||||
@@ -96,11 +100,11 @@ int main(int argc, char** argv) {
|
||||
std::cout << std::endl;
|
||||
}
|
||||
// Write ECM TS Packet to a file.
|
||||
std::ofstream file;
|
||||
file.open(kOutputFile, std::ios_base::binary);
|
||||
assert(file.is_open());
|
||||
file.write(reinterpret_cast<char *>(packet), kTsPacketSize);
|
||||
file.close();
|
||||
std::ofstream file;
|
||||
file.open(kOutputFile, std::ios_base::binary);
|
||||
assert(file.is_open());
|
||||
file.write(reinterpret_cast<char*>(packet), kTsPacketSize);
|
||||
file.close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -7,36 +7,39 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "gflags/gflags.h"
|
||||
#include "glog/logging.h"
|
||||
#include "absl/flags/flag.h"
|
||||
#include "absl/flags/parse.h"
|
||||
#include "common/status.h"
|
||||
#include "media_cas_packager_sdk/public/wv_cas_key_fetcher.h"
|
||||
#include "protos/public/media_cas_encryption.pb.h"
|
||||
|
||||
DEFINE_string(content_id, "21140844", "Content ID");
|
||||
DEFINE_bool(key_rotation, true, "Whether key rotation is enabled");
|
||||
DEFINE_string(track_type, "SD", "Provider name");
|
||||
ABSL_FLAG(std::string, content_id, "21140844", "Content ID");
|
||||
ABSL_FLAG(bool, key_rotation, true, "Whether key rotation is enabled");
|
||||
ABSL_FLAG(std::string, track_type, "SD", "Provider name");
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
gflags::ParseCommandLineFlags(&argc, &argv, true);
|
||||
CHECK(!FLAGS_content_id.empty() && !FLAGS_track_type.empty())
|
||||
absl::ParseCommandLine(argc, argv);
|
||||
CHECK(!absl::GetFlag(FLAGS_content_id).empty() &&
|
||||
!absl::GetFlag(FLAGS_track_type).empty())
|
||||
<< "Flags 'content_id' and 'track_type' are required";
|
||||
// Required flags in key fetcher.
|
||||
CHECK(!FLAGS_license_server.empty() && !FLAGS_signing_provider.empty() &&
|
||||
!FLAGS_signing_key.empty() && !FLAGS_signing_iv.empty())
|
||||
CHECK(!absl::GetFlag(FLAGS_license_server).empty() &&
|
||||
!absl::GetFlag(FLAGS_signing_provider).empty() &&
|
||||
!absl::GetFlag(FLAGS_signing_key).empty() &&
|
||||
!absl::GetFlag(FLAGS_signing_iv).empty())
|
||||
<< "Flags 'license_server', 'signing_provider', 'signing_key' "
|
||||
"and 'signing_iv' are required";
|
||||
|
||||
std::string request_str;
|
||||
widevine::CasEncryptionRequest request;
|
||||
request.set_provider(FLAGS_signing_provider);
|
||||
request.set_content_id(FLAGS_content_id);
|
||||
request.set_key_rotation(FLAGS_key_rotation);
|
||||
request.set_provider(absl::GetFlag(FLAGS_signing_provider));
|
||||
request.set_content_id(absl::GetFlag(FLAGS_content_id));
|
||||
request.set_key_rotation(absl::GetFlag(FLAGS_key_rotation));
|
||||
// Only 1 track in this example.
|
||||
request.add_track_types(FLAGS_track_type);
|
||||
request.add_track_types(absl::GetFlag(FLAGS_track_type));
|
||||
LOG(INFO) << "Request: " << request.ShortDebugString();
|
||||
if (!request.SerializeToString(&request_str)) {
|
||||
LOG(ERROR) << "Failed to serialize request";
|
||||
|
||||
Binary file not shown.
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "media_cas_packager_sdk/public/wv_cas_types.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user