DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
widevine_key_source.cc
1 // Copyright 2014 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #include "packager/media/base/widevine_key_source.h"
8 
9 #include <set>
10 
11 #include "packager/base/base64.h"
12 #include "packager/base/bind.h"
13 #include "packager/base/json/json_reader.h"
14 #include "packager/base/json/json_writer.h"
15 #include "packager/base/memory/ref_counted.h"
16 #include "packager/base/stl_util.h"
17 #include "packager/media/base/fixed_key_source.h"
18 #include "packager/media/base/http_key_fetcher.h"
19 #include "packager/media/base/producer_consumer_queue.h"
20 #include "packager/media/base/protection_system_specific_info.h"
21 #include "packager/media/base/rcheck.h"
22 #include "packager/media/base/request_signer.h"
23 #include "packager/media/base/widevine_pssh_data.pb.h"
24 
25 namespace shaka {
26 namespace {
27 
28 const bool kEnableKeyRotation = true;
29 
30 const char kLicenseStatusOK[] = "OK";
31 // Server may return INTERNAL_ERROR intermittently, which is a transient error
32 // and the next client request may succeed without problem.
33 const char kLicenseStatusTransientError[] = "INTERNAL_ERROR";
34 
35 // Number of times to retry requesting keys in case of a transient error from
36 // the server.
37 const int kNumTransientErrorRetries = 5;
38 const int kFirstRetryDelayMilliseconds = 1000;
39 
40 // Default crypto period count, which is the number of keys to fetch on every
41 // key rotation enabled request.
42 const int kDefaultCryptoPeriodCount = 10;
43 const int kGetKeyTimeoutInSeconds = 5 * 60; // 5 minutes.
44 const int kKeyFetchTimeoutInSeconds = 60; // 1 minute.
45 
46 bool Base64StringToBytes(const std::string& base64_string,
47  std::vector<uint8_t>* bytes) {
48  DCHECK(bytes);
49  std::string str;
50  if (!base::Base64Decode(base64_string, &str))
51  return false;
52  bytes->assign(str.begin(), str.end());
53  return true;
54 }
55 
56 void BytesToBase64String(const std::vector<uint8_t>& bytes,
57  std::string* base64_string) {
58  DCHECK(base64_string);
59  base::Base64Encode(base::StringPiece(reinterpret_cast<const char*>
60  (bytes.data()), bytes.size()),
61  base64_string);
62 }
63 
64 bool GetKeyFromTrack(const base::DictionaryValue& track_dict,
65  std::vector<uint8_t>* key) {
66  DCHECK(key);
67  std::string key_base64_string;
68  RCHECK(track_dict.GetString("key", &key_base64_string));
69  VLOG(2) << "Key:" << key_base64_string;
70  RCHECK(Base64StringToBytes(key_base64_string, key));
71  return true;
72 }
73 
74 bool GetKeyIdFromTrack(const base::DictionaryValue& track_dict,
75  std::vector<uint8_t>* key_id) {
76  DCHECK(key_id);
77  std::string key_id_base64_string;
78  RCHECK(track_dict.GetString("key_id", &key_id_base64_string));
79  VLOG(2) << "Keyid:" << key_id_base64_string;
80  RCHECK(Base64StringToBytes(key_id_base64_string, key_id));
81  return true;
82 }
83 
84 bool GetPsshDataFromTrack(const base::DictionaryValue& track_dict,
85  std::vector<uint8_t>* pssh_data) {
86  DCHECK(pssh_data);
87 
88  const base::ListValue* pssh_list;
89  RCHECK(track_dict.GetList("pssh", &pssh_list));
90  // Invariant check. We don't want to crash in release mode if possible.
91  // The following code handles it gracefully if GetSize() does not return 1.
92  DCHECK_EQ(1u, pssh_list->GetSize());
93 
94  const base::DictionaryValue* pssh_dict;
95  RCHECK(pssh_list->GetDictionary(0, &pssh_dict));
96  std::string drm_type;
97  RCHECK(pssh_dict->GetString("drm_type", &drm_type));
98  if (drm_type != "WIDEVINE") {
99  LOG(ERROR) << "Expecting drm_type 'WIDEVINE', get '" << drm_type << "'.";
100  return false;
101  }
102  std::string pssh_data_base64_string;
103  RCHECK(pssh_dict->GetString("data", &pssh_data_base64_string));
104 
105  VLOG(2) << "Pssh Data:" << pssh_data_base64_string;
106  RCHECK(Base64StringToBytes(pssh_data_base64_string, pssh_data));
107  return true;
108 }
109 
110 } // namespace
111 
112 namespace media {
113 
114 // A ref counted wrapper for EncryptionKeyMap.
115 class WidevineKeySource::RefCountedEncryptionKeyMap
116  : public base::RefCountedThreadSafe<RefCountedEncryptionKeyMap> {
117  public:
118  explicit RefCountedEncryptionKeyMap(EncryptionKeyMap* encryption_key_map) {
119  DCHECK(encryption_key_map);
120  encryption_key_map_.swap(*encryption_key_map);
121  }
122 
123  std::map<KeySource::TrackType, EncryptionKey*>& map() {
124  return encryption_key_map_;
125  }
126 
127  private:
128  friend class base::RefCountedThreadSafe<RefCountedEncryptionKeyMap>;
129 
130  ~RefCountedEncryptionKeyMap() { STLDeleteValues(&encryption_key_map_); }
131 
132  EncryptionKeyMap encryption_key_map_;
133 
134  DISALLOW_COPY_AND_ASSIGN(RefCountedEncryptionKeyMap);
135 };
136 
137 WidevineKeySource::WidevineKeySource(const std::string& server_url,
138  bool add_common_pssh)
139  : key_production_thread_("KeyProductionThread",
140  base::Bind(&WidevineKeySource::FetchKeysTask,
141  base::Unretained(this))),
142  key_fetcher_(new HttpKeyFetcher(kKeyFetchTimeoutInSeconds)),
143  server_url_(server_url),
144  crypto_period_count_(kDefaultCryptoPeriodCount),
145  add_common_pssh_(add_common_pssh),
146  key_production_started_(false),
147  start_key_production_(false, false),
148  first_crypto_period_index_(0) {
149  key_production_thread_.Start();
150 }
151 
152 WidevineKeySource::~WidevineKeySource() {
153  if (key_pool_)
154  key_pool_->Stop();
155  if (key_production_thread_.HasBeenStarted()) {
156  // Signal the production thread to start key production if it is not
157  // signaled yet so the thread can be joined.
158  start_key_production_.Signal();
159  key_production_thread_.Join();
160  }
161  STLDeleteValues(&encryption_key_map_);
162 }
163 
164 Status WidevineKeySource::FetchKeys(const std::vector<uint8_t>& content_id,
165  const std::string& policy) {
166  base::AutoLock scoped_lock(lock_);
167  request_dict_.Clear();
168  std::string content_id_base64_string;
169  BytesToBase64String(content_id, &content_id_base64_string);
170  request_dict_.SetString("content_id", content_id_base64_string);
171  request_dict_.SetString("policy", policy);
172  return FetchKeysInternal(!kEnableKeyRotation, 0, false);
173 }
174 
175 Status WidevineKeySource::FetchKeys(const std::vector<uint8_t>& pssh_box) {
176  const std::vector<uint8_t> widevine_system_id(
177  kWidevineSystemId, kWidevineSystemId + arraysize(kWidevineSystemId));
178 
180  if (!info.Parse(pssh_box.data(), pssh_box.size()))
181  return Status(error::PARSER_FAILURE, "Error parsing the PSSH box.");
182 
183  if (info.system_id() == widevine_system_id) {
184  base::AutoLock scoped_lock(lock_);
185  request_dict_.Clear();
186  std::string pssh_data_base64_string;
187 
188  BytesToBase64String(info.pssh_data(), &pssh_data_base64_string);
189  request_dict_.SetString("pssh_data", pssh_data_base64_string);
190  return FetchKeysInternal(!kEnableKeyRotation, 0, false);
191  } else if (!info.key_ids().empty()) {
192  // This is not a Widevine PSSH box. Try making the request for the key-IDs.
193  // Even if this is a different key-system, it should still work. Either
194  // the server will not recognize it and return an error, or it will
195  // recognize it and the key must be correct (or the content is bad).
196  return FetchKeys(info.key_ids());
197  } else {
198  return Status(error::NOT_FOUND, "No key IDs given in PSSH box.");
199  }
200 }
201 
203  const std::vector<std::vector<uint8_t>>& key_ids) {
204  base::AutoLock scoped_lock(lock_);
205  request_dict_.Clear();
206  std::string pssh_data_base64_string;
207 
208  // Generate Widevine PSSH data from the key-IDs.
209  WidevinePsshData widevine_pssh_data;
210  for (size_t i = 0; i < key_ids.size(); i++) {
211  widevine_pssh_data.add_key_id(key_ids[i].data(), key_ids[i].size());
212  }
213 
214  const std::string serialized_string = widevine_pssh_data.SerializeAsString();
215  std::vector<uint8_t> pssh_data(serialized_string.begin(),
216  serialized_string.end());
217 
218  BytesToBase64String(pssh_data, &pssh_data_base64_string);
219  request_dict_.SetString("pssh_data", pssh_data_base64_string);
220  return FetchKeysInternal(!kEnableKeyRotation, 0, false);
221 }
222 
224  base::AutoLock scoped_lock(lock_);
225  request_dict_.Clear();
226  // Javascript/JSON does not support int64_t or unsigned numbers. Use double
227  // instead as 32-bit integer can be lossless represented using double.
228  request_dict_.SetDouble("asset_id", asset_id);
229  return FetchKeysInternal(!kEnableKeyRotation, 0, true);
230 }
231 
232 Status WidevineKeySource::GetKey(TrackType track_type, EncryptionKey* key) {
233  DCHECK(key);
234  if (encryption_key_map_.find(track_type) == encryption_key_map_.end()) {
235  return Status(error::INTERNAL_ERROR,
236  "Cannot find key of type " + TrackTypeToString(track_type));
237  }
238  *key = *encryption_key_map_[track_type];
239  return Status::OK;
240 }
241 
242 Status WidevineKeySource::GetKey(const std::vector<uint8_t>& key_id,
243  EncryptionKey* key) {
244  DCHECK(key);
245  for (std::map<TrackType, EncryptionKey*>::iterator iter =
246  encryption_key_map_.begin();
247  iter != encryption_key_map_.end();
248  ++iter) {
249  if (iter->second->key_id == key_id) {
250  *key = *iter->second;
251  return Status::OK;
252  }
253  }
254  return Status(error::INTERNAL_ERROR,
255  "Cannot find key with specified key ID");
256 }
257 
258 Status WidevineKeySource::GetCryptoPeriodKey(uint32_t crypto_period_index,
259  TrackType track_type,
260  EncryptionKey* key) {
261  DCHECK(key_production_thread_.HasBeenStarted());
262  // TODO(kqyang): This is not elegant. Consider refactoring later.
263  {
264  base::AutoLock scoped_lock(lock_);
265  if (!key_production_started_) {
266  // Another client may have a slightly smaller starting crypto period
267  // index. Set the initial value to account for that.
268  first_crypto_period_index_ =
269  crypto_period_index ? crypto_period_index - 1 : 0;
270  DCHECK(!key_pool_);
271  key_pool_.reset(new EncryptionKeyQueue(crypto_period_count_,
272  first_crypto_period_index_));
273  start_key_production_.Signal();
274  key_production_started_ = true;
275  }
276  }
277  return GetKeyInternal(crypto_period_index, track_type, key);
278 }
279 
280 void WidevineKeySource::set_signer(scoped_ptr<RequestSigner> signer) {
281  signer_ = signer.Pass();
282 }
283 
284 void WidevineKeySource::set_key_fetcher(scoped_ptr<KeyFetcher> key_fetcher) {
285  key_fetcher_ = key_fetcher.Pass();
286 }
287 
288 Status WidevineKeySource::GetKeyInternal(uint32_t crypto_period_index,
289  TrackType track_type,
290  EncryptionKey* key) {
291  DCHECK(key_pool_);
292  DCHECK(key);
293  DCHECK_LE(track_type, NUM_VALID_TRACK_TYPES);
294  DCHECK_NE(track_type, TRACK_TYPE_UNKNOWN);
295 
296  scoped_refptr<RefCountedEncryptionKeyMap> ref_counted_encryption_key_map;
297  Status status =
298  key_pool_->Peek(crypto_period_index, &ref_counted_encryption_key_map,
299  kGetKeyTimeoutInSeconds * 1000);
300  if (!status.ok()) {
301  if (status.error_code() == error::STOPPED) {
302  CHECK(!common_encryption_request_status_.ok());
303  return common_encryption_request_status_;
304  }
305  return status;
306  }
307 
308  EncryptionKeyMap& encryption_key_map = ref_counted_encryption_key_map->map();
309  if (encryption_key_map.find(track_type) == encryption_key_map.end()) {
310  return Status(error::INTERNAL_ERROR,
311  "Cannot find key of type " + TrackTypeToString(track_type));
312  }
313  *key = *encryption_key_map[track_type];
314  return Status::OK;
315 }
316 
317 void WidevineKeySource::FetchKeysTask() {
318  // Wait until key production is signaled.
319  start_key_production_.Wait();
320  if (!key_pool_ || key_pool_->Stopped())
321  return;
322 
323  Status status = FetchKeysInternal(kEnableKeyRotation,
324  first_crypto_period_index_,
325  false);
326  while (status.ok()) {
327  first_crypto_period_index_ += crypto_period_count_;
328  status = FetchKeysInternal(kEnableKeyRotation,
329  first_crypto_period_index_,
330  false);
331  }
332  common_encryption_request_status_ = status;
333  key_pool_->Stop();
334 }
335 
336 Status WidevineKeySource::FetchKeysInternal(bool enable_key_rotation,
337  uint32_t first_crypto_period_index,
338  bool widevine_classic) {
339  std::string request;
340  FillRequest(enable_key_rotation,
341  first_crypto_period_index,
342  &request);
343 
344  std::string message;
345  Status status = GenerateKeyMessage(request, &message);
346  if (!status.ok())
347  return status;
348  VLOG(1) << "Message: " << message;
349 
350  std::string raw_response;
351  int64_t sleep_duration = kFirstRetryDelayMilliseconds;
352 
353  // Perform client side retries if seeing server transient error to workaround
354  // server limitation.
355  for (int i = 0; i < kNumTransientErrorRetries; ++i) {
356  status = key_fetcher_->FetchKeys(server_url_, message, &raw_response);
357  if (status.ok()) {
358  VLOG(1) << "Retry [" << i << "] Response:" << raw_response;
359 
360  std::string response;
361  if (!DecodeResponse(raw_response, &response)) {
362  return Status(error::SERVER_ERROR,
363  "Failed to decode response '" + raw_response + "'.");
364  }
365 
366  bool transient_error = false;
367  if (ExtractEncryptionKey(enable_key_rotation,
368  widevine_classic,
369  response,
370  &transient_error))
371  return Status::OK;
372 
373  if (!transient_error) {
374  return Status(
375  error::SERVER_ERROR,
376  "Failed to extract encryption key from '" + response + "'.");
377  }
378  } else if (status.error_code() != error::TIME_OUT) {
379  return status;
380  }
381 
382  // Exponential backoff.
383  if (i != kNumTransientErrorRetries - 1) {
384  base::PlatformThread::Sleep(
385  base::TimeDelta::FromMilliseconds(sleep_duration));
386  sleep_duration *= 2;
387  }
388  }
389  return Status(error::SERVER_ERROR,
390  "Failed to recover from server internal error.");
391 }
392 
393 void WidevineKeySource::FillRequest(bool enable_key_rotation,
394  uint32_t first_crypto_period_index,
395  std::string* request) {
396  DCHECK(request);
397  DCHECK(!request_dict_.empty());
398 
399  // Build tracks.
400  base::ListValue* tracks = new base::ListValue();
401 
402  base::DictionaryValue* track_sd = new base::DictionaryValue();
403  track_sd->SetString("type", "SD");
404  tracks->Append(track_sd);
405  base::DictionaryValue* track_hd = new base::DictionaryValue();
406  track_hd->SetString("type", "HD");
407  tracks->Append(track_hd);
408  base::DictionaryValue* track_audio = new base::DictionaryValue();
409  track_audio->SetString("type", "AUDIO");
410  tracks->Append(track_audio);
411 
412  request_dict_.Set("tracks", tracks);
413 
414  // Build DRM types.
415  base::ListValue* drm_types = new base::ListValue();
416  drm_types->AppendString("WIDEVINE");
417  request_dict_.Set("drm_types", drm_types);
418 
419  // Build key rotation fields.
420  if (enable_key_rotation) {
421  // Javascript/JSON does not support int64_t or unsigned numbers. Use double
422  // instead as 32-bit integer can be lossless represented using double.
423  request_dict_.SetDouble("first_crypto_period_index",
424  first_crypto_period_index);
425  request_dict_.SetInteger("crypto_period_count", crypto_period_count_);
426  }
427 
428  base::JSONWriter::WriteWithOptions(
429  request_dict_,
430  // Write doubles that have no fractional part as a normal integer, i.e.
431  // without using exponential notation or appending a '.0'.
432  base::JSONWriter::OPTIONS_OMIT_DOUBLE_TYPE_PRESERVATION, request);
433 }
434 
435 Status WidevineKeySource::GenerateKeyMessage(const std::string& request,
436  std::string* message) {
437  DCHECK(message);
438 
439  std::string request_base64_string;
440  base::Base64Encode(request, &request_base64_string);
441 
442  base::DictionaryValue request_dict;
443  request_dict.SetString("request", request_base64_string);
444 
445  // Sign the request.
446  if (signer_) {
447  std::string signature;
448  if (!signer_->GenerateSignature(request, &signature))
449  return Status(error::INTERNAL_ERROR, "Signature generation failed.");
450 
451  std::string signature_base64_string;
452  base::Base64Encode(signature, &signature_base64_string);
453 
454  request_dict.SetString("signature", signature_base64_string);
455  request_dict.SetString("signer", signer_->signer_name());
456  }
457 
458  base::JSONWriter::Write(request_dict, message);
459  return Status::OK;
460 }
461 
462 bool WidevineKeySource::DecodeResponse(
463  const std::string& raw_response,
464  std::string* response) {
465  DCHECK(response);
466 
467  // Extract base64 formatted response from JSON formatted raw response.
468  scoped_ptr<base::Value> root(base::JSONReader::Read(raw_response));
469  if (!root) {
470  LOG(ERROR) << "'" << raw_response << "' is not in JSON format.";
471  return false;
472  }
473  const base::DictionaryValue* response_dict = NULL;
474  RCHECK(root->GetAsDictionary(&response_dict));
475 
476  std::string response_base64_string;
477  RCHECK(response_dict->GetString("response", &response_base64_string));
478  RCHECK(base::Base64Decode(response_base64_string, response));
479  return true;
480 }
481 
482 bool WidevineKeySource::ExtractEncryptionKey(
483  bool enable_key_rotation,
484  bool widevine_classic,
485  const std::string& response,
486  bool* transient_error) {
487  DCHECK(transient_error);
488  *transient_error = false;
489 
490  scoped_ptr<base::Value> root(base::JSONReader::Read(response));
491  if (!root) {
492  LOG(ERROR) << "'" << response << "' is not in JSON format.";
493  return false;
494  }
495 
496  const base::DictionaryValue* license_dict = NULL;
497  RCHECK(root->GetAsDictionary(&license_dict));
498 
499  std::string license_status;
500  RCHECK(license_dict->GetString("status", &license_status));
501  if (license_status != kLicenseStatusOK) {
502  LOG(ERROR) << "Received non-OK license response: " << response;
503  *transient_error = (license_status == kLicenseStatusTransientError);
504  return false;
505  }
506 
507  const base::ListValue* tracks;
508  RCHECK(license_dict->GetList("tracks", &tracks));
509  // Should have at least one track per crypto_period.
510  RCHECK(enable_key_rotation ? tracks->GetSize() >= 1 * crypto_period_count_
511  : tracks->GetSize() >= 1);
512 
513  int current_crypto_period_index = first_crypto_period_index_;
514 
515  EncryptionKeyMap encryption_key_map;
516  for (size_t i = 0; i < tracks->GetSize(); ++i) {
517  const base::DictionaryValue* track_dict;
518  RCHECK(tracks->GetDictionary(i, &track_dict));
519 
520  if (enable_key_rotation) {
521  int crypto_period_index;
522  RCHECK(
523  track_dict->GetInteger("crypto_period_index", &crypto_period_index));
524  if (crypto_period_index != current_crypto_period_index) {
525  if (crypto_period_index != current_crypto_period_index + 1) {
526  LOG(ERROR) << "Expecting crypto period index "
527  << current_crypto_period_index << " or "
528  << current_crypto_period_index + 1 << "; Seen "
529  << crypto_period_index << " at track " << i;
530  return false;
531  }
532  if (!PushToKeyPool(&encryption_key_map))
533  return false;
534  ++current_crypto_period_index;
535  }
536  }
537 
538  std::string track_type_str;
539  RCHECK(track_dict->GetString("type", &track_type_str));
540  TrackType track_type = GetTrackTypeFromString(track_type_str);
541  DCHECK_NE(TRACK_TYPE_UNKNOWN, track_type);
542  RCHECK(encryption_key_map.find(track_type) == encryption_key_map.end());
543 
544  scoped_ptr<EncryptionKey> encryption_key(new EncryptionKey());
545 
546  if (!GetKeyFromTrack(*track_dict, &encryption_key->key))
547  return false;
548 
549  // Get key ID and PSSH data for CENC content only.
550  if (!widevine_classic) {
551  if (!GetKeyIdFromTrack(*track_dict, &encryption_key->key_id))
552  return false;
553 
554  ProtectionSystemSpecificInfo info;
555  info.add_key_id(encryption_key->key_id);
556  info.set_system_id(kWidevineSystemId, arraysize(kWidevineSystemId));
557  info.set_pssh_box_version(0);
558 
559  std::vector<uint8_t> pssh_data;
560  if (!GetPsshDataFromTrack(*track_dict, &pssh_data))
561  return false;
562  info.set_pssh_data(pssh_data);
563 
564  encryption_key->key_system_info.push_back(info);
565  }
566  encryption_key_map[track_type] = encryption_key.release();
567  }
568 
569  // If the flag exists, create a common system ID PSSH box that contains the
570  // key IDs of all the keys.
571  if (add_common_pssh_ && !widevine_classic) {
572  std::set<std::vector<uint8_t>> key_ids;
573  for (const EncryptionKeyMap::value_type& pair : encryption_key_map) {
574  key_ids.insert(pair.second->key_id);
575  }
576 
577  // Create a common system PSSH box.
578  ProtectionSystemSpecificInfo info;
579  info.set_system_id(kCommonSystemId, arraysize(kCommonSystemId));
580  info.set_pssh_box_version(1);
581  for (const std::vector<uint8_t>& key_id : key_ids) {
582  info.add_key_id(key_id);
583  }
584 
585  for (const EncryptionKeyMap::value_type& pair : encryption_key_map) {
586  pair.second->key_system_info.push_back(info);
587  }
588  }
589 
590  DCHECK(!encryption_key_map.empty());
591  if (!enable_key_rotation) {
592  encryption_key_map_ = encryption_key_map;
593  return true;
594  }
595  return PushToKeyPool(&encryption_key_map);
596 }
597 
598 bool WidevineKeySource::PushToKeyPool(
599  EncryptionKeyMap* encryption_key_map) {
600  DCHECK(key_pool_);
601  DCHECK(encryption_key_map);
602  Status status =
603  key_pool_->Push(scoped_refptr<RefCountedEncryptionKeyMap>(
604  new RefCountedEncryptionKeyMap(encryption_key_map)),
605  kInfiniteTimeout);
606  encryption_key_map->clear();
607  if (!status.ok()) {
608  DCHECK_EQ(error::STOPPED, status.error_code());
609  return false;
610  }
611  return true;
612 }
613 
614 } // namespace media
615 } // namespace shaka
void set_signer(scoped_ptr< RequestSigner > signer)
Status FetchKeys(const std::vector< uint8_t > &pssh_box) override
Status GetCryptoPeriodKey(uint32_t crypto_period_index, TrackType track_type, EncryptionKey *key) override
Status GetKey(TrackType track_type, EncryptionKey *key) override
static std::string TrackTypeToString(TrackType track_type)
Convert TrackType to string.
Definition: key_source.cc:33
void set_key_fetcher(scoped_ptr< KeyFetcher > key_fetcher)
static TrackType GetTrackTypeFromString(const std::string &track_type_string)
Convert string representation of track type to enum representation.
Definition: key_source.cc:19
WidevineKeySource(const std::string &server_url, bool add_common_pssh)
bool Parse(const uint8_t *data, size_t data_size)