2014-04-01 01:34:59 +00:00
|
|
|
// Copyright 2014 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.
|
|
|
|
|
2014-04-10 19:57:10 +00:00
|
|
|
#include "media/formats/mp2t/mp2t_media_parser.h"
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
#include "base/bind.h"
|
|
|
|
#include "base/memory/scoped_ptr.h"
|
|
|
|
#include "base/stl_util.h"
|
2014-04-10 19:57:10 +00:00
|
|
|
#include "media/base/media_sample.h"
|
|
|
|
#include "media/base/stream_info.h"
|
2014-04-01 01:34:59 +00:00
|
|
|
#include "media/formats/mp2t/es_parser.h"
|
|
|
|
#include "media/formats/mp2t/es_parser_adts.h"
|
|
|
|
#include "media/formats/mp2t/es_parser_h264.h"
|
|
|
|
#include "media/formats/mp2t/mp2t_common.h"
|
|
|
|
#include "media/formats/mp2t/ts_packet.h"
|
|
|
|
#include "media/formats/mp2t/ts_section.h"
|
|
|
|
#include "media/formats/mp2t/ts_section_pat.h"
|
|
|
|
#include "media/formats/mp2t/ts_section_pes.h"
|
|
|
|
#include "media/formats/mp2t/ts_section_pmt.h"
|
|
|
|
|
|
|
|
namespace media {
|
|
|
|
namespace mp2t {
|
|
|
|
|
|
|
|
enum StreamType {
|
|
|
|
// ISO-13818.1 / ITU H.222 Table 2.34 "Stream type assignments"
|
|
|
|
kStreamTypeMpeg1Audio = 0x3,
|
|
|
|
kStreamTypeAAC = 0xf,
|
|
|
|
kStreamTypeAVC = 0x1b,
|
|
|
|
};
|
|
|
|
|
|
|
|
class PidState {
|
|
|
|
public:
|
|
|
|
enum PidType {
|
|
|
|
kPidPat,
|
|
|
|
kPidPmt,
|
|
|
|
kPidAudioPes,
|
|
|
|
kPidVideoPes,
|
|
|
|
};
|
|
|
|
|
2014-04-10 19:57:10 +00:00
|
|
|
PidState(int pid, PidType pid_type,
|
2014-04-01 01:34:59 +00:00
|
|
|
scoped_ptr<TsSection> section_parser);
|
|
|
|
|
|
|
|
// Extract the content of the TS packet and parse it.
|
|
|
|
// Return true if successful.
|
|
|
|
bool PushTsPacket(const TsPacket& ts_packet);
|
|
|
|
|
|
|
|
// Flush the PID state (possibly emitting some pending frames)
|
|
|
|
// and reset its state.
|
|
|
|
void Flush();
|
|
|
|
|
|
|
|
// Enable/disable the PID.
|
|
|
|
// Disabling a PID will reset its state and ignore any further incoming TS
|
|
|
|
// packets.
|
|
|
|
void Enable();
|
|
|
|
void Disable();
|
|
|
|
bool IsEnabled() const;
|
|
|
|
|
|
|
|
PidType pid_type() const { return pid_type_; }
|
|
|
|
|
2014-04-10 19:57:10 +00:00
|
|
|
scoped_refptr<StreamInfo>& config() { return config_; }
|
|
|
|
void set_config(scoped_refptr<StreamInfo>& config) { config_ = config; }
|
|
|
|
|
|
|
|
SampleQueue& sample_queue() { return sample_queue_; }
|
|
|
|
|
2014-04-01 01:34:59 +00:00
|
|
|
private:
|
|
|
|
void ResetState();
|
|
|
|
|
|
|
|
int pid_;
|
|
|
|
PidType pid_type_;
|
|
|
|
scoped_ptr<TsSection> section_parser_;
|
|
|
|
|
|
|
|
bool enable_;
|
|
|
|
int continuity_counter_;
|
2014-04-10 19:57:10 +00:00
|
|
|
scoped_refptr<StreamInfo> config_;
|
|
|
|
SampleQueue sample_queue_;
|
2014-04-01 01:34:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
PidState::PidState(int pid, PidType pid_type,
|
|
|
|
scoped_ptr<TsSection> section_parser)
|
2014-04-10 19:57:10 +00:00
|
|
|
: pid_(pid),
|
|
|
|
pid_type_(pid_type),
|
|
|
|
section_parser_(section_parser.Pass()),
|
|
|
|
enable_(false),
|
|
|
|
continuity_counter_(-1) {
|
2014-04-01 01:34:59 +00:00
|
|
|
DCHECK(section_parser_);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PidState::PushTsPacket(const TsPacket& ts_packet) {
|
|
|
|
DCHECK_EQ(ts_packet.pid(), pid_);
|
|
|
|
|
|
|
|
// The current PID is not part of the PID filter,
|
|
|
|
// just discard the incoming TS packet.
|
|
|
|
if (!enable_)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
int expected_continuity_counter = (continuity_counter_ + 1) % 16;
|
|
|
|
if (continuity_counter_ >= 0 &&
|
|
|
|
ts_packet.continuity_counter() != expected_continuity_counter) {
|
|
|
|
DVLOG(1) << "TS discontinuity detected for pid: " << pid_;
|
2014-04-10 19:57:10 +00:00
|
|
|
// TODO(tinskip): Handle discontinuity better.
|
2014-04-01 01:34:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool status = section_parser_->Parse(
|
|
|
|
ts_packet.payload_unit_start_indicator(),
|
|
|
|
ts_packet.payload(),
|
|
|
|
ts_packet.payload_size());
|
|
|
|
|
|
|
|
// At the minimum, when parsing failed, auto reset the section parser.
|
2014-04-16 23:22:31 +00:00
|
|
|
// Components that use the Mp2tMediaParser can take further action if needed.
|
2014-04-01 01:34:59 +00:00
|
|
|
if (!status) {
|
|
|
|
DVLOG(1) << "Parsing failed for pid = " << pid_;
|
|
|
|
ResetState();
|
|
|
|
}
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PidState::Flush() {
|
|
|
|
section_parser_->Flush();
|
|
|
|
ResetState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PidState::Enable() {
|
|
|
|
enable_ = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PidState::Disable() {
|
|
|
|
if (!enable_)
|
|
|
|
return;
|
|
|
|
|
|
|
|
ResetState();
|
|
|
|
enable_ = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PidState::IsEnabled() const {
|
|
|
|
return enable_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PidState::ResetState() {
|
|
|
|
section_parser_->Reset();
|
|
|
|
continuity_counter_ = -1;
|
|
|
|
}
|
|
|
|
|
2014-04-16 23:22:31 +00:00
|
|
|
Mp2tMediaParser::Mp2tMediaParser()
|
2014-04-10 19:57:10 +00:00
|
|
|
: sbr_in_mimetype_(false),
|
|
|
|
is_initialized_(false) {
|
2014-04-01 01:34:59 +00:00
|
|
|
}
|
|
|
|
|
2014-04-16 23:22:31 +00:00
|
|
|
Mp2tMediaParser::~Mp2tMediaParser() {
|
2014-04-01 01:34:59 +00:00
|
|
|
STLDeleteValues(&pids_);
|
|
|
|
}
|
|
|
|
|
2014-04-16 23:22:31 +00:00
|
|
|
void Mp2tMediaParser::Init(
|
2014-04-01 01:34:59 +00:00
|
|
|
const InitCB& init_cb,
|
2014-04-10 19:57:10 +00:00
|
|
|
const NewSampleCB& new_sample_cb,
|
|
|
|
const NeedKeyCB& need_key_cb) {
|
2014-04-01 01:34:59 +00:00
|
|
|
DCHECK(!is_initialized_);
|
|
|
|
DCHECK(init_cb_.is_null());
|
|
|
|
DCHECK(!init_cb.is_null());
|
2014-04-10 19:57:10 +00:00
|
|
|
DCHECK(!new_sample_cb.is_null());
|
2014-04-01 01:34:59 +00:00
|
|
|
DCHECK(!need_key_cb.is_null());
|
|
|
|
|
|
|
|
init_cb_ = init_cb;
|
2014-04-10 19:57:10 +00:00
|
|
|
new_sample_cb_ = new_sample_cb;
|
2014-04-01 01:34:59 +00:00
|
|
|
need_key_cb_ = need_key_cb;
|
|
|
|
}
|
|
|
|
|
2014-04-16 23:22:31 +00:00
|
|
|
void Mp2tMediaParser::Flush() {
|
|
|
|
DVLOG(1) << "Mp2tMediaParser::Flush";
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
// Flush the buffers and reset the pids.
|
|
|
|
for (std::map<int, PidState*>::iterator it = pids_.begin();
|
|
|
|
it != pids_.end(); ++it) {
|
|
|
|
DVLOG(1) << "Flushing PID: " << it->first;
|
|
|
|
PidState* pid_state = it->second;
|
|
|
|
pid_state->Flush();
|
|
|
|
}
|
2014-04-10 19:57:10 +00:00
|
|
|
EmitRemainingSamples();
|
|
|
|
STLDeleteValues(&pids_);
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
// Remove any bytes left in the TS buffer.
|
|
|
|
// (i.e. any partial TS packet => less than 188 bytes).
|
|
|
|
ts_byte_queue_.Reset();
|
|
|
|
}
|
|
|
|
|
2014-04-16 23:22:31 +00:00
|
|
|
bool Mp2tMediaParser::Parse(const uint8* buf, int size) {
|
|
|
|
DVLOG(1) << "Mp2tMediaParser::Parse size=" << size;
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
// Add the data to the parser state.
|
|
|
|
ts_byte_queue_.Push(buf, size);
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
const uint8* ts_buffer;
|
|
|
|
int ts_buffer_size;
|
|
|
|
ts_byte_queue_.Peek(&ts_buffer, &ts_buffer_size);
|
|
|
|
if (ts_buffer_size < TsPacket::kPacketSize)
|
|
|
|
break;
|
|
|
|
|
|
|
|
// Synchronization.
|
|
|
|
int skipped_bytes = TsPacket::Sync(ts_buffer, ts_buffer_size);
|
|
|
|
if (skipped_bytes > 0) {
|
|
|
|
DVLOG(1) << "Packet not aligned on a TS syncword:"
|
|
|
|
<< " skipped_bytes=" << skipped_bytes;
|
|
|
|
ts_byte_queue_.Pop(skipped_bytes);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse the TS header, skipping 1 byte if the header is invalid.
|
|
|
|
scoped_ptr<TsPacket> ts_packet(TsPacket::Parse(ts_buffer, ts_buffer_size));
|
|
|
|
if (!ts_packet) {
|
|
|
|
DVLOG(1) << "Error: invalid TS packet";
|
|
|
|
ts_byte_queue_.Pop(1);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
DVLOG(LOG_LEVEL_TS)
|
|
|
|
<< "Processing PID=" << ts_packet->pid()
|
|
|
|
<< " start_unit=" << ts_packet->payload_unit_start_indicator();
|
|
|
|
|
|
|
|
// Parse the section.
|
|
|
|
std::map<int, PidState*>::iterator it = pids_.find(ts_packet->pid());
|
|
|
|
if (it == pids_.end() &&
|
|
|
|
ts_packet->pid() == TsSection::kPidPat) {
|
|
|
|
// Create the PAT state here if needed.
|
|
|
|
scoped_ptr<TsSection> pat_section_parser(
|
|
|
|
new TsSectionPat(
|
2014-04-16 23:22:31 +00:00
|
|
|
base::Bind(&Mp2tMediaParser::RegisterPmt,
|
2014-04-01 01:34:59 +00:00
|
|
|
base::Unretained(this))));
|
|
|
|
scoped_ptr<PidState> pat_pid_state(
|
|
|
|
new PidState(ts_packet->pid(), PidState::kPidPat,
|
|
|
|
pat_section_parser.Pass()));
|
|
|
|
pat_pid_state->Enable();
|
|
|
|
it = pids_.insert(
|
|
|
|
std::pair<int, PidState*>(ts_packet->pid(),
|
|
|
|
pat_pid_state.release())).first;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (it != pids_.end()) {
|
|
|
|
if (!it->second->PushTsPacket(*ts_packet))
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
DVLOG(LOG_LEVEL_TS) << "Ignoring TS packet for pid: " << ts_packet->pid();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Go to the next packet.
|
|
|
|
ts_byte_queue_.Pop(TsPacket::kPacketSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Emit the A/V buffers that kept accumulating during TS parsing.
|
2014-04-10 19:57:10 +00:00
|
|
|
return EmitRemainingSamples();
|
2014-04-01 01:34:59 +00:00
|
|
|
}
|
|
|
|
|
2014-04-16 23:22:31 +00:00
|
|
|
void Mp2tMediaParser::RegisterPmt(int program_number, int pmt_pid) {
|
2014-04-01 01:34:59 +00:00
|
|
|
DVLOG(1) << "RegisterPmt:"
|
|
|
|
<< " program_number=" << program_number
|
|
|
|
<< " pmt_pid=" << pmt_pid;
|
|
|
|
|
|
|
|
// Only one TS program is allowed. Ignore the incoming program map table,
|
|
|
|
// if there is already one registered.
|
|
|
|
for (std::map<int, PidState*>::iterator it = pids_.begin();
|
|
|
|
it != pids_.end(); ++it) {
|
|
|
|
PidState* pid_state = it->second;
|
|
|
|
if (pid_state->pid_type() == PidState::kPidPmt) {
|
|
|
|
DVLOG_IF(1, pmt_pid != it->first) << "More than one program is defined";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the PMT state here if needed.
|
|
|
|
DVLOG(1) << "Create a new PMT parser";
|
|
|
|
scoped_ptr<TsSection> pmt_section_parser(
|
|
|
|
new TsSectionPmt(
|
2014-04-16 23:22:31 +00:00
|
|
|
base::Bind(&Mp2tMediaParser::RegisterPes,
|
2014-04-01 01:34:59 +00:00
|
|
|
base::Unretained(this), pmt_pid)));
|
|
|
|
scoped_ptr<PidState> pmt_pid_state(
|
|
|
|
new PidState(pmt_pid, PidState::kPidPmt, pmt_section_parser.Pass()));
|
|
|
|
pmt_pid_state->Enable();
|
|
|
|
pids_.insert(std::pair<int, PidState*>(pmt_pid, pmt_pid_state.release()));
|
|
|
|
}
|
|
|
|
|
2014-04-16 23:22:31 +00:00
|
|
|
void Mp2tMediaParser::RegisterPes(int pmt_pid,
|
2014-04-29 18:51:28 +00:00
|
|
|
int pes_pid,
|
|
|
|
int stream_type) {
|
2014-04-01 01:34:59 +00:00
|
|
|
DVLOG(1) << "RegisterPes:"
|
|
|
|
<< " pes_pid=" << pes_pid
|
|
|
|
<< " stream_type=" << std::hex << stream_type << std::dec;
|
|
|
|
std::map<int, PidState*>::iterator it = pids_.find(pes_pid);
|
|
|
|
if (it != pids_.end())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Create a stream parser corresponding to the stream type.
|
|
|
|
bool is_audio = false;
|
|
|
|
scoped_ptr<EsParser> es_parser;
|
|
|
|
if (stream_type == kStreamTypeAVC) {
|
|
|
|
es_parser.reset(
|
|
|
|
new EsParserH264(
|
2014-04-10 19:57:10 +00:00
|
|
|
pes_pid,
|
2014-04-16 23:22:31 +00:00
|
|
|
base::Bind(&Mp2tMediaParser::OnNewStreamInfo,
|
2014-04-10 19:57:10 +00:00
|
|
|
base::Unretained(this)),
|
2014-04-16 23:22:31 +00:00
|
|
|
base::Bind(&Mp2tMediaParser::OnEmitSample,
|
2014-04-10 19:57:10 +00:00
|
|
|
base::Unretained(this))));
|
2014-04-01 01:34:59 +00:00
|
|
|
} else if (stream_type == kStreamTypeAAC) {
|
|
|
|
es_parser.reset(
|
|
|
|
new EsParserAdts(
|
2014-04-10 19:57:10 +00:00
|
|
|
pes_pid,
|
2014-04-16 23:22:31 +00:00
|
|
|
base::Bind(&Mp2tMediaParser::OnNewStreamInfo,
|
2014-04-10 19:57:10 +00:00
|
|
|
base::Unretained(this)),
|
2014-04-16 23:22:31 +00:00
|
|
|
base::Bind(&Mp2tMediaParser::OnEmitSample,
|
2014-04-10 19:57:10 +00:00
|
|
|
base::Unretained(this)),
|
2014-04-01 01:34:59 +00:00
|
|
|
sbr_in_mimetype_));
|
|
|
|
is_audio = true;
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the PES state here.
|
|
|
|
DVLOG(1) << "Create a new PES state";
|
|
|
|
scoped_ptr<TsSection> pes_section_parser(
|
|
|
|
new TsSectionPes(es_parser.Pass()));
|
|
|
|
PidState::PidType pid_type =
|
|
|
|
is_audio ? PidState::kPidAudioPes : PidState::kPidVideoPes;
|
|
|
|
scoped_ptr<PidState> pes_pid_state(
|
|
|
|
new PidState(pes_pid, pid_type, pes_section_parser.Pass()));
|
2014-04-10 19:57:10 +00:00
|
|
|
pes_pid_state->Enable();
|
2014-04-01 01:34:59 +00:00
|
|
|
pids_.insert(std::pair<int, PidState*>(pes_pid, pes_pid_state.release()));
|
|
|
|
}
|
|
|
|
|
2014-04-16 23:22:31 +00:00
|
|
|
void Mp2tMediaParser::OnNewStreamInfo(
|
2014-04-10 19:57:10 +00:00
|
|
|
scoped_refptr<StreamInfo>& new_stream_info) {
|
|
|
|
DCHECK(new_stream_info);
|
|
|
|
DVLOG(1) << "OnVideoConfigChanged for pid=" << new_stream_info->track_id();
|
2014-04-01 01:34:59 +00:00
|
|
|
|
2014-04-10 19:57:10 +00:00
|
|
|
PidMap::iterator pid_state = pids_.find(new_stream_info->track_id());
|
|
|
|
if (pid_state == pids_.end()) {
|
|
|
|
LOG(ERROR) << "PID State for new stream not found (pid = "
|
|
|
|
<< new_stream_info->track_id() << ").";
|
|
|
|
return;
|
2014-04-01 01:34:59 +00:00
|
|
|
}
|
|
|
|
|
2014-04-10 19:57:10 +00:00
|
|
|
// Set the stream configuration information for the PID.
|
|
|
|
pid_state->second->set_config(new_stream_info);
|
2014-04-01 01:34:59 +00:00
|
|
|
|
2014-04-10 19:57:10 +00:00
|
|
|
// Finish initialization if all streams have configs.
|
|
|
|
FinishInitializationIfNeeded();
|
2014-04-01 01:34:59 +00:00
|
|
|
}
|
|
|
|
|
2014-04-16 23:22:31 +00:00
|
|
|
bool Mp2tMediaParser::FinishInitializationIfNeeded() {
|
2014-04-01 01:34:59 +00:00
|
|
|
// Nothing to be done if already initialized.
|
|
|
|
if (is_initialized_)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// Wait for more data to come to finish initialization.
|
2014-04-10 19:57:10 +00:00
|
|
|
if (pids_.empty())
|
2014-04-01 01:34:59 +00:00
|
|
|
return true;
|
|
|
|
|
2014-04-10 19:57:10 +00:00
|
|
|
std::vector<scoped_refptr<StreamInfo> > all_stream_info;
|
|
|
|
uint32 num_es(0);
|
|
|
|
for (PidMap::const_iterator iter = pids_.begin(); iter != pids_.end();
|
|
|
|
++iter) {
|
|
|
|
if (((iter->second->pid_type() == PidState::kPidAudioPes) ||
|
|
|
|
(iter->second->pid_type() == PidState::kPidVideoPes))) {
|
|
|
|
++num_es;
|
|
|
|
if (iter->second->config())
|
|
|
|
all_stream_info.push_back(iter->second->config());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (num_es && (all_stream_info.size() == num_es)) {
|
|
|
|
// All stream configurations have been received. Initialization can
|
|
|
|
// be completed.
|
|
|
|
init_cb_.Run(all_stream_info);
|
|
|
|
DVLOG(1) << "Mpeg2TS stream parser initialization done";
|
|
|
|
is_initialized_ = true;
|
|
|
|
}
|
2014-04-01 01:34:59 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-04-16 23:22:31 +00:00
|
|
|
void Mp2tMediaParser::OnEmitSample(uint32 pes_pid,
|
|
|
|
scoped_refptr<MediaSample>& new_sample) {
|
2014-04-10 19:57:10 +00:00
|
|
|
DCHECK(new_sample);
|
2014-04-01 01:34:59 +00:00
|
|
|
DVLOG(LOG_LEVEL_ES)
|
2014-04-10 19:57:10 +00:00
|
|
|
<< "OnEmitSample: "
|
|
|
|
<< " pid="
|
|
|
|
<< pes_pid
|
2014-04-01 01:34:59 +00:00
|
|
|
<< " size="
|
2014-04-10 19:57:10 +00:00
|
|
|
<< new_sample->data_size()
|
2014-04-01 01:34:59 +00:00
|
|
|
<< " dts="
|
2014-04-10 19:57:10 +00:00
|
|
|
<< new_sample->dts()
|
2014-04-01 01:34:59 +00:00
|
|
|
<< " pts="
|
2014-04-10 19:57:10 +00:00
|
|
|
<< new_sample->pts();
|
2014-04-01 01:34:59 +00:00
|
|
|
|
2014-04-10 19:57:10 +00:00
|
|
|
// Add the sample to the appropriate PID sample queue.
|
|
|
|
PidMap::iterator pid_state = pids_.find(pes_pid);
|
|
|
|
if (pid_state == pids_.end()) {
|
|
|
|
LOG(ERROR) << "PID State for new sample not found (pid = "
|
|
|
|
<< pes_pid << ").";
|
2014-04-01 01:34:59 +00:00
|
|
|
return;
|
|
|
|
}
|
2014-04-10 19:57:10 +00:00
|
|
|
pid_state->second->sample_queue().push_back(new_sample);
|
2014-04-01 01:34:59 +00:00
|
|
|
}
|
|
|
|
|
2014-04-16 23:22:31 +00:00
|
|
|
bool Mp2tMediaParser::EmitRemainingSamples() {
|
|
|
|
DVLOG(LOG_LEVEL_ES) << "Mp2tMediaParser::EmitRemainingBuffers";
|
2014-04-01 01:34:59 +00:00
|
|
|
|
|
|
|
// No buffer should be sent until fully initialized.
|
|
|
|
if (!is_initialized_)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// Buffer emission.
|
2014-04-10 19:57:10 +00:00
|
|
|
for (PidMap::const_iterator pid_iter = pids_.begin(); pid_iter != pids_.end();
|
|
|
|
++pid_iter) {
|
|
|
|
SampleQueue& sample_queue = pid_iter->second->sample_queue();
|
|
|
|
for (SampleQueue::iterator sample_iter = sample_queue.begin();
|
|
|
|
sample_iter != sample_queue.end();
|
|
|
|
++sample_iter) {
|
|
|
|
if (!new_sample_cb_.Run(pid_iter->first, *sample_iter)) {
|
|
|
|
// Error processing sample. Propagate error condition.
|
2014-04-01 01:34:59 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2014-04-10 19:57:10 +00:00
|
|
|
sample_queue.clear();
|
2014-04-01 01:34:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace mp2t
|
|
|
|
} // namespace media
|