summaryrefslogtreecommitdiff
path: root/chromium/media/mojo/mojom/media_foundation_cdm_data_mojom_traits.cc
blob: 984d1efe43378c96330801735ee64f84ae993256 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "media/mojo/mojom/media_foundation_cdm_data_mojom_traits.h"

#include "third_party/abseil-cpp/absl/types/optional.h"

namespace mojo {

// static
bool StructTraits<media::mojom::MediaFoundationCdmDataDataView,
                  std::unique_ptr<media::MediaFoundationCdmData>>::
    Read(media::mojom::MediaFoundationCdmDataDataView input,
         std::unique_ptr<media::MediaFoundationCdmData>* output) {
  base::UnguessableToken origin_id;
  if (!input.ReadOriginId(&origin_id))
    return false;

  absl::optional<std::vector<uint8_t>> client_token;
  if (!input.ReadClientToken(&client_token))
    return false;

  base::FilePath cdm_store_path_root;
  if (!input.ReadCdmStorePathRoot(&cdm_store_path_root))
    return false;

  *output = std::make_unique<media::MediaFoundationCdmData>(
      origin_id, std::move(client_token), std::move(cdm_store_path_root));
  return true;
}

}  // namespace mojo