summaryrefslogtreecommitdiff
path: root/chromium/media/formats/mp2t/ts_section_cets_ecm.h
blob: ad9a0b346308c90dc3f07535d79ba3a84d455c98 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2015 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.

#ifndef MEDIA_FORMATS_MP2T_TS_SECTION_CETS_ECM_H_
#define MEDIA_FORMATS_MP2T_TS_SECTION_CETS_ECM_H_

#include <stdint.h>

#include <string>

#include "base/callback.h"
#include "base/macros.h"
#include "media/formats/mp2t/ts_section.h"

namespace media {

namespace mp2t {

class TsSectionCetsEcm : public TsSection {
 public:
  // RegisterNewKeyIdAndIvCB() may be called multiple times. From
  // ISO/IEC 23001-9:2016, section 7.2: "Key/IV information for every
  // encrypted PID should be carried in a separate ECM PID." So there may be
  // ECM's for each audio and video stream (and more if key rotation is used).
  using RegisterNewKeyIdAndIvCB =
      base::RepeatingCallback<void(const std::string& key_id,
                                   const std::string& iv)>;

  explicit TsSectionCetsEcm(
      const RegisterNewKeyIdAndIvCB& register_new_key_id_and_iv_cb);

  TsSectionCetsEcm(const TsSectionCetsEcm&) = delete;
  TsSectionCetsEcm& operator=(const TsSectionCetsEcm&) = delete;

  ~TsSectionCetsEcm() override;

  // TsSection implementation.
  bool Parse(bool payload_unit_start_indicator,
             const uint8_t* buf,
             int size) override;
  void Flush() override;
  void Reset() override;

 private:
  RegisterNewKeyIdAndIvCB register_new_key_id_and_iv_cb_;
};

}  // namespace mp2t
}  // namespace media

#endif  // MEDIA_FORMATS_MP2T_TS_SECTION_CETS_ECM_H_