Skip to content

Commit

Permalink
media: Migrate RegisterPesCb to repeating callback.
Browse files Browse the repository at this point in the history
This is a repeating callback because it's called from a for loop:
* https://cs.chromium.org/chromium/src/media/formats/mp2t/ts_section_pmt.cc?rcl=2072c031d444a367084f6fc8f766b264316b451c&l=111

This is part of the base::Callback migration.

Context: https://cs.chromium.org/chromium/src/docs/callback.md?rcl=9fcc3764aea8f97e9f6de4a9ee61d554e67edcda&l=40

Bug: 1007806
Change-Id: I45c07133eed8afd6894c22caa7ef4ff0a4f6167a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2080363
Commit-Queue: Jose Lopes <jabolopes@google.com>
Reviewed-by: Albert J. Wong <ajwong@chromium.org>
Reviewed-by: Xiaohan Wang <xhwang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747195}
  • Loading branch information
Jose Lopes authored and Commit Bot committed Mar 5, 2020
1 parent 102dc9c commit 60a15a3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
8 changes: 4 additions & 4 deletions media/formats/mp2t/mp2t_stream_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,10 @@ void Mp2tStreamParser::RegisterPmt(int program_number, int pmt_pid) {

// Create the PMT state here if needed.
DVLOG(1) << "Create a new PMT parser";
std::unique_ptr<TsSection> pmt_section_parser(new TsSectionPmt(
base::Bind(&Mp2tStreamParser::RegisterPes, base::Unretained(this))));
std::unique_ptr<PidState> pmt_pid_state(
new PidState(pmt_pid, PidState::kPidPmt, std::move(pmt_section_parser)));
auto pmt_section_parser = std::make_unique<TsSectionPmt>(base::BindRepeating(
&Mp2tStreamParser::RegisterPes, base::Unretained(this)));
auto pmt_pid_state = std::make_unique<PidState>(
pmt_pid, PidState::kPidPmt, std::move(pmt_section_parser));
pmt_pid_state->Enable();
pids_.insert(std::make_pair(pmt_pid, std::move(pmt_pid_state)));

Expand Down
6 changes: 2 additions & 4 deletions media/formats/mp2t/ts_section_pmt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@
namespace media {
namespace mp2t {

TsSectionPmt::TsSectionPmt(const RegisterPesCb& register_pes_cb)
: register_pes_cb_(register_pes_cb) {
}
TsSectionPmt::TsSectionPmt(RegisterPesCb register_pes_cb)
: register_pes_cb_(std::move(register_pes_cb)) {}

TsSectionPmt::~TsSectionPmt() {
}
Expand Down Expand Up @@ -118,4 +117,3 @@ void TsSectionPmt::ResetPsiSection() {

} // namespace mp2t
} // namespace media

6 changes: 3 additions & 3 deletions media/formats/mp2t/ts_section_pmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ class TsSectionPmt : public TsSectionPsi {
public:
// |stream_type| is defined in "Table 2-34 – Stream type assignments" in H.222
// TODO(damienv): add the program number.
using RegisterPesCb = base::Callback<
using RegisterPesCb = base::RepeatingCallback<
void(int pes_pid, int stream_type, const Descriptors& descriptors)>;

explicit TsSectionPmt(const RegisterPesCb& register_pes_cb);
explicit TsSectionPmt(RegisterPesCb register_pes_cb);
~TsSectionPmt() override;

// Mpeg2TsPsiParser implementation.
bool ParsePsiSection(BitReader* bit_reader) override;
void ResetPsiSection() override;

private:
RegisterPesCb register_pes_cb_;
const RegisterPesCb register_pes_cb_;

DISALLOW_COPY_AND_ASSIGN(TsSectionPmt);
};
Expand Down

0 comments on commit 60a15a3

Please sign in to comment.