Propagate Flush errors in MP2T parser.
Issue #832 Change-Id: I59f31ff491437b81ffc22ab5760ad0c059e9933e
This commit is contained in:
parent
89d407f9ae
commit
2eb32ee177
|
@ -35,7 +35,7 @@ class EsParser {
|
|||
int64_t dts) = 0;
|
||||
|
||||
// Flush any pending buffer.
|
||||
virtual void Flush() = 0;
|
||||
virtual bool Flush() = 0;
|
||||
|
||||
// Reset the state of the ES parser.
|
||||
virtual void Reset() = 0;
|
||||
|
|
|
@ -182,7 +182,9 @@ bool EsParserAudio::Parse(const uint8_t* buf,
|
|||
return true;
|
||||
}
|
||||
|
||||
void EsParserAudio::Flush() {}
|
||||
bool EsParserAudio::Flush() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void EsParserAudio::Reset() {
|
||||
es_byte_queue_.Reset();
|
||||
|
|
|
@ -36,7 +36,7 @@ class EsParserAudio : public EsParser {
|
|||
|
||||
// EsParser implementation.
|
||||
bool Parse(const uint8_t* buf, int size, int64_t pts, int64_t dts) override;
|
||||
void Flush() override;
|
||||
bool Flush() override;
|
||||
void Reset() override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -77,7 +77,7 @@ bool EsParserH26x::Parse(const uint8_t* buf,
|
|||
return ParseInternal();
|
||||
}
|
||||
|
||||
void EsParserH26x::Flush() {
|
||||
bool EsParserH26x::Flush() {
|
||||
DVLOG(1) << "EsParserH26x::Flush";
|
||||
|
||||
// Simulate two additional AUDs to force emitting the last access unit
|
||||
|
@ -95,7 +95,7 @@ void EsParserH26x::Flush() {
|
|||
es_queue_->Push(aud, sizeof(aud));
|
||||
}
|
||||
|
||||
CHECK(ParseInternal());
|
||||
RCHECK(ParseInternal());
|
||||
|
||||
if (pending_sample_) {
|
||||
// Flush pending sample.
|
||||
|
@ -103,6 +103,7 @@ void EsParserH26x::Flush() {
|
|||
pending_sample_->set_duration(pending_sample_duration_);
|
||||
emit_sample_cb_.Run(std::move(pending_sample_));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void EsParserH26x::Reset() {
|
||||
|
|
|
@ -35,7 +35,7 @@ class EsParserH26x : public EsParser {
|
|||
|
||||
// EsParser implementation overrides.
|
||||
bool Parse(const uint8_t* buf, int size, int64_t pts, int64_t dts) override;
|
||||
void Flush() override;
|
||||
bool Flush() override;
|
||||
void Reset() override;
|
||||
|
||||
protected:
|
||||
|
|
|
@ -45,7 +45,7 @@ class PidState {
|
|||
|
||||
// Flush the PID state (possibly emitting some pending frames)
|
||||
// and reset its state.
|
||||
void Flush();
|
||||
bool Flush();
|
||||
|
||||
// Enable/disable the PID.
|
||||
// Disabling a PID will reset its state and ignore any further incoming TS
|
||||
|
@ -119,9 +119,10 @@ bool PidState::PushTsPacket(const TsPacket& ts_packet) {
|
|||
return status;
|
||||
}
|
||||
|
||||
void PidState::Flush() {
|
||||
section_parser_->Flush();
|
||||
bool PidState::Flush() {
|
||||
RCHECK(section_parser_->Flush());
|
||||
ResetState();
|
||||
return true;
|
||||
}
|
||||
|
||||
void PidState::Enable() {
|
||||
|
@ -174,7 +175,7 @@ bool Mp2tMediaParser::Flush() {
|
|||
for (const auto& pair : pids_) {
|
||||
DVLOG(1) << "Flushing PID: " << pair.first;
|
||||
PidState* pid_state = pair.second.get();
|
||||
pid_state->Flush();
|
||||
RCHECK(pid_state->Flush());
|
||||
}
|
||||
bool result = EmitRemainingSamples();
|
||||
pids_.clear();
|
||||
|
|
|
@ -30,7 +30,7 @@ class TsSection {
|
|||
|
||||
// Process bytes that have not been processed yet (pending buffers in the
|
||||
// pipe). Flush might thus results in frame emission, as an example.
|
||||
virtual void Flush() = 0;
|
||||
virtual bool Flush() = 0;
|
||||
|
||||
// Reset the state of the parser to its initial state.
|
||||
virtual void Reset() = 0;
|
||||
|
|
|
@ -128,13 +128,13 @@ bool TsSectionPes::Parse(bool payload_unit_start_indicator,
|
|||
return (parse_result && Emit(false));
|
||||
}
|
||||
|
||||
void TsSectionPes::Flush() {
|
||||
bool TsSectionPes::Flush() {
|
||||
// Try emitting a packet since we might have a pending PES packet
|
||||
// with an undefined size.
|
||||
Emit(true);
|
||||
RCHECK(Emit(true));
|
||||
|
||||
// Flush the underlying ES parser.
|
||||
es_parser_->Flush();
|
||||
return es_parser_->Flush();
|
||||
}
|
||||
|
||||
void TsSectionPes::Reset() {
|
||||
|
|
|
@ -26,7 +26,7 @@ class TsSectionPes : public TsSection {
|
|||
bool Parse(bool payload_unit_start_indicator,
|
||||
const uint8_t* buf,
|
||||
int size) override;
|
||||
void Flush() override;
|
||||
bool Flush() override;
|
||||
void Reset() override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -118,7 +118,8 @@ bool TsSectionPsi::Parse(bool payload_unit_start_indicator,
|
|||
return status;
|
||||
}
|
||||
|
||||
void TsSectionPsi::Flush() {
|
||||
bool TsSectionPsi::Flush() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void TsSectionPsi::Reset() {
|
||||
|
|
|
@ -25,7 +25,7 @@ class TsSectionPsi : public TsSection {
|
|||
bool Parse(bool payload_unit_start_indicator,
|
||||
const uint8_t* buf,
|
||||
int size) override;
|
||||
void Flush() override;
|
||||
bool Flush() override;
|
||||
void Reset() override;
|
||||
|
||||
// Parse the content of the PSI section.
|
||||
|
|
Loading…
Reference in New Issue